mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
When location permission request is denied in NearbyActivity, instead of the NoPermissionsFragment, now an AlertDialog is shown providing options to either retry the permission request or cancel and quit the activity.
This commit is contained in:
parent
d4a89afafd
commit
11f9511495
2 changed files with 21 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.location.LocationManager;
|
import android.location.LocationManager;
|
||||||
|
|
@ -158,15 +159,30 @@ public class NearbyActivity extends NavigationBaseActivity {
|
||||||
if (progressBar != null) {
|
if (progressBar != null) {
|
||||||
progressBar.setVisibility(View.GONE);
|
progressBar.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
|
||||||
Fragment noPermissionsFragment = new NoPermissionsFragment();
|
showLocationPermissionDeniedErrorDialog();
|
||||||
fragmentTransaction.replace(R.id.container, noPermissionsFragment);
|
|
||||||
fragmentTransaction.commit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void showLocationPermissionDeniedErrorDialog() {
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setMessage(R.string.nearby_needs_permissions)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(R.string.give_permission, (dialog, which) -> {
|
||||||
|
//will ask for the location permission again
|
||||||
|
checkLocationPermission();
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.cancel, (dialog, which) -> {
|
||||||
|
//dismiss dialog and finish activity
|
||||||
|
dialog.cancel();
|
||||||
|
finish();
|
||||||
|
})
|
||||||
|
.create()
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
private void checkGps() {
|
private void checkGps() {
|
||||||
LocationManager manager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
LocationManager manager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||||
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||||
|
|
|
||||||
|
|
@ -203,5 +203,6 @@ Tap this message (or hit back) to skip this step.</string>
|
||||||
<string name="error_while_cache">Error while caching pictures</string>
|
<string name="error_while_cache">Error while caching pictures</string>
|
||||||
<string name="title_info">A unique descriptive title for the file, which will serve as a filename. You may use plain language with spaces. Do not include the file extension</string>
|
<string name="title_info">A unique descriptive title for the file, which will serve as a filename. You may use plain language with spaces. Do not include the file extension</string>
|
||||||
<string name="description_info">Please describe the media as much as possible: Where was it taken? What does it show? What is the context? Please describe the objects or persons. Reveal information that can not be easily guessed, for instance the time of day if it is a landscape. If the media shows something unusual, please explain what makes it unusual.</string>
|
<string name="description_info">Please describe the media as much as possible: Where was it taken? What does it show? What is the context? Please describe the objects or persons. Reveal information that can not be easily guessed, for instance the time of day if it is a landscape. If the media shows something unusual, please explain what makes it unusual.</string>
|
||||||
|
<string name="give_permission">Give permission</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue