Skip to content

Fix #5276: improve the media location access dialog strings #5368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,33 +265,19 @@ public void onActivityResult(Map<String, Boolean> result) {
}
});

/**
* This function is used to display an Android requesting block
* and response to the user's decision.
*/
private ActivityResultLauncher<String[]> locationPermissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), new ActivityResultCallback<Map<String, Boolean>>() {
@Override
public void onActivityResult(Map<String, Boolean> result) {
boolean areAllGranted = true;
for (final boolean b : result.values()) {
areAllGranted = areAllGranted && b;
}

if (areAllGranted) {
locationPermissionGranted();
} else {
if (shouldShowRequestPermissionRationale(permission.ACCESS_FINE_LOCATION)) {
DialogUtil.showAlertDialog(getActivity(), getActivity().getString(R.string.location_permission_title),
getActivity().getString(R.string.location_permission_rationale_nearby),
getActivity().getString(android.R.string.ok),
getActivity().getString(android.R.string.cancel),
() -> {
if (!(locationManager.isNetworkProviderEnabled() || locationManager.isGPSProviderEnabled())) {
showLocationOffDialog();
}
},
() -> isPermissionDenied = true,
null,
false);
} else {
isPermissionDenied = true;
if (shouldShowRequestPermissionRationale(permission.ACCESS_FINE_LOCATION)) {
if (!(locationManager.isNetworkProviderEnabled() || locationManager.isGPSProviderEnabled())) {
showLocationOffDialog();
}
} else {
isPermissionDenied = true;
}
}
});
Expand Down Expand Up @@ -1265,10 +1251,24 @@ public void setTabItemContributions() {
// TODO
}

/**
*This funcion should show the developers' defined dialog block first
* If the user click the ok button of this block, an Android
* requesting block will be displayed.
*/
@Override
public void checkPermissionsAndPerformAction() {
Timber.d("Checking permission and perfoming action");
locationPermissionLauncher.launch(new String[]{permission.ACCESS_FINE_LOCATION});
DialogUtil.showAlertDialog(getActivity(), getActivity().getString(R.string.location_permission_title),
getActivity().getString(R.string.location_permission_rationale_nearby),
getActivity().getString(android.R.string.ok),
getActivity().getString(android.R.string.cancel),
() -> {
locationPermissionLauncher.launch(new String[]{permission.ACCESS_FINE_LOCATION});
},
() -> isPermissionDenied = true,
null,
false);
}

/**
Expand Down