diff --git a/.idea/assetWizardSettings.xml b/.idea/assetWizardSettings.xml
deleted file mode 100644
index 2a9c5e0..0000000
--- a/.idea/assetWizardSettings.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index 1403eca..8169dc0 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -8,7 +8,7 @@ android {
}
defaultConfig {
applicationId "com.uam.wmi.findmytutor"
- minSdkVersion 19
+ minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
@@ -33,9 +33,10 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7: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'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -55,5 +56,6 @@ dependencies {
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'
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5e716d0..304f508 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,15 +1,20 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
@@ -45,6 +53,17 @@
+
+
+
+
+
+
-
\ No newline at end of file
+
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
index c4f0dc5..bc64274 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/LoginActivity.java
@@ -31,6 +31,8 @@ import android.widget.Switch;
import android.widget.TextView;
import android.widget.ToggleButton;
+import com.auth0.android.jwt.Claim;
+import com.auth0.android.jwt.JWT;
import com.uam.wmi.findmytutor.R;
import com.uam.wmi.findmytutor.model.JwtToken;
import com.uam.wmi.findmytutor.model.LdapUser;
@@ -209,7 +211,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
// Show a progress spinner, and kick off a background task to
// perform the user login attempt.
showProgress(true);
- mAuthTask = new UserLoginTask(email, password,loginOption);
+ mAuthTask = new UserLoginTask(email, password, loginOption);
mAuthTask.execute((Void) null);
}
}
@@ -307,7 +309,7 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
private interface ProfileQuery {
String[] PROJECTION = {
ContactsContract.CommonDataKinds.Email.ADDRESS,
- ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
+ ContactsContract.CommonDataKinds.Email.IS_PRIMARY,
};
int ADDRESS = 0;
@@ -331,16 +333,18 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
UserLoginTask(String email, String password, Boolean loginOption) {
mEmail = email;
mPassword = password;
- isTutor=loginOption;
+ isTutor = loginOption;
this.ldapService = ApiClient.getClient(getApplicationContext())
.create(LdapService.class);
this.isAuthorizate = false;
+
+ PrefUtils.storeIsTutor(getApplicationContext(), this.isTutor);
}
@Override
protected Boolean doInBackground(Void... params) {
- LdapUser user = new LdapUser("string",mPassword,"string",(isTutor)?"tutor":"student","string","string",mEmail);
- Log.d("LoginRole","Login role is : " + user.getTitle());
+ LdapUser user = new LdapUser(mEmail,mPassword,"admin",(isTutor)?"Tutor":"Student","string","string",mEmail);
+
disposable.add(
ldapService
.fakeValidate(user)
@@ -349,7 +353,15 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
.subscribeWith(new DisposableSingleObserver() {
@Override
public void onSuccess(JwtToken jwtToken) {
- PrefUtils.storeApiKey(getApplicationContext(), jwtToken.getToken());
+ 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());
+
onPostExecute(true);
}
@@ -368,9 +380,9 @@ public class LoginActivity extends AppCompatActivity implements LoaderCallbacks<
showProgress(false);
if (success) {
- // DONE: returns the role of signed user and return code
Intent data = new Intent();
- data.putExtra("is_tutor", isTutor);
+ String txt = "Main Activity";
+ data.setData(Uri.parse(txt));
setResult(RESULT_OK, data);
finish();
} else {
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java
index 43ff86e..f22dab9 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/MainActivity.java
@@ -2,42 +2,46 @@ package com.uam.wmi.findmytutor.activity;
import android.app.Fragment;
import android.app.FragmentTransaction;
-import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.location.Geocoder;
+
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.NavigationView;
+
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AppCompatActivity;
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.text.TextUtils;
import android.view.Menu;
+
import android.view.MenuItem;
+import android.content.pm.PackageManager;
+import android.os.Build;
+
import android.view.View;
import android.widget.AdapterView;
import android.widget.FrameLayout;
+
import android.support.v7.widget.Toolbar;
import android.widget.ListView;
import android.widget.Toast;
import com.mapbox.mapboxsdk.Mapbox;
-import com.mapbox.mapboxsdk.maps.MapView;
import com.uam.wmi.findmytutor.ListViewAdapter;
import com.uam.wmi.findmytutor.R;
-import com.uam.wmi.findmytutor.model.Coordinate;
-import com.uam.wmi.findmytutor.network.ApiClient;
-import com.uam.wmi.findmytutor.service.CoordinateService;
-
-
import java.util.ArrayList;
-import java.util.List;
+import java.util.Locale;
+import com.uam.wmi.findmytutor.service.BackgroundLocalizationService;
+import com.uam.wmi.findmytutor.utils.PrefUtils;
public class MainActivity extends AppCompatActivity {
@@ -48,16 +52,17 @@ public class MainActivity extends AppCompatActivity {
private NotificationFragment notificationFragment;
private ProfileFragment profileFragment;
+
+ private static final int REQUEST_PERMISSIONS = 100;
+ boolean boolean_permission;
+ SharedPreferences mPref;
+ SharedPreferences.Editor medit;
+ Double latitude, longitude;
+ Geocoder geocoder;
+
private DrawerLayout drawerLayout;
private ActionBarDrawerToggle actionBarDrawerToggle;
- public List coordinates;
- public List getCoordinates() {
- return this.coordinates;
- }
- public void setCoordinates(List coordinates) {
- this.coordinates = coordinates;
- }
// 4 search
private ListView listView;
@@ -68,6 +73,8 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
+
+ Bundle extras = getIntent().getExtras();
Mapbox.getInstance(this, getString(R.string.access_token));
configureconfigureNavigationDrawer();
@@ -80,8 +87,6 @@ public class MainActivity extends AppCompatActivity {
Toolbar toolbar = findViewById(R.id.toolbar_main);
setSupportActionBar(toolbar);
- //***/
-
setData();
adapter = new ListViewAdapter(this, R.layout.item_listview, stringArrayList);
listView.setAdapter(adapter);
@@ -94,8 +99,6 @@ public class MainActivity extends AppCompatActivity {
});
- //***/
-
drawerLayout = findViewById(R.id.drawer_layout);
actionBarDrawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
@@ -121,10 +124,9 @@ public class MainActivity extends AppCompatActivity {
mMainFrame = (FrameLayout) findViewById(R.id.main_frame);
mMainNav = (BottomNavigationView) findViewById(R.id.main_nav);
+ isTutor = PrefUtils.getIsTutor(getApplicationContext());
- Bundle extras = getIntent().getExtras();
- isTutor = (boolean) extras.get("is_tutor");
- if (!isTutor){
+ if (!isTutor) {
mMainNav.findViewById(R.id.nav_profile).setVisibility(View.GONE);
}
@@ -161,16 +163,17 @@ public class MainActivity extends AppCompatActivity {
private void configureLogoutButton(){
// Logout button
final FloatingActionButton button = findViewById(R.id.logoutButton);
- button.setOnClickListener(new View.OnClickListener(){
+
+ button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- SharedPreferences preferences = getSharedPreferences("fmtPrefs",Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = preferences.edit();
- editor.clear().commit();
+ PrefUtils.cleanUserLocalStorage(getApplicationContext());
Intent i = getBaseContext().getPackageManager()
- .getLaunchIntentForPackage( getBaseContext().getPackageName() );
- i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ .getLaunchIntentForPackage(getBaseContext().getPackageName());
+ if (i != null) {
+ i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ }
startActivity(i);
finish();
}
@@ -220,14 +223,22 @@ public class MainActivity extends AppCompatActivity {
}
});
+
return true;
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
+
+
// Sync the toggle state after onRestoreInstanceState has occurred.
actionBarDrawerToggle.syncState();
+
+ if (isTutor) {
+ fn_permission();
+ }
+
}
@Override
@@ -236,12 +247,73 @@ public class MainActivity extends AppCompatActivity {
actionBarDrawerToggle.onConfigurationChanged(newConfig);
}
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (actionBarDrawerToggle.onOptionsItemSelected(item)) {
return true;
}
return super.onOptionsItemSelected(item);
+
+ }
+
+
+ private void fn_permission() {
+ if ((ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED)) {
+
+ if ((ActivityCompat.shouldShowRequestPermissionRationale(MainActivity.this, android.Manifest.permission.ACCESS_FINE_LOCATION))) {
+
+ } else {
+ ActivityCompat.requestPermissions(MainActivity.this, new String[]{android.Manifest.permission.ACCESS_FINE_LOCATION
+
+ },
+ REQUEST_PERMISSIONS);
+ }
+ } else {
+
+ if (isTutor) {
+ Intent intent = new Intent(getApplicationContext(), BackgroundLocalizationService.class);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ startForegroundService(intent);
+ } else {
+ startService(intent);
+ }
+
+ } else {
+ Toast.makeText(getApplicationContext(), "Please enable the gps", Toast.LENGTH_SHORT).show();
+ }
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+
+ switch (requestCode) {
+ case REQUEST_PERMISSIONS: {
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+ boolean_permission = true;
+ } else {
+ Toast.makeText(getApplicationContext(), "Please allow the permission", Toast.LENGTH_LONG).show();
+ }
+ }
+ }
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ }
+
+ protected void onDestroy() {
+ super.onDestroy();
}
}
+
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
index 16d923b..2297c0e 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/activity/StartupActivity.java
@@ -1,20 +1,22 @@
package com.uam.wmi.findmytutor.activity;
import android.app.Activity;
-import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
+import com.uam.wmi.findmytutor.utils.PrefUtils;
+
public class StartupActivity extends AppCompatActivity {
- private static final int AUTHENTICATION_REQUEST_CODE = 666;
+ private static final int AUTHENTICATION_REQUEST_CODE = 666;
@Override
protected void onCreate(Bundle savedInstanceState) {
if (isLoggedIn()){
+
Intent startupIntent = new Intent(this, MainActivity.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(startupIntent);
@@ -25,20 +27,17 @@ public class StartupActivity extends AppCompatActivity {
}
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);
+ return PrefUtils.isLoggedIn(getApplicationContext());
}
@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) {
Intent startupIntent = new Intent(this, MainActivity.class);
startupIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- startupIntent.putExtra("is_tutor",(boolean) data.getExtras().get("is_tutor"));
startActivity(startupIntent);
}
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java
index 95e9b59..a83053a 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/model/Coordinate.java
@@ -1,5 +1,7 @@
package com.uam.wmi.findmytutor.model;
+import android.util.Range;
+
import com.google.gson.annotations.SerializedName;
import java.util.Objects;
@@ -11,18 +13,21 @@ import io.swagger.annotations.ApiModelProperty;
* Coordinate
*/
-public class Coordinate extends BaseResponse{
+public class Coordinate extends BaseResponse {
+ Range latitudeRange = Range.create(52.466709, 52.467007);
+ Range longtitudeRange = Range.create(16.926159, 16.926976);
+
@SerializedName("coordinateId")
private UUID coordinateId = null;
@SerializedName("latitude")
- private Float latitude = null;
+ private Double latitude;
@SerializedName("longitude")
- private Float longitude = null;
+ private Double longitude = null;
@SerializedName("altitude")
- private Float altitude = null;
+ private Double altitude = null;
@SerializedName("userId")
private String userId = null;
@@ -37,7 +42,21 @@ public class Coordinate extends BaseResponse{
private Long timeStamp = null;
@SerializedName("label")
- private String label = null;
+ private String label;
+
+ public Coordinate (Double latitude, Double longitude, String label, String userId) {
+ //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.userId = userId;
+ this.label = label;
+ }
+
+ public Coordinate (Double latitude) {
+ this.latitude = latitude;
+ }
public Coordinate coordinateId(UUID coordinateId) {
this.coordinateId = coordinateId;
@@ -57,7 +76,7 @@ public class Coordinate extends BaseResponse{
this.coordinateId = coordinateId;
}
- public Coordinate latitude(Float latitude) {
+ public Coordinate latitude(Double latitude) {
this.latitude = latitude;
return this;
}
@@ -67,15 +86,15 @@ public class Coordinate extends BaseResponse{
* @return latitude
**/
@ApiModelProperty(required = true, value = "")
- public Float getLatitude() {
+ public Double getLatitude() {
return latitude;
}
- public void setLatitude(Float latitude) {
+ public void setLatitude(Double latitude) {
this.latitude = latitude;
}
- public Coordinate longitude(Float longitude) {
+ public Coordinate longitude(Double longitude) {
this.longitude = longitude;
return this;
}
@@ -85,15 +104,15 @@ public class Coordinate extends BaseResponse{
* @return longitude
**/
@ApiModelProperty(required = true, value = "")
- public Float getLongitude() {
+ public Double getLongitude() {
return longitude;
}
- public void setLongitude(Float longitude) {
+ public void setLongitude(Double longitude) {
this.longitude = longitude;
}
- public Coordinate altitude(Float altitude) {
+ public Coordinate altitude(Double altitude) {
this.altitude = altitude;
return this;
}
@@ -103,11 +122,11 @@ public class Coordinate extends BaseResponse{
* @return altitude
**/
@ApiModelProperty(required = true, value = "")
- public Float getAltitude() {
+ public Double getAltitude() {
return altitude;
}
- public void setAltitude(Float altitude) {
+ public void setAltitude(Double altitude) {
this.altitude = altitude;
}
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java b/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java
index 008a6cc..70e3a9e 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/network/ApiClient.java
@@ -62,7 +62,7 @@ public class ApiClient {
// Adding Authorization token (API Key)
// Requests will be denied without API key
if (!TextUtils.isEmpty(PrefUtils.getApiKey(context))) {
- requestBuilder.addHeader("Authorization", PrefUtils.getApiKey(context));
+ requestBuilder.addHeader("Authorization", "Bearer " + PrefUtils.getApiKey(context));
}
Request request = requestBuilder.build();
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java
new file mode 100644
index 0000000..0f1dc6c
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/service/BackgroundLocalizationService.java
@@ -0,0 +1,365 @@
+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.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.IBinder;
+import android.support.annotation.RequiresApi;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.app.NotificationCompat;
+import android.util.Log;
+import android.content.Context;
+
+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 org.json.JSONObject;
+
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.util.Timer;
+import java.util.TimerTask;
+
+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;
+
+public class BackgroundLocalizationService extends Service {
+
+ public static String str_receiver = "background.location.broadcast";
+ private static final String TAG = "MyLocationService";
+ private LocationManager mLocationManager = null;
+ private static final int LOCATION_INTERVAL = 1000;
+ private static final float LOCATION_DISTANCE = 10f;
+ private Handler mHandler = new Handler();
+ private static long notify_interval = 10000;
+
+ double latitude, longitude;
+ boolean isGPSEnable = false;
+ boolean isNetworkEnable = false;
+
+ Location mLastLocation;
+ Intent intent;
+ LocationManager locationManager;
+ Location location;
+
+
+ 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);
+ fn_update(mLastLocation);
+ }
+
+ @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);
+ }
+ }
+
+ LocationListener[] 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);
+
+ return START_STICKY;
+ }
+
+ @Override
+ public void onCreate() {
+
+ Log.e(TAG, "onCreate");
+
+ 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);
+
+ }
+
+ initializeLocationManager();
+
+ try {
+ mLocationManager.requestLocationUpdates(
+ LocationManager.PASSIVE_PROVIDER,
+ LOCATION_INTERVAL,
+ LOCATION_DISTANCE,
+ mLocationListeners[0]
+ );
+ } 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());
+ }
+
+ try {
+ mLocationManager.requestLocationUpdates(
+ LocationManager.GPS_PROVIDER,
+ LOCATION_INTERVAL,
+ LOCATION_DISTANCE,
+ mLocationListeners[1]
+ );
+ } catch (java.lang.SecurityException ex) {
+ Log.i(TAG, "fail to request location update, ignore", ex);
+ } catch (IllegalArgumentException ex) {
+ Log.d(TAG, "gps provider does not exist " + ex.getMessage());
+ }
+ Timer mTimer = new Timer();
+ mTimer.schedule(new TimerTaskToGetLocation(), 5, notify_interval);
+ intent = new Intent(str_receiver);
+
+ }
+
+ @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() {
+ locationManager = (LocationManager) getApplicationContext().getSystemService(LOCATION_SERVICE);
+ isGPSEnable = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
+ isNetworkEnable = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
+
+ if (!isGPSEnable && !isNetworkEnable) {
+
+ } else {
+
+
+ if (isGPSEnable) {
+ location = null;
+ 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;
+ }
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0, mLocationListeners[1]);
+ if (locationManager != null) {
+ location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+
+ fn_update(location);
+ }
+ }
+ }
+
+ if (isNetworkEnable) {
+ location = null;
+ 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;
+ }
+
+ locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1000, 0, mLocationListeners[0]);
+
+ if (locationManager != null) {
+ 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;
+ }
+ location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
+ if (location != null) {
+ latitude = location.getLatitude();
+ longitude = location.getLongitude();
+ fn_update(location);
+ }
+ }
+
+ }
+
+
+ }
+
+ }
+
+
+ private class TimerTaskToGetLocation extends TimerTask {
+ @Override
+ public void run() {
+ mHandler.post(BackgroundLocalizationService.this::fn_getlocation);
+ }
+ }
+
+ private void fn_update(Location location) {
+ intent.putExtra("latitude", location.getLatitude());
+ intent.putExtra("longitude", location.getLongitude());
+ Log.e(TAG, String.valueOf(location));
+ new Task(location).execute();
+ }
+
+ @Override
+ public void onDestroy() {
+ Log.e(TAG, "onDestroy");
+ super.onDestroy();
+ if (mLocationManager != null) {
+ for (int i = 0; i < mLocationListeners.length; i++) {
+ 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(mLocationListeners[i]);
+ } 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 Task extends AsyncTask {
+ private Double latitude;
+ private Double longitude;
+
+ private CompositeDisposable disposable = new CompositeDisposable();
+ private CoordinateService coordinateService = ApiClient.getClient(getApplicationContext())
+ .create(CoordinateService.class);
+
+ private Task(Location location) {
+ this.latitude = location.getLatitude();
+ this.longitude = location.getLongitude();
+ }
+
+
+ @Override
+ protected Object doInBackground(Object[] objects) {
+
+ try {
+
+ Coordinate coordinate = new Coordinate(
+ this.latitude,
+ this.longitude,
+ PrefUtils.getUserStatus(getApplicationContext()),
+ PrefUtils.getUserId(getApplicationContext())
+ );
+
+ disposable.add(
+ coordinateService
+ .postCoordinate(coordinate)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribeWith(new DisposableSingleObserver() {
+ @SuppressLint("LongLogTag")
+ @Override
+ public void onSuccess(Coordinate coord) {
+ Log.e("CoordinateService onSuccess", String.valueOf(coord));
+ }
+
+ @SuppressLint("LongLogTag")
+ @Override
+ public void onError(Throwable e) {
+ ((HttpException) e).code();
+ Log.e("CoordinateService onError", e.getMessage());
+
+ if (e instanceof HttpException) {
+ ResponseBody responseBody = ((HttpException)e).response().errorBody();
+ Log.e("CoordinateService onError", getErrorMessage(responseBody));
+ }
+
+ }
+ }));
+ } catch (IllegalArgumentException e) {
+ Timber.e(String.valueOf(e));
+ }
+
+ return null;
+ }
+
+ private String getErrorMessage(ResponseBody responseBody) {
+ try {
+ JSONObject jsonObject = new JSONObject(responseBody.string());
+ return jsonObject.getString("message");
+ } catch (Exception e) {
+ return e.getMessage();
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java
index 877bec2..ce3d2fe 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/service/CoordinateService.java
@@ -1,13 +1,12 @@
package com.uam.wmi.findmytutor.service;
import com.uam.wmi.findmytutor.model.Coordinate;
-
import java.util.List;
-import okhttp3.ResponseBody;
-import retrofit2.Call;
+import io.reactivex.Single;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
+
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
@@ -16,31 +15,31 @@ import retrofit2.http.Path;
public interface CoordinateService {
@GET("api/coordinates")
- Call> getAllCoordinates();
+ Single> getAllCoordinates();
@GET("api/coordinates/{id}")
- Call getCoordinatesById(@Path("id") String id);
+ Single getCoordinatesById(@Path("id") String id);
@GET("api/coordinates/user/{userId}")
- Call> getCoordinatesByUserId(@Path("userId") String userId);
+ Single> getCoordinatesByUserId(@Path("userId") String userId);
@GET("api/coordinates/userTop/{userId}")
- Call> getTopCoordinatesByUserId(@Path("userId") String userId);
+ Single> getTopCoordinatesByUserId(@Path("userId") String userId);
@GET("api/coordinates/top")
- Call> getTopCoordinates();
+ Single> getTopCoordinates();
@GET("api/coordinates/top/online")
- Call> getOnlineCoordinates();
+ Single> getOnlineCoordinates();
@POST("api/coordinates")
- Call postCoordinate(@Body Coordinate coordinate);
+ Single postCoordinate(@Body Coordinate coordinate);
@PUT("api/coordinates/{id}")
- Call putCoordinatesById(@Path("id") String id);
+ Single putCoordinatesById(@Path("id") String id);
@DELETE("api/coordinates/{id}")
- Call deleteCoordinatesById(@Path("id") String id);
+ Single deleteCoordinatesById(@Path("id") String id);
}
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/BroadcastLocalizationHandler.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/BroadcastLocalizationHandler.java
new file mode 100644
index 0000000..afd7765
--- /dev/null
+++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/BroadcastLocalizationHandler.java
@@ -0,0 +1,104 @@
+package com.uam.wmi.findmytutor.utils;
+
+import android.annotation.SuppressLint;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.os.AsyncTask;
+import android.support.v4.content.LocalBroadcastManager;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import com.auth0.android.jwt.Claim;
+import com.auth0.android.jwt.JWT;
+import com.uam.wmi.findmytutor.model.Coordinate;
+import com.uam.wmi.findmytutor.model.JwtToken;
+import com.uam.wmi.findmytutor.model.LdapUser;
+import com.uam.wmi.findmytutor.network.ApiClient;
+import com.uam.wmi.findmytutor.service.CoordinateService;
+import com.uam.wmi.findmytutor.service.LdapService;
+
+import org.json.JSONObject;
+import org.reactivestreams.Subscriber;
+import org.reactivestreams.Subscription;
+
+import java.util.Map;
+
+import io.reactivex.android.schedulers.AndroidSchedulers;
+import io.reactivex.disposables.CompositeDisposable;
+import io.reactivex.observers.DisposableObserver;
+import io.reactivex.observers.DisposableSingleObserver;
+import io.reactivex.schedulers.Schedulers;
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
+import retrofit2.Call;
+import retrofit2.Callback;
+import timber.log.Timber;
+
+import static android.content.ContentValues.TAG;
+import static com.mapbox.mapboxsdk.Mapbox.getApplicationContext;
+
+public class BroadcastLocalizationHandler extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context arg0, Intent intent) {
+ final PendingResult pendingResult = goAsync();
+ Task asyncTask = new Task(pendingResult, intent);
+ asyncTask.execute();
+ }
+
+ private static class Task extends AsyncTask {
+ private Double latitude;
+ private Double longitude;
+
+ private CompositeDisposable disposable = new CompositeDisposable();
+ private CoordinateService coordinateService = ApiClient.getClient(getApplicationContext())
+ .create(CoordinateService.class);
+
+ private Task(PendingResult pendingResult, Intent intent) {
+ this.latitude = intent.getDoubleExtra("latitude", 0);
+ this.longitude = intent.getDoubleExtra("longitude", 0);
+ }
+
+
+ @Override
+ protected Object doInBackground(Object[] objects) {
+
+ try {
+
+ Coordinate coordinate = new Coordinate(
+ this.latitude,
+ this.longitude,
+ PrefUtils.getUserStatus(getApplicationContext()),
+ PrefUtils.getUserId(getApplicationContext())
+ );
+
+ disposable.add(
+ coordinateService
+ .postCoordinate(coordinate)
+ .subscribeOn(Schedulers.io())
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribeWith(new DisposableSingleObserver() {
+ @SuppressLint("LongLogTag")
+ @Override
+ public void onSuccess(Coordinate coord) {
+ Log.e("CoordinateService onSuccess", String.valueOf(coord));
+ }
+
+ @Override
+ public void onError(Throwable e) {
+ Log.e("LoginError", "onError: " + e.getMessage());
+ }
+ }));
+ } catch (IllegalArgumentException e) {
+ Timber.e(String.valueOf(e));
+ }
+
+ return null;
+ }
+ }
+}
+
+
+
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java
deleted file mode 100644
index 96a4d62..0000000
--- a/app/src/main/java/com/uam/wmi/findmytutor/utils/MyDividerItemDecoration.java
+++ /dev/null
@@ -1,98 +0,0 @@
-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 + dpToPx(margin), top, right - dpToPx(margin), 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()));
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
index 8613c34..0c6fe6a 100644
--- a/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
+++ b/app/src/main/java/com/uam/wmi/findmytutor/utils/PrefUtils.java
@@ -2,12 +2,13 @@ package com.uam.wmi.findmytutor.utils;
import android.content.Context;
import android.content.SharedPreferences;
+import android.util.Log;
+
+import com.auth0.android.jwt.Claim;
+import com.auth0.android.jwt.JWT;
public class PrefUtils {
- /**
- * Storing API Key in shared preferences to
- * add it in header part of every retrofit request
- */
+
public PrefUtils() {
}
@@ -18,10 +19,63 @@ public class PrefUtils {
public static void storeApiKey(Context context, String apiKey) {
SharedPreferences.Editor editor = getSharedPreferences(context).edit();
editor.putString("API_KEY", apiKey);
- editor.commit();
+ 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("USER_STATUS", "Android");
+ }
+
+ 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 void cleanUserLocalStorage(Context context) {
+ SharedPreferences preferences = getSharedPreferences(context);
+ SharedPreferences.Editor editor = preferences.edit();
+ editor.clear().apply();
+ }
+
+ public static void storeIsServiceRunning(Context context, Boolean flag) {
+ SharedPreferences.Editor editor = getSharedPreferences(context).edit();
+ editor.putBoolean("IS_SERVIS_RUNNING", flag);
+ editor.apply();
+ }
+
+ public static boolean getIsServiceRunning(Context context) {
+ return getSharedPreferences(context).getBoolean("IS_SERVIS_RUNNING", false);
+ }
+
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java b/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java
deleted file mode 100644
index 28aef5d..0000000
--- a/app/src/main/java/com/uam/wmi/findmytutor/utils/RecyclerTouchListener.java
+++ /dev/null
@@ -1,54 +0,0 @@
-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;
-
-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);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml
index 6383218..f4cbc1b 100644
--- a/app/src/main/res/layout/activity_login.xml
+++ b/app/src/main/res/layout/activity_login.xml
@@ -80,6 +80,8 @@
android:text="@string/action_sign_in"
android:textStyle="bold" />
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index 9939aa5..807eab3 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -18,6 +18,7 @@
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer">
+
+
40sp
14sp
13sp
+ 12dp
+ 10dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index c983375..aac502f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -33,10 +33,14 @@
"Contacts permissions are needed for providing email
completions."
+ Permission was denied, but is needed for core
+functionality.
MainActivity
pk.eyJ1IjoiZG9tYWdhbHNreSIsImEiOiJjamd4am4zazYwNXo1MzBxeDZtYjA4d2s4In0.KzNdhc9V_-SYe14AZ-q3Ew
+
Black List
White List
+
Settings
@@ -175,4 +179,21 @@
Silent
Vibrate
+
+
+ Settings
+ OK
+
+ Request updates
+ Remove updates
+ Unknown location
+
+ Batched location updates
+
+
+ - No location reported
+ - One location reported
+ - %d locations reported
+
+
diff --git a/build.gradle b/build.gradle
index 077cb2f..d9fe839 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,8 +7,8 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.4'
-
+ classpath 'com.android.tools.build:gradle:3.2.0'
+
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index efbeabf..71be508 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Sun Aug 12 23:17:46 CEST 2018
+#Sat Sep 29 16:56:56 CEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip