Merge "Update description when device allows guest user" into rvc-dev am: 6b82df2603 am: 6182b3cb55 am: 6a32ace8a2

Change-Id: I80436e46ddfa3481a7abe79b93f0265dbfbf7b7a
This commit is contained in:
Tsung-Mao Fang
2020-05-06 09:58:19 +00:00
committed by Automerger Merge Worker
2 changed files with 17 additions and 2 deletions

View File

@@ -9250,10 +9250,10 @@
\t\n3.\tTap the app icon at the top of the screen, then tap Pin \t\n3.\tTap the app icon at the top of the screen, then tap Pin
</string> </string>
<!-- [CHAR LIMIT=none] Screen pinning description --> <!-- [CHAR LIMIT=none] Screen pinning description -->
<string name="screen_pinning_guest_mode_description"> <string name="screen_pinning_guest_user_description">
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. 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\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\nIf you want to securely share your device with someone, try using a guest user instead.
\n\nTo use app pinning: \n\nTo use app pinning:
\t\n1.\tTurn on app pinning \t\n1.\tTurn on app pinning
\t\n2.\tOpen Overview \t\n2.\tOpen Overview

View File

@@ -22,6 +22,7 @@ import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.UserHandle; import android.os.UserHandle;
import android.os.UserManager;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import android.provider.Settings; import android.provider.Settings;
import android.widget.Switch; import android.widget.Switch;
@@ -61,6 +62,7 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
private SwitchPreference mUseScreenLock; private SwitchPreference mUseScreenLock;
private FooterPreference mFooterPreference; private FooterPreference mFooterPreference;
private LockPatternUtils mLockPatternUtils; private LockPatternUtils mLockPatternUtils;
private UserManager mUserManager;
@Override @Override
public int getMetricsCategory() { public int getMetricsCategory() {
@@ -74,6 +76,7 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
final SettingsActivity activity = (SettingsActivity) getActivity(); final SettingsActivity activity = (SettingsActivity) getActivity();
activity.setTitle(R.string.screen_pinning_title); activity.setTitle(R.string.screen_pinning_title);
mLockPatternUtils = new LockPatternUtils(activity); mLockPatternUtils = new LockPatternUtils(activity);
mUserManager = activity.getSystemService(UserManager.class);
addPreferencesFromResource(R.xml.screen_pinning_settings); addPreferencesFromResource(R.xml.screen_pinning_settings);
final PreferenceScreen root = getPreferenceScreen(); final PreferenceScreen root = getPreferenceScreen();
@@ -224,10 +227,22 @@ public class ScreenPinningSettings extends SettingsPreferenceFragment
mUseScreenLock.setTitle(getCurrentSecurityTitle()); mUseScreenLock.setTitle(getCurrentSecurityTitle());
} else { } else {
mFooterPreference.setVisible(true); mFooterPreference.setVisible(true);
mFooterPreference.setSummary(getAppPinningContent());
mUseScreenLock.setVisible(false); mUseScreenLock.setVisible(false);
} }
} }
private boolean isGuestModeSupported() {
return UserManager.supportsMultipleUsers()
&& !mUserManager.hasUserRestriction(UserManager.DISALLOW_USER_SWITCH);
}
private CharSequence getAppPinningContent() {
return isGuestModeSupported()
? getActivity().getText(R.string.screen_pinning_guest_user_description)
: getActivity().getText(R.string.screen_pinning_description);
}
/** /**
* For search * For search
*/ */