mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Merge pull request #866 from Bluesir9/issue_861_nearby_permission_deny_crash_fix
Replaced usage of NoPermissionsFragment with AlertDialog in NearbyActivity
This commit is contained in:
commit
cfcfcaf194
2 changed files with 21 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ package fr.free.nrw.commons.nearby;
|
|||
|
||||
import android.Manifest;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.location.LocationManager;
|
||||
|
|
@ -158,15 +159,30 @@ public class NearbyActivity extends NavigationBaseActivity {
|
|||
if (progressBar != null) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
|
||||
Fragment noPermissionsFragment = new NoPermissionsFragment();
|
||||
fragmentTransaction.replace(R.id.container, noPermissionsFragment);
|
||||
fragmentTransaction.commit();
|
||||
|
||||
showLocationPermissionDeniedErrorDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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() {
|
||||
LocationManager manager = (LocationManager) getSystemService(LOCATION_SERVICE);
|
||||
if (!manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
|
|
|
|||
|
|
@ -204,6 +204,7 @@ Tap this message (or hit back) to skip this step.</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="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>
|
||||
<string name="use_external_storage">Use external storage</string>
|
||||
<string name="use_external_storage_summary">Save pictures taken with the in-app camera on your device</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue