* commit '4adc3b00915febd11e149ae0c4d4edcc02c00767': Hide KeyguardMessageArea if empty
This commit is contained in:
@@ -26,8 +26,7 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true">
|
||||||
android:clickable="true">
|
|
||||||
|
|
||||||
<com.android.keyguard.CarrierText
|
<com.android.keyguard.CarrierText
|
||||||
android:id="@+id/carrier_text"
|
android:id="@+id/carrier_text"
|
||||||
|
|||||||
@@ -29,5 +29,5 @@
|
|||||||
android:textAppearance="?android:attr/textAppearance"
|
android:textAppearance="?android:attr/textAppearance"
|
||||||
android:textSize="@dimen/kg_status_line_font_size"
|
android:textSize="@dimen/kg_status_line_font_size"
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
android:clickable="true" />
|
android:focusable="true" />
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@
|
|||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:contentDescription="@string/keyguard_accessibility_pattern_area"
|
android:contentDescription="@string/keyguard_accessibility_pattern_area"
|
||||||
|
android:focusable="true"
|
||||||
|
android:focusableInTouchMode="true"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
|||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
mLockPatternUtils = new LockPatternUtils(mContext);
|
mLockPatternUtils = new LockPatternUtils(mContext);
|
||||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
|
||||||
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
||||||
|
|
||||||
EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
|
EmergencyButton button = (EmergencyButton) findViewById(R.id.emergency_call_button);
|
||||||
|
|||||||
@@ -16,27 +16,21 @@
|
|||||||
|
|
||||||
package com.android.keyguard;
|
package com.android.keyguard;
|
||||||
|
|
||||||
import android.animation.Animator;
|
|
||||||
import android.animation.AnimatorListenerAdapter;
|
|
||||||
import android.animation.ObjectAnimator;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.os.SystemClock;
|
import android.os.SystemClock;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
import android.util.MutableInt;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
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.
|
* 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. */
|
/** Handler token posted with accessibility announcement runnables. */
|
||||||
private static final Object ANNOUNCE_TOKEN = new Object();
|
private static final Object ANNOUNCE_TOKEN = new Object();
|
||||||
|
|
||||||
@@ -46,96 +40,23 @@ class KeyguardMessageArea extends TextView {
|
|||||||
*/
|
*/
|
||||||
private static final long ANNOUNCEMENT_DELAY = 250;
|
private static final long ANNOUNCEMENT_DELAY = 250;
|
||||||
|
|
||||||
static final int SECURITY_MESSAGE_DURATION = 5000;
|
private static final int SECURITY_MESSAGE_DURATION = 5000;
|
||||||
protected static final int FADE_DURATION = 750;
|
|
||||||
|
|
||||||
private static final String TAG = "KeyguardMessageArea";
|
private final KeyguardUpdateMonitor mUpdateMonitor;
|
||||||
|
private final Handler mHandler;
|
||||||
// is the bouncer up?
|
|
||||||
boolean mShowingBouncer = false;
|
|
||||||
|
|
||||||
KeyguardUpdateMonitor mUpdateMonitor;
|
|
||||||
|
|
||||||
// Timeout before we reset the message to show charging/owner info
|
// Timeout before we reset the message to show charging/owner info
|
||||||
long mTimeout = SECURITY_MESSAGE_DURATION;
|
long mTimeout = SECURITY_MESSAGE_DURATION;
|
||||||
|
|
||||||
private Handler mHandler;
|
|
||||||
|
|
||||||
CharSequence mMessage;
|
CharSequence mMessage;
|
||||||
boolean mShowingMessage;
|
|
||||||
private CharSequence mSeparator;
|
|
||||||
private LockPatternUtils mLockPatternUtils;
|
|
||||||
|
|
||||||
Runnable mClearMessageRunnable = new Runnable() {
|
private final Runnable mClearMessageRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
mMessage = null;
|
mMessage = null;
|
||||||
mShowingMessage = false;
|
update();
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMessage(CharSequence msg, boolean important) {
|
|
||||||
if (!TextUtils.isEmpty(msg) && important) {
|
|
||||||
mMessageArea.mMessage = msg;
|
|
||||||
mMessageArea.securityMessageChanged();
|
|
||||||
} else {
|
|
||||||
mMessageArea.clearMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMessage(int resId, boolean important) {
|
|
||||||
if (resId != 0 && important) {
|
|
||||||
mMessageArea.mMessage = mMessageArea.getContext().getResources().getText(resId);
|
|
||||||
mMessageArea.securityMessageChanged();
|
|
||||||
} else {
|
|
||||||
mMessageArea.clearMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setMessage(int resId, boolean important, Object... formatArgs) {
|
|
||||||
if (resId != 0 && important) {
|
|
||||||
mMessageArea.mMessage = mMessageArea.getContext().getString(resId, formatArgs);
|
|
||||||
mMessageArea.securityMessageChanged();
|
|
||||||
} else {
|
|
||||||
mMessageArea.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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||||
public void onScreenTurnedOff(int why) {
|
public void onScreenTurnedOff(int why) {
|
||||||
setSelected(false);
|
setSelected(false);
|
||||||
@@ -153,28 +74,64 @@ class KeyguardMessageArea extends TextView {
|
|||||||
super(context, attrs);
|
super(context, attrs);
|
||||||
setLayerType(LAYER_TYPE_HARDWARE, null); // work around nested unclipped SaveLayer bug
|
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 = KeyguardUpdateMonitor.getInstance(getContext());
|
||||||
mUpdateMonitor.registerCallback(mInfoCallback);
|
mUpdateMonitor.registerCallback(mInfoCallback);
|
||||||
mHandler = new Handler(Looper.myLooper());
|
mHandler = new Handler(Looper.myLooper());
|
||||||
|
|
||||||
mSeparator = getResources().getString(
|
|
||||||
com.android.internal.R.string.kg_text_message_separator);
|
|
||||||
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMessage(CharSequence msg, boolean important) {
|
||||||
|
if (!TextUtils.isEmpty(msg) && important) {
|
||||||
|
securityMessageChanged(msg);
|
||||||
|
} else {
|
||||||
|
clearMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMessage(int resId, boolean important) {
|
||||||
|
if (resId != 0 && important) {
|
||||||
|
CharSequence message = getContext().getResources().getText(resId);
|
||||||
|
securityMessageChanged(message);
|
||||||
|
} else {
|
||||||
|
clearMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMessage(int resId, boolean important, Object... formatArgs) {
|
||||||
|
if (resId != 0 && important) {
|
||||||
|
String message = getContext().getString(resId, formatArgs);
|
||||||
|
securityMessageChanged(message);
|
||||||
|
} else {
|
||||||
|
clearMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTimeout(int timeoutMs) {
|
||||||
|
mTimeout = timeoutMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
return messageArea;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFinishInflate() {
|
protected void onFinishInflate() {
|
||||||
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
|
||||||
setSelected(screenOn); // This is required to ensure marquee works
|
setSelected(screenOn); // This is required to ensure marquee works
|
||||||
}
|
}
|
||||||
|
|
||||||
public void securityMessageChanged() {
|
private void securityMessageChanged(CharSequence message) {
|
||||||
setAlpha(1f);
|
mMessage = message;
|
||||||
mShowingMessage = true;
|
|
||||||
update();
|
update();
|
||||||
mHandler.removeCallbacks(mClearMessageRunnable);
|
mHandler.removeCallbacks(mClearMessageRunnable);
|
||||||
if (mTimeout > 0) {
|
if (mTimeout > 0) {
|
||||||
@@ -185,61 +142,18 @@ class KeyguardMessageArea extends TextView {
|
|||||||
(SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY));
|
(SystemClock.uptimeMillis() + ANNOUNCEMENT_DELAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearMessage() {
|
private void clearMessage() {
|
||||||
mHandler.removeCallbacks(mClearMessageRunnable);
|
mHandler.removeCallbacks(mClearMessageRunnable);
|
||||||
mHandler.post(mClearMessageRunnable);
|
mHandler.post(mClearMessageRunnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private void update() {
|
||||||
* Update the status lines based on these rules:
|
CharSequence status = mMessage;
|
||||||
* AlarmStatus: Alarm state always gets it's own line.
|
setVisibility(TextUtils.isEmpty(status) ? INVISIBLE : VISIBLE);
|
||||||
* 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);
|
|
||||||
setText(status);
|
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.
|
* Runnable used to delay accessibility announcements.
|
||||||
*/
|
*/
|
||||||
@@ -247,7 +161,7 @@ class KeyguardMessageArea extends TextView {
|
|||||||
private final WeakReference<View> mHost;
|
private final WeakReference<View> mHost;
|
||||||
private final CharSequence mTextToAnnounce;
|
private final CharSequence mTextToAnnounce;
|
||||||
|
|
||||||
public AnnounceRunnable(View host, CharSequence textToAnnounce) {
|
AnnounceRunnable(View host, CharSequence textToAnnounce) {
|
||||||
mHost = new WeakReference<View>(host);
|
mHost = new WeakReference<View>(host);
|
||||||
mTextToAnnounce = textToAnnounce;
|
mTextToAnnounce = textToAnnounce;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,6 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
|
|
||||||
mLockPatternView = (LockPatternView) findViewById(R.id.lockPatternView);
|
mLockPatternView = (LockPatternView) findViewById(R.id.lockPatternView);
|
||||||
mLockPatternView.setSaveEnabled(false);
|
mLockPatternView.setSaveEnabled(false);
|
||||||
mLockPatternView.setFocusable(false);
|
|
||||||
mLockPatternView.setOnPatternListener(new UnlockPatternListener());
|
mLockPatternView.setOnPatternListener(new UnlockPatternListener());
|
||||||
|
|
||||||
// stealth mode will be the same for the life of this screen
|
// stealth mode will be the same for the life of this screen
|
||||||
@@ -139,9 +138,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
|||||||
// vibrate mode will be the same for the life of this screen
|
// vibrate mode will be the same for the life of this screen
|
||||||
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
|
mLockPatternView.setTactileFeedbackEnabled(mLockPatternUtils.isTactileFeedbackEnabled());
|
||||||
|
|
||||||
setFocusableInTouchMode(true);
|
mSecurityMessageDisplay = KeyguardMessageArea.findSecurityMessageDisplay(this);
|
||||||
|
|
||||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
|
||||||
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
mEcaView = findViewById(R.id.keyguard_selector_fade_container);
|
||||||
mContainer = (ViewGroup) findViewById(R.id.container);
|
mContainer = (ViewGroup) findViewById(R.id.container);
|
||||||
mHelpMessage = (KeyguardMessageArea) findViewById(R.id.keyguard_message_area);
|
mHelpMessage = (KeyguardMessageArea) findViewById(R.id.keyguard_message_area);
|
||||||
|
|||||||
@@ -24,8 +24,4 @@ public interface SecurityMessageDisplay {
|
|||||||
public void setMessage(int resId, boolean important, Object... formatArgs);
|
public void setMessage(int resId, boolean important, Object... formatArgs);
|
||||||
|
|
||||||
public void setTimeout(int timeout_ms);
|
public void setTimeout(int timeout_ms);
|
||||||
|
|
||||||
public void showBouncer(int animationDuration);
|
|
||||||
|
|
||||||
public void hideBouncer(int animationDuration);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user