Skip to content

Commit

Permalink
* update google play service.
Browse files Browse the repository at this point in the history
* update Android support to 30.
  • Loading branch information
Prabhat rai committed Apr 11, 2021
1 parent 1d886b1 commit ceac102
Show file tree
Hide file tree
Showing 12 changed files with 109 additions and 128 deletions.
Binary file added .idea/caches/build_file_checksums.ser
Binary file not shown.
6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) {
latLong = findViewById(R.id.latlong);
diff = findViewById(R.id.diff);
getLocationDetail = new GetLocationDetail(this, this);
easyWayLocation = new EasyWayLocation(this, false,this);
easyWayLocation = new EasyWayLocation(this, false,true,this);
if (permissionIsGranted()) {
doLocationWork();
} else {
Expand Down
12 changes: 8 additions & 4 deletions easywaylocation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ apply plugin: 'kotlin-android'
apply plugin: 'com.github.dcendents.android-maven'
group='com.github.prabhat1707'
android {
compileSdkVersion 29
compileSdkVersion 30
defaultConfig {
minSdkVersion 16
targetSdkVersion 29
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -19,6 +19,10 @@ android {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
}
debug {
debuggable true
}
}
compileOptions {
Expand All @@ -32,9 +36,9 @@ android {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.5"
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-scalars:2.6.1'
implementation "androidx.core:core-ktx:+"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class EasyWayLocation {
private FusedLocationProviderClient fusedLocationClient;
boolean gps_enabled = false;
boolean network_enabled = false;
GoogleApiClient googleApiClient;
private Boolean locationReturn = true;
private Context activity;
private Context context;
Expand All @@ -138,13 +137,14 @@ public class EasyWayLocation {
private Listener mListener;
private LocationRequest locationRequest;


/**
* Constructs a new instance
*
* @param context the Context reference to get the system service from
*/
public EasyWayLocation(final Context context,final boolean requireLastLocation,final Listener listener) {
this(context, null, requireLastLocation,listener);
public EasyWayLocation(final Context context,final boolean requireLastLocation,Boolean isDebuggable,final Listener listener) {
this(context, null, isDebuggable,requireLastLocation,listener);
}

/**
Expand All @@ -155,23 +155,24 @@ public EasyWayLocation(final Context context,final boolean requireLastLocation,f
* @param requireLastLocation require last location or not
*/
public EasyWayLocation(Context context, final LocationRequest locationRequest, final boolean requireLastLocation,final Listener listener) {

public EasyWayLocation(Context context, final LocationRequest locationRequest, final boolean requireLastLocation,Boolean isDebuggable,final Listener listener) {
// mLocationManager = (LocationManager) context.getApplicationContext().getSystemService(Context.LOCATION_SERVICE);
this.context = context;
this.mListener = listener;
Logger.INSTANCE.setDebuggable(isDebuggable);
fusedLocationClient = LocationServices.getFusedLocationProviderClient(context);
if (locationRequest != null){
this.locationRequest = locationRequest;
}else {
this.locationRequest = new LocationRequest();
this.locationRequest = LocationRequest.create();
this.locationRequest.setInterval(10000);
// locationRequest.setSmallestDisplacement(10F);
this.locationRequest.setPriority(LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY);
}
this.mRequireLastLocation = requireLastLocation;
if (mRequireLastLocation) {
getCachedPosition();
//cachePosition();
}
}

Expand Down Expand Up @@ -477,55 +478,6 @@ public void setBlurRadius(final int blurRadius) {
}





/**
* Returns the name of the location provider that matches the specified settings and depends on the given granularity
*
* @return the provider's name
*/
// private String getProviderName(final boolean requireFine) {
// // if fine location (GPS) is required
// if (requireFine) {
// // we just have to decide between active and passive mode
//
// if (mPassive) {
// return PROVIDER_FINE_PASSIVE;
// } else {
// return PROVIDER_FINE;
// }
// }
// // if both fine location (GPS) and coarse location (network) are acceptable
// else {
// // if we can use coarse location (network)
// if (hasLocationEnabled(PROVIDER_COARSE)) {
// // if we wanted passive mode
// if (mPassive) {
// // throw an exception because this is not possible
// throw new RuntimeException("There is no passive provider for the coarse location");
// }
// // if we wanted active mode
// else {
// // use coarse location (network)
// return PROVIDER_COARSE;
// }
// }
// // if coarse location (network) is not available
// else {
// // if we can use fine location (GPS)
// if (hasLocationEnabled(PROVIDER_FINE) || hasLocationEnabled(PROVIDER_FINE_PASSIVE)) {
// // we have to use fine location (GPS) because coarse location (network) was not available
// return getProviderName(true);
// }
// // no location is available so return the provider with the minimum permission level
// else {
// return PROVIDER_COARSE;
// }
// }
// }
// }

@SuppressLint("MissingPermission")
private void getCachedPosition() {
fusedLocationClient.getLastLocation()
Expand Down Expand Up @@ -553,51 +505,6 @@ private void cachePosition() {
mCachedPosition = mPosition;
}
}
//
// @Override
// public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
// Toast.makeText(context, "failed", Toast.LENGTH_SHORT).show();
// }
//
// @Override
// public void onConnected(@Nullable Bundle bundle) {
//
// LocationRequest mLocationRequest = new LocationRequest();
// LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder().addLocationRequest(mLocationRequest);
// PendingResult<LocationSettingsResult> result = LocationServices.SettingsApi.checkLocationSettings(googleApiClient, builder.build());
//
// result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
// @Override
// public void onResult(@NonNull LocationSettingsResult result1) {
// Status status = result1.getStatus();
// final LocationSettingsStates states = result1.getLocationSettingsStates();
// switch (status.getStatusCode()) {
// case LocationSettingsStatusCodes.SUCCESS:
// mListener.locationOn();
// break;
// case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
// try {
//
// status.startResolutionForResult((Activity) context, LOCATION_SETTING_REQUEST_CODE);
//
// } catch (IntentSender.SendIntentException e) {
//
// }
// break;
// case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
// locationReturn = false;
// break;
// }
//
// }
// });
// }
//
// @Override
// public void onConnectionSuspended(int i) {
// }
//
//

/**
* Wrapper for two coordinates (latitude and longitude)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GetLocationDetail {
private static Retrofit retrofit;
private LocationData.AddressCallBack addressCallBack;
private Context context;
private final String TAG = "GetLocationDetailExc-->";

public GetLocationDetail(LocationData.AddressCallBack addressCallBack, Context context) {
this.addressCallBack = addressCallBack;
Expand Down Expand Up @@ -118,13 +119,16 @@ public void onResponse(Call<String> call, Response<String> response) {
}
addressCallBack.locationData(locationData);
} catch (JSONException e) {
e.printStackTrace();
Logger.INSTANCE.LogDebug(TAG,"From getAddressFromApi JSONException "+e.getMessage());
}
catch (NullPointerException e){
Logger.INSTANCE.LogDebug(TAG,"From getAddressFromApi NullPointerException "+e.getMessage());
}
}

@Override
public void onFailure(Call<String> call, Throwable t) {
Log.v("response", t.toString());
Logger.INSTANCE.LogDebug(TAG,"From getAddressFromApi onFailure "+ t.toString());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.easywaylocation

import android.util.Log

object Logger {
var isDebuggable = false;

fun LogDebug(tag:String,mess:String){
if (isDebuggable){
Log.e(tag,mess)
}
}

fun LogInfo(tag:String,mess:String){
if (isDebuggable){
Log.v(tag,mess)
}
}
}
Loading

0 comments on commit ceac102

Please sign in to comment.