From a35d753adda055582e319bc98f30f11b138b2936 Mon Sep 17 00:00:00 2001 From: Karl Rosaen Date: Fri, 25 Sep 2009 10:24:26 -0700 Subject: [PATCH] Remove keyguard view after a delay instead of just hiding it. The delay should make sure the animation works, and by still removing it, we preserve the initialization logic that depends on being reinstantiated each time the screen turns off. The logic could be adjusted to work without this, but seems safer to maintain the existing behavior. Also reduces risk from having keyguard around all the time. --- .../policy/impl/KeyguardViewManager.java | 16 +++++---- .../internal/policy/impl/LockScreen.java | 36 ++++++++++--------- .../internal/policy/impl/UnlockScreen.java | 21 +++++------ 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/policy/com/android/internal/policy/impl/KeyguardViewManager.java b/policy/com/android/internal/policy/impl/KeyguardViewManager.java index 61515d8553112..a1d3576c81335 100644 --- a/policy/com/android/internal/policy/impl/KeyguardViewManager.java +++ b/policy/com/android/internal/policy/impl/KeyguardViewManager.java @@ -211,14 +211,16 @@ public class KeyguardViewManager implements KeyguardWindowController { if (DEBUG) Log.d(TAG, "hide()"); if (mKeyguardHost != null) { mKeyguardHost.setVisibility(View.GONE); - // Don't do this, so we can let the view continue to animate + // Don't do this right away, so we can let the view continue to animate // as it goes away. - if (false) { - if (mKeyguardView != null) { - mKeyguardHost.removeView(mKeyguardView); - mKeyguardView.cleanUp(); - mKeyguardView = null; - } + if (mKeyguardView != null) { + mKeyguardHost.postDelayed(new Runnable() { + public void run() { + mKeyguardHost.removeView(mKeyguardView); + mKeyguardView.cleanUp(); + mKeyguardView = null; + } + }, 500); } } } diff --git a/policy/com/android/internal/policy/impl/LockScreen.java b/policy/com/android/internal/policy/impl/LockScreen.java index 8899ac323cef4..67533242f514f 100644 --- a/policy/com/android/internal/policy/impl/LockScreen.java +++ b/policy/com/android/internal/policy/impl/LockScreen.java @@ -158,10 +158,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM inflater.inflate(R.layout.keyguard_screen_rotary_unlock_land, this, true); } - mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo(); - mPluggedIn = updateMonitor.isDevicePluggedIn(); - mBatteryLevel = updateMonitor.getBatteryLevel(); - mCarrier = (TextView) findViewById(R.id.carrier); mTime = (TextView) findViewById(R.id.time); mDate = (TextView) findViewById(R.id.date); @@ -182,17 +178,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM setFocusableInTouchMode(true); setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS); - mStatus = getCurrentStatus(updateMonitor.getSimState()); - updateLayout(mStatus); - - refreshBatteryStringAndIcon(); - refreshAlarmDisplay(); - - mTimeFormat = DateFormat.getTimeFormat(getContext()); - mDateFormat = getLockScreenDateFormat(); - refreshTimeAndDateDisplay(); - updateStatusLines(); - updateMonitor.registerInfoCallback(this); updateMonitor.registerSimStateCallback(this); updateMonitor.registerConfigurationChangeCallback(this); @@ -205,6 +190,25 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM mRotary.setRightHandleResource(mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on); + + resetStatusInfo(updateMonitor); + } + + private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) { + mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo(); + mPluggedIn = updateMonitor.isDevicePluggedIn(); + mBatteryLevel = updateMonitor.getBatteryLevel(); + + mStatus = getCurrentStatus(updateMonitor.getSimState()); + updateLayout(mStatus); + + refreshBatteryStringAndIcon(); + refreshAlarmDisplay(); + + mTimeFormat = DateFormat.getTimeFormat(getContext()); + mDateFormat = getLockScreenDateFormat(); + refreshTimeAndDateDisplay(); + updateStatusLines(); } @Override @@ -540,7 +544,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM /** {@inheritDoc} */ public void onResume() { - + resetStatusInfo(mUpdateMonitor); } /** {@inheritDoc} */ diff --git a/policy/com/android/internal/policy/impl/UnlockScreen.java b/policy/com/android/internal/policy/impl/UnlockScreen.java index 5245c7cafa0df..f599b51f6084d 100644 --- a/policy/com/android/internal/policy/impl/UnlockScreen.java +++ b/policy/com/android/internal/policy/impl/UnlockScreen.java @@ -17,16 +17,13 @@ package com.android.internal.policy.impl; import android.content.Context; -import android.content.ServiceConnection; import android.os.CountDownTimer; import android.os.SystemClock; -import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.MotionEvent; import android.widget.Button; -import android.widget.ImageView; import android.widget.TextView; import android.text.format.DateFormat; import android.text.TextUtils; @@ -181,11 +178,7 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient mStatusSep = (TextView) findViewById(R.id.statusSep); mStatus2 = (TextView) findViewById(R.id.status2); - mShowingBatteryInfo = mUpdateMonitor.shouldShowBatteryInfo(); - mPluggedIn = mUpdateMonitor.isDevicePluggedIn(); - mBatteryLevel = mUpdateMonitor.getBatteryLevel(); - mNextAlarm = mLockPatternUtils.getNextAlarm(); - updateStatusLines(); + resetStatusInfo(); mLockPatternView = (LockPatternView) findViewById(R.id.lockPattern); @@ -245,6 +238,15 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient mUpdateMonitor.getTelephonySpn())); } + private void resetStatusInfo() { + mInstructions = null; + mShowingBatteryInfo = mUpdateMonitor.shouldShowBatteryInfo(); + mPluggedIn = mUpdateMonitor.isDevicePluggedIn(); + mBatteryLevel = mUpdateMonitor.getBatteryLevel(); + mNextAlarm = mLockPatternUtils.getNextAlarm(); + updateStatusLines(); + } + private void updateStatusLines() { if (mInstructions != null) { // instructions only @@ -391,8 +393,7 @@ class UnlockScreen extends LinearLayoutWithDefaultTouchRecepient /** {@inheritDoc} */ public void onResume() { // reset header - updateStatusLines(); - // TODO mUnlockIcon.setVisibility(View.VISIBLE); + resetStatusInfo(); // reset lock pattern mLockPatternView.enableInput();