Remove credential management app Settings
* Update string and icon
* Flip icon if languate is RTL e.g. Arabic
* Add dialog when 'Remove app' is selected
* Add Material Next theme to dialog
* Update string terminology when removing a
CA or user certificate to from 'remove'
to 'uninstall'
* Final UI tweaks to RequestManageCredentials screen
Screenshots
* Light mode: https://screenshot.googleplex.com/66QKFLhtn6ZueZQ
* Dark mode: https://screenshot.googleplex.com/9kkTaaDV6CiHudF
* RTL: https://screenshot.googleplex.com/AkwSibXakARYM8H
* Request light mode: https://screenshot.googleplex.com/6n6raBQ8drXRHcU
* Request dark mode: https://screenshot.googleplex.com/3bmWNoTwE6JBqAX
Bug: 189416800
Test: atest CredentialManagementAppButtonsControllerTest
manual testing with TestDPC
Change-Id: I5450d33603418930e92b03c4447aaa1095afe9a3
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index aa2a142..d86a6d8 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1485,6 +1485,7 @@
</activity>
<activity android:name=".security.RequestManageCredentials"
+ android:theme="@style/Theme.SubSettings"
android:exported="true">
<intent-filter>
<action android:name="android.security.MANAGE_CREDENTIALS"/>
diff --git a/res/drawable/ic_redo_24.xml b/res/drawable/ic_redo_24.xml
new file mode 100644
index 0000000..21a2020
--- /dev/null
+++ b/res/drawable/ic_redo_24.xml
@@ -0,0 +1,25 @@
+<!--
+ ~ Copyright (C) 2021 The Android Open Source Project
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?attr/colorControlNormal">
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M6,13.5C6,11.57 7.75,10 9.9,10h6.27l-2.59,2.59L15,14l5,-5 -5,-5 -1.41,1.41L16.17,8H9.9C6.65,8 4,10.47 4,13.5S6.65,19 9.9,19H17v-2H9.9C7.75,17 6,15.43 6,13.5z"/>
+</vector>
\ No newline at end of file
diff --git a/res/layout-land/request_manage_credentials.xml b/res/layout-land/request_manage_credentials.xml
index 0c7bded..fbe0bd0 100644
--- a/res/layout-land/request_manage_credentials.xml
+++ b/res/layout-land/request_manage_credentials.xml
@@ -123,11 +123,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_manage_credentials_more"
+ android:textColor="?android:attr/colorBackground"
android:theme="@style/Theme.CollapsingToolbar.Settings"
app:backgroundTint="?android:attr/colorAccent"
app:elevation="3dp"
app:icon="@drawable/ic_arrow_downward"
- app:iconTint="?android:attr/textColorPrimary"
+ app:iconTint="?android:attr/colorBackground"
app:layout_anchor="@id/apps_list"
app:layout_anchorGravity="bottom|center" />
diff --git a/res/layout-sw600dp/request_manage_credentials.xml b/res/layout-sw600dp/request_manage_credentials.xml
index f8cf559..42facd3 100644
--- a/res/layout-sw600dp/request_manage_credentials.xml
+++ b/res/layout-sw600dp/request_manage_credentials.xml
@@ -97,11 +97,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_manage_credentials_more"
+ android:textColor="?android:attr/colorBackground"
android:theme="@style/Theme.CollapsingToolbar.Settings"
app:backgroundTint="?android:attr/colorAccent"
app:elevation="3dp"
app:icon="@drawable/ic_arrow_downward"
- app:iconTint="?android:attr/textColorPrimary"
+ app:iconTint="?android:attr/colorBackground"
app:layout_anchor="@id/apps_list"
app:layout_anchorGravity="bottom|center" />
diff --git a/res/layout/request_manage_credentials.xml b/res/layout/request_manage_credentials.xml
index c8167b6..ee697f7 100644
--- a/res/layout/request_manage_credentials.xml
+++ b/res/layout/request_manage_credentials.xml
@@ -67,11 +67,12 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/request_manage_credentials_more"
+ android:textColor="?android:attr/colorBackground"
app:layout_anchor="@id/apps_list"
app:layout_anchorGravity="bottom|center"
app:elevation="3dp"
app:icon="@drawable/ic_arrow_downward"
- app:iconTint="?android:attr/textColorPrimary"
+ app:iconTint="?android:attr/colorBackground"
app:backgroundTint="?android:attr/colorAccent"
android:theme="@style/Theme.CollapsingToolbar.Settings"/>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0d88aae..99a0631 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -6869,7 +6869,11 @@
<!-- Label for button to uninstall all certificates installed by the credential management app [CHAR LIMIT=30] -->
<string name="uninstall_certs_credential_management_app">Uninstall certificates</string>
<!-- Label for button to remove the credential management app [CHAR LIMIT=30] -->
- <string name="remove_credential_management_app">Remove</string>
+ <string name="remove_credential_management_app">Remove app</string>
+ <!-- Dialog title for button to remove the credential management app [CHAR LIMIT=30] -->
+ <string name="remove_credential_management_app_dialog_title">Remove this app?</string>
+ <!-- Dialog message for button to remove the credential management app [CHAR LIMIT=NONE] -->
+ <string name="remove_credential_management_app_dialog_message">This app won\u2019t manage certificates, but it will stay on your device. Any certificates installed by the app will be uninstalled.</string>
<!-- List item found in the credential management app's authentication policy [CHAR LIMIT=NONE] -->
<plurals name="number_of_urls">
<item quantity="one"><xliff:g id="number">%d</xliff:g> URL</item>
@@ -7491,7 +7495,7 @@
<!-- Button label for enabling a system CA certificate. -->
<string name="trusted_credentials_enable_label">Enable</string>
<!-- Button label for removing a user CA certificate. -->
- <string name="trusted_credentials_remove_label">Remove</string>
+ <string name="trusted_credentials_remove_label">Uninstall</string>
<!-- Button label for trusting a user CA certificate. -->
<string name="trusted_credentials_trust_label">Trust</string>
<!-- Alert dialog confirmation when enabling a system CA certificate. -->
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 63ea86e..3445627 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -806,21 +806,18 @@
<item name="android:fontFamily">google-sans-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="RequestManageCredentialsDontAllowButton"
- parent="@style/Widget.AppCompat.Button.Borderless">
+ parent="@style/Widget.AppCompat.Button.Borderless.Colored">
<item name="android:fontFamily">google-sans-medium</item>
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
</style>
<style name="RequestManageCredentialsFab">
<item name="android:textSize">14sp</item>
<item name="android:textAllCaps">false</item>
- <item name="android:textColor">?android:attr/textColorPrimary</item>
<item name="android:layout_marginBottom">12dp</item>
</style>
diff --git a/src/com/android/settings/security/CredentialManagementAppButtonsController.java b/src/com/android/settings/security/CredentialManagementAppButtonsController.java
index b296f37..250dd13 100644
--- a/src/com/android/settings/security/CredentialManagementAppButtonsController.java
+++ b/src/com/android/settings/security/CredentialManagementAppButtonsController.java
@@ -16,8 +16,11 @@
package com.android.settings.security;
+import android.app.Dialog;
import android.app.admin.DevicePolicyEventLogger;
+import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
@@ -25,12 +28,15 @@
import android.security.KeyChain;
import android.stats.devicepolicy.DevicePolicyEnums;
import android.util.Log;
+import android.view.View;
+import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;
import androidx.preference.PreferenceScreen;
import com.android.settings.R;
import com.android.settings.core.BasePreferenceController;
+import com.android.settings.core.instrumentation.InstrumentedDialogFragment;
import com.android.settingslib.widget.ActionButtonsPreference;
import java.util.concurrent.ExecutorService;
@@ -48,9 +54,16 @@
private final Handler mHandler = new Handler(Looper.getMainLooper());
private boolean mHasCredentialManagerPackage;
private Fragment mFragment;
+ private final int mRemoveIcon;
public CredentialManagementAppButtonsController(Context context, String preferenceKey) {
super(context, preferenceKey);
+ if (context.getResources().getConfiguration().getLayoutDirection()
+ == View.LAYOUT_DIRECTION_RTL) {
+ mRemoveIcon = R.drawable.ic_redo_24;
+ } else {
+ mRemoveIcon = R.drawable.ic_undo_24;
+ }
}
public void setParentFragment(Fragment fragment) {
@@ -84,8 +97,8 @@
.setButton1Icon(R.drawable.ic_upload)
.setButton1OnClickListener(view -> uninstallCertificates())
.setButton2Text(R.string.remove_credential_management_app)
- .setButton2Icon(R.drawable.ic_delete)
- .setButton2OnClickListener(view -> removeCredentialManagementApp());
+ .setButton2Icon(mRemoveIcon)
+ .setButton2OnClickListener(view -> showRemoveCredentialManagementAppDialog());
}
}
@@ -103,18 +116,54 @@
});
}
- private void removeCredentialManagementApp() {
- mExecutor.execute(() -> {
- try {
- IKeyChainService service = KeyChain.bind(mContext).getService();
- service.removeCredentialManagementApp();
- DevicePolicyEventLogger
- .createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REMOVED)
- .write();
- mFragment.getActivity().finish();
- } catch (InterruptedException | RemoteException e) {
- Log.e(TAG, "Unable to remove the credential management app");
- }
- });
+ private void showRemoveCredentialManagementAppDialog() {
+ final RemoveCredentialManagementAppDialog dialog =
+ RemoveCredentialManagementAppDialog.newInstance();
+ dialog.show(mFragment.getParentFragmentManager(),
+ RemoveCredentialManagementAppDialog.class.getName());
}
-}
+
+ /**
+ * Implements an AlertDialog for confirming that a user wants to remove the credential
+ * management app. The app will no longer be able to manage certificates, but it will stay on
+ * the device. All certificates installed by the credential management app will be uninstalled.
+ */
+ public static class RemoveCredentialManagementAppDialog extends InstrumentedDialogFragment {
+
+ public static RemoveCredentialManagementAppDialog newInstance() {
+ return new RemoveCredentialManagementAppDialog();
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ return new AlertDialog.Builder(getContext(), R.style.Theme_AlertDialog)
+ .setTitle(R.string.remove_credential_management_app_dialog_title)
+ .setMessage(R.string.remove_credential_management_app_dialog_message)
+ .setPositiveButton(R.string.remove_credential_management_app,
+ (dialog, which) -> removeCredentialManagementApp())
+ .setNegativeButton(R.string.cancel, (dialog, which) -> dismiss())
+ .create();
+ }
+
+ private void removeCredentialManagementApp() {
+ final ExecutorService executor = Executors.newSingleThreadExecutor();
+ executor.execute(() -> {
+ try {
+ IKeyChainService service = KeyChain.bind(getContext()).getService();
+ service.removeCredentialManagementApp();
+ DevicePolicyEventLogger
+ .createEvent(DevicePolicyEnums.CREDENTIAL_MANAGEMENT_APP_REMOVED)
+ .write();
+ getParentFragment().getActivity().finish();
+ } catch (InterruptedException | RemoteException e) {
+ Log.e(TAG, "Unable to remove the credential management app");
+ }
+ });
+ }
+
+ @Override
+ public int getMetricsCategory() {
+ return SettingsEnums.CREDENTIAL_MANAGEMENT_APP_REMOVE_APP;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/com/android/settings/security/RequestManageCredentials.java b/src/com/android/settings/security/RequestManageCredentials.java
index cda97da..1a8da67 100644
--- a/src/com/android/settings/security/RequestManageCredentials.java
+++ b/src/com/android/settings/security/RequestManageCredentials.java
@@ -288,7 +288,7 @@
// On down scroll, hide text in floating action button by setting
// extended to false.
if (dy > 0 && mExtendedFab.getVisibility() == View.VISIBLE) {
- mExtendedFab.setExtended(false);
+ mExtendedFab.shrink();
}
if (isRecyclerScrollable()) {
mExtendedFab.show();