diff --git a/res/values/strings.xml b/res/values/strings.xml
index d4f3f7344ab..53e51022d27 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -9219,9 +9219,34 @@
Off
- Screen pinning
-
- When this setting is turned on, you can use screen pinning to keep the current screen in view until you unpin.\n\nTo use screen pinning:\n\n1. Make sure screen pinning is turned on\n\n2. Open Overview\n\n3. Tap the app icon at the top of the screen, then tap Pin
+ App pinning
+
+
+ App pinning allows you to keep the current app in view until you unpin it. This feature can be used, for example, to let a trusted friend play a specific game.
+ \n\nWhen an app is pinned, the pinned app may open other apps and personal data may be accessible.
+ \n\nTo use app pinning:
+ \t\n1.\tTurn on app pinning
+ \t\n2.\tOpen Overview
+ \t\n3.\tTap the app icon at the top of the screen, then tap Pin
+
+
+
+ App pinning allows you to keep the current app in view until you unpin it. This feature can be used, for example, to let a trusted friend play a specific game.
+ \n\nWhen an app is pinned, the pinned app may open other apps and personal data may be accessible.
+ \n\nIf you want to securely share your device with someone, try using a guest profile instead.
+ \n\nTo use app pinning:
+ \t\n1.\tTurn on app pinning
+ \t\n2.\tOpen Overview
+ \t\n3.\tTap the app icon at the top of the screen, then tap Pin
+
+
+
+ When app is pinned:
+ \n\n\u2022\t\tPersonal data may be accessible
+ \n\t\t(such as contacts and email content)
+ \n\u2022\t\tPinned app may open other apps
+ \n\nOnly use app pinning with people you trust.
+
Ask for unlock pattern before unpinning
diff --git a/src/com/android/settings/security/ScreenPinningSettings.java b/src/com/android/settings/security/ScreenPinningSettings.java
index 6b16a5d288c..9e14c9a3339 100644
--- a/src/com/android/settings/security/ScreenPinningSettings.java
+++ b/src/com/android/settings/security/ScreenPinningSettings.java
@@ -18,6 +18,7 @@ package com.android.settings.security;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.UserHandle;
@@ -25,6 +26,7 @@ import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.widget.Switch;
+import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.PreferenceScreen;
@@ -43,12 +45,13 @@ import com.android.settingslib.widget.FooterPreference;
import java.util.Arrays;
import java.util.List;
+
/**
* Screen pinning settings.
*/
@SearchIndexable
public class ScreenPinningSettings extends SettingsPreferenceFragment
- implements SwitchBar.OnSwitchChangeListener {
+ implements SwitchBar.OnSwitchChangeListener, DialogInterface.OnClickListener {
private static final String KEY_USE_SCREEN_LOCK = "use_screen_lock";
private static final String KEY_FOOTER = "screen_pinning_settings_screen_footer";
@@ -78,9 +81,9 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
mFooterPreference = root.findPreference(KEY_FOOTER);
mSwitchBar = activity.getSwitchBar();
- mSwitchBar.addOnSwitchChangeListener(this);
mSwitchBar.show();
mSwitchBar.setChecked(isLockToAppEnabled(getActivity()));
+ mSwitchBar.addOnSwitchChangeListener(this);
updateDisplay();
}
@@ -184,7 +187,26 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
*/
@Override
public void onSwitchChanged(Switch switchView, boolean isChecked) {
- setLockToAppEnabled(isChecked);
+ if (isChecked) {
+ new AlertDialog.Builder(getContext())
+ .setMessage(R.string.screen_pinning_dialog_message)
+ .setPositiveButton(R.string.dlg_ok, this)
+ .setNegativeButton(R.string.dlg_cancel, this)
+ .setCancelable(false)
+ .show();
+ } else {
+ setLockToAppEnabled(false);
+ updateDisplay();
+ }
+ }
+
+ @Override
+ public void onClick(DialogInterface dialogInterface, int which) {
+ if (which == DialogInterface.BUTTON_POSITIVE) {
+ setLockToAppEnabled(true);
+ } else {
+ mSwitchBar.setChecked(false);
+ }
updateDisplay();
}
@@ -210,14 +232,14 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
* For search
*/
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
- new BaseSearchIndexProvider() {
+ new BaseSearchIndexProvider() {
- @Override
- public List getXmlResourcesToIndex(Context context,
- boolean enabled) {
- final SearchIndexableResource sir = new SearchIndexableResource(context);
- sir.xmlResId = R.xml.screen_pinning_settings;
- return Arrays.asList(sir);
- }
- };
+ @Override
+ public List getXmlResourcesToIndex(Context context,
+ boolean enabled) {
+ final SearchIndexableResource sir = new SearchIndexableResource(context);
+ sir.xmlResId = R.xml.screen_pinning_settings;
+ return Arrays.asList(sir);
+ }
+ };
}