summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/Keyguard/src/com/android/keyguard/CarrierText.java11
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java15
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java34
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java28
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java51
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java19
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java2
7 files changed, 141 insertions, 19 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
index 03b09b1..c33f174 100644
--- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java
+++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
@@ -47,6 +47,14 @@ public class CarrierText extends TextView {
mSimState = simState;
updateCarrierText(mSimState, mPlmn, mSpn);
}
+
+ public void onScreenTurnedOff(int why) {
+ setSelected(false);
+ };
+
+ public void onScreenTurnedOn() {
+ setSelected(true);
+ };
};
/**
* The status of this lock screen. Primarily used for widgets on LockScreen.
@@ -79,7 +87,8 @@ public class CarrierText extends TextView {
protected void onFinishInflate() {
super.onFinishInflate();
mSeparator = getResources().getString(R.string.kg_text_message_separator);
- setSelected(true); // Allow marquee to work.
+ final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
+ setSelected(screenOn); // Allow marquee to work.
}
@Override
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
index ad59c02..69075ec 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMessageArea.java
@@ -163,6 +163,12 @@ class KeyguardMessageArea extends TextView {
mBatteryIsLow = status.isBatteryLow();
update();
}
+ public void onScreenTurnedOff(int why) {
+ setSelected(false);
+ };
+ public void onScreenTurnedOn() {
+ setSelected(true);
+ };
};
public KeyguardMessageArea(Context context) {
@@ -174,9 +180,6 @@ class KeyguardMessageArea extends TextView {
mLockPatternUtils = new LockPatternUtils(context);
- // This is required to ensure marquee works
- setSelected(true);
-
// Registering this callback immediately updates the battery state, among other things.
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
mUpdateMonitor.registerCallback(mInfoCallback);
@@ -187,6 +190,12 @@ class KeyguardMessageArea extends TextView {
update();
}
+ @Override
+ protected void onFinishInflate() {
+ final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
+ setSelected(screenOn); // This is required to ensure marquee works
+ }
+
public void securityMessageChanged() {
setAlpha(1f);
mShowingMessage = true;
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
index ffb619b..2acc87d 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardStatusView.java
@@ -21,6 +21,7 @@ import android.content.res.Resources;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.util.AttributeSet;
+import android.util.Log;
import android.util.Slog;
import android.view.View;
import android.widget.GridLayout;
@@ -42,6 +43,8 @@ public class KeyguardStatusView extends GridLayout {
private TextView mAlarmStatusView;
+ private final int MARQUEE_VIEWS[] = { R.id.alarm_status };
+
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
@Override
@@ -56,6 +59,14 @@ public class KeyguardStatusView extends GridLayout {
refresh();
}
};
+
+ public void onScreenTurnedOn() {
+ setEnableMarquee(true);
+ };
+
+ public void onScreenTurnedOff(int why) {
+ setEnableMarquee(false);
+ };
};
public KeyguardStatusView(Context context) {
@@ -70,22 +81,23 @@ public class KeyguardStatusView extends GridLayout {
super(context, attrs, defStyle);
}
+ private void setEnableMarquee(boolean enabled) {
+ if (DEBUG) Log.v(TAG, (enabled ? "Enable" : "Disable") + " transport text marquee");
+ for (int i = 0; i < MARQUEE_VIEWS.length; i++) {
+ View v = findViewById(MARQUEE_VIEWS[i]);
+ if (v != null) {
+ v.setSelected(enabled);
+ }
+ }
+ }
+
@Override
protected void onFinishInflate() {
super.onFinishInflate();
-
mAlarmStatusView = (TextView) findViewById(R.id.alarm_status);
mLockPatternUtils = new LockPatternUtils(getContext());
-
- // Required to get Marquee to work.
- final View marqueeViews[] = { mAlarmStatusView };
- for (int i = 0; i < marqueeViews.length; i++) {
- View v = marqueeViews[i];
- if (v == null) {
- throw new RuntimeException("Can't find widget at index " + i);
- }
- v.setSelected(true);
- }
+ final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
+ setEnableMarquee(screenOn);
refresh();
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java b/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java
index 6d7b743..945a0a7 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardTransportControlView.java
@@ -84,6 +84,8 @@ public class KeyguardTransportControlView extends FrameLayout {
private AudioManager mAudioManager;
private RemoteController mRemoteController;
+ private int MARQUEE_VIEWS[] = { R.id.title, R.id.artist_album };
+
private ImageView mBadge;
private boolean mSeekEnabled;
@@ -198,6 +200,16 @@ public class KeyguardTransportControlView extends FrameLayout {
KeyguardHostView.TransportControlCallback mTransportControlCallback;
+ private final KeyguardUpdateMonitorCallback mUpdateMonitor
+ = new KeyguardUpdateMonitorCallback() {
+ public void onScreenTurnedOff(int why) {
+ setEnableMarquee(false);
+ };
+ public void onScreenTurnedOn() {
+ setEnableMarquee(true);
+ };
+ };
+
public KeyguardTransportControlView(Context context, AttributeSet attrs) {
super(context, attrs);
if (DEBUG) Log.v(TAG, "Create TCV " + this);
@@ -250,6 +262,16 @@ public class KeyguardTransportControlView extends FrameLayout {
mTransportControlCallback = transportControlCallback;
}
+ private void setEnableMarquee(boolean enabled) {
+ if (DEBUG) Log.v(TAG, (enabled ? "Enable" : "Disable") + " transport text marquee");
+ for (int i = 0; i < MARQUEE_VIEWS.length; i++) {
+ View v = findViewById(MARQUEE_VIEWS[i]);
+ if (v != null) {
+ v.setSelected(enabled);
+ }
+ }
+ }
+
@Override
public void onFinishInflate() {
super.onFinishInflate();
@@ -257,9 +279,7 @@ public class KeyguardTransportControlView extends FrameLayout {
mMetadataContainer = (ViewGroup) findViewById(R.id.metadata_container);
mBadge = (ImageView) findViewById(R.id.badge);
mTrackTitle = (TextView) findViewById(R.id.title);
- mTrackTitle.setSelected(true); // enable marquee
mTrackArtistAlbum = (TextView) findViewById(R.id.artist_album);
- mTrackArtistAlbum.setSelected(true);
mTransientSeek = findViewById(R.id.transient_seek);
mTransientSeekBar = (SeekBar) findViewById(R.id.transient_seek_bar);
mTransientSeekBar.setOnSeekBarChangeListener(mOnSeekBarChangeListener);
@@ -273,6 +293,8 @@ public class KeyguardTransportControlView extends FrameLayout {
view.setOnClickListener(mTransportCommandListener);
view.setOnLongClickListener(mTransportShowSeekBarListener);
}
+ final boolean screenOn = KeyguardUpdateMonitor.getInstance(mContext).isScreenOn();
+ setEnableMarquee(screenOn);
}
@Override
@@ -285,6 +307,7 @@ public class KeyguardTransportControlView extends FrameLayout {
}
if (DEBUG) Log.v(TAG, "Registering TCV " + this);
mAudioManager.registerRemoteController(mRemoteController);
+ KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitor);
}
@Override
@@ -301,6 +324,7 @@ public class KeyguardTransportControlView extends FrameLayout {
super.onDetachedFromWindow();
if (DEBUG) Log.v(TAG, "Unregistering TCV " + this);
mAudioManager.unregisterRemoteController(mRemoteController);
+ KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitor);
mUserSeeking = false;
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 76deb77..45cd3d4 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -92,7 +92,8 @@ public class KeyguardUpdateMonitor {
protected static final int MSG_SET_PLAYBACK_STATE = 316;
protected static final int MSG_USER_INFO_CHANGED = 317;
protected static final int MSG_REPORT_EMERGENCY_CALL_ACTION = 318;
-
+ private static final int MSG_SCREEN_TURNED_ON = 319;
+ private static final int MSG_SCREEN_TURNED_OFF = 320;
private static KeyguardUpdateMonitor sInstance;
@@ -127,6 +128,8 @@ public class KeyguardUpdateMonitor {
private boolean mSwitchingUser;
+ private boolean mScreenOn;
+
private final Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
@@ -185,6 +188,12 @@ public class KeyguardUpdateMonitor {
case MSG_REPORT_EMERGENCY_CALL_ACTION:
handleReportEmergencyCallAction();
break;
+ case MSG_SCREEN_TURNED_OFF:
+ handleScreenTurnedOff(msg.arg1);
+ break;
+ case MSG_SCREEN_TURNED_ON:
+ handleScreenTurnedOn();
+ break;
}
}
};
@@ -411,6 +420,26 @@ public class KeyguardUpdateMonitor {
return sInstance;
}
+ protected void handleScreenTurnedOn() {
+ final int count = mCallbacks.size();
+ for (int i = 0; i < count; i++) {
+ KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+ if (cb != null) {
+ cb.onScreenTurnedOn();
+ }
+ }
+ }
+
+ protected void handleScreenTurnedOff(int arg1) {
+ final int count = mCallbacks.size();
+ for (int i = 0; i < count; i++) {
+ KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+ if (cb != null) {
+ cb.onScreenTurnedOff(arg1);
+ }
+ }
+ }
+
/**
* IMPORTANT: Must be called from UI thread.
*/
@@ -1041,4 +1070,24 @@ public class KeyguardUpdateMonitor {
public DisplayClientState getCachedDisplayClientState() {
return mDisplayClientState;
}
+
+ // TODO: use these callbacks elsewhere in place of the existing notifyScreen*()
+ // (KeyguardViewMediator, KeyguardHostView)
+ public void dispatchScreenTurnedOn() {
+ synchronized (this) {
+ mScreenOn = true;
+ }
+ mHandler.sendEmptyMessage(MSG_SCREEN_TURNED_ON);
+ }
+
+ public void dispatchScreenTurndOff(int why) {
+ synchronized(this) {
+ mScreenOn = false;
+ }
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_SCREEN_TURNED_OFF, why, 0));
+ }
+
+ public boolean isScreenOn() {
+ return mScreenOn;
+ }
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index e6dddab..76f9637 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -19,6 +19,7 @@ import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.graphics.Bitmap;
import android.media.AudioManager;
+import android.view.WindowManagerPolicy;
import com.android.internal.telephony.IccCardConstants;
@@ -137,7 +138,23 @@ class KeyguardUpdateMonitorCallback {
*/
void onEmergencyCallAction() { }
+ /**
+ * Called when the transport background changes.
+ * @param bitmap
+ */
public void onSetBackground(Bitmap bitmap) {
- // THIS SPACE FOR RENT
}
+
+ /**
+ * Called when the screen turns on
+ */
+ public void onScreenTurnedOn() { }
+
+ /**
+ * Called when the screen turns off
+ * @param why {@link WindowManagerPolicy#OFF_BECAUSE_OF_USER},
+ * {@link WindowManagerPolicy#OFF_BECAUSE_OF_TIMEOUT} or
+ * {@link WindowManagerPolicy#OFF_BECAUSE_OF_PROX_SENSOR}.
+ */
+ public void onScreenTurnedOff(int why) { }
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
index dc28bd0..a37a3a4 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
@@ -599,6 +599,7 @@ public class KeyguardViewMediator {
doKeyguardLocked(null);
}
}
+ KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurndOff(why);
}
private void doKeyguardLaterLocked() {
@@ -664,6 +665,7 @@ public class KeyguardViewMediator {
notifyScreenOnLocked(callback);
}
}
+ KeyguardUpdateMonitor.getInstance(mContext).dispatchScreenTurnedOn();
maybeSendUserPresentBroadcast();
}