Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JobGetabu committed Nov 8, 2020
1 parent 13a5efd commit caa71c0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import android.location.Geocoder;
import android.location.Location;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

Expand All @@ -27,15 +28,17 @@ protected Location getLastKnownLocation() {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
droidLocationDelegate = new DroidLocationDelegate(this,this);
droidLocationDelegate = new DroidLocationDelegate(this, this);
droidLocationDelegate.onCreate();
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
//droidLocationDelegate.showLocationSettingDialog(requestCode);
droidLocationDelegate.doWeStartLocationService(resultCode);
if (droidLocationDelegate != null) {
droidLocationDelegate.doWeStartLocationService(resultCode);
}
}

@Override
Expand All @@ -59,7 +62,7 @@ protected void requestSingleLocationFix(DroidLocationRequest droidLocationReques
droidLocationDelegate.requestSingleLocationFix(droidLocationRequest, ENABLE_LOCATION_SERVICES_REQUEST);
}

protected void requestAddressServices(Location location){
protected void requestAddressServices(Location location) {
droidLocationDelegate.startIntentService(location);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;

import androidx.appcompat.app.AlertDialog;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
Expand Down Expand Up @@ -134,6 +135,8 @@ private String hasLocationPermission() {
}

private void showPermissionRequireDialog(final int requestCode) {
if(droidLocationRequest == null) return;

String title = TextUtils.isEmpty(droidLocationRequest.locationPermissionDialogTitle) ? activity.getString(R.string.location_permission_dialog_title) : droidLocationRequest.locationPermissionDialogTitle;
String message = TextUtils.isEmpty(droidLocationRequest.locationPermissionDialogMessage) ? activity.getString(R.string.location_permission_dialog_message) : droidLocationRequest.locationPermissionDialogMessage;
String negativeButtonTitle = TextUtils.isEmpty(droidLocationRequest.locationPermissionDialogNegativeButtonText) ? activity.getString(android.R.string.cancel) : droidLocationRequest.locationPermissionDialogNegativeButtonText;
Expand All @@ -159,6 +162,8 @@ public void onClick(DialogInterface dialogInterface, int i) {
@Deprecated
// warning: Use @showLocationSettingDialog(int requestcode)
private void showLocationServicesRequireDialog() {
if(droidLocationRequest == null) return;

String title = TextUtils.isEmpty(droidLocationRequest.locationSettingsDialogTitle) ? activity.getString(R.string.location_services_off) : droidLocationRequest.locationSettingsDialogTitle;
String message = TextUtils.isEmpty(droidLocationRequest.locationSettingsDialogMessage) ? activity.getString(R.string.open_location_settings) : droidLocationRequest.locationSettingsDialogMessage;
String negativeButtonText = TextUtils.isEmpty(droidLocationRequest.locationSettingsDialogNegativeButtonText) ? activity.getString(android.R.string.cancel) : droidLocationRequest.locationSettingsDialogNegativeButtonText;
Expand All @@ -184,10 +189,15 @@ public void onClick(DialogInterface dialogInterface, int i) {

void doWeStartLocationService(int resultCode) {
Log.d("DroidLocation", "doWeStartLocationService: " + resultCode);
if(droidLocationRequest == null) return;

switch (resultCode) {
case Activity.RESULT_OK:
startLocationBGService(mLocationRequest, droidLocationRequest.fallBackToLastLocationTime);
droidLocationListener.onLocationProviderEnabled();

if(droidLocationRequest != null){
startLocationBGService(mLocationRequest, droidLocationRequest.fallBackToLastLocationTime);
droidLocationListener.onLocationProviderEnabled();
}
break;
case Activity.RESULT_CANCELED:
droidLocationListener.onLocationProviderDisabled();
Expand All @@ -201,6 +211,8 @@ void doWeStartLocationService(int resultCode) {
* */
void showLocationSettingDialog(final int requestcode) {

if(droidLocationRequest == null) return;

//requestcode = (requestcode == -1) ? ENABLE_LOCATION_SERVICES_REQUEST : requestcode;

GoogleApiClient mGoogleApiClient = new GoogleApiClient.Builder(activity)
Expand Down

0 comments on commit caa71c0

Please sign in to comment.