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.
This commit is contained in:
Karl Rosaen
2009-09-25 10:24:26 -07:00
parent d0071448cc
commit a35d753add
3 changed files with 40 additions and 33 deletions

View File

@@ -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);
}
}
}

View File

@@ -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} */

View File

@@ -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();