mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-26 20:06:52 +01:00
Improve requesting all permissions
This commit is contained in:
parent
2dabffa798
commit
ca1d1bc2f7
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user