Merge "Fix 3330653: Update lockscreen layouts to match latest mocks [DO NOT MERGE]" into honeycomb

This commit is contained in:
Jim Miller
2011-01-09 13:47:29 -08:00
committed by Android (Google) Code Review
20 changed files with 310 additions and 292 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 521 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 607 B

View File

@@ -22,18 +22,23 @@
android:layout_height="match_parent"
android:orientation="horizontal"
>
<!-- left side: status and emergency call button -->
<LinearLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip"
android:orientation="vertical"
android:gravity="center_vertical"
>
<include layout="@layout/keyguard_screen_status_land" />
</LinearLayout>
<!-- left side: status -->
<RelativeLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip">
<include layout="@layout/keyguard_screen_status_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="102dip"
android:layout_marginTop="320dip"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
<!-- right side: password -->
<LinearLayout
android:layout_width="0dip"

View File

@@ -19,21 +19,23 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<!-- left side: status and emergency call button -->
<LinearLayout
android:orientation="vertical">
<!-- top: status -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical"
>
<include layout="@layout/keyguard_screen_status_land" />
</LinearLayout>
<!-- right side: password -->
android:layout_weight="1">
<include layout="@layout/keyguard_screen_status_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="134dip"
android:layout_marginLeft="266dip"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
<!-- bottom: password -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"

View File

@@ -23,8 +23,6 @@
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dip"
android:layout_marginTop="20dip"
android:gravity="left"
>
@@ -58,7 +56,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="none"
android:textSize="120sp"
android:textSize="98sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/lockscreen_clock_background"
android:layout_marginBottom="6dip"
@@ -69,7 +67,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="none"
android:textSize="120sp"
android:textSize="98sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/lockscreen_clock_foreground"
android:layout_alignLeft="@id/timeDisplayBackground"
@@ -92,15 +90,29 @@
</com.android.internal.widget.DigitalClock>
<TextView
android:id="@+id/date"
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time"
android:layout_marginTop="10dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
/>
android:layout_marginTop="10dip">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="17sp"/>
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="17sp"/>
</LinearLayout>
<!-- Status2 is generally charge status -->
<TextView
@@ -109,18 +121,19 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
android:textSize="17sp"
android:layout_marginTop="10dip"
android:drawablePadding="4dip"
android:visibility="gone"
/>
<!-- Status1 is generally alarm status -->
<!-- Status1 is generally battery status and informational messages -->
<TextView
android:id="@+id/status1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:textSize="22sp"
android:textSize="17sp"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
@@ -130,9 +143,10 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
android:textSize="17sp"
android:layout_marginTop="20dip"
android:singleLine="false"
android:textColor="@color/lockscreen_owner_info"
android:visibility="invisible"
/>
</LinearLayout>

View File

@@ -44,8 +44,6 @@
<com.android.internal.widget.DigitalClock android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_marginTop="8dip"
android:layout_marginBottom="8dip"
android_layout_marginLeft="-10dip">
@@ -57,7 +55,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="none"
android:textSize="120sp"
android:textSize="98sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/lockscreen_clock_background"
android:layout_marginBottom="6dip"
@@ -68,7 +66,7 @@
android:layout_height="wrap_content"
android:singleLine="true"
android:ellipsize="none"
android:textSize="120sp"
android:textSize="98sp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/lockscreen_clock_foreground"
android:layout_marginBottom="6dip"
@@ -91,15 +89,29 @@
</com.android.internal.widget.DigitalClock>
<TextView
android:id="@+id/date"
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/time"
android:layout_marginTop="10dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
/>
android:layout_marginTop="10dip">
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="17sp"/>
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="17sp"/>
</LinearLayout>
<!-- used for status such as the next alarm, and charging status. -->
<TextView
@@ -108,9 +120,10 @@
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
android:textSize="17sp"
android:layout_marginTop="10dip"
android:drawablePadding="4dip"
android:visibility="gone"
/>
<TextView
@@ -118,7 +131,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:textSize="22sp"
android:textSize="17sp"
android:textAppearance="?android:attr/textAppearanceMedium"
/>
@@ -129,8 +142,9 @@
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="22sp"
android:textSize="17sp"
android:singleLine="false"
android:visibility="invisible"
android:textColor="@color/lockscreen_owner_info"
/>
</LinearLayout>

View File

@@ -29,15 +29,18 @@
android:id="@+id/root"
android:background="#70000000">
<!-- left side: status and emergency call button -->
<LinearLayout
<!-- top: status -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical">
<include layout="@layout/keyguard_screen_status_port" />
</LinearLayout>
android:orientation="vertical">
<include layout="@layout/keyguard_screen_status_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="134dip"
android:layout_marginLeft="266dip"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
@@ -75,6 +78,7 @@
android:text="@string/emergency_calls_only"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="@color/white"
android:visibility="gone"
/>
<!-- emergency call button shown when sim is PUKd and tab_selector is
@@ -86,7 +90,7 @@
android:drawableLeft="@drawable/ic_emergency"
android:layout_centerInParent="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dip"
android:layout_marginBottom="90dip"
style="@style/Widget.Button.Transparent"
android:drawablePadding="8dip"
android:visibility="gone"

View File

@@ -28,16 +28,21 @@
android:background="#70000000"
android:id="@+id/root">
<!-- left side: status and emergency call button -->
<LinearLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip"
android:orientation="vertical"
android:gravity="center_vertical"
>
<include layout="@layout/keyguard_screen_status_land" />
</LinearLayout>
<!-- left side: status -->
<RelativeLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip">
<include layout="@layout/keyguard_screen_status_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="102dip"
android:layout_marginTop="320dip"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
<!-- right side -->
<LinearLayout

View File

@@ -26,81 +26,92 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
android:background="#70000000">
<!-- left side: status and emergency call button -->
<LinearLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip"
android:orientation="vertical"
android:gravity="center_vertical"
>
<include layout="@layout/keyguard_screen_status_land" />
<!-- left side: status -->
<RelativeLayout
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_width="0dip">
<!-- footer -->
<FrameLayout
android:layout_width="match_parent"
<include layout="@layout/keyguard_screen_status_land"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dip"
>
android:layout_marginLeft="102dip"
android:layout_marginTop="320dip"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"/>
<!-- option 1: a single emergency call button -->
<RelativeLayout android:id="@+id/footerNormal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
>
<Button android:id="@+id/emergencyCallAlone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockscreen_emergency_call"
style="@style/Widget.Button.Transparent"
android:drawableLeft="@drawable/ic_emergency"
android:drawablePadding="8dip"
android:visibility="gone"
/>
</RelativeLayout>
<!-- option 2: an emergency call button, and a 'forgot pattern?' button -->
<LinearLayout android:id="@+id/footerForgotPattern"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="left"
>
<Button android:id="@+id/forgotPattern"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.Button.Transparent"
/>
<Button android:id="@+id/emergencyCallTogether"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lockscreen_emergency_call"
style="@style/Widget.Button.Transparent"
android:drawableLeft="@drawable/ic_emergency"
android:drawablePadding="8dip"
android:visibility="gone"
/>
</LinearLayout>
</FrameLayout>
</LinearLayout>
</RelativeLayout>
<!-- right side: lock pattern -->
<LinearLayout
<RelativeLayout
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:gravity="center"
>
android:layout_height="match_parent">
<com.android.internal.widget.LockPatternView android:id="@+id/lockPattern"
android:layout_width="354dip"
android:layout_height="354dip"
android:layout_marginTop="90dip"
android:layout_marginRight="90dip"
/>
</LinearLayout>
android:layout_marginLeft="143dip"
android:layout_marginTop="201dip"
android:layout_gravity="center_vertical"
/>
<!-- footer -->
<!-- option 1: a single emergency call button -->
<RelativeLayout android:id="@+id/footerNormal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/lockPattern"
android:layout_alignLeft="@id/lockPattern"
android:layout_alignRight="@id/lockPattern"
android:layout_marginTop="28dip"
android:layout_marginLeft="28dip"
android:layout_marginRight="28dip"
>
<Button android:id="@+id/emergencyCallAlone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/lockscreen_emergency_call"
style="@style/Widget.Button.Transparent"
android:drawableLeft="@drawable/ic_emergency"
android:drawablePadding="8dip"
android:visibility="gone"
/>
</RelativeLayout>
<!-- option 2: an emergency call button, and a 'forgot pattern?' button -->
<LinearLayout android:id="@+id/footerForgotPattern"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/footerNormal"
android:layout_alignLeft="@id/lockPattern"
android:layout_alignRight="@id/lockPattern"
android:layout_marginTop="28dip"
android:layout_marginLeft="28dip"
android:layout_marginRight="28dip">
<Button android:id="@+id/forgotPattern"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.Button.Transparent"
/>
<Button android:id="@+id/emergencyCallTogether"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lockscreen_emergency_call"
style="@style/Widget.Button.Transparent"
android:drawableLeft="@drawable/ic_emergency"
android:drawablePadding="8dip"
android:visibility="gone"
/>
</LinearLayout>
</RelativeLayout>
</com.android.internal.widget.LinearLayoutWithDefaultTouchRecepient>

View File

@@ -22,18 +22,21 @@
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#70000000"
>
<!-- left side: status and emergency call button -->
<!-- top: status -->
<LinearLayout
android:layout_height="0dip"
android:layout_weight="1"
android:layout_width="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
>
android:layout_height="0dip"
android:layout_weight="1"
android:layout_width="match_parent"
android:orientation="vertical">
<include layout="@layout/keyguard_screen_status_port" />
<include layout="@layout/keyguard_screen_status_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="134dip"
android:layout_marginLeft="266dip"/>
<!-- footer -->
<FrameLayout

View File

@@ -117,11 +117,24 @@
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<!-- TODO: Redo layout when we release on phones -->
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:drawablePadding="4dip"
android:layout_below="@id/date"
android:layout_marginTop="4dip"
android:layout_marginLeft="24dip"
/>
<TextView
android:id="@+id/status1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:layout_below="@id/alarm_status"
android:layout_marginTop="4dip"
android:layout_marginLeft="24dip"
android:textAppearance="?android:attr/textAppearanceMedium"

View File

@@ -118,11 +118,24 @@
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<!-- TODO: Redo layout when we release on phones -->
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:drawablePadding="4dip"
android:layout_below="@id/date"
android:layout_marginTop="4dip"
android:layout_marginLeft="24dip"
/>
<TextView
android:id="@+id/status1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/date"
android:layout_below="@id/alarm_status"
android:layout_marginTop="6dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:drawablePadding="4dip"

View File

@@ -38,6 +38,15 @@
android:layout_marginLeft="24dip"
android:gravity="left"
>
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:drawablePadding="4dip"
/>
<TextView
android:id="@+id/status1"
android:layout_width="wrap_content"

View File

@@ -127,6 +127,15 @@
android:layout_marginLeft="12dip"
android:gravity="left"
>
<!-- TODO: Redo layout when we release on phones -->
<TextView
android:id="@+id/alarm_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:drawablePadding="4dip"
/>
<TextView
android:id="@+id/status1"
android:layout_width="wrap_content"

View File

@@ -104,9 +104,10 @@
<color name="keyguard_text_color_decline">#fe0a5a</color>
<!-- keyguard clock -->
<color name="lockscreen_clock_background">#ff9a9a9a</color>
<color name="lockscreen_clock_foreground">#ff666666</color>
<color name="lockscreen_clock_background">#b3ffffff</color>
<color name="lockscreen_clock_foreground">#40000000</color>
<color name="lockscreen_clock_am_pm">#ff9a9a9a</color>
<color name="lockscreen_owner_info">#ff9a9a9a</color>
<!-- For holo theme -->
<drawable name="screen_background_holo_light">#fff3f3f3</drawable>

View File

@@ -80,11 +80,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
// last known battery level
private int mBatteryLevel = 100;
private String mNextAlarm = null;
private Drawable mAlarmIcon = null;
private String mCharging = null;
private Drawable mChargingIcon = null;
private boolean mSilentMode;
private AudioManager mAudioManager;
private String mDateFormatString;
@@ -356,9 +351,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
mStatus = getCurrentStatus(updateMonitor.getSimState());
updateLayout(mStatus);
refreshBatteryStringAndIcon();
refreshAlarmDisplay();
mTimeFormat = DateFormat.getTimeFormat(getContext());
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
refreshTimeAndDateDisplay();
@@ -417,14 +409,6 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
private Runnable mPendingR1;
private Runnable mPendingR2;
private void refreshAlarmDisplay() {
mNextAlarm = mLockPatternUtils.getNextAlarm();
if (mNextAlarm != null) {
mAlarmIcon = getContext().getResources().getDrawable(R.drawable.ic_lock_idle_alarm);
}
updateStatusLines();
}
/** {@inheritDoc} */
public void onRefreshBatteryInfo(boolean showBatteryInfo, boolean pluggedIn,
int batteryLevel) {
@@ -433,32 +417,9 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
mPluggedIn = pluggedIn;
mBatteryLevel = batteryLevel;
refreshBatteryStringAndIcon();
updateStatusLines();
}
private void refreshBatteryStringAndIcon() {
if (!mShowingBatteryInfo) {
mCharging = null;
return;
}
if (mChargingIcon == null) {
mChargingIcon =
getContext().getResources().getDrawable(R.drawable.ic_lock_idle_charging);
}
if (mPluggedIn) {
if (mBatteryLevel >= 100) {
mCharging = getContext().getString(R.string.lockscreen_charged);
} else {
mCharging = getContext().getString(R.string.lockscreen_plugged_in, mBatteryLevel);
}
} else {
mCharging = getContext().getString(R.string.lockscreen_low_battery);
}
}
/** {@inheritDoc} */
public void onTimeChanged() {
refreshTimeAndDateDisplay();
@@ -469,7 +430,7 @@ class LockScreen extends LinearLayout implements KeyguardScreen,
}
private void updateStatusLines() {
mStatusView.updateStatusLines(mStatus.showStatusLines(), mCharging, mChargingIcon, mAlarmIcon);
mStatusView.updateStatusLines(mStatus.showStatusLines());
}
/** {@inheritDoc} */

View File

@@ -396,7 +396,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
mLockPatternView
.setDisplayMode(LockPatternView.DisplayMode.Correct);
mStatusView.setInstructions("");
mStatusView.updateStatusLines();
mStatusView.updateStatusLines(true);
mCallback.keyguardDone(true);
mCallback.reportSuccessfulUnlockAttempt();
} else {
@@ -416,7 +416,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
// TODO mUnlockIcon.setVisibility(View.VISIBLE);
mStatusView.setInstructions(
getContext().getString(R.string.lockscreen_pattern_wrong));
mStatusView.updateStatusLines();
mStatusView.updateStatusLines(true);
mLockPatternView.postDelayed(
mCancelPatternRunnable,
PATTERN_CLEAR_TIMEOUT_MS);
@@ -437,7 +437,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
mStatusView.setInstructions(getContext().getString(
R.string.lockscreen_too_many_failed_attempts_countdown,
secondsRemaining));
mStatusView.updateStatusLines();
mStatusView.updateStatusLines(true);
}
@Override
@@ -445,7 +445,7 @@ class PatternUnlockScreen extends LinearLayoutWithDefaultTouchRecepient
mLockPatternView.setEnabled(true);
mStatusView.setInstructions(getContext().getString(
R.string.lockscreen_pattern_instructions));
mStatusView.updateStatusLines();
mStatusView.updateStatusLines(true);
// TODO mUnlockIcon.setVisibility(View.VISIBLE);
mFailedPatternAttemptsSinceLastTimeout = 0;
if (mEnableFallback) {

View File

@@ -19,6 +19,11 @@ import android.view.View;
import android.widget.TextView;
class StatusView {
private static final int LOCK_ICON = R.drawable.ic_lock_idle_lock;
private static final int ALARM_ICON = R.drawable.ic_lock_idle_alarm;
private static final int CHARGING_ICON = R.drawable.ic_lock_idle_charging;
private static final int BATTERY_LOW_ICON = R.drawable.ic_lock_idle_low_battery;
private String mDateFormatString;
private TextView mCarrier;
@@ -33,20 +38,18 @@ class StatusView {
// last known battery level
private int mBatteryLevel = 100;
private String mNextAlarm = null;
private String mInstructions = null;
private TextView mStatus1;
private TextView mStatus2;
private TextView mPropertyOf;
private boolean mHasStatus2;
private boolean mHasCarrier;
private boolean mHasDate;
private boolean mHasProperty;
private View mView;
private TextView mAlarmStatus;
private LockPatternUtils mLockPatternUtils;
private View findViewById(int id) {
return mView.findViewById(id);
}
@@ -69,7 +72,7 @@ class StatusView {
mShowingBatteryInfo = showBatteryInfo;
mPluggedIn = pluggedIn;
mBatteryLevel = batteryLevel;
updateStatusLines();
updateStatusLines(true);
}
void onTimeChanged() {
@@ -91,14 +94,14 @@ class StatusView {
mDate = (TextView) findViewById(R.id.date);
mHasDate = (mDate != null);
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
mLockPatternUtils = lockPatternUtils;
refreshTimeAndDateDisplay();
mStatus1 = (TextView) findViewById(R.id.status1);
mStatus2 = (TextView) findViewById(R.id.status2);
mHasStatus2 = (mStatus2 != null);
mAlarmStatus = (TextView) findViewById(R.id.alarm_status);
mAlarmStatus.setCompoundDrawablesWithIntrinsicBounds(ALARM_ICON, 0, 0, 0);
mPropertyOf = (TextView) findViewById(R.id.propertyOf);
mHasProperty = (mPropertyOf != null);
resetStatusInfo(updateMonitor, lockPatternUtils);
@@ -107,7 +110,6 @@ class StatusView {
mCarrier.setSelected(true);
mCarrier.setTextColor(0xffffffff);
}
}
void resetStatusInfo(KeyguardUpdateMonitor updateMonitor, LockPatternUtils lockPatternUtils) {
@@ -115,19 +117,18 @@ class StatusView {
mShowingBatteryInfo = updateMonitor.shouldShowBatteryInfo();
mPluggedIn = updateMonitor.isDevicePluggedIn();
mBatteryLevel = updateMonitor.getBatteryLevel();
mNextAlarm = lockPatternUtils.getNextAlarm();
updateStatusLines();
updateStatusLines(true);
}
void setInstructionText(int stringId) {
mStatus1.setText(stringId);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_lock, 0, 0, 0);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(LOCK_ICON, 0, 0, 0);
mStatus1.setVisibility(View.VISIBLE);
}
void setInstructionText(String string) {
mStatus1.setText(string);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_lock, 0, 0, 0);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(LOCK_ICON, 0, 0, 0);
mStatus1.setVisibility(View.VISIBLE);
}
@@ -138,9 +139,22 @@ class StatusView {
mCarrier.setText(string);
}
/** Originated from PatternUnlockScreen **/
void updateStatusLines() {
if (mHasProperty) {
/**
* Update the status lines based on these rules:
* AlarmStatus: Alarm state always gets it's own line.
* Status1 is shared between help, battery status and generic unlock instructions,
* prioritized in that order.
* @param showStatusLines status lines are shown if true
*/
void updateStatusLines(boolean showStatusLines) {
if (!showStatusLines) {
mStatus1.setVisibility(showStatusLines ? View.VISIBLE : View.GONE);
mAlarmStatus.setVisibility(showStatusLines ? View.VISIBLE : View.GONE);
return;
}
// Update owner info
if (mPropertyOf != null) {
ContentResolver res = getContext().getContentResolver();
String info = Settings.Secure.getString(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO);
boolean enabled = Settings.Secure.getInt(res,
@@ -151,104 +165,44 @@ class StatusView {
View.VISIBLE : View.INVISIBLE);
}
if (!mHasStatus2) return;
// Update Alarm status
String nextAlarm = mLockPatternUtils.getNextAlarm();
if (!TextUtils.isEmpty(nextAlarm)) {
mAlarmStatus.setText(nextAlarm);
mAlarmStatus.setVisibility(View.VISIBLE);
} else {
mAlarmStatus.setVisibility(View.GONE);
}
// Update Status1
if (mInstructions != null) {
// instructions only
// Instructions only
final int resId = TextUtils.isEmpty(mInstructions) ? 0 : LOCK_ICON;
mStatus1.setText(mInstructions);
if (TextUtils.isEmpty(mInstructions)) {
mStatus1.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
} else {
mStatus1.setCompoundDrawablesWithIntrinsicBounds(
R.drawable.ic_lock_idle_lock, 0, 0, 0);
}
mStatus1.setCompoundDrawablesWithIntrinsicBounds(resId, 0, 0, 0);
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
} else if (mShowingBatteryInfo && mNextAlarm == null) {
// battery only
} else if (mShowingBatteryInfo) {
// Battery status
if (mPluggedIn) {
if (mBatteryLevel >= 100) {
mStatus1.setText(getContext().getString(R.string.lockscreen_charged));
} else {
mStatus1.setText(getContext().getString(R.string.lockscreen_plugged_in,
mBatteryLevel));
}
// Charging or charged
if (mBatteryLevel >= 100) {
mStatus1.setText(getContext().getString(R.string.lockscreen_charged));
} else {
mStatus1.setText(getContext().getString(R.string.lockscreen_plugged_in,
mBatteryLevel));
}
mStatus1.setCompoundDrawablesWithIntrinsicBounds(CHARGING_ICON, 0, 0, 0);
} else {
// Battery is low
mStatus1.setText(getContext().getString(R.string.lockscreen_low_battery));
mStatus1.setCompoundDrawablesWithIntrinsicBounds(BATTERY_LOW_ICON, 0, 0, 0);
}
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_charging, 0,
0, 0);
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
} else if (mNextAlarm != null && !mShowingBatteryInfo) {
// alarm only
mStatus1.setText(mNextAlarm);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_alarm, 0,
0, 0);
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
} else if (mNextAlarm != null && mShowingBatteryInfo) {
// both battery and next alarm
mStatus1.setText(mNextAlarm);
mStatus2.setText(getContext().getString(
R.string.lockscreen_battery_short,
Math.min(100, mBatteryLevel)));
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_alarm, 0,
0, 0);
if (mPluggedIn) {
mStatus2.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_charging,
0, 0, 0);
} else {
mStatus2.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
}
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.VISIBLE);
} else {
// nothing specific to show; show general instructions
mStatus1.setText(R.string.lockscreen_pattern_instructions);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_idle_lock, 0,
0, 0);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(LOCK_ICON, 0,0, 0);
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
}
}
/** Originated from LockScreen **/
// TODO Merge with function above
void updateStatusLines(boolean showStatusLines, String charging, Drawable chargingIcon,
Drawable alarmIcon) {
if (!showStatusLines || (charging == null && mNextAlarm == null)) {
mStatus1.setVisibility(View.INVISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
} else if (charging != null && mNextAlarm == null) {
// charging only
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
mStatus1.setText(charging);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(chargingIcon, null, null, null);
} else if (mNextAlarm != null && charging == null) {
// next alarm only
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.INVISIBLE);
mStatus1.setText(mNextAlarm);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(alarmIcon, null, null, null);
} else if (charging != null && mNextAlarm != null) {
// both charging and next alarm
mStatus1.setVisibility(View.VISIBLE);
mStatus2.setVisibility(View.VISIBLE);
mStatus1.setText(charging);
mStatus1.setCompoundDrawablesWithIntrinsicBounds(chargingIcon, null, null, null);
mStatus2.setText(mNextAlarm);
mStatus2.setCompoundDrawablesWithIntrinsicBounds(alarmIcon, null, null, null);
}
}