Loading packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml +1 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,7 @@ android:orientation="vertical" android:gravity="center" android:layout_gravity="center_horizontal" android:layout_alignParentBottom="true" android:clickable="true"> android:layout_alignParentBottom="true"> <com.android.keyguard.CarrierText android:id="@+id/carrier_text" Loading packages/Keyguard/res/layout/keyguard_message_area.xml +1 −1 Original line number Diff line number Diff line Loading @@ -29,5 +29,5 @@ android:textAppearance="?android:attr/textAppearance" android:textSize="@dimen/kg_status_line_font_size" android:textColor="?android:attr/textColorSecondary" android:clickable="true" /> android:focusable="true" /> packages/Keyguard/res/layout/keyguard_pattern_view.xml +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ android:layout_gravity="center_horizontal" android:gravity="center" android:contentDescription="@string/keyguard_accessibility_pattern_area" android:focusable="true" android:focusableInTouchMode="true" android:clipChildren="false" android:clipToPadding="false" /> Loading packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout @Override protected void onFinishInflate() { mLockPatternUtils = new LockPatternUtils(mContext); mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this); mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this); mEcaView = findViewById(R.id.keyguard_selector_fade_container); EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button); Loading packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java +56 −142 Original line number Diff line number Diff line Loading @@ -16,27 +16,21 @@ package com.android.keyguard; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.SystemClock; import android.text.TextUtils; import android.util.AttributeSet; import android.util.MutableInt; import android.view.View; import android.widget.TextView; import java.lang.ref.WeakReference; import com.android.internal.widget.LockPatternUtils; /*** * Manages a number of views inside of the given layout. See below for a list of widgets. */ class KeyguardMessageArea extends TextView { class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { /** Handler token posted with accessibility announcement runnables. */ private static final Object ANNOUNCE_TOKEN = new Object(); Loading @@ -46,124 +40,88 @@ class KeyguardMessageArea extends TextView { */ private static final long ANNOUNCEMENT_DELAY = 250; static final int SECURITY_MESSAGE_DURATION = 5000; protected static final int FADE_DURATION = 750; private static final String TAG = "KeyguardMessageArea"; // is the bouncer up? boolean mShowingBouncer = false; private static final int SECURITY_MESSAGE_DURATION = 5000; KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardUpdateMonitor mUpdateMonitor; private final Handler mHandler; // Timeout before we reset the message to show charging/owner info long mTimeout = SECURITY_MESSAGE_DURATION; private Handler mHandler; CharSequence mMessage; boolean mShowingMessage; private CharSequence mSeparator; private LockPatternUtils mLockPatternUtils; Runnable mClearMessageRunnable = new Runnable() { private final Runnable mClearMessageRunnable = new Runnable() { @Override public void run() { mMessage = null; mShowingMessage = false; if (mShowingBouncer) { hideMessage(FADE_DURATION, true); } else { update(); } } }; public static class Helper implements SecurityMessageDisplay { KeyguardMessageArea mMessageArea; Helper(View v) { mMessageArea = (KeyguardMessageArea) v.findViewById(R.id.keyguard_message_area); if (mMessageArea == null) { throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass()); private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { public void onScreenTurnedOff(int why) { setSelected(false); }; public void onScreenTurnedOn() { setSelected(true); }; }; public KeyguardMessageArea(Context context) { this(context, null); } public KeyguardMessageArea(Context context, AttributeSet attrs) { super(context, attrs); setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext()); mUpdateMonitor.registerCallback(mInfoCallback); mHandler = new Handler(Looper.myLooper()); update(); } @Override public void setMessage(CharSequence msg, boolean important) { if (!TextUtils.isEmpty(msg) && important) { mMessageArea.mMessage = msg; mMessageArea.securityMessageChanged(); securityMessageChanged(msg); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void setMessage(int resId, boolean important) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getResources().getText(resId); mMessageArea.securityMessageChanged(); CharSequence message = getContext().getResources().getText(resId); securityMessageChanged(message); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void setMessage(int resId, boolean important, Object... formatArgs) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getString(resId, formatArgs); mMessageArea.securityMessageChanged(); String message = getContext().getString(resId, formatArgs); securityMessageChanged(message); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void showBouncer(int duration) { mMessageArea.hideMessage(duration, false); mMessageArea.mShowingBouncer = true; } @Override public void hideBouncer(int duration) { mMessageArea.showMessage(duration); mMessageArea.mShowingBouncer = false; } @Override public void setTimeout(int timeoutMs) { mMessageArea.mTimeout = timeoutMs; mTimeout = timeoutMs; } } private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { public void onScreenTurnedOff(int why) { setSelected(false); }; public void onScreenTurnedOn() { setSelected(true); }; }; public KeyguardMessageArea(Context context) { this(context, null); public static SecurityMessageDisplay findSecurityMessageDisplay(View v) { KeyguardMessageArea messageArea = (KeyguardMessageArea) v.findViewById( R.id.keyguard_message_area); if (messageArea == null) { throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass()); } public KeyguardMessageArea(Context context, AttributeSet attrs) { super(context, attrs); setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug mLockPatternUtils = new LockPatternUtils(context); // Registering this callback immediately updates the battery state, among other things. mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext()); mUpdateMonitor.registerCallback(mInfoCallback); mHandler = new Handler(Looper.myLooper()); mSeparator = getResources().getString( com.android.internal.R.string.kg_text_message_separator); update(); return messageArea; } @Override Loading @@ -172,9 +130,8 @@ class KeyguardMessageArea extends TextView { setSelected(screenOn); // This is required to ensure marquee works } public void securityMessageChanged() { setAlpha(1f); mShowingMessage = true; private void securityMessageChanged(CharSequence message) { mMessage = message; update(); mHandler.removeCallbacks(mClearMessageRunnable); if (mTimeout > 0) { Loading @@ -185,61 +142,18 @@ class KeyguardMessageArea extends TextView { (SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY)); } public void clearMessage() { private void clearMessage() { mHandler.removeCallbacks(mClearMessageRunnable); mHandler.post(mClearMessageRunnable); } /** * Update the status lines based on these rules: * AlarmStatus: Alarm state always gets it's own line. * Status1 is shared between help, battery status and generic unlock instructions, * prioritized in that order. * @param showStatusLines status lines are shown if true */ void update() { MutableInt icon = new MutableInt(0); CharSequence status = getCurrentMessage(); setCompoundDrawablesWithIntrinsicBounds(icon.value, 0, 0, 0); private void update() { CharSequence status = mMessage; setVisibility(TextUtils.isEmpty(status) ? INVISIBLE : VISIBLE); setText(status); } CharSequence getCurrentMessage() { return mShowingMessage ? mMessage : null; } private void hideMessage(int duration, boolean thenUpdate) { if (duration > 0) { Animator anim = ObjectAnimator.ofFloat(this, "alpha", 0f); anim.setDuration(duration); if (thenUpdate) { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { update(); } }); } anim.start(); } else { setAlpha(0f); if (thenUpdate) { update(); } } } private void showMessage(int duration) { if (duration > 0) { Animator anim = ObjectAnimator.ofFloat(this, "alpha", 1f); anim.setDuration(duration); anim.start(); } else { setAlpha(1f); } } /** * Runnable used to delay accessibility announcements. */ Loading @@ -247,7 +161,7 @@ class KeyguardMessageArea extends TextView { private final WeakReference<View> mHost; private final CharSequence mTextToAnnounce; public AnnounceRunnable(View host, CharSequence textToAnnounce) { AnnounceRunnable(View host, CharSequence textToAnnounce) { mHost = new WeakReference<View>(host); mTextToAnnounce = textToAnnounce; } Loading Loading
packages/Keyguard/res/layout/keyguard_emergency_carrier_area.xml +1 −2 Original line number Diff line number Diff line Loading @@ -26,8 +26,7 @@ android:orientation="vertical" android:gravity="center" android:layout_gravity="center_horizontal" android:layout_alignParentBottom="true" android:clickable="true"> android:layout_alignParentBottom="true"> <com.android.keyguard.CarrierText android:id="@+id/carrier_text" Loading
packages/Keyguard/res/layout/keyguard_message_area.xml +1 −1 Original line number Diff line number Diff line Loading @@ -29,5 +29,5 @@ android:textAppearance="?android:attr/textAppearance" android:textSize="@dimen/kg_status_line_font_size" android:textColor="?android:attr/textColorSecondary" android:clickable="true" /> android:focusable="true" />
packages/Keyguard/res/layout/keyguard_pattern_view.xml +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,8 @@ android:layout_gravity="center_horizontal" android:gravity="center" android:contentDescription="@string/keyguard_accessibility_pattern_area" android:focusable="true" android:focusableInTouchMode="true" android:clipChildren="false" android:clipToPadding="false" /> Loading
packages/Keyguard/src/com/android/keyguard/KeyguardAbsKeyInputView.java +1 −1 Original line number Diff line number Diff line Loading @@ -86,7 +86,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout @Override protected void onFinishInflate() { mLockPatternUtils = new LockPatternUtils(mContext); mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this); mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this); mEcaView = findViewById(R.id.keyguard_selector_fade_container); EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button); Loading
packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java +56 −142 Original line number Diff line number Diff line Loading @@ -16,27 +16,21 @@ package com.android.keyguard; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.ObjectAnimator; import android.content.Context; import android.os.Handler; import android.os.Looper; import android.os.SystemClock; import android.text.TextUtils; import android.util.AttributeSet; import android.util.MutableInt; import android.view.View; import android.widget.TextView; import java.lang.ref.WeakReference; import com.android.internal.widget.LockPatternUtils; /*** * Manages a number of views inside of the given layout. See below for a list of widgets. */ class KeyguardMessageArea extends TextView { class KeyguardMessageArea extends TextView implements SecurityMessageDisplay { /** Handler token posted with accessibility announcement runnables. */ private static final Object ANNOUNCE_TOKEN = new Object(); Loading @@ -46,124 +40,88 @@ class KeyguardMessageArea extends TextView { */ private static final long ANNOUNCEMENT_DELAY = 250; static final int SECURITY_MESSAGE_DURATION = 5000; protected static final int FADE_DURATION = 750; private static final String TAG = "KeyguardMessageArea"; // is the bouncer up? boolean mShowingBouncer = false; private static final int SECURITY_MESSAGE_DURATION = 5000; KeyguardUpdateMonitor mUpdateMonitor; private final KeyguardUpdateMonitor mUpdateMonitor; private final Handler mHandler; // Timeout before we reset the message to show charging/owner info long mTimeout = SECURITY_MESSAGE_DURATION; private Handler mHandler; CharSequence mMessage; boolean mShowingMessage; private CharSequence mSeparator; private LockPatternUtils mLockPatternUtils; Runnable mClearMessageRunnable = new Runnable() { private final Runnable mClearMessageRunnable = new Runnable() { @Override public void run() { mMessage = null; mShowingMessage = false; if (mShowingBouncer) { hideMessage(FADE_DURATION, true); } else { update(); } } }; public static class Helper implements SecurityMessageDisplay { KeyguardMessageArea mMessageArea; Helper(View v) { mMessageArea = (KeyguardMessageArea) v.findViewById(R.id.keyguard_message_area); if (mMessageArea == null) { throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass()); private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { public void onScreenTurnedOff(int why) { setSelected(false); }; public void onScreenTurnedOn() { setSelected(true); }; }; public KeyguardMessageArea(Context context) { this(context, null); } public KeyguardMessageArea(Context context, AttributeSet attrs) { super(context, attrs); setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext()); mUpdateMonitor.registerCallback(mInfoCallback); mHandler = new Handler(Looper.myLooper()); update(); } @Override public void setMessage(CharSequence msg, boolean important) { if (!TextUtils.isEmpty(msg) && important) { mMessageArea.mMessage = msg; mMessageArea.securityMessageChanged(); securityMessageChanged(msg); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void setMessage(int resId, boolean important) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getResources().getText(resId); mMessageArea.securityMessageChanged(); CharSequence message = getContext().getResources().getText(resId); securityMessageChanged(message); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void setMessage(int resId, boolean important, Object... formatArgs) { if (resId != 0 && important) { mMessageArea.mMessage = mMessageArea.getContext().getString(resId, formatArgs); mMessageArea.securityMessageChanged(); String message = getContext().getString(resId, formatArgs); securityMessageChanged(message); } else { mMessageArea.clearMessage(); clearMessage(); } } @Override public void showBouncer(int duration) { mMessageArea.hideMessage(duration, false); mMessageArea.mShowingBouncer = true; } @Override public void hideBouncer(int duration) { mMessageArea.showMessage(duration); mMessageArea.mShowingBouncer = false; } @Override public void setTimeout(int timeoutMs) { mMessageArea.mTimeout = timeoutMs; mTimeout = timeoutMs; } } private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() { public void onScreenTurnedOff(int why) { setSelected(false); }; public void onScreenTurnedOn() { setSelected(true); }; }; public KeyguardMessageArea(Context context) { this(context, null); public static SecurityMessageDisplay findSecurityMessageDisplay(View v) { KeyguardMessageArea messageArea = (KeyguardMessageArea) v.findViewById( R.id.keyguard_message_area); if (messageArea == null) { throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass()); } public KeyguardMessageArea(Context context, AttributeSet attrs) { super(context, attrs); setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug mLockPatternUtils = new LockPatternUtils(context); // Registering this callback immediately updates the battery state, among other things. mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext()); mUpdateMonitor.registerCallback(mInfoCallback); mHandler = new Handler(Looper.myLooper()); mSeparator = getResources().getString( com.android.internal.R.string.kg_text_message_separator); update(); return messageArea; } @Override Loading @@ -172,9 +130,8 @@ class KeyguardMessageArea extends TextView { setSelected(screenOn); // This is required to ensure marquee works } public void securityMessageChanged() { setAlpha(1f); mShowingMessage = true; private void securityMessageChanged(CharSequence message) { mMessage = message; update(); mHandler.removeCallbacks(mClearMessageRunnable); if (mTimeout > 0) { Loading @@ -185,61 +142,18 @@ class KeyguardMessageArea extends TextView { (SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY)); } public void clearMessage() { private void clearMessage() { mHandler.removeCallbacks(mClearMessageRunnable); mHandler.post(mClearMessageRunnable); } /** * Update the status lines based on these rules: * AlarmStatus: Alarm state always gets it's own line. * Status1 is shared between help, battery status and generic unlock instructions, * prioritized in that order. * @param showStatusLines status lines are shown if true */ void update() { MutableInt icon = new MutableInt(0); CharSequence status = getCurrentMessage(); setCompoundDrawablesWithIntrinsicBounds(icon.value, 0, 0, 0); private void update() { CharSequence status = mMessage; setVisibility(TextUtils.isEmpty(status) ? INVISIBLE : VISIBLE); setText(status); } CharSequence getCurrentMessage() { return mShowingMessage ? mMessage : null; } private void hideMessage(int duration, boolean thenUpdate) { if (duration > 0) { Animator anim = ObjectAnimator.ofFloat(this, "alpha", 0f); anim.setDuration(duration); if (thenUpdate) { anim.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { update(); } }); } anim.start(); } else { setAlpha(0f); if (thenUpdate) { update(); } } } private void showMessage(int duration) { if (duration > 0) { Animator anim = ObjectAnimator.ofFloat(this, "alpha", 1f); anim.setDuration(duration); anim.start(); } else { setAlpha(1f); } } /** * Runnable used to delay accessibility announcements. */ Loading @@ -247,7 +161,7 @@ class KeyguardMessageArea extends TextView { private final WeakReference<View> mHost; private final CharSequence mTextToAnnounce; public AnnounceRunnable(View host, CharSequence textToAnnounce) { AnnounceRunnable(View host, CharSequence textToAnnounce) { mHost = new WeakReference<View>(host); mTextToAnnounce = textToAnnounce; } Loading