Update the text shown when admin disabled fingerprint as unlock option.

When the admin has disabled fingerprint as unlock option, we let the
user know that the admin has disabled that option with a more details
link which will trigger the admin support dialog. And made some small
fixes apart from this.

Change-Id: I01021b952dc6fb29a65d37401a6411a6088d5cef
This commit is contained in:
Sudheer Shanka
2016-01-22 20:40:56 +00:00
parent a16852480f
commit 5590e2eb44
6 changed files with 51 additions and 23 deletions

View File

@@ -810,7 +810,7 @@
<!-- Text shown in fingerprint settings explaining what the fingerprint can be used for. [CHAR LIMIT=NONE] --> <!-- Text shown in fingerprint settings explaining what the fingerprint can be used for. [CHAR LIMIT=NONE] -->
<string name="security_settings_fingerprint_enroll_disclaimer">In addition to unlocking your phone, you can also use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string> <string name="security_settings_fingerprint_enroll_disclaimer">In addition to unlocking your phone, you can also use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string>
<!-- Text shown in fingerprint settings explaining what the fingerprint can be used for in the case unlocking is disabled [CHAR LIMIT=NONE] --> <!-- Text shown in fingerprint settings explaining what the fingerprint can be used for in the case unlocking is disabled [CHAR LIMIT=NONE] -->
<string name="security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled">Screen lock option disabled. You can still use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string> <string name="security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled">Screen lock option disabled. Contact your organization\'s administrator to learn more. <annotation id="admin_details">More details</annotation>\n\nYou can still use your fingerprint to authorize purchases and app access. <annotation id="url">Learn more</annotation></string>
<!-- Text shown in fingerprint enroll when we didn't observe progress for a few seconds. [CHAR LIMIT=100] --> <!-- Text shown in fingerprint enroll when we didn't observe progress for a few seconds. [CHAR LIMIT=100] -->
<string name="security_settings_fingerprint_enroll_lift_touch_again">Lift finger, then touch sensor again</string> <string name="security_settings_fingerprint_enroll_lift_touch_again">Lift finger, then touch sensor again</string>

View File

@@ -62,6 +62,9 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
private String mHelpUri; private String mHelpUri;
private static final int ORDER_FIRST = -1;
private static final int ORDER_LAST = Integer.MAX_VALUE -1;
// Cache the content resolver for async callbacks // Cache the content resolver for async callbacks
private ContentResolver mContentResolver; private ContentResolver mContentResolver;
@@ -235,7 +238,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
protected void setHeaderView(int resource) { protected void setHeaderView(int resource) {
mHeader = new LayoutPreference(getPrefContext(), resource); mHeader = new LayoutPreference(getPrefContext(), resource);
mHeader.setOrder(-1); mHeader.setOrder(ORDER_FIRST);
if (getPreferenceScreen() != null) { if (getPreferenceScreen() != null) {
getPreferenceScreen().addPreference(mHeader); getPreferenceScreen().addPreference(mHeader);
} }
@@ -255,7 +258,7 @@ public abstract class SettingsPreferenceFragment extends InstrumentedPreferenceF
} }
if (footer != null) { if (footer != null) {
mFooter = footer; mFooter = footer;
mFooter.setOrder(Integer.MAX_VALUE); mFooter.setOrder(ORDER_LAST);
if (getPreferenceScreen() != null) { if (getPreferenceScreen() != null) {
getPreferenceScreen().addPreference(mFooter); getPreferenceScreen().addPreference(mFooter);
} }

View File

@@ -72,6 +72,10 @@ public class LayoutPreference extends Preference {
public void onBindViewHolder(PreferenceViewHolder view) { public void onBindViewHolder(PreferenceViewHolder view) {
FrameLayout layout = (FrameLayout) view.itemView; FrameLayout layout = (FrameLayout) view.itemView;
layout.removeAllViews(); layout.removeAllViews();
ViewGroup parent = (ViewGroup) mRootView.getParent();
if (parent != null) {
parent.removeView(mRootView);
}
layout.addView(mRootView); layout.addView(mRootView);
} }

View File

@@ -64,9 +64,12 @@ import com.android.settings.HelpUtils;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment; import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.SubSettings; import com.android.settings.SubSettings;
import com.android.settingslib.RestrictedLockUtils;
import java.util.List; import java.util.List;
import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
/** /**
* Settings screen for fingerprints * Settings screen for fingerprints
*/ */
@@ -291,21 +294,16 @@ public class FingerprintSettings extends SubSettings {
super.onViewCreated(view, savedInstanceState); super.onViewCreated(view, savedInstanceState);
TextView v = (TextView) LayoutInflater.from(view.getContext()).inflate( TextView v = (TextView) LayoutInflater.from(view.getContext()).inflate(
R.layout.fingerprint_settings_footer, null); R.layout.fingerprint_settings_footer, null);
v.setText(LearnMoreSpan.linkify(getText(isFingerprintDisabled() EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
getActivity(), DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT);
v.setText(LearnMoreSpan.linkify(getText(admin != null
? R.string.security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled ? R.string.security_settings_fingerprint_enroll_disclaimer_lockscreen_disabled
: R.string.security_settings_fingerprint_enroll_disclaimer), : R.string.security_settings_fingerprint_enroll_disclaimer),
getString(getHelpResource()))); getString(getHelpResource()), admin));
v.setMovementMethod(new LinkMovementMethod()); v.setMovementMethod(new LinkMovementMethod());
setFooterView(v); setFooterView(v);
} }
private boolean isFingerprintDisabled() {
final DevicePolicyManager dpm =
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
return dpm != null && (dpm.getKeyguardDisabledFeatures(null)
& DevicePolicyManager.KEYGUARD_DISABLE_FINGERPRINT) != 0;
}
protected void removeFingerprintPreference(int fingerprintId) { protected void removeFingerprintPreference(int fingerprintId) {
String name = genKey(fingerprintId); String name = genKey(fingerprintId);
Preference prefToRemove = findPreference(name); Preference prefToRemove = findPreference(name);
@@ -332,6 +330,7 @@ public class FingerprintSettings extends SubSettings {
addPreferencesFromResource(R.xml.security_settings_fingerprint); addPreferencesFromResource(R.xml.security_settings_fingerprint);
root = getPreferenceScreen(); root = getPreferenceScreen();
addFingerprintItemPreferences(root); addFingerprintItemPreferences(root);
setPreferenceScreen(root);
return root; return root;
} }
@@ -729,19 +728,33 @@ public class FingerprintSettings extends SubSettings {
private static final Typeface TYPEFACE_MEDIUM = private static final Typeface TYPEFACE_MEDIUM =
Typeface.create("sans-serif-medium", Typeface.NORMAL); Typeface.create("sans-serif-medium", Typeface.NORMAL);
private static final String ANNOTATION_URL = "url";
private static final String ANNOTATION_ADMIN_DETAILS = "admin_details";
private EnforcedAdmin mEnforcedAdmin = null;
private LearnMoreSpan(String url) { private LearnMoreSpan(String url) {
super(url); super(url);
} }
private LearnMoreSpan(EnforcedAdmin admin) {
super((String) null);
mEnforcedAdmin = admin;
}
@Override @Override
public void onClick(View widget) { public void onClick(View widget) {
Context ctx = widget.getContext(); Context ctx = widget.getContext();
Intent intent = HelpUtils.getHelpIntent(ctx, getURL(), ctx.getClass().getName()); if (mEnforcedAdmin != null) {
try { RestrictedLockUtils.sendShowAdminSupportDetailsIntent(ctx, mEnforcedAdmin);
((Activity) ctx).startActivityForResult(intent, 0); } else {
} catch (ActivityNotFoundException e) { Intent intent = HelpUtils.getHelpIntent(ctx, getURL(), ctx.getClass().getName());
Log.w(FingerprintSettingsFragment.TAG, try {
"Actvity was not found for intent, " + intent.toString()); widget.startActivityForResult(intent, 0);
} catch (ActivityNotFoundException e) {
Log.w(FingerprintSettingsFragment.TAG,
"Actvity was not found for intent, " + intent.toString());
}
} }
} }
@@ -752,15 +765,23 @@ public class FingerprintSettings extends SubSettings {
ds.setTypeface(TYPEFACE_MEDIUM); ds.setTypeface(TYPEFACE_MEDIUM);
} }
public static CharSequence linkify(CharSequence rawText, String uri) { public static CharSequence linkify(CharSequence rawText, String uri, EnforcedAdmin admin) {
SpannableString msg = new SpannableString(rawText); SpannableString msg = new SpannableString(rawText);
Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class); Annotation[] spans = msg.getSpans(0, msg.length(), Annotation.class);
SpannableStringBuilder builder = new SpannableStringBuilder(msg); SpannableStringBuilder builder = new SpannableStringBuilder(msg);
for (Annotation annotation : spans) { for (Annotation annotation : spans) {
final String key = annotation.getValue();
int start = msg.getSpanStart(annotation); int start = msg.getSpanStart(annotation);
int end = msg.getSpanEnd(annotation); int end = msg.getSpanEnd(annotation);
LearnMoreSpan link = new LearnMoreSpan(uri); LearnMoreSpan link = null;
builder.setSpan(link, start, end, msg.getSpanFlags(link)); if (ANNOTATION_URL.equals(key)) {
link = new LearnMoreSpan(uri);
} else if (ANNOTATION_ADMIN_DETAILS.equals(key)) {
link = new LearnMoreSpan(admin);
}
if (link != null) {
builder.setSpan(link, start, end, msg.getSpanFlags(link));
}
} }
return builder; return builder;
} }

View File

@@ -191,7 +191,7 @@ public class ConfigureNotificationSettings extends SettingsPreferenceFragment {
private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry, private void setRestrictedIfNotificationFeaturesDisabled(CharSequence entry,
CharSequence entryValue, int keyguardNotificationFeatures) { CharSequence entryValue, int keyguardNotificationFeatures) {
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardNotificationFeaturesDisabled( EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
mContext, keyguardNotificationFeatures); mContext, keyguardNotificationFeatures);
if (admin != null) { if (admin != null) {
RestrictedItem item = new RestrictedItem(entry, entryValue, admin); RestrictedItem item = new RestrictedItem(entry, entryValue, admin);

View File

@@ -110,7 +110,7 @@ public class RedactionInterstitial extends SettingsActivity {
private void checkNotificationFeaturesAndSetDisabled(RestrictedRadioButton button, private void checkNotificationFeaturesAndSetDisabled(RestrictedRadioButton button,
int keyguardNotifications) { int keyguardNotifications) {
EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardNotificationFeaturesDisabled( EnforcedAdmin admin = RestrictedLockUtils.checkIfKeyguardFeaturesDisabled(
getActivity(), keyguardNotifications); getActivity(), keyguardNotifications);
button.setDisabledByAdmin(admin); button.setDisabledByAdmin(admin);
} }