am 9ea1107d: Fix for 2209086: Initial pass at new SlidingTab widget and integration into LockScreen.

Merge commit '9ea1107df165518909883429fb5cf20fce7a81e6' into eclair-mr2

* commit '9ea1107df165518909883429fb5cf20fce7a81e6':
  Fix for 2209086:  Initial pass at new SlidingTab widget and integration into LockScreen.
This commit is contained in:
Jim Miller
2009-11-11 17:13:21 -08:00
committed by Android Git Automerger

View File

@@ -17,8 +17,9 @@
package com.android.internal.policy.impl;
import com.android.internal.R;
import com.android.internal.telephony.IccCard;
import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.RotarySelector;
import com.android.internal.widget.SlidingTab;
import android.content.Context;
import android.content.res.Resources;
@@ -33,8 +34,6 @@ import android.util.Log;
import android.media.AudioManager;
import android.os.SystemProperties;
import com.android.internal.telephony.IccCard;
import java.util.Date;
import java.io.File;
import java.text.SimpleDateFormat;
@@ -46,7 +45,7 @@ import java.text.SimpleDateFormat;
*/
class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateMonitor.InfoCallback,
KeyguardUpdateMonitor.SimStateCallback, KeyguardUpdateMonitor.ConfigurationChangeCallback,
RotarySelector.OnDialTriggerListener {
SlidingTab.OnTriggerListener {
private static final boolean DBG = false;
private static final String TAG = "LockScreen";
@@ -59,7 +58,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
private final KeyguardScreenCallback mCallback;
private TextView mCarrier;
private RotarySelector mRotary;
private SlidingTab mSelector;
private TextView mTime;
private TextView mDate;
private TextView mStatus1;
@@ -175,9 +174,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
final LayoutInflater inflater = LayoutInflater.from(context);
if (mCreatedInPortrait) {
inflater.inflate(R.layout.keyguard_screen_rotary_unlock, this, true);
inflater.inflate(R.layout.keyguard_screen_tab_unlock, this, true);
} else {
inflater.inflate(R.layout.keyguard_screen_rotary_unlock_land, this, true);
inflater.inflate(R.layout.keyguard_screen_tab_unlock_land, this, true);
}
mCarrier = (TextView) findViewById(R.id.carrier);
@@ -189,7 +188,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
mEmergencyCallButton.setText(R.string.lockscreen_emergency_call);
mScreenLocked = (TextView) findViewById(R.id.screenLocked);
mRotary = (RotarySelector) findViewById(R.id.rotary);
mSelector = (SlidingTab) findViewById(R.id.tab_selector);
mSelector.setLeftHintText(R.string.lockscreen_unlock_label);
mSelector.setRightHintText(R.string.lockscreen_mute_unmute_label);
mEmergencyCallButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mCallback.takeEmergencyCallAction();
@@ -207,15 +208,28 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
mSilentMode = mAudioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT;
mRotary.setOnDialTriggerListener(this);
mRotary.setLeftHandleResource(R.drawable.ic_jog_dial_unlock);
mRotary.setRightHandleResource(mSilentMode ?
R.drawable.ic_jog_dial_sound_off :
R.drawable.ic_jog_dial_sound_on);
mSelector.setOnTriggerListener(this);
mSelector.setLeftTabResources(
R.drawable.ic_jog_dial_unlock,
R.drawable.jog_tab_target_green,
R.drawable.jog_tab_bar_left_unlock,
R.drawable.jog_tab_left_unlock);
updateRightTabResources();
resetStatusInfo(updateMonitor);
}
private void updateRightTabResources() {
mSelector.setRightTabResources(
mSilentMode ? R.drawable.ic_jog_dial_sound_off : R.drawable.ic_jog_dial_sound_on,
mSilentMode ? R.drawable.jog_tab_target_yellow : R.drawable.jog_tab_target_gray,
mSilentMode ? R.drawable.jog_tab_bar_right_sound_on
: R.drawable.jog_tab_bar_right_sound_off,
mSilentMode ? R.drawable.jog_tab_right_sound_on
: R.drawable.jog_tab_right_sound_off);
}
private void resetStatusInfo(KeyguardUpdateMonitor updateMonitor) {
mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo();
mPluggedIn = updateMonitor.isDevicePluggedIn();
@@ -242,24 +256,23 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
}
/** {@inheritDoc} */
public void onDialTrigger(View v, int whichHandle) {
if (whichHandle == RotarySelector.OnDialTriggerListener.LEFT_HANDLE) {
public void onTrigger(View v, int whichHandle) {
if (whichHandle == SlidingTab.OnTriggerListener.LEFT_HANDLE) {
mCallback.goToUnlockScreen();
} else if (whichHandle == RotarySelector.OnDialTriggerListener.RIGHT_HANDLE) {
} else if (whichHandle == SlidingTab.OnTriggerListener.RIGHT_HANDLE) {
// toggle silent mode
mSilentMode = !mSilentMode;
mAudioManager.setRingerMode(mSilentMode ? AudioManager.RINGER_MODE_SILENT
: AudioManager.RINGER_MODE_NORMAL);
final int handleIcon = mSilentMode ?
R.drawable.ic_jog_dial_sound_off :
R.drawable.ic_jog_dial_sound_on;
final int toastIcon = mSilentMode ?
R.drawable.ic_lock_ringer_off :
R.drawable.ic_lock_ringer_on;
mRotary.setRightHandleResource(handleIcon);
updateRightTabResources();
String message = mSilentMode ?
getContext().getString(R.string.global_action_silent_mode_on_status) :
getContext().getString(R.string.global_action_silent_mode_off_status);
final int toastIcon = mSilentMode ? R.drawable.ic_lock_ringer_off
: R.drawable.ic_lock_ringer_on;
toastMessage(mScreenLocked, message, toastIcon);
mCallback.pokeWakelock();
}
@@ -268,6 +281,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
/** {@inheritDoc} */
public void onGrabbedStateChange(View v, int grabbedState) {
// TODO: Update onscreen hint text based on the new state.
mCallback.pokeWakelock();
}
/**
@@ -468,7 +482,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.VISIBLE);
mRotary.setVisibility(View.VISIBLE);
mSelector.setVisibility(View.VISIBLE);
mEmergencyCallButton.setVisibility(View.GONE);
break;
case NetworkLocked:
@@ -478,7 +492,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.VISIBLE);
mRotary.setVisibility(View.VISIBLE);
mSelector.setVisibility(View.VISIBLE);
mEmergencyCallButton.setVisibility(View.GONE);
break;
case SimMissing:
@@ -488,7 +502,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.INVISIBLE);
mRotary.setVisibility(View.VISIBLE);
mSelector.setVisibility(View.VISIBLE);
mEmergencyCallButton.setVisibility(View.VISIBLE);
putEmergencyBelow(R.id.divider);
break;
@@ -499,7 +513,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.VISIBLE);
mRotary.setVisibility(View.GONE);
mSelector.setVisibility(View.GONE);
mEmergencyCallButton.setVisibility(View.VISIBLE);
putEmergencyBelow(R.id.screenLocked);
break;
@@ -509,7 +523,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.INVISIBLE);
mRotary.setVisibility(View.VISIBLE);
mSelector.setVisibility(View.VISIBLE);
mEmergencyCallButton.setVisibility(View.GONE);
break;
case SimPukLocked:
@@ -519,7 +533,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen, KeyguardUpdateM
// layout
mScreenLocked.setVisibility(View.VISIBLE);
mRotary.setVisibility(View.GONE);
mSelector.setVisibility(View.GONE);
mEmergencyCallButton.setVisibility(View.VISIBLE);
putEmergencyBelow(R.id.screenLocked);
break;