Merge branch 'develop' of s416084/find-my-tutor-android into master

This commit is contained in:
Adam Domagalski 2018-11-10 17:52:35 +00:00 committed by Gogs
commit e34ccbb6d8
125 changed files with 64410 additions and 640 deletions

73
.gitignore vendored
View File

@ -1,10 +1,67 @@
# Built application files
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml *.iml
.gradle .idea/workspace.xml
/local.properties .idea/tasks.xml
/.idea/libraries .idea/gradle.xml
/.idea/modules.xml .idea/assetWizardSettings.xml
/.idea/workspace.xml .idea/dictionaries
.DS_Store .idea/libraries
/build .idea/caches
/captures .idea/vcs.xml
.idea/workspace.xml
.idea/modules.xml
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild .externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
app/src/main/res/.DS_Store

View File

@ -5,22 +5,26 @@
<option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myDefaultNotNull" value="android.support.annotation.NonNull" />
<option name="myNullables"> <option name="myNullables">
<value> <value>
<list size="5"> <list size="7">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" /> <item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" /> <item index="4" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
</list> </list>
</value> </value>
</option> </option>
<option name="myNotNulls"> <option name="myNotNulls">
<value> <value>
<list size="4"> <list size="6">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" /> <item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
<item index="5" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
</list> </list>
</value> </value>
</option> </option>

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FindMyTutorAndroid</name>
<comment>Project FindMyTutorAndroid created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1

6
app/.classpath Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin/default"/>
</classpath>

65
app/.gitignore vendored
View File

@ -1 +1,66 @@
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following line if you do not want to check your keystore files in.
#*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
/build /build

23
app/.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>app</name>
<comment>Project app created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,2 @@
connection.project.dir=..
eclipse.preferences.version=1

View File

@ -2,13 +2,18 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 27 compileSdkVersion 27
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig { defaultConfig {
applicationId "com.uam.wmi.findmytutor" applicationId "com.uam.wmi.findmytutor"
minSdkVersion 19 minSdkVersion 22
targetSdkVersion 27 targetSdkVersion 27
versionCode 1 versionCode 1
versionName "1.0" versionName "0.9.0-alpha"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
} }
buildTypes { buildTypes {
release { release {
@ -18,15 +23,43 @@ android {
} }
} }
repositories {
maven {
url 'http://dl.bintray.com/amulyakhare/maven'
}
}
dependencies { dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar']) implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2' implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.code.gson:gson:2.8.2' implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0' implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation "io.swagger:swagger-annotations:1.5.15"
implementation "org.threeten:threetenbp:1.3.5"
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.6.5'
implementation 'io.reactivex.rxjava2:rxjava:2.2.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.0'
implementation "com.jakewharton:butterknife:8.8.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
implementation "com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0"
implementation "com.squareup.okhttp3:okhttp:3.11.0"
implementation "com.squareup.okhttp3:okhttp-urlconnection:3.10.0"
implementation "com.squareup.okhttp3:logging-interceptor:3.11.0"
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.auth0.android:jwtdecode:1.1.1'
implementation 'com.annimon:stream:1.2.1'
implementation 'com.google.android.gms:play-services-location:16.0.0'
// FloatingBarMenu
implementation 'com.getbase:floatingactionbutton:1.10.1'
} }

BIN
app/release/release/app.aab Normal file

Binary file not shown.

View File

@ -1,12 +1,21 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.uam.wmi.findmytutor"> package="com.uam.wmi.findmytutor">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-feature android:name="android.hardware.location.gps" />
<application <application
android:allowBackup="true" android:allowBackup="true"
@ -15,29 +24,39 @@
android:roundIcon="@mipmap/ic_launcher_round" android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity
<activity android:name=".activity.StartupActivity" android:name=".activity.StartupActivity"
android:label="@string/title_activity_startup" android:label="@string/title_activity_startup"
android:launchMode="singleInstance"> android:launchMode="singleInstance"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity <activity
android:name=".activity.MainActivity" android:name=".activity.MapActivity"
android:label="@string/title_activity_main" android:label="@string/map_activity_label"
android:launchMode="singleTop"> android:launchMode="singleTop" />
</activity>
<activity <activity
android:name=".activity.LoginActivity" android:name=".activity.LoginActivity"
android:excludeFromRecents="true" android:excludeFromRecents="true"
android:launchMode="singleTask"
android:label="@string/title_activity_login" android:label="@string/title_activity_login"
android:noHistory="true"> android:launchMode="singleTask"
</activity> android:noHistory="true" />
<activity
android:name=".activity.SettingsActivity"
android:label="@string/title_activity_settings" />
<service
android:name=".service.BackgroundLocalizationService"
android:exported="false"
android:launchMode="singleTop"
android:enabled="true"
/>
</application> </application>
</manifest> </manifest>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
package com.uam.wmi.findmytutor.activity;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* A {@link android.preference.PreferenceActivity} which implements and proxies the necessary calls
* to be used with AppCompat.
*/
public abstract class AppCompatPreferenceActivity extends PreferenceActivity {
private AppCompatDelegate mDelegate;
@Override
protected void onCreate(Bundle savedInstanceState) {
getDelegate().installViewFactory();
getDelegate().onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
getDelegate().onPostCreate(savedInstanceState);
}
public ActionBar getSupportActionBar() {
return getDelegate().getSupportActionBar();
}
public void setSupportActionBar(@Nullable Toolbar toolbar) {
getDelegate().setSupportActionBar(toolbar);
}
@Override
public MenuInflater getMenuInflater() {
return getDelegate().getMenuInflater();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
getDelegate().setContentView(layoutResID);
}
@Override
public void setContentView(View view) {
getDelegate().setContentView(view);
}
@Override
public void setContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().setContentView(view, params);
}
@Override
public void addContentView(View view, ViewGroup.LayoutParams params) {
getDelegate().addContentView(view, params);
}
@Override
protected void onPostResume() {
super.onPostResume();
getDelegate().onPostResume();
}
@Override
protected void onTitleChanged(CharSequence title, int color) {
super.onTitleChanged(title, color);
getDelegate().setTitle(title);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
getDelegate().onConfigurationChanged(newConfig);
}
@Override
protected void onStop() {
super.onStop();
getDelegate().onStop();
}
@Override
protected void onDestroy() {
super.onDestroy();
getDelegate().onDestroy();
}
public void invalidateOptionsMenu() {
getDelegate().invalidateOptionsMenu();
}
private AppCompatDelegate getDelegate() {
if (mDelegate == null) {
mDelegate = AppCompatDelegate.create(this, null);
}
return mDelegate;
}
}

View File

@ -0,0 +1,358 @@
package com.uam.wmi.findmytutor.activity;
import android.Manifest;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.SearchView;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
import com.uam.wmi.findmytutor.utils.ActiveFragment;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
public abstract class BaseActivity
extends AppCompatActivity
implements BottomNavigationView.OnNavigationItemSelectedListener {
String tag = getClass().getName();
protected static final int REQUEST_PERMISSIONS = 100;
private final static int REQUEST_CODE_ASK_PERMISSIONS = 1;
private static final String[] REQUIRED_SDK_PERMISSIONS = new String[] {
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS };
public DrawerLayout drawerLayout;
protected BottomNavigationView navigationView;
protected NavigationView drawerNavigationView;
protected DrawerLayout sideDrawer;
protected Toolbar toolbar;
protected boolean isTutor;
private ActionBarDrawerToggle actionBarDrawerToggle;
private SharingFragment sharingFragment;
private Fragment userListFragment;
private ActiveFragment activeFragment = ActiveFragment.NONE;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getContentViewId());
drawerNavigationView = findViewById(R.id.nav_view);
sideDrawer = findViewById(R.id.activity_container);
drawerNavigationView.setNavigationItemSelectedListener(
item -> {
String itemName = (String) item.getTitle();
Intent launchIntent;
if (itemName.equals(getResources().getString(R.string.navigation_item_whitelist))) {
/* launchIntent = new Intent(getApplicationContext(), WhitelistActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals(getResources().getString(R.string.navigation_item_blacklist))) {
/* launchIntent = new Intent(getApplicationContext(), BlacklistActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals(getResources().getString(R.string.navigation_item_profile))) {
/* launchIntent = new Intent(getApplicationContext(), ProfileActivity.class);
startActivity(launchIntent);*/
} else if (itemName.equals(getResources().getString(R.string.navigation_item_settings))) {
launchIntent = new Intent(getApplicationContext(), SettingsActivity.class);
startActivity(launchIntent);
} else if (itemName.equals(getResources().getString(R.string.navigation_item_logout))) {
if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext())) {
stopBackgroundLocalizationTask();
}
storeBackgroundLocationStatus(getApplication(),false);
PrefUtils.storeIsLoggedIn(getApplicationContext(),false);
Intent i = getBaseContext().getPackageManager()
.getLaunchIntentForPackage(getBaseContext().getPackageName());
if (i != null) {
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
startActivity(i);
finish();
}
sideDrawer.closeDrawers();
return true;
}
);
navigationView = findViewById(R.id.navigation);
navigationView.setOnNavigationItemSelectedListener(this);
sharingFragment = new SharingFragment();
userListFragment = new UsersListFragment();
isTutor = PrefUtils.getIsTutor(getApplicationContext());
if (!isTutor) {
navigationView.findViewById(R.id.nav_profile).setVisibility(View.GONE);
}
}
protected void checkPermissions() {
final List<String> missingPermissions = new ArrayList<String>();
for (final String permission : REQUIRED_SDK_PERMISSIONS) {
final int result = ContextCompat.checkSelfPermission(this, permission);
if (result != PackageManager.PERMISSION_GRANTED) {
missingPermissions.add(permission);
}
}
if (!missingPermissions.isEmpty()) {
// request all missing permissions
final String[] permissions = missingPermissions
.toArray(new String[missingPermissions.size()]);
ActivityCompat.requestPermissions(this, permissions, REQUEST_CODE_ASK_PERMISSIONS);
} else {
final int[] grantResults = new int[REQUIRED_SDK_PERMISSIONS.length];
Arrays.fill(grantResults, PackageManager.PERMISSION_GRANTED);
onRequestPermissionsResult(REQUEST_CODE_ASK_PERMISSIONS, REQUIRED_SDK_PERMISSIONS,
grantResults);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[],
@NonNull int[] grantResults) {
switch (requestCode) {
case REQUEST_CODE_ASK_PERMISSIONS:
for (int index = permissions.length - 1; index >= 0; --index) {
if (grantResults[index] != PackageManager.PERMISSION_GRANTED) {
// exit the app if one permission is not granted
Toast.makeText(this, "Required permission '" + permissions[index]
+ "' not granted, exiting", Toast.LENGTH_LONG).show();
finish();
return;
}
}
break;
}
}
public void stopBackgroundLocalizationTask() {
Intent stopIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
stopIntent.putExtra("request_stop", true);
startService(stopIntent);
}
public void startBackgroundLocalizationTask() {
checkPermissions();
Intent startIntent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(startIntent);
} else {
startService(startIntent);
}
}
public void handleBackgroundTaskLifeCycle() {
Boolean shouldServiceRun = PrefUtils.isEnableSharingLocalization(getApplicationContext())
&& !PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext());
if (shouldServiceRun){
startBackgroundLocalizationTask();
} else if(PrefUtils.isBackgroundLocationServiceRunning(getApplicationContext()) &&
!PrefUtils.isEnableSharingLocalization(getApplicationContext())) {
stopBackgroundLocalizationTask();
}
}
@Override
public void setContentView(int layoutResID) {
DrawerLayout fullView = (DrawerLayout) getLayoutInflater().inflate(R.layout.base_activity, null);
FrameLayout activityContainer = fullView.findViewById(R.id.activity_content);
getLayoutInflater().inflate(layoutResID, activityContainer, true);
super.setContentView(fullView);
initToolbar();
}
private void initToolbar() {
toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
private void setUpNav() {
drawerLayout = findViewById(R.id.activity_container);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawerLayout.addDrawerListener(actionBarDrawerToggle);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
}
}
@Override
public void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
setUpNav();
actionBarDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
actionBarDrawerToggle.onConfigurationChanged(newConfig);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
MenuItem myActionMenuItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) myActionMenuItem.getActionView();
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String input) {
if (activeFragment.equals(ActiveFragment.USER_LIST)) {
executeUserListSearch(input);
}
return false;
}
@Override
public boolean onQueryTextChange(String input) {
if (activeFragment.equals(ActiveFragment.USER_LIST)) {
executeUserListSearch(input);
}
return true;
}
});
return true;
}
private void executeUserListSearch(String input) {
((UsersListFragment) userListFragment).searchUser(input);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onStart() {
super.onStart();
updateNavigationBarState();
}
@Override
public void onPause() {
super.onPause();
overridePendingTransition(0, 0);
}
private void removeFragment(Fragment fragment) {
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.hide(fragment);
fragmentTransaction.commit();
}
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
navigationView.postDelayed(() -> {
int itemId = item.getItemId();
if (itemId == R.id.nav_map) {
removeFragment(sharingFragment);
removeFragment(userListFragment);
} else if (itemId == R.id.nav_profile) {
loadUserSettingsFragment();
} else if (itemId == R.id.nav_user_list) {
loadUserListFragment();
}
}, 300);
return true;
}
private void loadUserSettingsFragment() {
activeFragment = ActiveFragment.SHARED_PREFERENCES;
sharingFragment = SharingFragment.newInstance();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.activity_content, sharingFragment);
ft.commit();
}
private void loadUserListFragment() {
activeFragment = ActiveFragment.USER_LIST;
userListFragment = UsersListFragment.newInstance();
FragmentTransaction ft = getFragmentManager().beginTransaction();
ft.replace(R.id.activity_content, userListFragment);
ft.commit();
}
private void updateNavigationBarState() {
int actionId = getNavigationMenuItemId();
selectBottomNavigationBarItem(actionId);
}
private void selectBottomNavigationBarItem(int itemId) {
MenuItem item = navigationView.getMenu().findItem(itemId);
item.setChecked(true);
}
abstract int getNavigationMenuItemId();
abstract int getContentViewId();
}

View File

@ -3,418 +3,228 @@ package com.uam.wmi.findmytutor.activity;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.app.LoaderManager.LoaderCallbacks;
import android.content.CursorLoader;
import android.content.Loader;
import android.database.Cursor;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.provider.ContactsContract; import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Button; import android.widget.Button;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; import android.widget.Switch;
import android.widget.Toast;
import com.auth0.android.jwt.Claim;
import com.auth0.android.jwt.JWT;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R; import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.JwtToken; import com.uam.wmi.findmytutor.model.JwtToken;
import com.uam.wmi.findmytutor.model.LdapUser; import com.uam.wmi.findmytutor.model.LdapUser;
import com.uam.wmi.findmytutor.network.RetrofitClientInstance; import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.model.ValidateUser;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.LdapService; import com.uam.wmi.findmytutor.service.LdapService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.io.IOException; import java.util.regex.Matcher;
import java.util.ArrayList; import java.util.regex.Pattern;
import java.util.List;
import retrofit2.Call; import io.reactivex.android.schedulers.AndroidSchedulers;
import retrofit2.Callback; import io.reactivex.disposables.CompositeDisposable;
import retrofit2.Response; import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static android.Manifest.permission.READ_CONTACTS; public class LoginActivity extends AppCompatActivity {
/**
* A login screen that offers login via email/password.
*/
public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<Cursor> {
/**
* Id to identity READ_CONTACTS permission request.
*/
private static final int REQUEST_READ_CONTACTS = 0;
/**
* A dummy authentication store containing known user names and passwords.
* TODO: remove after connecting to a real authentication system.
*/
private static final String[] DUMMY_CREDENTIALS = new String[]{
"adam@o2.pl:adamadam", "foo@example.com:hello", "bar@example.com:world"
};
/**
* Keep track of the login task to ensure we can cancel it if requested.
*/
private UserLoginTask mAuthTask = null;
// UI references. // UI references.
private AutoCompleteTextView mEmailView; private AutoCompleteTextView mLoginNameView;
private EditText mPasswordView; private EditText mPasswordView;
private View mProgressView; private View mProgressView;
private View mLoginFormView; private View mLoginFormView;
private LdapService ldapService;
private UserService userService;
private CompositeDisposable disposable = new CompositeDisposable();
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login); setContentView(R.layout.activity_login);
// Set up the login form. mLoginNameView = findViewById(R.id.email);
mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
populateAutoComplete();
mPasswordView = (EditText) findViewById(R.id.password); ldapService = ApiClient.getClient(getApplicationContext())
mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() { .create(LdapService.class);
@Override userService = ApiClient.getClient(getApplicationContext())
public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) { .create(UserService.class);
if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
attemptLogin();
return true;
}
return false;
}
});
mPasswordView = findViewById(R.id.password);
Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button); mPasswordView.setOnEditorActionListener((textView, id, keyEvent) -> {
mEmailSignInButton.setOnClickListener(new OnClickListener() { if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
@Override
public void onClick(View view) {
attemptLogin(); attemptLogin();
return true;
} }
return false;
}); });
Switch tutorLogin = findViewById(R.id.tutor_login_switch);
tutorLogin.setOnCheckedChangeListener((buttonView, isChecked) -> {
PrefUtils.storeIsTutor(getApplicationContext(), isChecked);
});
Button mEmailSignInButton = findViewById(R.id.email_sign_in_button);
mEmailSignInButton.setOnClickListener(view -> attemptLogin());
mLoginFormView = findViewById(R.id.login_form); mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress); mProgressView = findViewById(R.id.login_progress);
} }
private void populateAutoComplete() {
if (!mayRequestContacts()) {
return;
}
getLoaderManager().initLoader(0, null, this);
}
private boolean mayRequestContacts() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
return true;
}
if (checkSelfPermission(READ_CONTACTS) == PackageManager.PERMISSION_GRANTED) {
return true;
}
if (shouldShowRequestPermissionRationale(READ_CONTACTS)) {
Snackbar.make(mEmailView, R.string.permission_rationale, Snackbar.LENGTH_INDEFINITE)
.setAction(android.R.string.ok, new View.OnClickListener() {
@Override
@TargetApi(Build.VERSION_CODES.M)
public void onClick(View v) {
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
}
});
} else {
requestPermissions(new String[]{READ_CONTACTS}, REQUEST_READ_CONTACTS);
}
return false;
}
/**
* Callback received when a permissions request has been completed.
*/
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
if (requestCode == REQUEST_READ_CONTACTS) {
if (grantResults.length == 1 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
populateAutoComplete();
}
}
}
/**
* Attempts to sign in or register the account specified by the login form.
* If there are form errors (invalid email, missing fields, etc.), the
* errors are presented and no actual login attempt is made.
*/
private void attemptLogin() { private void attemptLogin() {
if (mAuthTask != null) {
return;
}
// Reset errors. // Reset errors.
mEmailView.setError(null); mLoginNameView.setError(null);
mPasswordView.setError(null); mPasswordView.setError(null);
// Store values at the time of the login attempt. // Store values at the time of the login attempt.
String email = mEmailView.getText().toString(); String loginName = mLoginNameView.getText().toString();
String password = mPasswordView.getText().toString(); String password = mPasswordView.getText().toString();
boolean cancel = false; boolean cancel = false;
View focusView = null; View focusView = null;
// Check for a valid password, if the user entered one. // Check for a valid email address.
if (!TextUtils.isEmpty(password) && !isPasswordValid(password)) { if (TextUtils.isEmpty(loginName)) {
mPasswordView.setError(getString(R.string.error_invalid_password)); mLoginNameView.setError(getString(R.string.error_field_required));
focusView = mLoginNameView;
cancel = true;
} else if (!isEmailValid(loginName)) {
mLoginNameView.setError(getString(R.string.error_invalid_login_name));
focusView = mLoginNameView;
cancel = true;
}
// Check for a valid password address.
if (TextUtils.isEmpty(password)) {
mPasswordView.setError(getString(R.string.error_field_required));
focusView = mPasswordView; focusView = mPasswordView;
cancel = true; cancel = true;
} }
// Check for a valid email address.
if (TextUtils.isEmpty(email)) {
mEmailView.setError(getString(R.string.error_field_required));
focusView = mEmailView;
cancel = true;
} else if (!isEmailValid(email)) {
mEmailView.setError(getString(R.string.error_invalid_email));
focusView = mEmailView;
cancel = true;
}
if (cancel) { if (cancel) {
// There was an error; don't attempt login and focus the first
// form field with an error.
focusView.requestFocus(); focusView.requestFocus();
} else { } else {
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true); showProgress(true);
mAuthTask = new UserLoginTask(email, password); loginProcess(loginName, password);
mAuthTask.execute((Void) null);
} }
} }
private boolean isEmailValid(String email) { private boolean isEmailValid(String loginName) {
//TODO: Replace this with your own logic Pattern pattern = Pattern.compile("\\s");
return email.contains("@"); Matcher matcher = pattern.matcher(loginName);
return !matcher.find();
} }
private boolean isPasswordValid(String password) {
//TODO: Replace this with your own logic
return password.length() > 4;
}
/**
* Shows the progress UI and hides the login form.
*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2) @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
private void showProgress(final boolean show) { private void showProgress(final boolean show) {
// On Honeycomb MR2 we have the ViewPropertyAnimator APIs, which allow int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
// for very easy animations. If available, use these APIs to fade-in
// the progress spinner.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
int shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
mLoginFormView.animate().setDuration(shortAnimTime).alpha(
show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
}
});
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
mProgressView.animate().setDuration(shortAnimTime).alpha( mLoginFormView.animate().setDuration(shortAnimTime).alpha(
show ? 1 : 0).setListener(new AnimatorListenerAdapter() { show ? 0 : 1).setListener(new AnimatorListenerAdapter() {
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE); mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
} }
}); });
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
mProgressView.animate().setDuration(shortAnimTime).alpha(
show ? 1 : 0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
}
});
}
private void loginProcess(String email, String password) {
Log.e("LOGIN", String.valueOf(PrefUtils.getIsTutor(getApplicationContext())));
//Fake validate
LdapUser user = new LdapUser(email, password, "admin", (PrefUtils.getIsTutor(getApplicationContext())) ? "Tutor" : "Student", "Imię", "Nazwisko", email);
// ValidateUser user = new ValidateUser(email, password);
// LDAP logging
// disposable.add(ldapService.validate(user)
disposable.add(ldapService.fakeValidate(user)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::handleResponse, this::handleError));
}
private void getUserProfile(String userId) {
disposable.add(userService.getUserById(userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::saveUserProfileToSharedPreferences, this::handleError));
}
private void showSnackBarMessage(String message) {
Snackbar.make(findViewById(R.id.login_form), message, Snackbar.LENGTH_LONG)
.show();
}
private void handleResponse(JwtToken jwtToken) {
showProgress(false);
String token = jwtToken.getToken();
JWT jwt = new JWT(token);
Claim role = jwt.getClaim("nameid");
PrefUtils.storeIsLoggedIn(getApplicationContext(), true);
PrefUtils.storeApiKey(getApplicationContext(), token);
PrefUtils.storeUserId(getApplicationContext(), role.asString());
getUserProfile(role.asString());
Intent data = new Intent();
String txt = "Main Activity";
data.setData(Uri.parse(txt));
setResult(RESULT_OK, data);
finish();
}
private void handleError(Throwable error) {
showProgress(false);
if (error instanceof HttpException) {
ResponseBody responseBody = ((HttpException) error).response().errorBody();
showSnackBarMessage(RestApiHelper.getErrorMessage(responseBody));
} else { } else {
// The ViewPropertyAnimator APIs are not available, so simply show showSnackBarMessage("Network Error !");
// and hide the relevant UI components.
mProgressView.setVisibility(show ? View.VISIBLE : View.GONE);
mLoginFormView.setVisibility(show ? View.GONE : View.VISIBLE);
} }
} }
@Override private void saveUserProfileToSharedPreferences(User user) {
public Loader<Cursor> onCreateLoader(int i, Bundle bundle) { PrefUtils.storeUserFirstName(getApplicationContext(), user.getFirstName());
return new CursorLoader(this, PrefUtils.storeUserLastName(getApplicationContext(), user.getLastName());
// Retrieve data rows for the device user's 'profile' contact. PrefUtils.storeUserName(getApplicationContext(), user.getUserName());
Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI,
ContactsContract.Contacts.Data.CONTENT_DIRECTORY), ProfileQuery.PROJECTION,
// Select only email addresses.
ContactsContract.Contacts.Data.MIMETYPE +
" = ?", new String[]{ContactsContract.CommonDataKinds.Email
.CONTENT_ITEM_TYPE},
// Show primary email addresses first. Note that there won't be
// a primary email address if the user hasn't specified one.
ContactsContract.Contacts.Data.IS_PRIMARY + " DESC");
} }
@Override
public void onLoadFinished(Loader<Cursor> cursorLoader, Cursor cursor) {
List<String> emails = new ArrayList<>();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
emails.add(cursor.getString(ProfileQuery.ADDRESS));
cursor.moveToNext();
}
addEmailsToAutoComplete(emails);
}
@Override
public void onLoaderReset(Loader<Cursor> cursorLoader) {
}
private void addEmailsToAutoComplete(List<String> emailAddressCollection) {
//Create adapter to tell the AutoCompleteTextView what to show in its dropdown list.
ArrayAdapter<String> adapter =
new ArrayAdapter<>(LoginActivity.this,
android.R.layout.simple_dropdown_item_1line, emailAddressCollection);
mEmailView.setAdapter(adapter);
}
private interface ProfileQuery {
String[] PROJECTION = {
ContactsContract.CommonDataKinds.Email.ADDRESS,
ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
};
int ADDRESS = 0;
int IS_PRIMARY = 1;
}
/**
* Represents an asynchronous login/registration task used to authenticate
* the user.
*/
public class UserLoginTask extends AsyncTask<Void, Void, Boolean> {
private final String mEmail;
private final String mPassword;
// Constructor
UserLoginTask(String email, String password) {
mEmail = email;
mPassword = password;
}
@Override
protected Boolean doInBackground(Void... params) {
LdapService service = RetrofitClientInstance.getRetrofitLoginInstance().create(LdapService.class);
LdapUser user = new LdapUser("string",mPassword,"string","string","string","string",mEmail);
try {
Response<JwtToken> loginResponse = service.fakeValidate(user).execute();
if (loginResponse.isSuccessful()) {
String authToken = loginResponse.body().getToken();
Log.e("Login", "jwt token: " + authToken);
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
sharedPref.edit().putString("authToken", authToken).putBoolean("loggedIn", true).apply();
return true;
}
} catch (IOException e) {
Log.e("Login error", "nie udalo sie kurde...");
return false;
}
//To jest async i nie da sie zwrocic :(
// Call<JwtToken> call = service.fakeValidate(user);
//
// call.enqueue(new Callback<JwtToken>() {
// @Override
// public void onResponse(Call<JwtToken> call, Response<JwtToken> response) {
// Log.e("jwt", response.body().getToken());
// }
//
// @Override
// public void onFailure(Call<JwtToken> call, Throwable t) {
// Toast.makeText(LoginActivity.this, "Something went wrong...Please try later!", Toast.LENGTH_SHORT).show();
// return false;
// }
// });
// TODO: attempt authentication against a network service.
// try {
// // Simulate network access.
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// return false;
// }
//
// for (String credential : DUMMY_CREDENTIALS) {
// String[] pieces = credential.split(":");
// if (pieces[0].equals(mEmail)) {
// // Account exists, return true if the password matches.
// return pieces[1].equals(mPassword);
// }
// }
// TODO: register the new account here.
return false;
}
@Override
protected void onPostExecute(final Boolean success) {
mAuthTask = null;
showProgress(false);
if (success) {
// TODO: Ustawiam localstora kluczyk jakis
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putString("test", "jakieś gówno");
editor.commit();
Log.e("okurwa", "eealslasla");
// TODO: Ma zwracac 666 i cos jeszcze, do tego wpisywac jwt to shared prefs... kurwa
Intent data = new Intent();
String txt = "siema eee";
data.setData(Uri.parse(txt));
setResult(RESULT_OK, data);
finish();
} else {
mPasswordView.setError(getString(R.string.error_incorrect_password));
mPasswordView.requestFocus();
}
}
@Override
protected void onCancelled() {
mAuthTask = null;
showProgress(false);
}
}
} }

View File

@ -1,26 +0,0 @@
package com.uam.wmi.findmytutor.activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;
import com.uam.wmi.findmytutor.R;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
String text = sharedPref.getString("test",null);
Log.e("Mainactivity", text);
}
}

View File

@ -0,0 +1,594 @@
package com.uam.wmi.findmytutor.activity;
import android.Manifest;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.location.Location;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.mapbox.android.core.permissions.PermissionsListener;
import com.mapbox.android.core.permissions.PermissionsManager;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.location.LocationComponentOptions;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
import com.mapbox.mapboxsdk.style.layers.CircleLayer;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.sources.VectorSource;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.CoordinateService;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import com.uam.wmi.findmytutor.utils.mapUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import timber.log.Timber;
import java.util.Set;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleColor;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.circleRadius;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
public class MapActivity extends BaseActivity
implements PermissionsListener, OnMapReadyCallback {
private String tag = getClass().getName();
private PermissionsManager permissionsManager;
private LocationComponent locationComponent;
private CoordinateService coordinateService;
private UserService userService;
private CompositeDisposable disposable = new CompositeDisposable();
private int mInterval = 10000;
private Handler mHandler = new Handler();
private Runnable mStatusChecker;
private MapView mapView;
private MapboxMap mapboxMap;
private Marker droppedMarker;
private HashMap<String, Coordinate> coordsMap = new HashMap<>();
private HashMap<String, Marker> markerHash = new HashMap<>();
private Set<String> previousCoordsIds = new HashSet<>();
private int zoomParam = 17;
private int bearingParam = 180;
private int tiltParam = 30;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final SharedPreferences sharedPref = getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE);
// fetching coords service
coordinateService = ApiClient.getClient(getApplicationContext())
.create(CoordinateService.class);
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
mStatusChecker = () -> {
try {
fetchTopCoords();
} finally {
mHandler.postDelayed(mStatusChecker, mInterval);
}
};
Bundle extras = getIntent().getExtras();
Mapbox.getInstance(this, getString(R.string.access_token));
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
//start background task
handleBackgroundTaskLifeCycle();
}
@Override
public void onMapReady(MapboxMap mapboxMap) {
MapActivity.this.mapboxMap = mapboxMap;
mStatusChecker.run();
enableLocationPlugin();
mapboxMap.setOnMarkerClickListener(marker -> {
createMarkerModal(marker.getTitle());
return true;
});
setOnMapLongClickListener();
// addStaticLayer();
}
private void createMarkerModal(String userId) {
disposable.add(userService.getUserById(userId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::createMarkerModal, this::handleError));
}
private void createMarkerModal(User user) {
String cordStatus = coordsMap.get(user.getId()).getLabel();
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getApplicationContext());
@SuppressLint("InflateParams") View view = layoutInflaterAndroid.inflate(R.layout.marker_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new android.support.v7.app.AlertDialog.Builder(this);
alertDialogBuilderUserInput.setView(view);
alertDialogBuilderUserInput.setNegativeButton(R.string.cancel, (dialog, id) -> {
// User cancelled the dialog
});
TextView userName = view.findViewById(R.id.userName);
TextView status = view.findViewById(R.id.label);
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
status.setText(String.format("%s ", cordStatus));
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
alertDialog.show();
}
private void handleError(Throwable error) {
showError(error);
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
}else {
message = "Network Error!";
}
Toast.makeText(MapActivity.this, message, Toast.LENGTH_SHORT).show();
}
private void setOnMapLongClickListener() {
final boolean[] cancel = {false};
Button selectLocationButton = findViewById(R.id.select_location_button);
mapboxMap.addOnMapLongClickListener((LatLng latLng) -> {
selectLocationButton.setVisibility(View.VISIBLE);
Icon icon = IconFactory.getInstance(MapActivity.this).fromResource(R.drawable.green_marker);
if (droppedMarker == null) {
droppedMarker = mapboxMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(icon)
.title("My Loc")
.setSnippet("Snipecik"));
} else if (!cancel[0]) {
ValueAnimator markerAnimator = ObjectAnimator.ofObject(droppedMarker, "position",
new mapUtils.LatLngEvaluator(), droppedMarker.getPosition(), latLng);
markerAnimator.setDuration(2000);
markerAnimator.start();
}
selectLocationButton.setOnClickListener((View view) -> {
if (!cancel[0] && droppedMarker != null) {
// Toast instructing user to tap on the mapboxMap
// TODO PUT MANUAL CORD
try {
Coordinate coordinate = new Coordinate(
latLng.getLatitude(),
latLng.getLongitude(),
latLng.getAltitude(),
PrefUtils.getUserFirstName(getApplicationContext()) + " " + PrefUtils.getUserLastName(getApplicationContext()),
PrefUtils.getUserId(getApplicationContext()),
PrefUtils.getLocationLevel(getApplicationContext())
);
disposable.add(
coordinateService
.postCoordinate(coordinate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
@SuppressLint("LongLogTag")
@Override
public void onSuccess(Coordinate coord) {
Log.e(tag + "POST", String.valueOf(coord));
}
@SuppressLint("LongLogTag")
@Override
public void onError(Throwable e) {
Log.e(tag + "onError", e.getMessage());
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
Log.e(tag + "onError", RestApiHelper.getErrorMessage(responseBody));
}
}
}));
} catch (IllegalArgumentException e) {
Timber.e(String.valueOf(e));
}
Toast.makeText(
MapActivity.this,
"Manual Locations selected!" + latLng,
Toast.LENGTH_LONG
).show();
selectLocationButton.setBackgroundColor(
ContextCompat.getColor(MapActivity.this, R.color.colorAccent));
selectLocationButton.setText("Remove Manual location");
selectLocationButton.setVisibility(View.VISIBLE);
cancel[0] = true;
} else {
// TODO REMOVE Manual Locatio
mapboxMap.removeMarker(droppedMarker);
droppedMarker = null;
Toast.makeText(
MapActivity.this,
"REMOVED!!" + latLng,
Toast.LENGTH_LONG
).show();
cancel[0] = false;
selectLocationButton.setVisibility(View.GONE);
selectLocationButton.setText(R.string.select_a_location);
selectLocationButton.setBackgroundColor(
ContextCompat.getColor(MapActivity.this, R.color.colorPrimary));
}
});
});
}
private void addStaticLayer() {
// Toggle layer button
final FloatingActionButton button = findViewById(R.id.toggleMarkerLayerButton);
button.setVisibility(View.VISIBLE);
button.setOnClickListener(view -> {
Layer layer = mapboxMap.getLayer("museums");
if (layer != null) {
if (VISIBLE.equals(layer.getVisibility().getValue())) {
layer.setProperties(visibility(NONE));
} else {
layer.setProperties(visibility(VISIBLE));
}
}
});
// TODO here we create static layer, we are able to hide/show (but we cannot put markers inthere)
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
mapboxMap.addSource(museums);
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
museumsLayer.setSourceLayer("museum-cusco");
museumsLayer.setProperties(
visibility(VISIBLE),
circleRadius(8f),
circleColor(Color.argb(255, 55, 148, 179))
);
mapboxMap.addLayer(museumsLayer);
}
private void fetchTopCoords() {
disposable.add(
// coordinateService.getTopCoordinates()
coordinateService.getOnlineCoordinates()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<List<Coordinate>>() {
@Override
public void onSuccess(List<Coordinate> coordsList) {
if(coordsList.isEmpty()) {
Log.e(tag, "200 empty []");
mapboxMap.clear();
return;
}
ArrayList<String> tmp = new ArrayList<>();
for (Coordinate coordinate : coordsList) {
tmp.add(coordinate.getUserId());
}
Set<String> currentCoordsIds = new HashSet<>(tmp);
if (previousCoordsIds.isEmpty()){
previousCoordsIds.addAll(currentCoordsIds);
} else {
// here we clear + it returns bool if smthing was removed
if (previousCoordsIds.removeAll(currentCoordsIds)) {
for (String toRemoveId: previousCoordsIds) {
Log.e(tag+ "delete: " , "removing: " + toRemoveId + ": " + markerHash.get(toRemoveId));
mapboxMap.removeMarker(markerHash.get(toRemoveId));
markerHash.remove(toRemoveId);
coordsMap.remove(toRemoveId);
}
} else {
// TODO double check when some markers api will change
Log.e(tag+ "delete: ","nothing to remove");
}
}
for (Coordinate element : coordsList) {
String id = element.getUserId();
String newLabel = element.getLabel();
Coordinate coordinate = coordsMap.get(id);
Log.e(tag, "hashMapSize: " + coordsMap.size());
Log.e(tag, "markerMapSize: " + coordsMap.size());
if (coordinate != null) {
Log.e(tag, "Coordin: " + coordinate.getLatitude() + " | " + coordinate.getLongitude());
// Log.e(tag, "Element: " + element.getLatitude()+" | " + element.getLongitude());
// Log.e(tag, "isEqual: " + coordinate.getLatitude().equals(element.getLatitude()));
// Log.e(tag, "isEqual: " + coordinate.getLongitude().equals(element.getLongitude()));
boolean statement = coordinate.getLatitude().equals(element.getLatitude()) || coordinate.getLongitude().equals(element.getLongitude());
Log.e(tag, "diff || diff: " + !statement);
if (!statement) {
Log.e(tag, "replace and animate");
Marker marker = markerHash.get(id);
LatLng toDestination = new LatLng(element.getLatitude(), element.getLongitude());
// TODO fix flickiering markers
ValueAnimator markerAnimator = ObjectAnimator.ofObject(marker, "position",
new mapUtils.LatLngEvaluator(),
marker.getPosition(),
toDestination);
markerAnimator.setDuration(2000);
markerAnimator.setInterpolator(new LinearInterpolator());
markerAnimator.start();
// chba niepotrzbene
mapboxMap.getMarkerViewManager().update();
coordsMap.put(id, element);
marker.setPosition(toDestination);
}
} else {
Log.e(tag, "Marker Added: " + id);
coordsMap.put(id, element);
Marker marker = mapboxMap.addMarker(new MarkerOptions()
.title(id)
.position(new LatLng(element.getLatitude(), element.getLongitude())));
markerHash.put(id, marker);
}
coordsMap.get(id).setLabel(newLabel);
}
// For next fetch
previousCoordsIds.clear();
previousCoordsIds.addAll(currentCoordsIds);
}
@SuppressLint("LongLogTag")
@Override
public void onError(Throwable e) {
Log.e("MapActivity onError", e.getMessage());
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
Log.e("MapActivity onError", RestApiHelper.getErrorMessage(responseBody));
}
}
})
);
}
// Add the mapView lifecycle to the activity's lifecycle methods
@Override
public void onResume() {
super.onResume();
mapView.onResume();
}
@Override
protected void onStart() {
super.onStart();
mapView.onStart();
}
@Override
protected void onStop() {
super.onStop();
mapView.onStop();
}
@Override
public void onPause() {
super.onPause();
mapView.onPause();
}
@Override
public void onLowMemory() {
super.onLowMemory();
mapView.onLowMemory();
}
@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
mHandler.removeCallbacks(mStatusChecker);
disposable.dispose();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mapView.onSaveInstanceState(outState);
}
@Override
protected int getContentViewId() {
return R.layout.activity_map;
}
@Override
protected int getNavigationMenuItemId() {
return R.id.nav_map;
}
@SuppressWarnings({"MissingPermission"})
private void enableLocationPlugin() {
Log.e(tag, "enableLocationPlugin");
// Check if permissions are enabled and if not request
if (PermissionsManager.areLocationPermissionsGranted(this)) {
Log.e(tag, "enableLocationPlugin true");
FloatingActionButton myLocationButton = findViewById(R.id.myLocationButton);
myLocationButton.setVisibility(View.VISIBLE);
LocationComponentOptions options = LocationComponentOptions.builder(this)
.trackingGesturesManagement(true)
.accuracyColor(ContextCompat.getColor(this, R.color.mapboxGray))
.build();
// Get an instance of the component
locationComponent = mapboxMap.getLocationComponent();
//Log.e(tag + "Last", locationComponent.getLastKnownLocation() + "");
// Activate with options
locationComponent.activateLocationComponent(this, options);
// Enable to make component visible
locationComponent.setLocationComponentEnabled(true);
// Set the component's camera mode
locationComponent.setCameraMode(CameraMode.TRACKING);
locationComponent.setRenderMode(RenderMode.COMPASS);
// Button 4 centring
FloatingActionButton myLocFAB = findViewById(R.id.myLocationButton);
myLocFAB.setOnClickListener(v -> {
Location lastKnownLocation = locationComponent.getLastKnownLocation();
if (lastKnownLocation != null) {
CameraPosition position = new CameraPosition.Builder()
.target(new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude())) // Sets the new camera position
.zoom(zoomParam) // Sets the zoom
.bearing(bearingParam) // Rotate the camera
.tilt(tiltParam) // Set the camera tilt
.build(); // Creates a CameraPosition from the builder
mapboxMap.animateCamera(CameraUpdateFactory
.newCameraPosition(position), 4000);
}
// Camera aniamtion
zoomParam = (zoomParam == 17) ? 19 : 17;
bearingParam += 90;
tiltParam = (tiltParam == 30) ? 0 : 30;
});
} else {
Log.e(tag, "enableLocationPlugin false");
permissionsManager = new PermissionsManager(this);
permissionsManager.requestLocationPermissions(this);
permissionsManager.onRequestPermissionsResult(0, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, new int[]{0});
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @android.support.annotation.NonNull String[] permissions, @android.support.annotation.NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
// permissionsManager.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
@Override
public void onExplanationNeeded(List<String> permissionsToExplain) {
Toast.makeText(this, R.string.user_location_permission_explanation, Toast.LENGTH_LONG).show();
}
@Override
public void onPermissionResult(boolean granted) {
// if (granted) {
// enableLocationPlugin();
// } else {
// Toast.makeText(this, R.string.user_location_permission_not_granted, Toast.LENGTH_LONG).show();
// finish();
// }
}
}

View File

@ -0,0 +1,133 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.view.MenuItem;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import java.util.Locale;
public class SettingsActivity extends AppCompatPreferenceActivity {
private static final String TAG = SettingsActivity.class.getSimpleName();
String currentLang;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getFragmentManager().beginTransaction().replace(android.R.id.content, new MainPreferenceFragment()).commit();
}
public void setLocale(String localeName) {
Locale myLocale = new Locale(localeName);
Resources res = getResources();
DisplayMetrics dm = res.getDisplayMetrics();
Configuration conf = res.getConfiguration();
conf.locale = myLocale;
res.updateConfiguration(conf, dm);
Intent refresh = new Intent(this, MapActivity.class);
refresh.putExtra(currentLang, localeName);
startActivity(refresh);
}
public static class MainPreferenceFragment extends PreferenceFragment {
@SuppressLint("ResourceType")
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.pref_main);
Preference languagesList = findPreference(getResources().getString(R.string.key_language));
languagesList.setDefaultValue(0);
if(PrefUtils.getLocale(getActivity()).equals("pl")){
languagesList.setDefaultValue(1);
}
languagesList.setOnPreferenceChangeListener((preference, newValue) -> {
if (!newValue.toString().equals("0")){
((SettingsActivity)getActivity()).setLocale("pl");
PrefUtils.storeLocale(getActivity(),"pl");
}else{
((SettingsActivity)getActivity()).setLocale("en");
PrefUtils.storeLocale(getActivity(),"en");
}
return true;
});
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
private static void bindPreferenceSummaryToValue(Preference preference) {
preference.setOnPreferenceChangeListener(sBindPreferenceSummaryToValueListener);
sBindPreferenceSummaryToValueListener.onPreferenceChange(preference,
PreferenceManager
.getDefaultSharedPreferences(preference.getContext())
.getString(preference.getKey(), ""));
}
/**
* A preference value change listener that updates the preference's summary
* to reflect its new value.
*/
private static Preference.OnPreferenceChangeListener sBindPreferenceSummaryToValueListener = new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String stringValue = newValue.toString();
if (preference instanceof ListPreference) {
// For list preferences, look up the correct display value in
// the preference's 'entries' list.
ListPreference listPreference = (ListPreference) preference;
int index = listPreference.findIndexOfValue(stringValue);
// Set the summary to reflect the new value.
preference.setSummary(
index >= 0
? listPreference.getEntries()[index]
: null);
} else if (preference instanceof EditTextPreference) {
if (preference.getKey().equals("key_gallery_name")) {
// update the changed gallery name to summary filed
preference.setSummary(stringValue);
}
} else {
preference.setSummary(stringValue);
}
return true;
}
};
}

View File

@ -0,0 +1,128 @@
package com.uam.wmi.findmytutor.activity;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class SharingFragment extends PreferenceFragment {
private HashMap<Integer, String> locationLevelMapping;
// private HashMap<Integer, String> statusMapping;
@SuppressLint("ResourceType")
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
locationLevelMapping = new HashMap<Integer, String>();
locationLevelMapping.put(0,"presence");
locationLevelMapping.put(1,"approximated");
locationLevelMapping.put(2,"exact");
addPreferencesFromResource(R.layout.pref_sharing);
Preference manualStatus = findPreference("key_manual_status");
Preference locationSharing = findPreference("key_sharing_enabled");
Preference locationMode = findPreference("key_location_level");
Preference statusList = findPreference("key_status_value");
manualStatus.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) findPreference("key_status_value");
updateListPreference(lp, newValue, "manual_statuses");
PrefUtils.storeStatus(getApplicationContext(),(String) newValue);
return true;
});
locationMode.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) preference;
PrefUtils.storeLocationMode(getApplicationContext(),locationLevelMapping.get(Integer.parseInt((String) newValue)));
return true;
});
statusList.setOnPreferenceChangeListener((preference, newValue) -> {
ListPreference lp = (ListPreference) preference;
CharSequence [] entries = lp.getEntries();
PrefUtils.storeStatus(getApplicationContext(),(String) entries[Integer.parseInt((String) newValue)]);
return true;
});
locationSharing.setOnPreferenceChangeListener((buttonView, newValue) -> {
PrefUtils.storeEnableSharingLocalization(getApplicationContext(), (Boolean) newValue);
((MapActivity)getActivity()).handleBackgroundTaskLifeCycle();
return true;
});
}
public static SharingFragment newInstance() {
return new SharingFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
Objects.requireNonNull(view).setBackgroundColor(getResources().getColor(android.R.color.white));
return view;
}
public String getListPreferenceValue(String key){
ListPreference lp = (ListPreference) findPreference(key);
return (String)lp.getEntry();
}
protected void updateListPreference(ListPreference lp,Object newValue,String storageKey){
CharSequence [] entries = lp.getEntries();
Set<String> defaultEntries = new HashSet(Arrays.asList(entries));
SharedPreferences sharedPref = getActivity().getPreferences(Context.MODE_PRIVATE);
Set <String> manualStatusSet = sharedPref.getStringSet(storageKey,defaultEntries);
manualStatusSet.add((String) newValue);
String [] manualStatusArr = manualStatusSet.toArray(new String[0]);
Arrays.sort(manualStatusArr);
setListPreferenceData(lp.getKey(),manualStatusArr);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putStringSet(storageKey,manualStatusSet);
editor.apply();
}
protected void setListPreferenceData(String lp_name, String [] entries) {
ListPreference lp = (ListPreference) findPreference(lp_name);
lp.setEntries(entries);
CharSequence[] entryValues = new CharSequence [entries.length];
for (int i = 0; i < entries.length; i++){
entryValues[i] = Integer.toString(i);
}
lp.setDefaultValue("1");
lp.setEntryValues(entryValues);
}
}

View File

@ -1,30 +1,29 @@
package com.uam.wmi.findmytutor.activity; package com.uam.wmi.findmytutor.activity;
import android.app.Activity; import android.app.Activity;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v7.app.AppCompatActivity; import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log; import android.support.v7.app.AppCompatActivity;
import android.util.DisplayMetrics;
import android.widget.Toast; import android.widget.Toast;
import com.uam.wmi.findmytutor.model.JwtToken;
import com.uam.wmi.findmytutor.model.LdapUser;
import com.uam.wmi.findmytutor.network.RetrofitClientInstance;
import com.uam.wmi.findmytutor.service.LdapService;
import retrofit2.Call; import com.uam.wmi.findmytutor.utils.PrefUtils;
import retrofit2.Callback;
import retrofit2.Response; import java.util.Locale;
public class StartupActivity extends AppCompatActivity { public class StartupActivity extends AppCompatActivity {
private static final int AUTHENTICATION_REQUEST_CODE = 666; private static final int AUTHENTICATION_REQUEST_CODE = 666;
String currentLang;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
if (isLoggedIn()){ if (PrefUtils.isLoggedIn(getApplicationContext())){
Intent startupIntent = new Intent(this, MainActivity.class); Intent startupIntent = new Intent(this, MapActivity.class);
startupIntent.putExtra(currentLang, PrefUtils.getLocale(getApplicationContext()));
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent); startActivity(startupIntent);
finish(); finish();
@ -35,18 +34,12 @@ public class StartupActivity extends AppCompatActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
//to nie ma miec layoutu wiec elo
// setContentView(R.layout.activity_startup);
}
private boolean isLoggedIn() {
return this.getSharedPreferences("fmtPrefs", Context.MODE_PRIVATE).getBoolean("loggedIn",false);
} }
@Override @Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) { if (requestCode == AUTHENTICATION_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
Intent startupIntent = new Intent(this, MainActivity.class); Intent startupIntent = new Intent(this, MapActivity.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent); startActivity(startupIntent);
} }

View File

@ -0,0 +1,265 @@
package com.uam.wmi.findmytutor.activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.annimon.stream.Stream;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.adapters.TutorsListAdapter;
import com.uam.wmi.findmytutor.model.DutyHourViewModel;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import com.uam.wmi.findmytutor.model.User;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.service.TutorTabApi;
import com.uam.wmi.findmytutor.service.UserService;
import com.uam.wmi.findmytutor.utils.MyDividerItemDecoration;
import com.uam.wmi.findmytutor.utils.RecyclerTouchListener;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
public class UsersListFragment extends Fragment {
private static final String TAG = UsersListFragment.class.getSimpleName();
@BindView(R.id.coordinator_layout)
CoordinatorLayout coordinatorLayout;
@BindView(R.id.recycler_view)
RecyclerView recyclerView;
@BindView(R.id.txt_empty_notes_view)
TextView noNotesView;
private UserService userService;
private TutorTabApi tutorTabService;
private CompositeDisposable disposable = new CompositeDisposable();
private TutorsListAdapter mAdapter;
private List<User> tutorsList = new ArrayList<>();
private List<User> tutorsFiltered = new ArrayList<>();
public UsersListFragment() {
}
public static UsersListFragment newInstance() {
return new UsersListFragment();
}
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mAdapter = new TutorsListAdapter(getActivity().getApplicationContext(), tutorsFiltered);
View view = inflater.inflate(R.layout.users_list, container, false);
view.setBackgroundColor(getResources().getColor(android.R.color.white));
return view;
}
public void onViewCreated(View view, Bundle savedInstanceState) {
ButterKnife.bind(this, view);
userService = ApiClient.getClient(getApplicationContext())
.create(UserService.class);
tutorTabService = ApiClient.getClient(getActivity().getApplicationContext())
.create(TutorTabApi.class);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
recyclerView.setLayoutManager(mLayoutManager);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new MyDividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL, 16));
recyclerView.setAdapter(mAdapter);
fetchAllTutors();
recyclerView.addOnItemTouchListener(new RecyclerTouchListener(getActivity().getApplicationContext(),
recyclerView, new RecyclerTouchListener.ClickListener() {
@Override
public void onClick(View view, final int position) {
showNoteDialog(tutorsFiltered.get(position));
}
@Override
public void onLongClick(View view, int position) {
}
}));
}
public void searchUser(String textToSearch) {
tutorsFiltered.clear();
tutorsFiltered.addAll(Stream.of(tutorsList).filter(t ->
t.toSearchAbleString().toLowerCase().contains(textToSearch.toLowerCase())).toList());
mAdapter.notifyDataSetChanged();
}
private void showNoteDialog(final User user) {
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(getActivity().getApplicationContext());
View view = layoutInflaterAndroid.inflate(R.layout.user_list_modal, null);
AlertDialog.Builder alertDialogBuilderUserInput = new AlertDialog.Builder(getActivity());
alertDialogBuilderUserInput.setView(view);
alertDialogBuilderUserInput.setNegativeButton(R.string.cancel, (dialog, id) -> {
// User cancelled the dialog
});
TextView userName = view.findViewById(R.id.userName);
ListView userDutyHours = view.findViewById(R.id.userDutyHours);
TextView userDutyHoursTitle = view.findViewById(R.id.userDutyHoursTitle);
TextView userNote = view.findViewById(R.id.userNote);
TextView userRoom = view.findViewById(R.id.userRoom);
TextView userEmail = view.findViewById(R.id.userEmail);
TextView department = view.findViewById(R.id.userDepartment);
userName.setText(String.format("%s %s", user.getFirstName(), user.getLastName()));
disposable.add(
tutorTabService.apiUsersTutorTabByTutorIdGet(user.getId())
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<TutorTabViewModel>() {
@Override
public void onSuccess(TutorTabViewModel tutorTabViewModel) {
final AlertDialog alertDialog = alertDialogBuilderUserInput.create();
List<String> dutyHoursList = Stream.of(tutorTabViewModel.getDutyHours())
.map(DutyHourViewModel::getSummary).toList();
userRoom.setText(String.format("%s: %s", getString(R.string.userRoom), tutorTabViewModel.getRoom()));
userEmail.setText(String.format("%s: %s", getString(R.string.userEmail), tutorTabViewModel.getEmailTutorTab()));
userNote.setText(String.format("%s: %s", getString(R.string.userNote), tutorTabViewModel.getNote()));
department.setText(String.format("%s: %s", getString(R.string.userDepartment), user.getDepartment()));
userDutyHoursTitle.setText(String.format("%s:", getString(R.string.userDutyHoursHeader)));
final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(getActivity(),
android.R.layout.test_list_item, dutyHoursList);
userDutyHours.setAdapter(arrayAdapter);
alertDialog.show();
}
@Override
public void onError(Throwable e) {
showError(e);
}
}));
}
private void fetchAllTutors() {
disposable.add(
userService.apiUsersGet()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.map(tutors -> {
List<User> tutorsList = new ArrayList<>(tutors);
List<User> onlineTutors = Stream.of(tutorsList).filter(User::isIsOnline).toList();
List<User> activeNotOnlineTutors = Stream.of(tutorsList)
.filter(t -> t.isIsActive() && !onlineTutors.contains(t)).toList();
List<User> notActiveTutors = Stream.of(tutorsList)
.filterNot(User::isIsActive).toList();
Collections.sort(onlineTutors, this::sortByUserName);
Collections.sort(activeNotOnlineTutors, this::sortByUserName);
Collections.sort(notActiveTutors, this::sortByUserName);
List<User> sortedUserList = new ArrayList<>(onlineTutors);
sortedUserList.addAll(activeNotOnlineTutors);
sortedUserList.addAll(notActiveTutors);
return sortedUserList;
})
.subscribeWith(new DisposableSingleObserver<List<User>>() {
@Override
public void onSuccess(List<User> users) {
tutorsList.clear();
tutorsList.addAll(users);
tutorsFiltered.addAll(users);
mAdapter.notifyDataSetChanged();
toggleEmptyNotes();
}
@Override
public void onError(Throwable e) {
showError(e);
}
}));
}
private int sortByUserName(User t1, User t2) {
return t1.getFirstName().compareTo(t2.getFirstName());
}
private void showError(Throwable e) {
String message;
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
}else{
message = "Network Error !";
}
Snackbar.make(coordinatorLayout, message, Snackbar.LENGTH_LONG)
.show();
}
private void toggleEmptyNotes() {
if (tutorsList.size() > 0) {
noNotesView.setVisibility(View.GONE);
} else {
noNotesView.setVisibility(View.VISIBLE);
}
}
@Override
public void onDestroy() {
super.onDestroy();
disposable.dispose();
}
@Override
public void onResume() {
super.onResume();
fetchAllTutors();
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onStop() {
super.onStop();
}
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
}

View File

@ -0,0 +1,87 @@
package com.uam.wmi.findmytutor.adapters;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.User;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class TutorsListAdapter extends RecyclerView.Adapter<TutorsListAdapter.MyViewHolder> {
private Context context;
private List<User> tutorsList;
public TutorsListAdapter(Context context, List<User> tutors) {
this.context = context;
this.tutorsList = tutors;
}
class MyViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.firstName)
TextView firstName;
@BindView(R.id.lastName)
TextView lastName;
@BindView(R.id.isOnline)
TextView isOnline;
MyViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
}
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.tutor_list_row, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
Drawable image = null;
User tutor = tutorsList.get(position);
holder.firstName.setText(tutor.getFirstName());
holder.lastName.setText(tutor.getLastName());
if(tutor.isIsOnline()) {
image = context.getResources().getDrawable(R.drawable.online_user);
} else {
image = context.getResources().getDrawable(R.drawable.not_online);
}
if(!tutor.isIsActive()){
image = context.getResources().getDrawable(R.drawable.not_active_user);
}
image.setBounds(0, 0, image.getIntrinsicWidth(), image.getIntrinsicHeight());
holder.isOnline.setCompoundDrawables(image, null, null, null);
}
@Override
public int getItemCount() {
return tutorsList.size();
}
}

View File

@ -0,0 +1,9 @@
package com.uam.wmi.findmytutor.model;
public class BaseResponse {
String error;
public String getError() {
return error;
}
}

View File

@ -0,0 +1,281 @@
package com.uam.wmi.findmytutor.model;
import android.util.Range;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import java.util.UUID;
import io.swagger.annotations.ApiModelProperty;
/**
* Coordinate
*/
public class Coordinate extends BaseResponse {
Range<Double> latitudeRange = Range.create(52.466709, 52.467007);
Range<Double> longtitudeRange = Range.create(16.926159, 16.926976);
@SerializedName("coordinateId")
private UUID coordinateId = null;
@SerializedName("latitude")
private Double latitude;
@SerializedName("longitude")
private Double longitude = null;
@SerializedName("altitude")
private Double altitude = null;
@SerializedName("userId")
private String userId = null;
@SerializedName("approximatedLocation")
private String approximatedLocation = null;
@SerializedName("displayMode")
private String displayMode = "exact";
@SerializedName("timeStamp")
private Long timeStamp = null;
@SerializedName("label")
private String label;
public Coordinate (Double latitude, Double longitude, Double altitude, String label, String userId, String displayMode) {
//if (!latitudeRange.contains(latitude)) throw new IllegalArgumentException("Inappropriate latitude value" + latitude);
//if (!longtitudeRange.contains(longitude)) throw new IllegalArgumentException("Inappropriate longitude value" + longitude);
this.latitude = latitude;
this.longitude = longitude;
this.altitude = altitude;
this.label = label;
this.userId = userId;
this.displayMode = displayMode;
}
public Coordinate (Double latitude) {
this.latitude = latitude;
}
public Coordinate coordinateId(UUID coordinateId) {
this.coordinateId = coordinateId;
return this;
}
/**
* Get coordinateId
* @return coordinateId
**/
@ApiModelProperty(required = true, value = "")
public UUID getCoordinateId() {
return coordinateId;
}
public void setCoordinateId(UUID coordinateId) {
this.coordinateId = coordinateId;
}
public Coordinate latitude(Double latitude) {
this.latitude = latitude;
return this;
}
/**
* Get latitude
* @return latitude
**/
@ApiModelProperty(required = true, value = "")
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Coordinate longitude(Double longitude) {
this.longitude = longitude;
return this;
}
/**
* Get longitude
* @return longitude
**/
@ApiModelProperty(required = true, value = "")
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Coordinate altitude(Double altitude) {
this.altitude = altitude;
return this;
}
/**
* Get altitude
* @return altitude
**/
@ApiModelProperty(required = true, value = "")
public Double getAltitude() {
return altitude;
}
public void setAltitude(Double altitude) {
this.altitude = altitude;
}
public Coordinate userId(String userId) {
this.userId = userId;
return this;
}
/**
* Get userId
* @return userId
**/
@ApiModelProperty(required = true, value = "")
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public Coordinate approximatedLocation(String approximatedLocation) {
this.approximatedLocation = approximatedLocation;
return this;
}
/**
* Get approximatedLocation
* @return approximatedLocation
**/
@ApiModelProperty(value = "")
public String getApproximatedLocation() {
return approximatedLocation;
}
public void setApproximatedLocation(String approximatedLocation) {
this.approximatedLocation = approximatedLocation;
}
public Coordinate displayMode(String displayMode) {
this.displayMode = displayMode;
return this;
}
/**
* Get displayMode
* @return displayMode
**/
@ApiModelProperty(required = true, value = "")
public String getDisplayMode() {
return displayMode;
}
public void setDisplayMode(String displayMode) {
this.displayMode = displayMode;
}
public Coordinate timeStamp(Long timeStamp) {
this.timeStamp = timeStamp;
return this;
}
/**
* Get timeStamp
* @return timeStamp
**/
@ApiModelProperty(value = "")
public Long getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Long timeStamp) {
this.timeStamp = timeStamp;
}
public Coordinate label(String label) {
this.label = label;
return this;
}
/**
* Get label
* @return label
**/
@ApiModelProperty(value = "")
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Coordinate coordinate = (Coordinate) o;
return Objects.equals(this.coordinateId, coordinate.coordinateId) &&
Objects.equals(this.latitude, coordinate.latitude) &&
Objects.equals(this.longitude, coordinate.longitude) &&
Objects.equals(this.altitude, coordinate.altitude) &&
Objects.equals(this.userId, coordinate.userId) &&
Objects.equals(this.approximatedLocation, coordinate.approximatedLocation) &&
Objects.equals(this.displayMode, coordinate.displayMode) &&
Objects.equals(this.timeStamp, coordinate.timeStamp) &&
Objects.equals(this.label, coordinate.label);
}
@Override
public int hashCode() {
return Objects.hash(coordinateId, latitude, longitude, altitude, userId, approximatedLocation, displayMode, timeStamp, label);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Coordinate {\n");
sb.append(" coordinateId: ").append(toIndentedString(coordinateId)).append("\n");
sb.append(" latitude: ").append(toIndentedString(latitude)).append("\n");
sb.append(" longitude: ").append(toIndentedString(longitude)).append("\n");
sb.append(" altitude: ").append(toIndentedString(altitude)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" approximatedLocation: ").append(toIndentedString(approximatedLocation)).append("\n");
sb.append(" displayMode: ").append(toIndentedString(displayMode)).append("\n");
sb.append(" timeStamp: ").append(toIndentedString(timeStamp)).append("\n");
sb.append(" label: ").append(toIndentedString(label)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,192 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import java.util.UUID;
import io.swagger.annotations.ApiModelProperty;
/**
* DutyHour
*/
public class DutyHour extends BaseResponse {
@SerializedName("dutyHourId")
private UUID dutyHourId = null;
@SerializedName("tutorTabId")
private UUID tutorTabId = null;
@SerializedName("day")
private String day = null;
@SerializedName("start")
private String start = null;
@SerializedName("end")
private String end = null;
@SerializedName("tutorTab")
private TutorTab tutorTab = null;
public DutyHour dutyHourId(UUID dutyHourId) {
this.dutyHourId = dutyHourId;
return this;
}
/**
* Get dutyHourId
* @return dutyHourId
**/
@ApiModelProperty(value = "")
public UUID getDutyHourId() {
return dutyHourId;
}
public void setDutyHourId(UUID dutyHourId) {
this.dutyHourId = dutyHourId;
}
public DutyHour tutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
return this;
}
/**
* Get tutorTabId
* @return tutorTabId
**/
@ApiModelProperty(required = true, value = "")
public UUID getTutorTabId() {
return tutorTabId;
}
public void setTutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
}
public DutyHour day(String day) {
this.day = day;
return this;
}
/**
* Get day
* @return day
**/
@ApiModelProperty(value = "")
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
public DutyHour start(String start) {
this.start = start;
return this;
}
/**
* Get start
* @return start
**/
@ApiModelProperty(value = "")
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public DutyHour end(String end) {
this.end = end;
return this;
}
/**
* Get end
* @return end
**/
@ApiModelProperty(value = "")
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
public DutyHour tutorTab(TutorTab tutorTab) {
this.tutorTab = tutorTab;
return this;
}
/**
* Get tutorTab
* @return tutorTab
**/
@ApiModelProperty(value = "")
public TutorTab getTutorTab() {
return tutorTab;
}
public void setTutorTab(TutorTab tutorTab) {
this.tutorTab = tutorTab;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DutyHour dutyHour = (DutyHour) o;
return Objects.equals(this.dutyHourId, dutyHour.dutyHourId) &&
Objects.equals(this.tutorTabId, dutyHour.tutorTabId) &&
Objects.equals(this.day, dutyHour.day) &&
Objects.equals(this.start, dutyHour.start) &&
Objects.equals(this.end, dutyHour.end) &&
Objects.equals(this.tutorTab, dutyHour.tutorTab);
}
@Override
public int hashCode() {
return Objects.hash(dutyHourId, tutorTabId, day, start, end, tutorTab);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DutyHour {\n");
sb.append(" dutyHourId: ").append(toIndentedString(dutyHourId)).append("\n");
sb.append(" tutorTabId: ").append(toIndentedString(tutorTabId)).append("\n");
sb.append(" day: ").append(toIndentedString(day)).append("\n");
sb.append(" start: ").append(toIndentedString(start)).append("\n");
sb.append(" end: ").append(toIndentedString(end)).append("\n");
sb.append(" tutorTab: ").append(toIndentedString(tutorTab)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,127 @@
package com.uam.wmi.findmytutor.model;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
/**
* DutyHourViewModel
*/
public class DutyHourViewModel {
@SerializedName("day")
private String day = null;
@SerializedName("start")
private String start = null;
@SerializedName("end")
private String end = null;
public DutyHourViewModel day(String day) {
this.day = day;
return this;
}
/**
* Get day
* @return day
**/
@ApiModelProperty(value = "")
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
public DutyHourViewModel start(String start) {
this.start = start;
return this;
}
/**
* Get start
* @return start
**/
@ApiModelProperty(value = "")
public String getStart() {
return start;
}
public void setStart(String start) {
this.start = start;
}
public DutyHourViewModel end(String end) {
this.end = end;
return this;
}
/**
* Get end
* @return end
**/
@ApiModelProperty(value = "")
public String getEnd() {
return end;
}
public void setEnd(String end) {
this.end = end;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DutyHourViewModel dutyHourViewModel = (DutyHourViewModel) o;
return Objects.equals(this.day, dutyHourViewModel.day) &&
Objects.equals(this.start, dutyHourViewModel.start) &&
Objects.equals(this.end, dutyHourViewModel.end);
}
@Override
public int hashCode() {
return Objects.hash(day, start, end);
}
public String getSummary() {
return this.getDay() + " " + this.getStart() + " " + this.getEnd();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DutyHourViewModel {\n");
sb.append(" day: ").append(toIndentedString(day)).append("\n");
sb.append(" start: ").append(toIndentedString(start)).append("\n");
sb.append(" end: ").append(toIndentedString(end)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,20 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class IsUsingListBool extends BaseResponse{
@SerializedName("isUsing")
@Expose
private Boolean isUsing;
public Boolean getIsUsing() {
return isUsing;
}
public void setIsUsing(Boolean isUsing) {
this.isUsing = isUsing;
}
}

View File

@ -0,0 +1,76 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* IsUsingListBoolModel
*/
public class IsUsingListBoolModel extends BaseResponse {
@SerializedName("isUsing")
private Boolean isUsing = null;
public IsUsingListBoolModel isUsing(Boolean isUsing) {
this.isUsing = isUsing;
return this;
}
/**
* Get isUsing
* @return isUsing
**/
@ApiModelProperty(value = "")
public Boolean isIsUsing() {
return isUsing;
}
public void setIsUsing(Boolean isUsing) {
this.isUsing = isUsing;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IsUsingListBoolModel isUsingListBoolModel = (IsUsingListBoolModel) o;
return Objects.equals(this.isUsing, isUsingListBoolModel.isUsing);
}
@Override
public int hashCode() {
return Objects.hash(isUsing);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class IsUsingListBoolModel {\n");
sb.append(" isUsing: ").append(toIndentedString(isUsing)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -1,96 +1,225 @@
package com.uam.wmi.findmytutor.model; package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
public class LdapUser { import java.util.Objects;
@SerializedName("login") import io.swagger.annotations.ApiModelProperty;
@Expose
private String login;
@SerializedName("password")
@Expose
private String password;
@SerializedName("department")
@Expose
private String department;
@SerializedName("title")
@Expose
private String title;
@SerializedName("firstName")
@Expose
private String firstName;
@SerializedName("lastName")
@Expose
private String lastName;
@SerializedName("email")
@Expose
private String email;
public LdapUser(String login, String password, String department, String title, String firstName, String lastName, String email) {
this.login = login; /**
this.password = password; * LdapUser
this.department = department; */
this.title = title;
this.firstName = firstName; public class LdapUser extends BaseResponse {
this.lastName = lastName; @SerializedName("login")
this.email = email; private String login = null;
@SerializedName("password")
private String password = null;
@SerializedName("department")
private String department = null;
@SerializedName("title")
private String title = null;
@SerializedName("firstName")
private String firstName = null;
@SerializedName("lastName")
private String lastName = null;
@SerializedName("email")
private String email = null;
public LdapUser(String login, String password, String department, String title, String firstName, String lastName, String email) {
this.login = login;
this.password = password;
this.department = department;
this.title = title;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
public LdapUser login(String login) {
this.login = login;
return this;
}
/**
* Get login
* @return login
**/
@ApiModelProperty(required = true, value = "")
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public LdapUser password(String password) {
this.password = password;
return this;
}
/**
* Get password
* @return password
**/
@ApiModelProperty(required = true, value = "")
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public LdapUser department(String department) {
this.department = department;
return this;
}
/**
* Get department
* @return department
**/
@ApiModelProperty(value = "")
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public LdapUser title(String title) {
this.title = title;
return this;
}
/**
* Get title
* @return title
**/
@ApiModelProperty(value = "")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public LdapUser firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* Get firstName
* @return firstName
**/
@ApiModelProperty(value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public LdapUser lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* Get lastName
* @return lastName
**/
@ApiModelProperty(value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public LdapUser email(String email) {
this.email = email;
return this;
}
/**
* Get email
* @return email
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
} }
if (o == null || getClass() != o.getClass()) {
public String getLogin() { return false;
return login;
} }
LdapUser ldapUser = (LdapUser) o;
return Objects.equals(this.login, ldapUser.login) &&
Objects.equals(this.password, ldapUser.password) &&
Objects.equals(this.department, ldapUser.department) &&
Objects.equals(this.title, ldapUser.title) &&
Objects.equals(this.firstName, ldapUser.firstName) &&
Objects.equals(this.lastName, ldapUser.lastName) &&
Objects.equals(this.email, ldapUser.email);
}
public void setLogin(String login) { @Override
this.login = login; public int hashCode() {
return Objects.hash(login, password, department, title, firstName, lastName, email);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class LdapUser {\n");
sb.append(" login: ").append(toIndentedString(login)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append(" department: ").append(toIndentedString(department)).append("\n");
sb.append(" title: ").append(toIndentedString(title)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
} }
return o.toString().replace("\n", "\n ");
}
public String getPassword() { }
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}

View File

@ -0,0 +1,18 @@
/*
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
public class Model
{
@SerializedName("data")
private PagedResult data;
public PagedResult getData ()
{
return data;
}
}
*/

View File

@ -0,0 +1,101 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class PagedResult {
@SerializedName("results")
@Expose
private List<ReturnedTutors> results = null;
@SerializedName("currentPage")
@Expose
private Integer currentPage;
@SerializedName("pageCount")
@Expose
private Integer pageCount;
@SerializedName("pageSize")
@Expose
private Integer pageSize;
@SerializedName("rowCount")
@Expose
private Integer rowCount;
@SerializedName("firstRowOnPage")
@Expose
private Integer firstRowOnPage;
@SerializedName("lastRowOnPage")
@Expose
private Integer lastRowOnPage;
public List<ReturnedTutors> getResults() {
return results;
}
public void setResults(List<ReturnedTutors> results) {
this.results = results;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageCount() {
return pageCount;
}
public void setPageCount(Integer pageCount) {
this.pageCount = pageCount;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getRowCount() {
return rowCount;
}
public void setRowCount(Integer rowCount) {
this.rowCount = rowCount;
}
public Integer getFirstRowOnPage() {
return firstRowOnPage;
}
public void setFirstRowOnPage(Integer firstRowOnPage) {
this.firstRowOnPage = firstRowOnPage;
}
public Integer getLastRowOnPage() {
return lastRowOnPage;
}
public void setLastRowOnPage(Integer lastRowOnPage) {
this.lastRowOnPage = lastRowOnPage;
}
}

View File

@ -0,0 +1,89 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import com.uam.wmi.findmytutor.model.Results;
public class PagedResultReturnedTutors extends BaseResponse{
@SerializedName("results")
@Expose
private Results results;
@SerializedName("currentPage")
@Expose
private Integer currentPage;
@SerializedName("pageCount")
@Expose
private Integer pageCount;
@SerializedName("pageSize")
@Expose
private Integer pageSize;
@SerializedName("rowCount")
@Expose
private Integer rowCount;
@SerializedName("firstRowOnPage")
@Expose
private Integer firstRowOnPage;
@SerializedName("lastRowOnPage")
@Expose
private Integer lastRowOnPage;
public Results getResults() {
return results;
}
public void setResults(Results results) {
this.results = results;
}
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public Integer getPageCount() {
return pageCount;
}
public void setPageCount(Integer pageCount) {
this.pageCount = pageCount;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Integer getRowCount() {
return rowCount;
}
public void setRowCount(Integer rowCount) {
this.rowCount = rowCount;
}
public Integer getFirstRowOnPage() {
return firstRowOnPage;
}
public void setFirstRowOnPage(Integer firstRowOnPage) {
this.firstRowOnPage = firstRowOnPage;
}
public Integer getLastRowOnPage() {
return lastRowOnPage;
}
public void setLastRowOnPage(Integer lastRowOnPage) {
this.lastRowOnPage = lastRowOnPage;
}
}

View File

@ -0,0 +1,214 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* PagedResultUserResponseModel
*/
public class PagedResultUserResponseModel extends BaseResponse {
@SerializedName("results")
@Expose
private List<UserResponseModel> results = null;
@SerializedName("currentPage")
@Expose
private Integer currentPage = null;
@SerializedName("pageCount")
@Expose
private Integer pageCount = null;
@SerializedName("pageSize")
@Expose
private Integer pageSize = null;
@SerializedName("rowCount")
@Expose
private Integer rowCount = null;
@SerializedName("firstRowOnPage")
@Expose
private Integer firstRowOnPage = null;
@SerializedName("lastRowOnPage")
@Expose
private Integer lastRowOnPage = null;
public PagedResultUserResponseModel results(List<UserResponseModel> results) {
this.results = results;
return this;
}
public PagedResultUserResponseModel addResultsItem(UserResponseModel resultsItem) {
if (this.results == null) {
this.results = new ArrayList<UserResponseModel>();
}
this.results.add(resultsItem);
return this;
}
/**
* Get results
* @return results
**/
@ApiModelProperty(value = "")
public List<UserResponseModel> getResults() {
return results;
}
public void setResults(List<UserResponseModel> results) {
this.results = results;
}
public PagedResultUserResponseModel currentPage(Integer currentPage) {
this.currentPage = currentPage;
return this;
}
/**
* Get currentPage
* @return currentPage
**/
@ApiModelProperty(value = "")
public Integer getCurrentPage() {
return currentPage;
}
public void setCurrentPage(Integer currentPage) {
this.currentPage = currentPage;
}
public PagedResultUserResponseModel pageCount(Integer pageCount) {
this.pageCount = pageCount;
return this;
}
/**
* Get pageCount
* @return pageCount
**/
@ApiModelProperty(value = "")
public Integer getPageCount() {
return pageCount;
}
public void setPageCount(Integer pageCount) {
this.pageCount = pageCount;
}
public PagedResultUserResponseModel pageSize(Integer pageSize) {
this.pageSize = pageSize;
return this;
}
/**
* Get pageSize
* @return pageSize
**/
@ApiModelProperty(value = "")
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public PagedResultUserResponseModel rowCount(Integer rowCount) {
this.rowCount = rowCount;
return this;
}
/**
* Get rowCount
* @return rowCount
**/
@ApiModelProperty(value = "")
public Integer getRowCount() {
return rowCount;
}
public void setRowCount(Integer rowCount) {
this.rowCount = rowCount;
}
/**
* Get firstRowOnPage
* @return firstRowOnPage
**/
@ApiModelProperty(value = "")
public Integer getFirstRowOnPage() {
return firstRowOnPage;
}
/**
* Get lastRowOnPage
* @return lastRowOnPage
**/
@ApiModelProperty(value = "")
public Integer getLastRowOnPage() {
return lastRowOnPage;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PagedResultUserResponseModel pagedResultUserResponseModel = (PagedResultUserResponseModel) o;
return Objects.equals(this.results, pagedResultUserResponseModel.results) &&
Objects.equals(this.currentPage, pagedResultUserResponseModel.currentPage) &&
Objects.equals(this.pageCount, pagedResultUserResponseModel.pageCount) &&
Objects.equals(this.pageSize, pagedResultUserResponseModel.pageSize) &&
Objects.equals(this.rowCount, pagedResultUserResponseModel.rowCount) &&
Objects.equals(this.firstRowOnPage, pagedResultUserResponseModel.firstRowOnPage) &&
Objects.equals(this.lastRowOnPage, pagedResultUserResponseModel.lastRowOnPage);
}
@Override
public int hashCode() {
return Objects.hash(results, currentPage, pageCount, pageSize, rowCount, firstRowOnPage, lastRowOnPage);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PagedResultUserResponseModel {\n");
sb.append(" results: ").append(toIndentedString(results)).append("\n");
sb.append(" currentPage: ").append(toIndentedString(currentPage)).append("\n");
sb.append(" pageCount: ").append(toIndentedString(pageCount)).append("\n");
sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n");
sb.append(" rowCount: ").append(toIndentedString(rowCount)).append("\n");
sb.append(" firstRowOnPage: ").append(toIndentedString(firstRowOnPage)).append("\n");
sb.append(" lastRowOnPage: ").append(toIndentedString(lastRowOnPage)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,164 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class Result extends BaseResponse {
@SerializedName("id")
@Expose
private String id;
@SerializedName("isOnline")
@Expose
private Boolean isOnline;
@SerializedName("isUsingBlacklist")
@Expose
private Boolean isUsingBlacklist;
@SerializedName("isUsingWhitelist")
@Expose
private Boolean isUsingWhitelist;
@SerializedName("blacklist")
@Expose
private List<String> blacklist = null;
@SerializedName("whitelist")
@Expose
private List<String> whitelist = null;
@SerializedName("ldapLogin")
@Expose
private String ldapLogin;
@SerializedName("title")
@Expose
private String title;
@SerializedName("firstName")
@Expose
private String firstName;
@SerializedName("lastName")
@Expose
private String lastName;
@SerializedName("department")
@Expose
private String department;
@SerializedName("userName")
@Expose
private String userName;
@SerializedName("email")
@Expose
private String email;
@SerializedName("isActive")
@Expose
private Boolean isActive;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Boolean getIsOnline() {
return isOnline;
}
public void setIsOnline(Boolean isOnline) {
this.isOnline = isOnline;
}
public Boolean getIsUsingBlacklist() {
return isUsingBlacklist;
}
public void setIsUsingBlacklist(Boolean isUsingBlacklist) {
this.isUsingBlacklist = isUsingBlacklist;
}
public Boolean getIsUsingWhitelist() {
return isUsingWhitelist;
}
public void setIsUsingWhitelist(Boolean isUsingWhitelist) {
this.isUsingWhitelist = isUsingWhitelist;
}
public List<String> getBlacklist() {
return blacklist;
}
public void setBlacklist(List<String> blacklist) {
this.blacklist = blacklist;
}
public List<String> getWhitelist() {
return whitelist;
}
public void setWhitelist(List<String> whitelist) {
this.whitelist = whitelist;
}
public String getLdapLogin() {
return ldapLogin;
}
public void setLdapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
}

View File

@ -0,0 +1,33 @@
package com.uam.wmi.findmytutor.model;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Results extends BaseResponse {
@SerializedName("tutors")
@Expose
private List<Tutor> tutors = null;
@SerializedName("blacklistersTutors")
@Expose
private List<Object> blacklistersTutors = null;
public List<Tutor> getTutors() {
return tutors;
}
public void setTutors(List<Tutor> tutors) {
this.tutors = tutors;
}
public List<Object> getBlacklistersTutors() {
return blacklistersTutors;
}
public void setBlacklistersTutors(List<Object> blacklistersTutors) {
this.blacklistersTutors = blacklistersTutors;
}
}

View File

@ -0,0 +1,108 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class ReturnedTutors {
@SerializedName("id")
@Expose
private String id;
@SerializedName("isOnline")
@Expose
private Boolean isOnline;
@SerializedName("title")
@Expose
private String title;
@SerializedName("firstName")
@Expose
private String firstName;
@SerializedName("lastName")
@Expose
private String lastName;
@SerializedName("department")
@Expose
private String department;
@SerializedName("userName")
@Expose
private String userName;
@SerializedName("email")
@Expose
private String email;
@SerializedName("isActive")
@Expose
private Boolean isActive;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Boolean getIsOnline() {
return isOnline;
}
public void setIsOnline(Boolean isOnline) {
this.isOnline = isOnline;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
}

View File

@ -0,0 +1,100 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* StudentIdModel
*/
public class StudentIdModel extends BaseResponse{
@SerializedName("studentId")
private String studentId = null;
@SerializedName("ldapLogin")
private String ldapLogin = null;
public StudentIdModel studentId(String studentId) {
this.studentId = studentId;
return this;
}
/**
* Get studentId
* @return studentId
**/
@ApiModelProperty(value = "")
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId;
}
public StudentIdModel ldapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
return this;
}
/**
* Get ldapLogin
* @return ldapLogin
**/
@ApiModelProperty(value = "")
public String getLdapLogin() {
return ldapLogin;
}
public void setLdapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
StudentIdModel studentIdModel = (StudentIdModel) o;
return Objects.equals(this.studentId, studentIdModel.studentId) &&
Objects.equals(this.ldapLogin, studentIdModel.ldapLogin);
}
@Override
public int hashCode() {
return Objects.hash(studentId, ldapLogin);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class StudentIdModel {\n");
sb.append(" studentId: ").append(toIndentedString(studentId)).append("\n");
sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,109 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Tutor {
@SerializedName("id")
@Expose
private String id;
@SerializedName("isOnline")
@Expose
private Boolean isOnline;
@SerializedName("title")
@Expose
private String title;
@SerializedName("firstName")
@Expose
private String firstName;
@SerializedName("lastName")
@Expose
private String lastName;
@SerializedName("department")
@Expose
private String department;
@SerializedName("userName")
@Expose
private String userName;
@SerializedName("email")
@Expose
private String email;
@SerializedName("isActive")
@Expose
private Boolean isActive;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Boolean getIsOnline() {
return isOnline;
}
public void setIsOnline(Boolean isOnline) {
this.isOnline = isOnline;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Boolean getIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
}

View File

@ -0,0 +1,204 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import io.swagger.annotations.ApiModelProperty;
/**
* TutorTab
*/
public class TutorTab extends BaseResponse{
@SerializedName("tutorTabId")
private UUID tutorTabId = null;
@SerializedName("userId")
private String userId = null;
@SerializedName("room")
private String room = null;
@SerializedName("emailTutorTab")
private String emailTutorTab = null;
@SerializedName("dutyHours")
private List<DutyHour> dutyHours = null;
@SerializedName("user")
private User user = null;
public TutorTab tutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
return this;
}
/**
* Get tutorTabId
* @return tutorTabId
**/
@ApiModelProperty(value = "")
public UUID getTutorTabId() {
return tutorTabId;
}
public void setTutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
}
public TutorTab userId(String userId) {
this.userId = userId;
return this;
}
/**
* Get userId
* @return userId
**/
@ApiModelProperty(required = true, value = "")
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public TutorTab room(String room) {
this.room = room;
return this;
}
/**
* Get room
* @return room
**/
@ApiModelProperty(value = "")
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public TutorTab emailTutorTab(String emailTutorTab) {
this.emailTutorTab = emailTutorTab;
return this;
}
/**
* Get emailTutorTab
* @return emailTutorTab
**/
@ApiModelProperty(value = "")
public String getEmailTutorTab() {
return emailTutorTab;
}
public void setEmailTutorTab(String emailTutorTab) {
this.emailTutorTab = emailTutorTab;
}
public TutorTab dutyHours(List<DutyHour> dutyHours) {
this.dutyHours = dutyHours;
return this;
}
public TutorTab addDutyHoursItem(DutyHour dutyHoursItem) {
if (this.dutyHours == null) {
this.dutyHours = new ArrayList<DutyHour>();
}
this.dutyHours.add(dutyHoursItem);
return this;
}
/**
* Get dutyHours
* @return dutyHours
**/
@ApiModelProperty(value = "")
public List<DutyHour> getDutyHours() {
return dutyHours;
}
public void setDutyHours(List<DutyHour> dutyHours) {
this.dutyHours = dutyHours;
}
public TutorTab user(User user) {
this.user = user;
return this;
}
/**
* Get user
* @return user
**/
@ApiModelProperty(value = "")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TutorTab tutorTab = (TutorTab) o;
return Objects.equals(this.tutorTabId, tutorTab.tutorTabId) &&
Objects.equals(this.userId, tutorTab.userId) &&
Objects.equals(this.room, tutorTab.room) &&
Objects.equals(this.emailTutorTab, tutorTab.emailTutorTab) &&
Objects.equals(this.dutyHours, tutorTab.dutyHours) &&
Objects.equals(this.user, tutorTab.user);
}
@Override
public int hashCode() {
return Objects.hash(tutorTabId, userId, room, emailTutorTab, dutyHours, user);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TutorTab {\n");
sb.append(" tutorTabId: ").append(toIndentedString(tutorTabId)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" room: ").append(toIndentedString(room)).append("\n");
sb.append(" emailTutorTab: ").append(toIndentedString(emailTutorTab)).append("\n");
sb.append(" dutyHours: ").append(toIndentedString(dutyHours)).append("\n");
sb.append(" user: ").append(toIndentedString(user)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,202 @@
package com.uam.wmi.findmytutor.model;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModelProperty;
import java.util.UUID;
/**
* TutorTabViewModel
*/
public class TutorTabViewModel {
@SerializedName("tutorTabId")
private UUID tutorTabId = null;
@SerializedName("userId")
private String userId = null;
@SerializedName("room")
private String room = "";
@SerializedName("emailTutorTab")
private String emailTutorTab = "";
@SerializedName("note")
private String note = "";
@SerializedName("dutyHours")
private List<DutyHourViewModel> dutyHours = null;
public TutorTabViewModel tutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
return this;
}
/**
* Get tutorTabId
* @return tutorTabId
**/
@ApiModelProperty(value = "")
public UUID getTutorTabId() {
return tutorTabId;
}
public void setTutorTabId(UUID tutorTabId) {
this.tutorTabId = tutorTabId;
}
public TutorTabViewModel userId(String userId) {
this.userId = userId;
return this;
}
/**
* Get userId
* @return userId
**/
@ApiModelProperty(value = "")
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public TutorTabViewModel room(String room) {
this.room = room;
return this;
}
/**
* Get room
* @return room
**/
@ApiModelProperty(value = "")
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public TutorTabViewModel emailTutorTab(String emailTutorTab) {
this.emailTutorTab = emailTutorTab;
return this;
}
/**
* Get emailTutorTab
* @return emailTutorTab
**/
@ApiModelProperty(value = "")
public String getEmailTutorTab() {
return emailTutorTab;
}
public void setEmailTutorTab(String emailTutorTab) {
this.emailTutorTab = emailTutorTab;
}
public TutorTabViewModel note(String note) {
this.note = note;
return this;
}
public String getNote() {
if(note == null)
return "";
return note;
}
public void setNote(String note) {
this.note = note;
}
public TutorTabViewModel dutyHours(List<DutyHourViewModel> dutyHours) {
this.dutyHours = dutyHours;
return this;
}
public TutorTabViewModel addDutyHoursItem(DutyHourViewModel dutyHoursItem) {
if (this.dutyHours == null) {
this.dutyHours = new ArrayList<DutyHourViewModel>();
}
this.dutyHours.add(dutyHoursItem);
return this;
}
/**
* Get dutyHours
* @return dutyHours
**/
@ApiModelProperty(value = "")
public List<DutyHourViewModel> getDutyHours() {
return dutyHours;
}
public void setDutyHours(List<DutyHourViewModel> dutyHours) {
this.dutyHours = dutyHours;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TutorTabViewModel tutorTabViewModel = (TutorTabViewModel) o;
return Objects.equals(this.tutorTabId, tutorTabViewModel.tutorTabId) &&
Objects.equals(this.userId, tutorTabViewModel.userId) &&
Objects.equals(this.room, tutorTabViewModel.room) &&
Objects.equals(this.emailTutorTab, tutorTabViewModel.emailTutorTab) &&
Objects.equals(this.note, tutorTabViewModel.note) &&
Objects.equals(this.dutyHours, tutorTabViewModel.dutyHours);
}
@Override
public int hashCode() {
return Objects.hash(tutorTabId, userId, room, emailTutorTab, note, dutyHours);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TutorTabViewModel {\n");
sb.append(" tutorTabId: ").append(toIndentedString(tutorTabId)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" room: ").append(toIndentedString(room)).append("\n");
sb.append(" emailTutorTab: ").append(toIndentedString(emailTutorTab)).append("\n");
sb.append(" note: ").append(toIndentedString(note)).append("\n");
sb.append(" dutyHours: ").append(toIndentedString(dutyHours)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,764 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import org.threeten.bp.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* User
*/
public class User extends BaseResponse {
@SerializedName("isOnline")
private Boolean isOnline = null;
@SerializedName("isUsingBlacklist")
private Boolean isUsingBlacklist = null;
@SerializedName("isUsingWhitelist")
private Boolean isUsingWhitelist = null;
@SerializedName("blacklist")
private List<String> blacklist = null;
@SerializedName("whitelist")
private List<String> whitelist = null;
@SerializedName("department")
private String department = null;
@SerializedName("ldapLogin")
private String ldapLogin = null;
@SerializedName("title")
private String title = null;
@SerializedName("firstName")
private String firstName = null;
@SerializedName("lastName")
private String lastName = null;
@SerializedName("isActive")
private Boolean isActive = null;
@SerializedName("tutorTab")
private TutorTab tutorTab = null;
@SerializedName("coordinates")
private List<Coordinate> coordinates = null;
@SerializedName("id")
private String id = null;
@SerializedName("userName")
private String userName = null;
@SerializedName("normalizedUserName")
private String normalizedUserName = null;
@SerializedName("email")
private String email = null;
@SerializedName("normalizedEmail")
private String normalizedEmail = null;
@SerializedName("emailConfirmed")
private Boolean emailConfirmed = null;
@SerializedName("passwordHash")
private String passwordHash = null;
@SerializedName("securityStamp")
private String securityStamp = null;
@SerializedName("concurrencyStamp")
private String concurrencyStamp = null;
@SerializedName("phoneNumber")
private String phoneNumber = null;
@SerializedName("phoneNumberConfirmed")
private Boolean phoneNumberConfirmed = null;
@SerializedName("twoFactorEnabled")
private Boolean twoFactorEnabled = null;
@SerializedName("lockoutEnd")
private OffsetDateTime lockoutEnd = null;
@SerializedName("lockoutEnabled")
private Boolean lockoutEnabled = null;
@SerializedName("accessFailedCount")
private Integer accessFailedCount = null;
public User isOnline(Boolean isOnline) {
this.isOnline = isOnline;
return this;
}
/**
* Get isOnline
*
* @return isOnline
**/
@ApiModelProperty(value = "")
public Boolean isIsOnline() {
return isOnline;
}
public void setIsOnline(Boolean isOnline) {
this.isOnline = isOnline;
}
public User isUsingBlacklist(Boolean isUsingBlacklist) {
this.isUsingBlacklist = isUsingBlacklist;
return this;
}
/**
* Get isUsingBlacklist
*
* @return isUsingBlacklist
**/
@ApiModelProperty(value = "")
public Boolean isIsUsingBlacklist() {
return isUsingBlacklist;
}
public void setIsUsingBlacklist(Boolean isUsingBlacklist) {
this.isUsingBlacklist = isUsingBlacklist;
}
public User isUsingWhitelist(Boolean isUsingWhitelist) {
this.isUsingWhitelist = isUsingWhitelist;
return this;
}
/**
* Get isUsingWhitelist
*
* @return isUsingWhitelist
**/
@ApiModelProperty(value = "")
public Boolean isIsUsingWhitelist() {
return isUsingWhitelist;
}
public void setIsUsingWhitelist(Boolean isUsingWhitelist) {
this.isUsingWhitelist = isUsingWhitelist;
}
public User blacklist(List<String> blacklist) {
this.blacklist = blacklist;
return this;
}
public User addBlacklistItem(String blacklistItem) {
if (this.blacklist == null) {
this.blacklist = new ArrayList<String>();
}
this.blacklist.add(blacklistItem);
return this;
}
/**
* Get blacklist
*
* @return blacklist
**/
@ApiModelProperty(value = "")
public List<String> getBlacklist() {
return blacklist;
}
public void setBlacklist(List<String> blacklist) {
this.blacklist = blacklist;
}
public User whitelist(List<String> whitelist) {
this.whitelist = whitelist;
return this;
}
public User addWhitelistItem(String whitelistItem) {
if (this.whitelist == null) {
this.whitelist = new ArrayList<String>();
}
this.whitelist.add(whitelistItem);
return this;
}
/**
* Get whitelist
*
* @return whitelist
**/
@ApiModelProperty(value = "")
public List<String> getWhitelist() {
return whitelist;
}
public void setWhitelist(List<String> whitelist) {
this.whitelist = whitelist;
}
public User department(String department) {
this.department = department;
return this;
}
/**
* Get department
*
* @return department
**/
@ApiModelProperty(required = true, value = "")
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public User ldapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
return this;
}
/**
* Get ldapLogin
*
* @return ldapLogin
**/
@ApiModelProperty(required = true, value = "")
public String getLdapLogin() {
return ldapLogin;
}
public void setLdapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
}
public User title(String title) {
this.title = title;
return this;
}
/**
* Get title
*
* @return title
**/
@ApiModelProperty(required = true, value = "")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public User firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* Get firstName
*
* @return firstName
**/
@ApiModelProperty(required = true, value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public User lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* Get lastName
*
* @return lastName
**/
@ApiModelProperty(required = true, value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public User isActive(Boolean isActive) {
this.isActive = isActive;
return this;
}
/**
* Get isActive
*
* @return isActive
**/
@ApiModelProperty(required = true, value = "")
public Boolean isIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
public User tutorTab(TutorTab tutorTab) {
this.tutorTab = tutorTab;
return this;
}
/**
* Get tutorTab
*
* @return tutorTab
**/
@ApiModelProperty(value = "")
public TutorTab getTutorTab() {
return tutorTab;
}
public void setTutorTab(TutorTab tutorTab) {
this.tutorTab = tutorTab;
}
public User coordinates(List<Coordinate> coordinates) {
this.coordinates = coordinates;
return this;
}
public User addCoordinatesItem(Coordinate coordinatesItem) {
if (this.coordinates == null) {
this.coordinates = new ArrayList<Coordinate>();
}
this.coordinates.add(coordinatesItem);
return this;
}
/**
* Get coordinates
*
* @return coordinates
**/
@ApiModelProperty(value = "")
public List<Coordinate> getCoordinates() {
return coordinates;
}
public void setCoordinates(List<Coordinate> coordinates) {
this.coordinates = coordinates;
}
public User id(String id) {
this.id = id;
return this;
}
/**
* Get id
*
* @return id
**/
@ApiModelProperty(value = "")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public User userName(String userName) {
this.userName = userName;
return this;
}
/**
* Get userName
*
* @return userName
**/
@ApiModelProperty(value = "")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public User normalizedUserName(String normalizedUserName) {
this.normalizedUserName = normalizedUserName;
return this;
}
/**
* Get normalizedUserName
*
* @return normalizedUserName
**/
@ApiModelProperty(value = "")
public String getNormalizedUserName() {
return normalizedUserName;
}
public void setNormalizedUserName(String normalizedUserName) {
this.normalizedUserName = normalizedUserName;
}
public User email(String email) {
this.email = email;
return this;
}
/**
* Get email
*
* @return email
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public User normalizedEmail(String normalizedEmail) {
this.normalizedEmail = normalizedEmail;
return this;
}
/**
* Get normalizedEmail
*
* @return normalizedEmail
**/
@ApiModelProperty(value = "")
public String getNormalizedEmail() {
return normalizedEmail;
}
public void setNormalizedEmail(String normalizedEmail) {
this.normalizedEmail = normalizedEmail;
}
public User emailConfirmed(Boolean emailConfirmed) {
this.emailConfirmed = emailConfirmed;
return this;
}
/**
* Get emailConfirmed
*
* @return emailConfirmed
**/
@ApiModelProperty(value = "")
public Boolean isEmailConfirmed() {
return emailConfirmed;
}
public void setEmailConfirmed(Boolean emailConfirmed) {
this.emailConfirmed = emailConfirmed;
}
public User passwordHash(String passwordHash) {
this.passwordHash = passwordHash;
return this;
}
/**
* Get passwordHash
*
* @return passwordHash
**/
@ApiModelProperty(value = "")
public String getPasswordHash() {
return passwordHash;
}
public void setPasswordHash(String passwordHash) {
this.passwordHash = passwordHash;
}
public User securityStamp(String securityStamp) {
this.securityStamp = securityStamp;
return this;
}
/**
* Get securityStamp
*
* @return securityStamp
**/
@ApiModelProperty(value = "")
public String getSecurityStamp() {
return securityStamp;
}
public void setSecurityStamp(String securityStamp) {
this.securityStamp = securityStamp;
}
public User concurrencyStamp(String concurrencyStamp) {
this.concurrencyStamp = concurrencyStamp;
return this;
}
/**
* Get concurrencyStamp
*
* @return concurrencyStamp
**/
@ApiModelProperty(value = "")
public String getConcurrencyStamp() {
return concurrencyStamp;
}
public void setConcurrencyStamp(String concurrencyStamp) {
this.concurrencyStamp = concurrencyStamp;
}
public User phoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
return this;
}
/**
* Get phoneNumber
*
* @return phoneNumber
**/
@ApiModelProperty(value = "")
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public User phoneNumberConfirmed(Boolean phoneNumberConfirmed) {
this.phoneNumberConfirmed = phoneNumberConfirmed;
return this;
}
/**
* Get phoneNumberConfirmed
*
* @return phoneNumberConfirmed
**/
@ApiModelProperty(value = "")
public Boolean isPhoneNumberConfirmed() {
return phoneNumberConfirmed;
}
public void setPhoneNumberConfirmed(Boolean phoneNumberConfirmed) {
this.phoneNumberConfirmed = phoneNumberConfirmed;
}
public User twoFactorEnabled(Boolean twoFactorEnabled) {
this.twoFactorEnabled = twoFactorEnabled;
return this;
}
/**
* Get twoFactorEnabled
*
* @return twoFactorEnabled
**/
@ApiModelProperty(value = "")
public Boolean isTwoFactorEnabled() {
return twoFactorEnabled;
}
public void setTwoFactorEnabled(Boolean twoFactorEnabled) {
this.twoFactorEnabled = twoFactorEnabled;
}
public User lockoutEnd(OffsetDateTime lockoutEnd) {
this.lockoutEnd = lockoutEnd;
return this;
}
/**
* Get lockoutEnd
*
* @return lockoutEnd
**/
@ApiModelProperty(value = "")
public OffsetDateTime getLockoutEnd() {
return lockoutEnd;
}
public void setLockoutEnd(OffsetDateTime lockoutEnd) {
this.lockoutEnd = lockoutEnd;
}
public User lockoutEnabled(Boolean lockoutEnabled) {
this.lockoutEnabled = lockoutEnabled;
return this;
}
/**
* Get lockoutEnabled
*
* @return lockoutEnabled
**/
@ApiModelProperty(value = "")
public Boolean isLockoutEnabled() {
return lockoutEnabled;
}
public void setLockoutEnabled(Boolean lockoutEnabled) {
this.lockoutEnabled = lockoutEnabled;
}
public User accessFailedCount(Integer accessFailedCount) {
this.accessFailedCount = accessFailedCount;
return this;
}
/**
* Get accessFailedCount
*
* @return accessFailedCount
**/
@ApiModelProperty(value = "")
public Integer getAccessFailedCount() {
return accessFailedCount;
}
public void setAccessFailedCount(Integer accessFailedCount) {
this.accessFailedCount = accessFailedCount;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
User user = (User) o;
return Objects.equals(this.isOnline, user.isOnline) &&
Objects.equals(this.isUsingBlacklist, user.isUsingBlacklist) &&
Objects.equals(this.isUsingWhitelist, user.isUsingWhitelist) &&
Objects.equals(this.blacklist, user.blacklist) &&
Objects.equals(this.whitelist, user.whitelist) &&
Objects.equals(this.department, user.department) &&
Objects.equals(this.ldapLogin, user.ldapLogin) &&
Objects.equals(this.title, user.title) &&
Objects.equals(this.firstName, user.firstName) &&
Objects.equals(this.lastName, user.lastName) &&
Objects.equals(this.isActive, user.isActive) &&
Objects.equals(this.tutorTab, user.tutorTab) &&
Objects.equals(this.coordinates, user.coordinates) &&
Objects.equals(this.id, user.id) &&
Objects.equals(this.userName, user.userName) &&
Objects.equals(this.normalizedUserName, user.normalizedUserName) &&
Objects.equals(this.email, user.email) &&
Objects.equals(this.normalizedEmail, user.normalizedEmail) &&
Objects.equals(this.emailConfirmed, user.emailConfirmed) &&
Objects.equals(this.passwordHash, user.passwordHash) &&
Objects.equals(this.securityStamp, user.securityStamp) &&
Objects.equals(this.concurrencyStamp, user.concurrencyStamp) &&
Objects.equals(this.phoneNumber, user.phoneNumber) &&
Objects.equals(this.phoneNumberConfirmed, user.phoneNumberConfirmed) &&
Objects.equals(this.twoFactorEnabled, user.twoFactorEnabled) &&
Objects.equals(this.lockoutEnd, user.lockoutEnd) &&
Objects.equals(this.lockoutEnabled, user.lockoutEnabled) &&
Objects.equals(this.accessFailedCount, user.accessFailedCount);
}
@Override
public int hashCode() {
return Objects.hash(isOnline, isUsingBlacklist, isUsingWhitelist, blacklist, whitelist, department, ldapLogin, title, firstName, lastName, isActive, tutorTab, coordinates, id, userName, normalizedUserName, email, normalizedEmail, emailConfirmed, passwordHash, securityStamp, concurrencyStamp, phoneNumber, phoneNumberConfirmed, twoFactorEnabled, lockoutEnd, lockoutEnabled, accessFailedCount);
}
public String toSearchAbleString() {
StringBuilder sb = new StringBuilder();
sb.append(getFirstName()).append(" ");
sb.append(getLastName()).append(" ");
sb.append(getDepartment()).append(" ");
sb.append(getEmail());
return sb.toString();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class User {\n");
sb.append(" isOnline: ").append(toIndentedString(isOnline)).append("\n");
sb.append(" isUsingBlacklist: ").append(toIndentedString(isUsingBlacklist)).append("\n");
sb.append(" isUsingWhitelist: ").append(toIndentedString(isUsingWhitelist)).append("\n");
sb.append(" blacklist: ").append(toIndentedString(blacklist)).append("\n");
sb.append(" whitelist: ").append(toIndentedString(whitelist)).append("\n");
sb.append(" department: ").append(toIndentedString(department)).append("\n");
sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n");
sb.append(" title: ").append(toIndentedString(title)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" isActive: ").append(toIndentedString(isActive)).append("\n");
sb.append(" tutorTab: ").append(toIndentedString(tutorTab)).append("\n");
sb.append(" coordinates: ").append(toIndentedString(coordinates)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" userName: ").append(toIndentedString(userName)).append("\n");
sb.append(" normalizedUserName: ").append(toIndentedString(normalizedUserName)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" normalizedEmail: ").append(toIndentedString(normalizedEmail)).append("\n");
sb.append(" emailConfirmed: ").append(toIndentedString(emailConfirmed)).append("\n");
sb.append(" passwordHash: ").append(toIndentedString(passwordHash)).append("\n");
sb.append(" securityStamp: ").append(toIndentedString(securityStamp)).append("\n");
sb.append(" concurrencyStamp: ").append(toIndentedString(concurrencyStamp)).append("\n");
sb.append(" phoneNumber: ").append(toIndentedString(phoneNumber)).append("\n");
sb.append(" phoneNumberConfirmed: ").append(toIndentedString(phoneNumberConfirmed)).append("\n");
sb.append(" twoFactorEnabled: ").append(toIndentedString(twoFactorEnabled)).append("\n");
sb.append(" lockoutEnd: ").append(toIndentedString(lockoutEnd)).append("\n");
sb.append(" lockoutEnabled: ").append(toIndentedString(lockoutEnabled)).append("\n");
sb.append(" accessFailedCount: ").append(toIndentedString(accessFailedCount)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,393 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import java.util.List;
import java.util.ArrayList;
import io.swagger.annotations.ApiModelProperty;
/**
* UserResponseModel
*/
public class UserResponseModel extends BaseResponse{
@SerializedName("id")
private String id = null;
@SerializedName("isOnline")
private Boolean isOnline = null;
@SerializedName("isUsingBlacklist")
private Boolean isUsingBlacklist = null;
@SerializedName("isUsingWhitelist")
private Boolean isUsingWhitelist = null;
@SerializedName("blacklist")
private List<String> blacklist = null;
@SerializedName("whitelist")
private List<String> whitelist = null;
@SerializedName("ldapLogin")
private String ldapLogin = null;
@SerializedName("title")
private String title = null;
@SerializedName("firstName")
private String firstName = null;
@SerializedName("lastName")
private String lastName = null;
@SerializedName("department")
private String department = null;
@SerializedName("userName")
private String userName = null;
@SerializedName("email")
private String email = null;
@SerializedName("isActive")
private Boolean isActive = null;
public UserResponseModel id(String id) {
this.id = id;
return this;
}
/**
* Get id
* @return id
**/
@ApiModelProperty(value = "")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public UserResponseModel isOnline(Boolean isOnline) {
this.isOnline = isOnline;
return this;
}
/**
* Get isOnline
* @return isOnline
**/
@ApiModelProperty(value = "")
public Boolean isIsOnline() {
return isOnline;
}
public void setIsOnline(Boolean isOnline) {
this.isOnline = isOnline;
}
public UserResponseModel isUsingBlacklist(Boolean isUsingBlacklist) {
this.isUsingBlacklist = isUsingBlacklist;
return this;
}
/**
* Get isUsingBlacklist
* @return isUsingBlacklist
**/
@ApiModelProperty(value = "")
public Boolean isIsUsingBlacklist() {
return isUsingBlacklist;
}
public void setIsUsingBlacklist(Boolean isUsingBlacklist) {
this.isUsingBlacklist = isUsingBlacklist;
}
public UserResponseModel isUsingWhitelist(Boolean isUsingWhitelist) {
this.isUsingWhitelist = isUsingWhitelist;
return this;
}
/**
* Get isUsingWhitelist
* @return isUsingWhitelist
**/
@ApiModelProperty(value = "")
public Boolean isIsUsingWhitelist() {
return isUsingWhitelist;
}
public void setIsUsingWhitelist(Boolean isUsingWhitelist) {
this.isUsingWhitelist = isUsingWhitelist;
}
public UserResponseModel blacklist(List<String> blacklist) {
this.blacklist = blacklist;
return this;
}
public UserResponseModel addBlacklistItem(String blacklistItem) {
if (this.blacklist == null) {
this.blacklist = new ArrayList<String>();
}
this.blacklist.add(blacklistItem);
return this;
}
/**
* Get blacklist
* @return blacklist
**/
@ApiModelProperty(value = "")
public List<String> getBlacklist() {
return blacklist;
}
public void setBlacklist(List<String> blacklist) {
this.blacklist = blacklist;
}
public UserResponseModel whitelist(List<String> whitelist) {
this.whitelist = whitelist;
return this;
}
public UserResponseModel addWhitelistItem(String whitelistItem) {
if (this.whitelist == null) {
this.whitelist = new ArrayList<String>();
}
this.whitelist.add(whitelistItem);
return this;
}
/**
* Get whitelist
* @return whitelist
**/
@ApiModelProperty(value = "")
public List<String> getWhitelist() {
return whitelist;
}
public void setWhitelist(List<String> whitelist) {
this.whitelist = whitelist;
}
public UserResponseModel ldapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
return this;
}
/**
* Get ldapLogin
* @return ldapLogin
**/
@ApiModelProperty(value = "")
public String getLdapLogin() {
return ldapLogin;
}
public void setLdapLogin(String ldapLogin) {
this.ldapLogin = ldapLogin;
}
public UserResponseModel title(String title) {
this.title = title;
return this;
}
/**
* Get title
* @return title
**/
@ApiModelProperty(value = "")
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public UserResponseModel firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* Get firstName
* @return firstName
**/
@ApiModelProperty(value = "")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public UserResponseModel lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* Get lastName
* @return lastName
**/
@ApiModelProperty(value = "")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public UserResponseModel department(String department) {
this.department = department;
return this;
}
/**
* Get department
* @return department
**/
@ApiModelProperty(value = "")
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public UserResponseModel userName(String userName) {
this.userName = userName;
return this;
}
/**
* Get userName
* @return userName
**/
@ApiModelProperty(value = "")
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public UserResponseModel email(String email) {
this.email = email;
return this;
}
/**
* Get email
* @return email
**/
@ApiModelProperty(value = "")
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public UserResponseModel isActive(Boolean isActive) {
this.isActive = isActive;
return this;
}
/**
* Get isActive
* @return isActive
**/
@ApiModelProperty(value = "")
public Boolean isIsActive() {
return isActive;
}
public void setIsActive(Boolean isActive) {
this.isActive = isActive;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserResponseModel userResponseModel = (UserResponseModel) o;
return Objects.equals(this.id, userResponseModel.id) &&
Objects.equals(this.isOnline, userResponseModel.isOnline) &&
Objects.equals(this.isUsingBlacklist, userResponseModel.isUsingBlacklist) &&
Objects.equals(this.isUsingWhitelist, userResponseModel.isUsingWhitelist) &&
Objects.equals(this.blacklist, userResponseModel.blacklist) &&
Objects.equals(this.whitelist, userResponseModel.whitelist) &&
Objects.equals(this.ldapLogin, userResponseModel.ldapLogin) &&
Objects.equals(this.title, userResponseModel.title) &&
Objects.equals(this.firstName, userResponseModel.firstName) &&
Objects.equals(this.lastName, userResponseModel.lastName) &&
Objects.equals(this.department, userResponseModel.department) &&
Objects.equals(this.userName, userResponseModel.userName) &&
Objects.equals(this.email, userResponseModel.email) &&
Objects.equals(this.isActive, userResponseModel.isActive);
}
@Override
public int hashCode() {
return Objects.hash(id, isOnline, isUsingBlacklist, isUsingWhitelist, blacklist, whitelist, ldapLogin, title, firstName, lastName, department, userName, email, isActive);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UserResponseModel {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" isOnline: ").append(toIndentedString(isOnline)).append("\n");
sb.append(" isUsingBlacklist: ").append(toIndentedString(isUsingBlacklist)).append("\n");
sb.append(" isUsingWhitelist: ").append(toIndentedString(isUsingWhitelist)).append("\n");
sb.append(" blacklist: ").append(toIndentedString(blacklist)).append("\n");
sb.append(" whitelist: ").append(toIndentedString(whitelist)).append("\n");
sb.append(" ldapLogin: ").append(toIndentedString(ldapLogin)).append("\n");
sb.append(" title: ").append(toIndentedString(title)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" department: ").append(toIndentedString(department)).append("\n");
sb.append(" userName: ").append(toIndentedString(userName)).append("\n");
sb.append(" email: ").append(toIndentedString(email)).append("\n");
sb.append(" isActive: ").append(toIndentedString(isActive)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,94 @@
package com.uam.wmi.findmytutor.model;
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
import io.swagger.annotations.ApiModelProperty;
/**
* ValidateUser
*/
public class ValidateUser extends BaseResponse {
@SerializedName("login")
private String login = null;
@SerializedName("password")
private String password = null;;
public ValidateUser(String login, String password) {
this.login = login;
this.password = password;
}
public ValidateUser login(String login) {
this.login = login;
return this;
}
/**
* Get login
* @return login
**/
@ApiModelProperty(required = true, value = "")
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public ValidateUser password(String password) {
this.password = password;
return this;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ValidateUser ValidateUser = (ValidateUser) o;
return Objects.equals(this.login, ValidateUser.login) &&
Objects.equals(this.password, ValidateUser.password);
}
@Override
public int hashCode() {
return Objects.hash(login, password);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ValidateUser {\n");
sb.append(" login: ").append(toIndentedString(login)).append("\n");
sb.append(" password: ").append(toIndentedString(password)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}

View File

@ -0,0 +1,76 @@
package com.uam.wmi.findmytutor.network;
import android.content.Context;
import android.text.TextUtils;
import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import okhttp3.Interceptor;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class ApiClient {
private static Retrofit retrofit = null;
private static int REQUEST_TIMEOUT = 60;
private static OkHttpClient okHttpClient;
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
public static Retrofit getClient(Context context) {
if (okHttpClient == null)
initOkHttp(context);
if (retrofit == null) {
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.client(okHttpClient)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build();
}
return retrofit;
}
private static void initOkHttp(final Context context) {
OkHttpClient.Builder httpClient = new OkHttpClient().newBuilder()
.connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS);
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
httpClient.addInterceptor(interceptor);
httpClient.addInterceptor(new Interceptor() {
@Override
public Response intercept(Chain chain) throws IOException {
Request original = chain.request();
Request.Builder requestBuilder = original.newBuilder()
.addHeader("Accept", "application/json")
.addHeader("Content-Type", "application/json");
// Adding Authorization token (API Key)
// Requests will be denied without API key
if (!TextUtils.isEmpty(PrefUtils.getApiKey(context))) {
requestBuilder.addHeader("Authorization", "Bearer " + PrefUtils.getApiKey(context));
}
Request request = requestBuilder.build();
return chain.proceed(request);
}
});
okHttpClient = httpClient.build();
}
};

View File

@ -1,32 +0,0 @@
package com.uam.wmi.findmytutor.network;
import java.io.IOException;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
public abstract class NetworkConnectionInterceptor implements Interceptor {
public abstract boolean isInternetAvailable();
public abstract void onInternetUnavailable();
public abstract void onCacheUnavailable();
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
if (!isInternetAvailable()) {
onInternetUnavailable();
request = request.newBuilder().header("Cache-Control",
"public, only-if-cached, max-stale=" + 60 * 60 * 24).build();
Response response = chain.proceed(request);
if (response.cacheResponse() == null) {
onCacheUnavailable();
}
return response;
}
return chain.proceed(request);
}
}

View File

@ -1,71 +1,55 @@
package com.uam.wmi.findmytutor.network; package com.uam.wmi.findmytutor.network;
import java.util.concurrent.TimeUnit; import com.jakewharton.retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.logging.HttpLoggingInterceptor;
import retrofit2.Retrofit; import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory; import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitClientInstance { public class RetrofitClientInstance {
private static Retrofit retrofit;
private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/"; private static final String BASE_URL = "https://s416084.projektstudencki.pl/develop/";
private static Retrofit.Builder builder
= new Retrofit.Builder()
.baseUrl(BASE_URL)
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.addConverterFactory(GsonConverterFactory.create());
public static Retrofit getRetrofitLoginInstance() { private static Retrofit retrofit = builder.build();
if (retrofit == null) {
retrofit = new retrofit2.Retrofit.Builder() private static OkHttpClient.Builder httpClient
.baseUrl(BASE_URL) = new OkHttpClient.Builder();
.addConverterFactory(GsonConverterFactory.create())
.build(); private static HttpLoggingInterceptor logging
= new HttpLoggingInterceptor()
.setLevel(HttpLoggingInterceptor.Level.BASIC);
public static <S> S createService(Class<S> serviceClass) {
if (!httpClient.interceptors().contains(logging)) {
httpClient.addInterceptor(logging);
builder.client(httpClient.build());
retrofit = builder.build();
} }
return retrofit; return retrofit.create(serviceClass);
} }
public static Retrofit getRetrofitInstance() { public static <S> S createService(Class<S> serviceClass, final String token) {
if (retrofit == null) { if (token != null) {
retrofit = new retrofit2.Retrofit.Builder() httpClient.interceptors().clear();
.baseUrl(BASE_URL) httpClient.addInterceptor(chain -> {
.client(provideOkHttpClient()) Request original = chain.request();
.addConverterFactory(GsonConverterFactory.create()) Request.Builder builder1 = original.newBuilder()
.build(); .header("Authorization", "Bearer " + token);
Request request = builder1.build();
return chain.proceed(request);
});
builder.client(httpClient.build());
retrofit = builder.build();
} }
return retrofit; return retrofit.create(serviceClass);
} }
private static OkHttpClient provideOkHttpClient() {
OkHttpClient.Builder okhttpClientBuilder = new OkHttpClient.Builder();
okhttpClientBuilder.connectTimeout(30, TimeUnit.SECONDS);
okhttpClientBuilder.readTimeout(30, TimeUnit.SECONDS);
okhttpClientBuilder.writeTimeout(30, TimeUnit.SECONDS);
return okhttpClientBuilder.build();
}
//
// private OkHttpClient provideokHttpClient() {
// OkHttpClient.Builder okhttpClientBuilder = new OkHttpClient.Builder();
// okhttpClientBuilder.connectTimeout(30, TimeUnit.SECONDS);
// okhttpClientBuilder.readTimeout(30, TimeUnit.SECONDS);
// okhttpClientBuilder.writeTimeout(30, TimeUnit.SECONDS);
//
// okhttpClientBuilder.addInterceptor(new NetworkConnectionInterceptor() {
// @Override
// public boolean isInternetAvailable() {
// return this.isInternetAvailable();
// }
//
// @Override
// public void onInternetUnavailable() {
// if (mInternetConnectionListener != null) {
// mInternetConnectionListener.onInternetUnavailable();
// }
// }
//
// @Override
// public void onCacheUnavailable() {
// if (mInternetConnectionListener != null) {
// mInternetConnectionListener.onCacheUnavailable();
// }
// }
// });
// }
} }

View File

@ -0,0 +1,346 @@
package com.uam.wmi.findmytutor.service;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.location.Location;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.support.annotation.RequiresApi;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.tasks.OnSuccessListener;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.model.Coordinate;
import com.uam.wmi.findmytutor.network.ApiClient;
import com.uam.wmi.findmytutor.utils.PrefUtils;
import com.uam.wmi.findmytutor.utils.RestApiHelper;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executor;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.observers.DisposableSingleObserver;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;
import timber.log.Timber;
import static com.uam.wmi.findmytutor.utils.PrefUtils.storeBackgroundLocationStatus;
public class BackgroundLocalizationService extends Service {
private static final String TAG = "MyLocationService";
private static final int LOCATION_INTERVAL = 1000;
private static final float LOCATION_DISTANCE = 5f;
public static String str_receiver = "background.location.broadcast";
private static long notify_interval = 10000;
Location mLastLocation;
Boolean stopService = false;
ArrayList<String> providers = new ArrayList<String>();
LocationListener[] mLocationListeners;
private LocationManager mLocationManager = null;
private Handler mHandler = new Handler();
private HandlerThread mHandlerThread = null;
private Runnable mStatusChecker;
private FusedLocationProviderClient mFusedLocationClient;
public BackgroundLocalizationService() {
providers.add(LocationManager.GPS_PROVIDER);
providers.add(LocationManager.NETWORK_PROVIDER);
providers.add(LocationManager.PASSIVE_PROVIDER);
mLocationListeners = new LocationListener[]{
new LocationListener(LocationManager.GPS_PROVIDER),
new LocationListener(LocationManager.NETWORK_PROVIDER),
new LocationListener(LocationManager.PASSIVE_PROVIDER)
};
}
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.e(TAG, "onStartCommand");
super.onStartCommand(intent, flags, startId);
if (intent != null) {
stopService = intent.getBooleanExtra("request_stop", false);
}
if (stopService) {
storeBackgroundLocationStatus(getApplication(),false);
stopForeground(true);
stopSelf();
return START_STICKY;
}
return START_STICKY;
}
@Override
public void onCreate() {
Log.e(TAG, "onCreate");
storeBackgroundLocationStatus(getApplication(),true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
startMyOwnForeground();
else {
Notification notification = new NotificationCompat.Builder(this, "NOTIFICATION_CHANNEL")
.setContentText("Content").build();
startForeground(1001, notification);
}
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
initializeLocationManager();
Integer providerIndex = 0;
for (LocationListener listener : mLocationListeners) {
try {
mLocationManager.requestLocationUpdates(
providers.get(providerIndex),
LOCATION_INTERVAL,
LOCATION_DISTANCE,
listener
);
} catch (java.lang.SecurityException ex) {
Log.i(TAG, "fail to request location update, ignore", ex);
} catch (IllegalArgumentException ex) {
Log.d(TAG, "network provider does not exist, " + ex.getMessage());
}
providerIndex++;
}
if(!stopService){
mStatusChecker = () -> {
try {
fn_getlocation();
} finally {
mHandler.postDelayed(mStatusChecker, notify_interval);
}
};
AsyncTask.execute(mStatusChecker);
}
}
@RequiresApi(api = Build.VERSION_CODES.O)
private void startMyOwnForeground() {
String NOTIFICATION_CHANNEL_ID = "com.example.simpleapp";
String channelName = "My Background Service";
NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, NotificationManager.IMPORTANCE_NONE);
chan.setLightColor(Color.BLUE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
assert manager != null;
manager.createNotificationChannel(chan);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID);
Notification notification = notificationBuilder.setOngoing(true)
.setContentTitle("App is running in background")
.setPriority(NotificationManager.IMPORTANCE_MIN)
.setCategory(Notification.CATEGORY_SERVICE)
.build();
startForeground(2, notification);
}
private void fn_getlocation() {
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
List<String> providers1 = mLocationManager.getProviders(true);
Location bestLocation = null;
for (String provider : providers1) {
Location location = mLocationManager.getLastKnownLocation(provider);
if (location == null) {
continue;
}
if (bestLocation == null || location.getAccuracy() < bestLocation.getAccuracy()) {
bestLocation = location;
}
}
Log.e("Best localization:", String.valueOf(bestLocation));
/* if (bestLocation != null)
fn_update(bestLocation);
*/
mFusedLocationClient.getLastLocation().addOnSuccessListener(
new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
if (location != null) {
mLastLocation = location;
fn_update(location);
}
}
});
}
private void fn_update(Location location) {
new Task(location).execute();
}
@Override
public void onDestroy() {
Log.e(TAG, "onDestroy");
super.onDestroy();
mHandler.removeCallbacks(mStatusChecker);
if (mLocationManager != null) {
for (LocationListener listener : mLocationListeners) {
try {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocationManager.removeUpdates(listener);
Log.i(TAG, "Removed");
} catch (Exception ex) {
Log.i(TAG, "fail to remove location listener, ignore", ex);
}
}
}
}
private void initializeLocationManager() {
Log.e(TAG, "initializeLocationManager - LOCATION_INTERVAL: " + LOCATION_INTERVAL + " LOCATION_DISTANCE: " + LOCATION_DISTANCE);
if (mLocationManager == null) {
mLocationManager = (LocationManager) getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
}
}
private class LocationListener implements android.location.LocationListener {
public LocationListener(String provider) {
Log.e(TAG, "LocationListener " + provider);
mLastLocation = new Location(provider);
}
@Override
public void onLocationChanged(Location location) {
Log.e(TAG, "onLocationChanged: " + location);
mLastLocation.set(location);
}
@Override
public void onProviderDisabled(String provider) {
Log.e(TAG, "onProviderDisabled: " + provider);
}
@Override
public void onProviderEnabled(String provider) {
Log.e(TAG, "onProviderEnabled: " + provider);
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
Log.e(TAG, "onStatusChanged: " + provider);
}
}
private class Task extends AsyncTask {
private Double latitude;
private Double longitude;
private Double altitude;
private CompositeDisposable disposable = new CompositeDisposable();
private CoordinateService coordinateService = ApiClient.getClient(getApplicationContext())
.create(CoordinateService.class);
private Task(Location location) {
latitude = location.getLatitude();
longitude = location.getLongitude();
altitude = location.getAltitude();
}
@Override
protected Object doInBackground(Object[] objects) {
try {
Coordinate coordinate = new Coordinate(
latitude,
longitude,
altitude,
PrefUtils.getUserStatus(getApplicationContext()),
PrefUtils.getUserId(getApplicationContext()),
PrefUtils.getLocationLevel(getApplicationContext())
);
disposable.add(
coordinateService
.postCoordinate(coordinate)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribeWith(new DisposableSingleObserver<Coordinate>() {
@SuppressLint("LongLogTag")
@Override
public void onSuccess(Coordinate coord) {
Log.e("CoordinateService onSuccess", String.valueOf(coord));
}
@SuppressLint("LongLogTag")
@Override
public void onError(Throwable e) {
Log.e("CoordinateService onError", e.getMessage());
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
Log.e("CoordinateService onError", RestApiHelper.getErrorMessage(responseBody));
}
}
}));
} catch (IllegalArgumentException e) {
Timber.e(String.valueOf(e));
}
return null;
}
}
}

View File

@ -0,0 +1,44 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.Coordinate;
import java.util.List;
import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface CoordinateService {
@GET("api/coordinates")
Single<List<Coordinate>> getAllCoordinates();
@GET("api/coordinates/{id}")
Single<Coordinate> getCoordinatesById(@Path("id") String id);
@GET("api/coordinates/user/{userId}")
Single<List<Coordinate>> getCoordinatesByUserId(@Path("userId") String userId);
@GET("api/coordinates/userTop/{userId}")
Single<List<Coordinate>> getTopCoordinatesByUserId(@Path("userId") String userId);
@GET("api/coordinates/top")
Single<List<Coordinate>> getTopCoordinates();
@GET("api/coordinates/top/online")
Single<List<Coordinate>> getOnlineCoordinates();
@POST("api/coordinates")
Single <Coordinate> postCoordinate(@Body Coordinate coordinate);
@PUT("api/coordinates/{id}")
Single<Coordinate> putCoordinatesById(@Path("id") String id);
@DELETE("api/coordinates/{id}")
Single<Coordinate> deleteCoordinatesById(@Path("id") String id);
}

View File

@ -2,8 +2,9 @@ package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.JwtToken; import com.uam.wmi.findmytutor.model.JwtToken;
import com.uam.wmi.findmytutor.model.LdapUser; import com.uam.wmi.findmytutor.model.LdapUser;
import com.uam.wmi.findmytutor.model.ValidateUser;
import retrofit2.Call; import io.reactivex.Single;
import retrofit2.http.Body; import retrofit2.http.Body;
import retrofit2.http.GET; import retrofit2.http.GET;
import retrofit2.http.POST; import retrofit2.http.POST;
@ -12,15 +13,15 @@ import retrofit2.http.Path;
public interface LdapService { public interface LdapService {
@POST("api/ldap/fakeValidate") @POST("api/ldap/fakeValidate")
Call<JwtToken> fakeValidate(@Body LdapUser user); Single<JwtToken> fakeValidate(@Body LdapUser user);
@POST("api/ldap/validate") @POST("api/ldap/validate")
Call<JwtToken> validate(@Body LdapUser user); Single<JwtToken> validate(@Body ValidateUser user);
@GET("api/ldap/getUserData/{login}") @GET("api/ldap/getUserData/{login}")
Call<LdapUser> getUserDataByLogin(@Path("login") String userLogin); Single<LdapUser> getUserDataByLogin(@Path("login") String userLogin);
@GET("api/ldap/getUserData/email/{email}") @GET("api/ldap/getUserData/email/{email}")
Call<LdapUser> getUserDataByMail(@Path("email") String userMail); Single<LdapUser> getUserDataByMail(@Path("email") String userMail);
} }

View File

@ -1,4 +0,0 @@
package com.uam.wmi.findmytutor.service;
public interface Session {
}

View File

@ -0,0 +1,58 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.TutorTabViewModel;
import io.reactivex.Observable;
import io.reactivex.Single;
import retrofit2.http.*;
public interface TutorTabApi {
/**
* Scrap all tutor tabs
* With this method, you can initialize tutor tabs scrapper. The effect will be: - all tutor tabs will be overwritten with data from the WMI source
* @param tutorId (required)
* @return Call&lt;Void&gt;
*/
@POST("api/users/scrapTutorTab/{tutorId}")
Observable<Void> apiUsersScrapTutorTabByTutorIdPost(
@retrofit2.http.Path("tutorId") String tutorId
);
/**
* Scrap all tutor tabs
* With this method, you can initialize tutor tabs scrapper. The effect will be: - all tutor tabs will be overwritten with data from the WMI source
* @return Call&lt;Void&gt;
*/
@POST("api/users/scrapTutorTab")
Observable<Void> apiUsersScrapTutorTabPost();
/**
*
*
* @param tutorId (required)
* @return Call&lt;TutorTabViewModel&gt;
*/
@GET("api/users/tutorTab/{tutorId}")
Single<TutorTabViewModel> apiUsersTutorTabByTutorIdGet(
@retrofit2.http.Path("tutorId") String tutorId
);
/**
*
*
* @param tutorId (required)
* @param tutorTab (optional)
* @return Call&lt;Void&gt;
*/
@Headers({
"Content-Type:application/json"
})
@PUT("api/users/tutorTab/{tutorId}")
Observable<Void> apiUsersTutorTabByTutorIdPut(
@retrofit2.http.Path("tutorId") String tutorId, @retrofit2.http.Body TutorTabViewModel tutorTab
);
}

View File

@ -0,0 +1,83 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.IsUsingListBool;
import com.uam.wmi.findmytutor.model.PagedResultReturnedTutors;
import com.uam.wmi.findmytutor.model.ReturnedTutors;
import com.uam.wmi.findmytutor.model.StudentIdModel;
import com.uam.wmi.findmytutor.model.User;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
import retrofit2.Response;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
public interface UserService {
@GET("api/users")
Single <List<User>> getAllUsers();
@GET("api/users")
Single <List<User>> apiUsersGet();
@POST("api/users")
Completable createUser(@Body User user);
@GET("api/users/page/{pageNum}")
Single <PagedResultReturnedTutors> getPagedUsers(@Path("pageNum") String pageNum );
@GET("api/users/tutors/page/{pageNum}")
Single <PagedResultReturnedTutors> getPagedTutors(@Path("pageNum") Integer pageNum );
@GET("api/users/students/page/{pageNum}")
Single<PagedResultReturnedTutors> getPagedStudents(@Path("pageNum") String pageNum);
@GET("api/users/{id}")
Single <User> getUserById(@Path("id") String userID);
@PUT("api/users/{id}")
Completable updateUserByID(@Path("id") String userID, @Body User user);
@DELETE("api/users/{id}")
Completable deleteUserByID(@Path("id") String userID);
@GET("api/users/userLogin/{ldapLogin}")
Single<String> getUserLdapLogin(@Path("ldapLogin") String ldapLogin);
@PUT("api/users/setActive/{userID}")
Completable setUserActive(@Path("userID") String userID);
@PUT("api/users/setInActive/{userID}")
Completable setUserInActive(@Path("userID") String userID);
@GET("api/users/blacklist/{tutorID}")
Single<List<User>> getTutorBlacklistedByID(@Path("tutorID") String tutorID);
@PUT("api/users/blacklist/{tutorID}")
Completable setTutorBlacklist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/blacklist/{tutorID}")
Completable addStudentToBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@DELETE("api/users/blacklist/{tutorID}")
Completable removeStudentFromBlacklist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@GET("api/users/whitelist/{tutorID}")
Single<List<User>> getTutorwhitelistedByID(@Path("tutorID") String tutorID);
@PUT("api/users/whitelist/{tutorID}")
Completable setTutorWhitelist(@Path("tutorID") String tutorID, @Body IsUsingListBool isUsing);
@POST("api/users/whitelist/{tutorID}")
Completable addStudentTowhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
@DELETE("api/users/whitelist/{tutorID}")
Completable removeStudentFromWhitelist(@Path("tutorID") String tutorID, @Body StudentIdModel student);
}

View File

@ -0,0 +1,8 @@
package com.uam.wmi.findmytutor.utils;
public enum ActiveFragment {
USER_LIST,
SHARED_PREFERENCES,
NONE
}

View File

@ -0,0 +1,98 @@
package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.TypedValue;
import android.view.View;
public class MyDividerItemDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = new int[]{
android.R.attr.listDivider
};
public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
private Drawable mDivider;
private int mOrientation;
private Context context;
private int margin;
public MyDividerItemDecoration(Context context, int orientation, int margin) {
this.context = context;
this.margin = margin;
final TypedArray a = context.obtainStyledAttributes(ATTRS);
mDivider = a.getDrawable(0);
a.recycle();
setOrientation(orientation);
}
public void setOrientation(int orientation) {
if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
throw new IllegalArgumentException("invalid orientation");
}
mOrientation = orientation;
}
@Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (mOrientation == VERTICAL_LIST) {
drawVertical(c, parent);
} else {
drawHorizontal(c, parent);
}
}
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
public void drawHorizontal(Canvas c, RecyclerView parent) {
final int top = parent.getPaddingTop();
final int bottom = parent.getHeight() - parent.getPaddingBottom();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child
.getLayoutParams();
final int left = child.getRight() + params.rightMargin;
final int right = left + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top + dpToPx(margin), right, bottom - dpToPx(margin));
mDivider.draw(c);
}
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
if (mOrientation == VERTICAL_LIST) {
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
private int dpToPx(int dp) {
Resources r = context.getResources();
return Math.round(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, r.getDisplayMetrics()));
}
}

View File

@ -0,0 +1,149 @@
package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.ListPreference;
import android.preference.PreferenceFragment;
import android.util.Log;
import com.uam.wmi.findmytutor.activity.SharingFragment;
import com.auth0.android.jwt.Claim;
import com.auth0.android.jwt.JWT;
import java.util.Map;
public class PrefUtils {
public PrefUtils() {
}
public static SharedPreferences getSharedPreferences(Context context) {
return context.getSharedPreferences("com.uam.wmi.findmytutor_preferences", Context.MODE_PRIVATE);
}
public static void getAllKeys(Context context){
Map<String,?> keys = getSharedPreferences(context).getAll();
for(Map.Entry<String,?> entry : keys.entrySet()){
Log.d("map values",entry.getKey() + ": " + entry.getValue().toString());
}
}
public static void cleanUserLocalStorage(Context context) {
SharedPreferences preferences = getSharedPreferences(context);
SharedPreferences.Editor editor = preferences.edit();
editor.clear().apply();
}
public static void storeApiKey(Context context, String apiKey) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("API_KEY", apiKey);
editor.apply();
}
public static String getApiKey(Context context) {
return getSharedPreferences(context).getString("API_KEY", null);
}
public static void storeUserId(Context applicationContext, String userId) {
SharedPreferences.Editor editor = getSharedPreferences(applicationContext).edit();
editor.putString("USER_ID", userId);
editor.apply();
}
public static String getUserId(Context context) {
return getSharedPreferences(context).getString("USER_ID", null);
}
public static String getUserStatus(Context context) {
return getSharedPreferences(context).getString("status_entry", "Available");
}
public static void storeStatus(Context context, String status){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("status_entry", status);
editor.apply();
}
public static void storeIsTutor(Context applicationContext, boolean isTutor) {
SharedPreferences.Editor editor = getSharedPreferences(applicationContext).edit();
editor.putBoolean("IS_TUTOR", isTutor);
editor.apply();
}
public static boolean getIsTutor(Context context) {
return getSharedPreferences(context).getBoolean("IS_TUTOR", false);
}
public static void storeIsLoggedIn(Context applicationContext, boolean isLogged) {
SharedPreferences.Editor editor = getSharedPreferences(applicationContext).edit();
editor.putBoolean("IS_LOGGED_IN", isLogged);
editor.apply();
}
public static boolean isLoggedIn(Context context) {
return getSharedPreferences(context).getBoolean("IS_LOGGED_IN", false);
}
public static boolean isEnableSharingLocalization(Context context) {
return getSharedPreferences(context).getBoolean("key_sharing_enabled", false);
}
public static void storeEnableSharingLocalization(Context context,Boolean isChecked) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("key_sharing_enabled", isChecked);
editor.apply();
}
public static String getLocationLevel(Context context){
return getSharedPreferences(context).getString("location_mode", "exact");
}
public static void storeLocationMode(Context context, String mode){
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("location_mode", mode);
editor.apply();
}
public static void storeUserFirstName(Context context, String userName) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("USER_FIRST_NAME", userName);
editor.apply();
}
public static String getUserFirstName(Context context) {
return getSharedPreferences(context).getString("USER_FIRST_NAME", null);
}
public static void storeUserLastName(Context context, String userLastName) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("USER_LAST_NAME", userLastName);
editor.apply();
}
public static String getUserLastName(Context context) {
return getSharedPreferences(context).getString("USER_LAST_NAME", null);
}
public static void storeUserName(Context context, String userName) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("USER_NAME", userName);
editor.apply();
}
public static void storeLocale(Context context, String locale) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("LOCALE", locale);
editor.apply();
}
public static String getLocale(Context context) {
return getSharedPreferences(context).getString("LOCALE", "pl");
}
public static Boolean isBackgroundLocationServiceRunning(Context context) {
return getSharedPreferences(context).getBoolean("BACKGROUND_SERVICE_STATUS", false);
}
public static void storeBackgroundLocationStatus(Context context, Boolean status) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putBoolean("BACKGROUND_SERVICE_STATUS", status);
editor.apply();
}
}

View File

@ -0,0 +1,62 @@
package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/**
* Created by ravi on 21/02/18.
*/
public class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
private ClickListener clicklistener;
private GestureDetector gestureDetector;
public RecyclerTouchListener(Context context, final RecyclerView recycleView, final ClickListener clicklistener) {
this.clicklistener = clicklistener;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
@Override
public void onLongPress(MotionEvent e) {
View child = recycleView.findChildViewUnder(e.getX(), e.getY());
if (child != null && clicklistener != null) {
clicklistener.onLongClick(child, recycleView.getChildAdapterPosition(child));
}
}
});
}
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
View child = rv.findChildViewUnder(e.getX(), e.getY());
if (child != null && clicklistener != null && gestureDetector.onTouchEvent(e)) {
clicklistener.onClick(child, rv.getChildAdapterPosition(child));
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
public interface ClickListener {
void onClick(View view, int position);
void onLongClick(View view, int position);
}
}

View File

@ -0,0 +1,48 @@
package com.uam.wmi.findmytutor.utils;
import android.app.Activity;
import android.graphics.Color;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.widget.TextView;
import com.jakewharton.retrofit2.adapter.rxjava2.HttpException;
import com.uam.wmi.findmytutor.R;
import org.json.JSONObject;
import okhttp3.ResponseBody;
public class RestApiHelper extends Activity {
public RestApiHelper() {
}
public static String getErrorMessage(ResponseBody responseBody) {
try {
JSONObject jsonObject = new JSONObject(responseBody.string());
return jsonObject.getString("message");
} catch (Exception e) {
return e.getMessage();
}
}
public void showError(Throwable e) {
String message = e.toString();
if (e instanceof HttpException) {
ResponseBody responseBody = ((HttpException) e).response().errorBody();
message = RestApiHelper.getErrorMessage(responseBody);
} else {
message ="Network Error !";
}
Snackbar snackbar = Snackbar.make(findViewById(R.id.activity_content), message, Snackbar.LENGTH_LONG);
View sbView = snackbar.getView();
TextView textView = sbView.findViewById(android.support.design.R.id.snackbar_text);
textView.setTextColor(Color.BLUE);
snackbar.show();
}
}

View File

@ -0,0 +1,44 @@
package com.uam.wmi.findmytutor.utils;
import android.animation.TypeEvaluator;
import android.content.Context;
import com.mapbox.mapboxsdk.geometry.LatLng;
import java.io.IOException;
import java.io.InputStream;
public class mapUtils {
public static class LatLngEvaluator implements TypeEvaluator<LatLng> {
// Method is used to interpolate the marker animation.
private LatLng latLng = new LatLng();
@Override
public LatLng evaluate(float fraction, LatLng startValue, LatLng endValue) {
latLng.setLatitude(startValue.getLatitude()
+ ((endValue.getLatitude() - startValue.getLatitude()) * fraction));
latLng.setLongitude(startValue.getLongitude()
+ ((endValue.getLongitude() - startValue.getLongitude()) * fraction));
return latLng;
}
}
public static String loadJsonFromAsset(Context context, String filename) {
// Using this method to load in GeoJSON files from the assets folder.
try {
InputStream is = context.getAssets().open(filename);
int size = is.available();
byte[] buffer = new byte[size];
is.read(buffer);
is.close();
return new String(buffer, "UTF-8");
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/colorWhite"
android:state_checked="true"/>
<item android:color="@color/colorWhiteTransparent" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 349 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

View File

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M12,12m-3.2,0a3.2,3.2 0,1 1,6.4 0a3.2,3.2 0,1 1,-6.4 0" />
<path
android:fillColor="#FF000000"
android:pathData="M9,2L7.17,4H4c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V6c0,-1.1 -0.9,-2 -2,-2h-3.17L15,2H9zm3,15c-2.76,0 -5,-2.24 -5,-5s2.24,-5 5,-5 5,2.24 5,5 -2.24,5 -5,5z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22,16V4c0,-1.1 -0.9,-2 -2,-2H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2zm-11,-4l2.03,2.71L16,11l4,5H8l3,-4zM2,6v14c0,1.1 0.9,2 2,2h14v-2H4V6H2z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M22.7,19l-9.1,-9.1c0.9,-2.3 0.4,-5 -1.5,-6.9 -2,-2 -5,-2.4 -7.4,-1.3L9,6 6,9 1.6,4.7C0.4,7.1 0.9,10.1 2.9,12.1c1.9,1.9 4.6,2.4 6.9,1.5l9.1,9.1c0.4,0.4 1,0.4 1.4,0l2.3,-2.3c0.5,-0.4 0.5,-1.1 0.1,-1.4z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M2.01,21L23,12 2.01,3 2,10l15,2 -15,2z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.46 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.24 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z" />
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M4,6H2v14c0,1.1 0.9,2 2,2h14v-2H4V6zm16,-4H8c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h12c1.1,0 2,-0.9 2,-2V4c0,-1.1 -0.9,-2 -2,-2zm-8,12.5v-9l6,4.5 -6,4.5z" />
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_semi_transparent"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/>
<corners
android:radius="2dp"/>
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<solid android:color="@android:color/darker_gray" />
<corners android:radius="16dp" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 923 B

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/black_semi_transparent"/>
<padding
android:left="16dp"
android:top="4dp"
android:right="16dp"
android:bottom="4dp"/>
<corners
android:radius="2dp"/>
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
</selector>

View File

@ -0,0 +1,34 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportHeight="108"
android:viewportWidth="108">
<path
android:fillType="evenOdd"
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z"
android:strokeColor="#00000000"
android:strokeWidth="1">
<aapt:attr name="android:fillColor">
<gradient
android:endX="78.5885"
android:endY="90.9159"
android:startX="48.7653"
android:startY="61.0927"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z"
android:strokeColor="#00000000"
android:strokeWidth="1" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M15.5 14h-0.79l-0.28-0.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-0.59 4.23-1.57l0.27 0.28 v0.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
<path
android:pathData="M0 0h24v24H0z" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path
android:pathData="M0 0h20v20H0V0z" />
<path
android:fillColor="#000000"
android:pathData="M15.95 10.78c0.03-0.25 0.05 -0.51 0.05 -0.78s-0.02-0.53-0.06-0.78l1.69-1.32c0.15-0.12 0.19 -0.34 0.1 -0.51l-1.6-2.77c-0.1-0.18-0.31-0.24-0.49-0.18l-1.99 0.8 c-0.42-0.32-0.86-0.58-1.35-0.78L12 2.34c-0.03-0.2-0.2-0.34-0.4-0.34H8.4c-0.2 0-0.36 0.14 -0.39 0.34 l-0.3 2.12c-0.49 0.2 -0.94 0.47 -1.35 0.78 l-1.99-0.8c-0.18-0.07-0.39 0-0.49 0.18 l-1.6 2.77c-0.1 0.18 -0.06 0.39 0.1 0.51 l1.69 1.32c-0.04 0.25 -0.07 0.52 -0.07 0.78 s0.02 0.53 0.06 0.78 L2.37 12.1c-0.15 0.12 -0.19 0.34 -0.1 0.51 l1.6 2.77c0.1 0.18 0.31 0.24 0.49 0.18 l1.99-0.8c0.42 0.32 0.86 0.58 1.35 0.78 l0.3 2.12c0.04 0.2 0.2 0.34 0.4 0.34 h3.2c0.2 0 0.37-0.14 0.39 -0.34l0.3-2.12c0.49-0.2 0.94 -0.47 1.35-0.78l1.99 0.8 c0.18 0.07 0.39 0 0.49-0.18l1.6-2.77c0.1-0.18 0.06 -0.39-0.1-0.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z" />
</vector>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<path android:pathData="M0 0h20v20H0V0z" />
<path
android:fillColor="#000000"
android:pathData="M15.95 10.78c0.03-0.25 0.05 -0.51 0.05 -0.78s-0.02-0.53-0.06-0.78l1.69-1.32c0.15-0.12 0.19 -0.34 0.1 -0.51l-1.6-2.77c-0.1-0.18-0.31-0.24-0.49-0.18l-1.99 0.8 c-0.42-0.32-0.86-0.58-1.35-0.78L12 2.34c-0.03-0.2-0.2-0.34-0.4-0.34H8.4c-0.2 0-0.36 0.14 -0.39 0.34 l-0.3 2.12c-0.49 0.2 -0.94 0.47 -1.35 0.78 l-1.99-0.8c-0.18-0.07-0.39 0-0.49 0.18 l-1.6 2.77c-0.1 0.18 -0.06 0.39 0.1 0.51 l1.69 1.32c-0.04 0.25 -0.07 0.52 -0.07 0.78 s0.02 0.53 0.06 0.78 L2.37 12.1c-0.15 0.12 -0.19 0.34 -0.1 0.51 l1.6 2.77c0.1 0.18 0.31 0.24 0.49 0.18 l1.99-0.8c0.42 0.32 0.86 0.58 1.35 0.78 l0.3 2.12c0.04 0.2 0.2 0.34 0.4 0.34 h3.2c0.2 0 0.37-0.14 0.39 -0.34l0.3-2.12c0.49-0.2 0.94 -0.47 1.35-0.78l1.99 0.8 c0.18 0.07 0.39 0 0.49-0.18l1.6-2.77c0.1-0.18 0.06 -0.39-0.1-0.51l-1.67-1.32zM10 13c-1.65 0-3-1.35-3-3s1.35-3 3-3 3 1.35 3 3-1.35 3-3 3z" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0V0z" />
<path
android:fillColor="#000000"
android:pathData="M13 8.2l-1-1-4 4-4-4-1 1 4 4-4 4 1 1 4-4 4 4 1-1-4-4 4-4zM19 1H9c-1.1 0-2 0.9-2 2v3h2V4h10v16H9v-2H7v3c0 1.1 0.9 2 2 2h10c1.1 0 2-0.9 2-2V3c0-1.1-0.9-2-2-2z" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M10.09 15.59L11.5 17l5-5-5-5-1.41 1.41L12.67 11H3v2h9.67l-2.58 2.59zM19 3H5c-1.11 0-2 0.9-2 2v4h2V5h14v14H5v-4H3v4c0 1.1 0.89 2 2 2h14c1.1 0 2-0.9 2-2V5c0-1.1-0.9-2-2-2z" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-0.29 0-0.62 0.02 -0.97 0.05 1.16 0.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z" />
</vector>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M0 0h24v24H0z" />
<path
android:fillColor="#000000"
android:pathData="M16.5 13c-1.2 0-3.07 0.34 -4.5 1-1.43-0.67-3.3-1-4.5-1C5.33 13 1 14.08 1 16.25V19h22v-2.75c0-2.17-4.33-3.25-6.5-3.25zm-4 4.5h-10v-1.25c0-0.54 2.56-1.75 5-1.75s5 1.21 5 1.75v1.25zm9 0H14v-1.25c0-0.46-0.2-0.86-0.52-1.22 0.88 -0.3 1.96-0.53 3.02-0.53 2.44 0 5 1.21 5 1.75v1.25zM7.5 12c1.93 0 3.5-1.57 3.5-3.5S9.43 5 7.5 5 4 6.57 4 8.5 5.57 12 7.5 12zm0-5.5c1.1 0 2 0.9 2 2s-0.9 2-2 2-2-0.9-2-2 0.9-2 2-2zm9 5.5c1.93 0 3.5-1.57 3.5-3.5S18.43 5 16.5 5 13 6.57 13 8.5s1.57 3.5 3.5 3.5zm0-5.5c1.1 0 2 0.9 2 2s-0.9 2-2 2-2-0.9-2-2 0.9-2 2-2z" />
</vector>

View File

@ -0,0 +1,49 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="68dp"
android:height="68dp"
android:viewportWidth="68"
android:viewportHeight="68">
<path
android:pathData="M56.3,44.2c-2.1,2.2 -4.6,3.9 -7.3,5.2c-1.5,0.7 -29,8.5 -40.7,11.8c-1,0.3 -1.9,0.5 -2.6,0.7c0.2,-0.7 0.4,-1.6 0.7,-2.6c2.9,-11.6 9.9,-38.9 10.5,-40.4c1.2,-2.7 2.9,-5.1 5,-7.3c9.1,-9.3 23.8,-10.2 33.7,-2.5c0.4,0.3 0.7,0.6 1.1,0.9c0.3,0.3 0.6,0.6 0.9,1C65.8,20.5 65.4,34.9 56.3,44.2z"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:pathData="M46.7,48.1"
android:strokeWidth="3"
android:fillColor="#00000000"
android:strokeColor="#000000"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.8,29.7l1,1.8l3.5,-2l1.5,2.7l-3.5,2l2.2,3.9l-3.1,1.7l-6.2,-11l7,-4l1.6,2.7L24.8,29.7z"/>
<path
android:fillColor="#FF000000"
android:pathData="M28,22.9l1.4,2.5l2.9,-1.6l-1.4,-2.5L28,22.9zM30,26.5l4.8,8.5l1.2,-4.8l-3,-5.4L30,26.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M45,22.4l2.9,5.2L45,29.2l-2.7,-4.8c-0.6,-1 -1.2,-1.3 -1.9,-0.9c-0.9,0.5 -1.1,1.5 -0.5,2.5l2.6,4.5l-2.9,1.7l-4.8,-8.5l2.1,-1.2l0.9,0.6c0.2,-1.1 0.9,-2 2,-2.6C41.7,19.5 43.8,20.2 45,22.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M52.1,9.9l6.6,11.6l-2.2,1.2l-0.6,-0.5c-0.4,1 -1.1,1.8 -2,2.4c-2.6,1.5 -5.5,0.6 -7,-2c-1.5,-2.6 -0.7,-5.6 1.9,-7.1c0.8,-0.4 1.6,-0.6 2.4,-0.6l-1.9,-3.4L52.1,9.9zM53.6,18.8c-0.6,-1.1 -1.9,-1.5 -3,-0.9c-1.1,0.6 -1.4,1.9 -0.8,3c0.6,1.1 1.9,1.5 3,0.9S54.2,19.9 53.6,18.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M24.1,42.1l-3,1.7l4.7,8.3l-3,1.7L18,45.5l-3,1.7l-1.5,-2.7l9,-5.1L24.1,42.1z"/>
<path
android:fillColor="#FF000000"
android:pathData="M27.2,46.4l-2.7,-4.8l2.9,-1.7l2.7,4.7c0.5,0.9 1.3,1.2 2.1,0.7c0.8,-0.4 1,-1.2 0.4,-2.1l-2.7,-4.7l2.9,-1.7l2.7,4.8c1.3,2.4 0.6,4.9 -2,6.3C31.1,49.4 28.6,48.8 27.2,46.4z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.7,38.5l1.5,2.6l-2,1.1c-1.9,1.1 -3.7,0.6 -4.7,-1.3l-1.8,-3.2L35,38.6l-0.4,-0.7l1.5,-6.2l0.6,-0.3l1.4,2.5l2.1,-1.2l1.3,2.3l-2.1,1.2l1.5,2.7c0.3,0.6 0.9,0.8 1.5,0.4L43.7,38.5z"/>
<path
android:fillColor="#FF000000"
android:pathData="M43.6,36.4c-1.5,-2.6 -0.6,-5.7 2.2,-7.2c2.8,-1.6 5.8,-0.8 7.3,1.8c1.5,2.6 0.6,5.7 -2.2,7.2C48.1,39.8 45,39 43.6,36.4zM49.4,35.6c1.1,-0.6 1.4,-1.8 0.8,-2.9c-0.6,-1.1 -1.8,-1.5 -2.9,-0.9s-1.4,1.8 -0.8,2.9C47.1,35.8 48.3,36.2 49.4,35.6L49.4,35.6z"/>
<path
android:fillColor="#FF000000"
android:pathData="M57.5,22.8l1.5,2.7l-1.1,0.6c-1,0.6 -1.2,1.3 -0.6,2.4l2.4,4.3l-2.9,1.7L52,26l2,-1.1l1,0.7c0.2,-1 0.8,-1.7 1.8,-2.3L57.5,22.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M20.8,37.8l0.9,1.7L20.8,40L20,38.5c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.3,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-0.9,-1.6c-0.2,-0.3 -0.3,-0.4 -0.5,-0.2c-0.2,0.1 -0.3,0.4 -0.1,0.7l0.8,1.5l-0.9,0.5l-1.5,-2.7l0.6,-0.4l0.3,0.2c0.1,-0.3 0.3,-0.6 0.6,-0.8c0.3,-0.2 0.7,-0.2 1,0c0.1,-0.3 0.3,-0.7 0.6,-0.9C19.8,37 20.5,37.2 20.8,37.8z"/>
<path
android:fillColor="#FF000000"
android:pathData="M22.3,35.7l0.3,1.8l-1.4,-1.1l-1,0.6l2.5,1.8c0,0.2 0,0.4 -0.1,0.5l0.5,0.8c0.5,-0.4 0.6,-0.8 0.5,-1.7l-0.3,-3.2L22.3,35.7z"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#252525"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#010101" android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#BD120A"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#010101" android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#0ABD48"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#010101" android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"/>
</vector>

View File

@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#0ABD48"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#010101" android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,9 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:angle="135"
android:centerColor="#009688"
android:endColor="#00695C"
android:startColor="#4DB6AC"
android:type="linear" />
</shape>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
@ -11,7 +12,14 @@
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".activity.LoginActivity"> tools:context=".activity.LoginActivity">
<!-- Login progress -->
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="180dp"
android:contentDescription="@string/logo_find_my_tutor"
app:srcCompat="@drawable/logo_design_black2" />
<ProgressBar <ProgressBar
android:id="@+id/login_progress" android:id="@+id/login_progress"
style="?android:attr/progressBarStyleLarge" style="?android:attr/progressBarStyleLarge"
@ -39,7 +47,7 @@
android:id="@+id/email" android:id="@+id/email"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/prompt_email" android:hint="@string/prompt_login"
android:inputType="textEmailAddress" android:inputType="textEmailAddress"
android:maxLines="1" android:maxLines="1"
android:singleLine="true" /> android:singleLine="true" />
@ -64,15 +72,22 @@
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
<Switch
android:id="@+id/tutor_login_switch"
android:layout_width="192dp"
android:layout_height="wrap_content"
android:text="Login as Tutor" />
<Button <Button
android:id="@+id/email_sign_in_button" android:id="@+id/email_sign_in_button"
style="?android:textAppearanceSmall" style="?android:textAppearanceSmall"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:text="@string/action_sign_in" android:text="@string/action_log_in"
android:textStyle="bold" /> android:textStyle="bold" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</LinearLayout> </LinearLayout>

View File

@ -1,32 +1,92 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".activity.MainActivity"> android:clickable="true"
android:focusableInTouchMode="true"
android:visibility="visible"
tools:openDrawer="start">
<android.support.design.widget.AppBarLayout <com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:theme="@style/AppTheme.AppBarOverlay"> android:visibility="visible"
mapbox:mapbox_cameraTargetLat="52.466799"
mapbox:mapbox_cameraTargetLng="16.927002"
mapbox:mapbox_cameraZoom="17"
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
</android.support.design.widget.AppBarLayout> <android.support.design.widget.NavigationView
android:id="@+id/nav_view"
<include layout="@layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:layout_gravity="bottom|end" android:layout_gravity="start"
android:layout_margin="@dimen/fab_margin" app:headerLayout="@layout/nav_header_main"
app:srcCompat="@android:drawable/ic_dialog_email" /> app:menu="@menu/activity_main_drawer">
<TextView
android:id="@+id/textView" </android.support.design.widget.NavigationView>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:text="TextView" /> tools:context=".activity.MainActivity">
</android.support.design.widget.CoordinatorLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.FloatingActionButton
android:id="@+id/logoutButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginTop="77dp"
app:backgroundTint="@android:color/holo_red_dark"
app:srcCompat="@android:drawable/ic_lock_power_off" />
<include
android:id="@+id/include"
layout="@layout/content_main" />
<FrameLayout
android:id="@+id/main_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/main_nav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginStart="0dp"
android:background="@color/colorPrimaryDark"
app:itemBackground="@color/colorPrimaryDark"
app:itemIconTint="@color/nav_item_colors"
app:itemTextColor="@color/nav_item_colors"
app:layout_anchor="@+id/include"
app:layout_anchorGravity="bottom|center"
app:menu="@menu/nav_items" />
</RelativeLayout>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.CoordinatorLayout>
</android.support.v4.widget.DrawerLayout>

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:fab="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.MapActivity">
<com.mapbox.mapboxsdk.maps.MapView
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible"
mapbox:mapbox_cameraTargetLat="52.466799"
mapbox:mapbox_cameraTargetLng="16.927002"
mapbox:mapbox_cameraZoom="17"
mapbox:mapbox_styleUrl="mapbox://styles/domagalsky/cjiyzrqjp05l72rmj6ntvv2n8">
</com.mapbox.mapboxsdk.maps.MapView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
android:orientation="vertical"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="1dp">
<!-- Implementation of find my location button -->
<android.support.design.widget.FloatingActionButton
android:id="@+id/toggleMarkerLayerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:clickable="true"
android:visibility="gone"
app:backgroundTint="@color/msg_no_notes"
app:layout_constraintTop_toBottomOf="@+id/logoutButton"
mapbox:srcCompat="@android:drawable/ic_dialog_map"
tools:layout_editor_absoluteX="0dp" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/myLocationButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_marginRight="20dp"
android:layout_marginBottom="20dp"
android:background="@color/half_black"
android:backgroundTint="@color/materialDarkGrey"
android:src="@android:drawable/ic_menu_mylocation"
android:visibility="invisible"
app:borderWidth="0dp"
app:elevation="6dp"
app:fabSize="normal"
app:fab_colorDisabled="@color/mapboxGray"
app:fab_colorNormal="@color/mapboxGray"
app:pressedTranslationZ="12dp" />
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/multiple_actions_parent_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
fab:fab_addButtonColorNormal="@color/mapboxRed"
fab:fab_addButtonColorPressed="@color/mapboxWhite"
fab:fab_addButtonPlusIconColor="@color/mapboxWhite"
fab:fab_labelStyle="@style/menu_labels_style"
tools:layout_editor_absoluteX="200dp"
tools:layout_editor_absoluteY="255dp">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_hotels"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxBlue"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_hotels" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_parks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxGreen"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_parks" />
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_toggle_attractions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/mapboxRed"
fab:fab_colorPressed="@color/mapboxWhite"
fab:fab_size="mini"
fab:fab_title="@string/fab_title_attractions" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
<Button
android:id="@+id/select_location_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="8dp"
android:background="@color/colorPrimary"
android:text="@string/select_a_location"
android:textColor="@android:color/white"
android:visibility="gone" />
</LinearLayout>
</android.support.constraint.ConstraintLayout>

Some files were not shown because too many files have changed in this diff Show More