diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentPermissions.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentPermissions.java index af3c9f145..3ca4e540c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentPermissions.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/activities/welcome/WelcomeFragmentPermissions.java @@ -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 { diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/PermissionsUtils.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/PermissionsUtils.java index ac3b2d9cb..93736d0eb 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/PermissionsUtils.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/PermissionsUtils.java @@ -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); } }