1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-30 05:52:57 +01:00

Improve requesting all permissions

This commit is contained in:
Arjan Schrijver 2024-06-12 23:07:42 +02:00
parent a889f671d7
commit 2422e02e5d
2 changed files with 9 additions and 1 deletions

View File

@ -44,6 +44,7 @@ public class WelcomeFragmentPermissions extends Fragment {
private RecyclerView permissionsListView;
private PermissionAdapter permissionAdapter;
private Button requestAllButton;
@Nullable
@Override
@ -51,7 +52,7 @@ public class WelcomeFragmentPermissions extends Fragment {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.fragment_welcome_permissions, container, false);
Button requestAllButton = view.findViewById(R.id.button_request_all);
requestAllButton = view.findViewById(R.id.button_request_all);
requestAllButton.setOnClickListener(v -> PermissionsUtils.requestAllPermissions(requireActivity()));
// Initialize RecyclerView and data
@ -69,6 +70,9 @@ public class WelcomeFragmentPermissions extends Fragment {
public void onResume() {
super.onResume();
permissionAdapter.notifyDataSetChanged();
if (PermissionsUtils.checkAllPermissions(requireActivity())) {
requestAllButton.setEnabled(false);
}
}
private class PermissionHolder extends RecyclerView.ViewHolder {

View File

@ -205,6 +205,10 @@ public class PermissionsUtils {
requestPermission(activity, CUSTOM_PERM_NOTIFICATION_SERVICE);
if (wantedPermissionsStrings.contains(CUSTOM_PERM_DISPLAY_OVER) && !checkPermission(activity, CUSTOM_PERM_DISPLAY_OVER))
requestPermission(activity, CUSTOM_PERM_DISPLAY_OVER);
if (wantedPermissionsStrings.contains(Manifest.permission.ACCESS_FINE_LOCATION) && !checkPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION))
requestPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION);
if (wantedPermissionsStrings.contains(Manifest.permission.ACCESS_BACKGROUND_LOCATION) && !checkPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION))
requestPermission(activity, Manifest.permission.ACCESS_BACKGROUND_LOCATION);
ActivityCompat.requestPermissions(activity, wantedPermissionsStrings.toArray(new String[0]), 0);
}
}