Fields Summary |
---|
private final com.android.internal.widget.LockPatternUtils | mLockPatternUtils |
private final KeyguardUpdateMonitor | mUpdateMonitor |
private final KeyguardScreenCallback | mCallback |
private android.widget.TextView | mHeaderSimOk1 |
private android.widget.TextView | mHeaderSimOk2 |
private android.widget.TextView | mHeaderSimBad1 |
private android.widget.TextView | mHeaderSimBad2 |
private android.widget.TextView | mTime |
private android.widget.TextView | mDate |
private android.view.ViewGroup | mBatteryInfoGroup |
private android.widget.ImageView | mBatteryInfoIcon |
private android.widget.TextView | mBatteryInfoText |
private android.view.View | mBatteryInfoSpacer |
private android.view.ViewGroup | mNextAlarmGroup |
private android.widget.TextView | mAlarmText |
private android.view.View | mAlarmSpacer |
private android.view.ViewGroup | mScreenLockedMessageGroup |
private android.widget.TextView | mLockInstructions |
private android.widget.Button | mEmergencyCallButton |
private boolean | mSimOkfalse means sim is missing or PUK'd |
private boolean | mShowingBatteryInfo |
private boolean | mPluggedIn |
private int | mBatteryLevel |
private android.view.View[] | mOnlyVisibleWhenSimOk |
private android.view.View[] | mOnlyVisibleWhenSimNotOk |
Constructors Summary |
---|
LockScreen(android.content.Context context, com.android.internal.widget.LockPatternUtils lockPatternUtils, KeyguardUpdateMonitor updateMonitor, KeyguardScreenCallback callback)
super(context);
mLockPatternUtils = lockPatternUtils;
mUpdateMonitor = updateMonitor;
mCallback = callback;
final LayoutInflater inflater = LayoutInflater.from(context);
inflater.inflate(R.layout.keyguard_screen_lock, this, true);
mSimOk = isSimOk(updateMonitor.getSimState());
mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo();
mPluggedIn = updateMonitor.isDevicePluggedIn();
mBatteryLevel = updateMonitor.getBatteryLevel();
mHeaderSimOk1 = (TextView) findViewById(R.id.headerSimOk1);
mHeaderSimOk2 = (TextView) findViewById(R.id.headerSimOk2);
mHeaderSimBad1 = (TextView) findViewById(R.id.headerSimBad1);
mHeaderSimBad2 = (TextView) findViewById(R.id.headerSimBad2);
mTime = (TextView) findViewById(R.id.time);
mDate = (TextView) findViewById(R.id.date);
mBatteryInfoGroup = (ViewGroup) findViewById(R.id.batteryInfo);
mBatteryInfoIcon = (ImageView) findViewById(R.id.batteryInfoIcon);
mBatteryInfoText = (TextView) findViewById(R.id.batteryInfoText);
mBatteryInfoSpacer = findViewById(R.id.batteryInfoSpacer);
mNextAlarmGroup = (ViewGroup) findViewById(R.id.nextAlarmInfo);
mAlarmText = (TextView) findViewById(R.id.nextAlarmText);
mAlarmSpacer = findViewById(R.id.nextAlarmSpacer);
mScreenLockedMessageGroup = (ViewGroup) findViewById(R.id.screenLockedInfo);
mLockInstructions = (TextView) findViewById(R.id.lockInstructions);
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
mEmergencyCallButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mCallback.takeEmergencyCallAction();
}
});
mOnlyVisibleWhenSimOk = new View[] {
mHeaderSimOk1,
mHeaderSimOk2,
mBatteryInfoGroup,
mBatteryInfoSpacer,
mNextAlarmGroup,
mAlarmSpacer,
mScreenLockedMessageGroup,
mLockInstructions
};
mOnlyVisibleWhenSimNotOk = new View[] {
mHeaderSimBad1,
mHeaderSimBad2,
mEmergencyCallButton
};
setFocusable(true);
setFocusableInTouchMode(true);
setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
refreshBatteryDisplay();
refreshAlarmDisplay();
refreshTimeAndDateDisplay();
refreshUnlockIntructions();
refreshViewsWRTSimOk();
refreshSimOkHeaders(mUpdateMonitor.getTelephonyPlmn(), mUpdateMonitor.getTelephonySpn());
updateMonitor.registerInfoCallback(this);
updateMonitor.registerSimStateCallback(this);
updateMonitor.registerConfigurationChangeCallback(this);
|
Methods Summary |
---|
public void | cleanUp(){@inheritDoc}
mUpdateMonitor.removeCallback(this);
|
private boolean | isSimOk(SimCard.State simState)
boolean missingAndNotProvisioned = (!mUpdateMonitor.isDeviceProvisioned()
&& simState == SimCard.State.ABSENT);
return !(missingAndNotProvisioned || simState == SimCard.State.PUK_REQUIRED);
|
public boolean | needsInput(){@inheritDoc}
return false;
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
if (keyCode == KeyEvent.KEYCODE_MENU) {
mCallback.goToUnlockScreen();
}
return false;
|
public void | onKeyboardChange(boolean isKeyboardOpen)
if (isKeyboardOpen) {
mCallback.goToUnlockScreen();
}
|
public void | onOrientationChange(boolean inPortrait)
|
public void | onPause(){@inheritDoc}
|
public void | onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn, int batteryLevel)
mShowingBatteryInfo = showBatteryInfo;
mPluggedIn = pluggedIn;
mBatteryLevel = batteryLevel;
refreshBatteryDisplay();
|
public void | onRefreshCarrierInfo(java.lang.CharSequence plmn, java.lang.CharSequence spn)
refreshSimOkHeaders(plmn, spn);
|
public void | onResume(){@inheritDoc}
|
public void | onSimStateChanged(SimCard.State simState)
mSimOk = isSimOk(simState);
refreshViewsWRTSimOk();
|
public void | onTimeChanged()
refreshTimeAndDateDisplay();
|
private void | refreshAlarmDisplay()
String nextAlarmText = mLockPatternUtils.getNextAlarm();
if (nextAlarmText != null && mSimOk) {
setAlarmInfoVisible(true);
mAlarmText.setText(nextAlarmText);
} else {
setAlarmInfoVisible(false);
}
|
private void | refreshBatteryDisplay()
if (!mShowingBatteryInfo || !mSimOk) {
mBatteryInfoGroup.setVisibility(View.GONE);
mBatteryInfoSpacer.setVisibility(View.GONE);
return;
}
mBatteryInfoGroup.setVisibility(View.VISIBLE);
mBatteryInfoSpacer.setVisibility(View.VISIBLE);
if (mPluggedIn) {
mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_charging);
mBatteryInfoText.setText(
getContext().getString(R.string.lockscreen_plugged_in, mBatteryLevel));
} else {
mBatteryInfoIcon.setImageResource(R.drawable.ic_lock_idle_low_battery);
mBatteryInfoText.setText(R.string.lockscreen_low_battery);
}
|
private void | refreshSimBadInfo()
final SimCard.State simState = mUpdateMonitor.getSimState();
if (simState == SimCard.State.PUK_REQUIRED) {
mHeaderSimBad1.setText(R.string.lockscreen_sim_puk_locked_message);
mHeaderSimBad2.setText(R.string.lockscreen_sim_puk_locked_instructions);
} else if (simState == SimCard.State.ABSENT) {
mHeaderSimBad1.setText(R.string.lockscreen_missing_sim_message);
mHeaderSimBad2.setVisibility(View.GONE);
//mHeaderSimBad2.setText(R.string.lockscreen_missing_sim_instructions);
} else {
mHeaderSimBad1.setVisibility(View.GONE);
mHeaderSimBad2.setVisibility(View.GONE);
}
|
private void | refreshSimOkHeaders(java.lang.CharSequence plmn, java.lang.CharSequence spn)
final SimCard.State simState = mUpdateMonitor.getSimState();
if (simState == SimCard.State.READY) {
if (plmn != null) {
mHeaderSimOk1.setVisibility(View.VISIBLE);
mHeaderSimOk1.setText(plmn);
} else {
mHeaderSimOk1.setVisibility(View.GONE);
}
if (spn != null) {
mHeaderSimOk2.setVisibility(View.VISIBLE);
mHeaderSimOk2.setText(spn);
} else {
mHeaderSimOk2.setVisibility(View.GONE);
}
} else if (simState == SimCard.State.PIN_REQUIRED) {
mHeaderSimOk1.setVisibility(View.VISIBLE);
mHeaderSimOk1.setText(R.string.lockscreen_sim_locked_message);
mHeaderSimOk2.setVisibility(View.GONE);
} else if (simState == SimCard.State.ABSENT) {
mHeaderSimOk1.setVisibility(View.VISIBLE);
mHeaderSimOk1.setText(R.string.lockscreen_missing_sim_message_short);
mHeaderSimOk2.setVisibility(View.GONE);
} else if (simState == SimCard.State.NETWORK_LOCKED) {
mHeaderSimOk1.setVisibility(View.VISIBLE);
mHeaderSimOk1.setText(R.string.lockscreen_network_locked_message);
mHeaderSimOk2.setVisibility(View.GONE);
}
|
private void | refreshTimeAndDateDisplay()
Date now = new Date();
mTime.setText(DateFormat.getTimeFormat(getContext()).format(now));
mDate.setText(DateFormat.getDateFormat(getContext()).format(now));
|
private void | refreshUnlockIntructions()
if (mLockPatternUtils.isLockPatternEnabled()
|| mUpdateMonitor.getSimState() == SimCard.State.PIN_REQUIRED) {
mLockInstructions.setText(R.string.lockscreen_instructions_when_pattern_enabled);
} else {
mLockInstructions.setText(R.string.lockscreen_instructions_when_pattern_disabled);
}
|
private void | refreshViewsWRTSimOk()
if (mSimOk) {
for (int i = 0; i < mOnlyVisibleWhenSimOk.length; i++) {
final View view = mOnlyVisibleWhenSimOk[i];
if (view == null) throw new RuntimeException("index " + i + " null");
view.setVisibility(View.VISIBLE);
}
for (int i = 0; i < mOnlyVisibleWhenSimNotOk.length; i++) {
final View view = mOnlyVisibleWhenSimNotOk[i];
view.setVisibility(View.GONE);
}
refreshSimOkHeaders(mUpdateMonitor.getTelephonyPlmn(), mUpdateMonitor.getTelephonySpn());
refreshAlarmDisplay();
refreshBatteryDisplay();
} else {
for (int i = 0; i < mOnlyVisibleWhenSimOk.length; i++) {
final View view = mOnlyVisibleWhenSimOk[i];
view.setVisibility(View.GONE);
}
for (int i = 0; i < mOnlyVisibleWhenSimNotOk.length; i++) {
final View view = mOnlyVisibleWhenSimNotOk[i];
view.setVisibility(View.VISIBLE);
}
refreshSimBadInfo();
}
|
private void | setAlarmInfoVisible(boolean visible)
final int visibilityFlag = visible ? View.VISIBLE : View.GONE;
mNextAlarmGroup.setVisibility(visibilityFlag);
mAlarmSpacer.setVisibility(visibilityFlag);
|