Loading src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java +36 −22 Original line number Diff line number Diff line /** /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.packageinstaller.permission.ui.auto; Loading Loading @@ -63,6 +62,7 @@ public final class AppPermissionsFragment extends Fragment{ /** * Creates a new instance. * * @param packageName the packageName of the application that we are listing the * permissions here. */ Loading Loading @@ -172,6 +172,8 @@ public final class AppPermissionsFragment extends Fragment{ private class PermissionLineItem extends TextListItem { private boolean mSwitchState; PermissionLineItem(AppPermissionGroup permissionGroup, Context context) { super(context); setTitle(permissionGroup.getLabel().toString()); Loading @@ -182,7 +184,20 @@ public final class AppPermissionsFragment extends Fragment{ permissionGroup.areRuntimePermissionsGranted(), /* showDivider= */ false, (button, isChecked) -> { if (isChecked) { mSwitchState = isChecked; updatePermission(permissionGroup, context, mSwitchState); }); setOnClickListener(v -> { mSwitchState = !mSwitchState; setSwitchState(mSwitchState); updatePermission(permissionGroup, context, mSwitchState); notifyDataSetChanged(); }); } private void updatePermission(AppPermissionGroup permissionGroup, Context context, boolean isGranted) { if (isGranted) { permissionGroup.grantRuntimePermissions(/* fixedByTheUser= */ false); return; } Loading @@ -201,7 +216,6 @@ public final class AppPermissionsFragment extends Fragment{ permissionGroup.revokeRuntimePermissions( /* fixedByTheUser= */ false)) .show(); }); } } } Loading
src/com/android/packageinstaller/permission/ui/auto/AppPermissionsFragment.java +36 −22 Original line number Diff line number Diff line /** /* * Copyright (C) 2017 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); Loading @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.packageinstaller.permission.ui.auto; Loading Loading @@ -63,6 +62,7 @@ public final class AppPermissionsFragment extends Fragment{ /** * Creates a new instance. * * @param packageName the packageName of the application that we are listing the * permissions here. */ Loading Loading @@ -172,6 +172,8 @@ public final class AppPermissionsFragment extends Fragment{ private class PermissionLineItem extends TextListItem { private boolean mSwitchState; PermissionLineItem(AppPermissionGroup permissionGroup, Context context) { super(context); setTitle(permissionGroup.getLabel().toString()); Loading @@ -182,7 +184,20 @@ public final class AppPermissionsFragment extends Fragment{ permissionGroup.areRuntimePermissionsGranted(), /* showDivider= */ false, (button, isChecked) -> { if (isChecked) { mSwitchState = isChecked; updatePermission(permissionGroup, context, mSwitchState); }); setOnClickListener(v -> { mSwitchState = !mSwitchState; setSwitchState(mSwitchState); updatePermission(permissionGroup, context, mSwitchState); notifyDataSetChanged(); }); } private void updatePermission(AppPermissionGroup permissionGroup, Context context, boolean isGranted) { if (isGranted) { permissionGroup.grantRuntimePermissions(/* fixedByTheUser= */ false); return; } Loading @@ -201,7 +216,6 @@ public final class AppPermissionsFragment extends Fragment{ permissionGroup.revokeRuntimePermissions( /* fixedByTheUser= */ false)) .show(); }); } } }