Update status area and emergency call logic to match new spec
Change-Id: Ic43d9d58168166aacf2b145663dc9412b099f9c2
This commit is contained in:
@@ -28,4 +28,4 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
androidprv:pageSpacing="10dp">
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel>
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardWidgetCarousel>
|
||||
@@ -67,7 +67,6 @@
|
||||
android:paddingLeft="@dimen/keyguard_security_view_margin"
|
||||
android:paddingTop="@dimen/keyguard_security_view_margin"
|
||||
android:paddingRight="@dimen/keyguard_security_view_margin"
|
||||
android:paddingBottom="@dimen/keyguard_security_view_margin"
|
||||
android:gravity="center">
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardSecurityViewFlipper>
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardSecurityContainer>
|
||||
|
||||
@@ -29,4 +29,4 @@
|
||||
android:clipChildren="false"
|
||||
android:clipToPadding="false"
|
||||
androidprv:pageSpacing="10dp">
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
|
||||
</com.android.internal.policy.impl.keyguard.KeyguardWidgetPager>
|
||||
@@ -23,7 +23,9 @@
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<include layout="@layout/keyguard_sim_puk_pin_account_navigation"/>
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -36,16 +36,39 @@
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
<com.android.internal.policy.impl.keyguard.EmergencyButton
|
||||
android:id="@+id/emergency_call_button"
|
||||
android:layout_width="wrap_content"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:drawableLeft="@*android:drawable/lockscreen_emergency_button"
|
||||
android:text="@string/kg_emergency_call_label"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:drawablePadding="8dip" />
|
||||
android:layout_marginTop="-10dip"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:weightSum="2">
|
||||
|
||||
<com.android.internal.policy.impl.keyguard.EmergencyButton
|
||||
android:id="@+id/emergency_call_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@*android:drawable/lockscreen_emergency_button"
|
||||
android:text="@string/kg_emergency_call_label"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:drawablePadding="8dip" />
|
||||
|
||||
<Button android:id="@+id/forgot_password_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:drawablePadding="8dip"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
**
|
||||
** Copyright 2012, The Android Open Source Project
|
||||
**
|
||||
** Licensed under the Apache License, Version 2.0 (the "License")
|
||||
** you may not use this file except in compliance with the License.
|
||||
** You may obtain a copy of the License at
|
||||
**
|
||||
** http://www.apache.org/licenses/LICENSE-2.0
|
||||
**
|
||||
** Unless required by applicable law or agreed to in writing, software
|
||||
** distributed under the License is distributed on an "AS IS" BASIS,
|
||||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
** See the License for the specific language governing permissions and
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
|
||||
<!-- This contains emergency call button and carrier as shared by pin/pattern/password screens -->
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_alignParentBottom="true">
|
||||
|
||||
<com.android.internal.policy.impl.keyguard.CarrierText
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?android:attr/buttonBarStyle"
|
||||
android:orientation="horizontal"
|
||||
android:gravity="center"
|
||||
android:weightSum="2">
|
||||
|
||||
<com.android.internal.policy.impl.keyguard.EmergencyButton
|
||||
android:id="@+id/emergency_call_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@*android:drawable/lockscreen_emergency_button"
|
||||
android:text="@string/kg_emergency_call_label"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:drawablePadding="8dip" />
|
||||
|
||||
<Button android:id="@+id/forgot_password_button"
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:drawableLeft="@*android:drawable/lockscreen_forgot_password_button"
|
||||
style="?android:attr/buttonBarButtonStyle"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:drawablePadding="8dip"
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -25,7 +25,10 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/keyguard_navigation"/>
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/face_unlock_area_view"
|
||||
|
||||
@@ -16,6 +16,17 @@
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<include layout="@layout/empty_navigation" />
|
||||
</merge>
|
||||
|
||||
<!-- This contains emergency call button and carrier as shared by pin/pattern/password screens -->
|
||||
<com.android.internal.policy.impl.keyguard.KeyguardMessageArea
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:id="@+id/keyguard_message_area"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textAppearance="?android:attr/textAppearance"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
@@ -16,4 +16,16 @@
|
||||
** limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android" />
|
||||
|
||||
<!-- This contains emergency call button and carrier as shared by pin/pattern/password screens -->
|
||||
<com.android.internal.policy.impl.keyguard.KeyguardMessageArea
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:id="@+id/keyguard_message_area"
|
||||
android:maxLines="4"
|
||||
android:textAppearance="?android:attr/textAppearance"
|
||||
android:textSize="@dimen/kg_status_line_font_size"
|
||||
android:textColor="?android:attr/textColorSecondary" />
|
||||
|
||||
@@ -29,20 +29,17 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:gravity="center">
|
||||
<include layout="@layout/keyguard_navigation"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -32,14 +32,16 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:layout_gravity="center">
|
||||
|
||||
<include layout="@layout/keyguard_navigation"/>
|
||||
|
||||
<!-- We need MATCH_PARENT here only to force the size of the parent to be passed to
|
||||
the pattern view for it to compute its size. This is an unusual case, caused by
|
||||
LockPatternView's requirement to maintain a square aspect ratio based on the width
|
||||
@@ -55,7 +57,7 @@
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center" />
|
||||
|
||||
<include layout="@layout/keyguard_emergency_carrier_area_and_recovery"
|
||||
<include layout="@layout/keyguard_emergency_carrier_area"
|
||||
android:id="@+id/keyguard_selector_fade_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -25,6 +25,10 @@
|
||||
android:layout_height="350dp"
|
||||
android:orientation="vertical"
|
||||
>
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
@@ -186,7 +190,7 @@
|
||||
/>
|
||||
<ImageButton
|
||||
android:id="@+id/key_enter"
|
||||
style="@android:style/Widget.Button.NumPadKey"
|
||||
style="@style/Widget.Button.NumPadKey"
|
||||
android:gravity="center"
|
||||
android:layout_width="0px"
|
||||
android:layout_height="match_parent"
|
||||
@@ -195,7 +199,7 @@
|
||||
/>
|
||||
</LinearLayout>
|
||||
|
||||
<include layout="@layout/keyguard_emergency_carrier_area_and_recovery"
|
||||
<include layout="@layout/keyguard_emergency_carrier_area"
|
||||
android:id="@+id/keyguard_selector_fade_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
||||
@@ -36,6 +36,10 @@
|
||||
android:clipToPadding="false"
|
||||
android:gravity="center">
|
||||
|
||||
<include layout="@layout/keyguard_message_area"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<include layout="@layout/keyguard_glow_pad_container" />
|
||||
|
||||
<include layout="@layout/keyguard_emergency_carrier_area"
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_lockscreen_sim"/>
|
||||
|
||||
<include layout="@layout/keyguard_sim_puk_pin_account_navigation"/>
|
||||
<include layout="@layout/keyguard_message_area_large"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- Password entry field -->
|
||||
|
||||
@@ -44,7 +44,9 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_lockscreen_sim"/>
|
||||
|
||||
<include layout="@layout/keyguard_sim_puk_pin_account_navigation"/>
|
||||
<include layout="@layout/keyguard_message_area_large"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@
|
||||
<!-- Size of margin on the right of keyguard's status view -->
|
||||
<dimen name="kg_status_line_font_right_margin">16dp</dimen>
|
||||
|
||||
<!-- Top margin for the clock view -->
|
||||
<!-- Top margin for the clock view -->
|
||||
<dimen name="kg_clock_top_margin">-16dp</dimen>
|
||||
|
||||
<!-- Horizontal gap between keys in PIN and SIM PIN numeric keyboards in keyguard -->
|
||||
|
||||
@@ -2503,4 +2503,5 @@ please see styles_device_defaults.xml.
|
||||
<item name="android:textStyle">normal</item>
|
||||
<item name="android:textColor">#80ffffff</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -91,9 +91,6 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
// We always set a dummy NavigationManager to avoid null checks
|
||||
mSecurityMessageDisplay = new KeyguardNavigationManager(null);
|
||||
|
||||
mLockPatternUtils = new LockPatternUtils(mContext);
|
||||
|
||||
mPasswordEntry = (TextView) findViewById(R.id.passwordEntry);
|
||||
@@ -120,6 +117,7 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
}
|
||||
}
|
||||
});
|
||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -219,12 +217,6 @@ public abstract class KeyguardAbsKeyInputView extends LinearLayout
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
reset();
|
||||
}
|
||||
|
||||
// Cause a VIRTUAL_KEY vibration
|
||||
public void doHapticKeyClick() {
|
||||
if (mEnableHaptics) {
|
||||
|
||||
@@ -84,9 +84,6 @@ public class KeyguardAccountView extends LinearLayout implements KeyguardSecurit
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
// We always set a dummy NavigationManager to avoid null checks
|
||||
mSecurityMessageDisplay = new KeyguardNavigationManager(null);
|
||||
|
||||
mLogin = (EditText) findViewById(R.id.login);
|
||||
mLogin.setFilters(new InputFilter[] { new LoginFilter.UsernameFilterGeneric() } );
|
||||
mLogin.addTextChangedListener(this);
|
||||
@@ -96,6 +93,8 @@ public class KeyguardAccountView extends LinearLayout implements KeyguardSecurit
|
||||
|
||||
mOk = (Button) findViewById(R.id.ok);
|
||||
mOk.setOnClickListener(this);
|
||||
|
||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -316,12 +315,6 @@ public class KeyguardAccountView extends LinearLayout implements KeyguardSecurit
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu
|
||||
private KeyguardSecurityCallback mKeyguardSecurityCallback;
|
||||
private LockPatternUtils mLockPatternUtils;
|
||||
private BiometricSensorUnlock mBiometricUnlock;
|
||||
private SecurityMessageDisplay mSecurityMessageDisplay;
|
||||
private View mFaceUnlockAreaView;
|
||||
private ImageButton mCancelButton;
|
||||
|
||||
@@ -214,11 +213,6 @@ public class KeyguardFaceUnlockView extends LinearLayout implements KeyguardSecu
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@@ -625,19 +625,7 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
View v = inflater.inflate(layoutId, this, false);
|
||||
mSecurityViewContainer.addView(v);
|
||||
updateSecurityView(v);
|
||||
|
||||
view = (KeyguardSecurityView) v;
|
||||
TextView navigationText = ((TextView) findViewById(R.id.keyguard_message_area));
|
||||
|
||||
// Some devices can fit a navigation area, others cannot. On devices that cannot,
|
||||
// we display the security message in status area.
|
||||
if (navigationText != null) {
|
||||
view.setSecurityMessageDisplay(new KeyguardNavigationManager(navigationText));
|
||||
} else {
|
||||
if (mKeyguardStatusViewManager != null) {
|
||||
view.setSecurityMessageDisplay(mKeyguardStatusViewManager);
|
||||
}
|
||||
}
|
||||
view = (KeyguardSecurityView)v;
|
||||
}
|
||||
|
||||
if (view instanceof KeyguardSelectorView) {
|
||||
@@ -955,13 +943,6 @@ public class KeyguardHostView extends KeyguardViewBase {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
KeyguardStatusView ksv = (KeyguardStatusView)
|
||||
findViewById(R.id.keyguard_status_view_face_palm);
|
||||
if (ksv != null) {
|
||||
mKeyguardStatusViewManager = ksv.getManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addWidgetsFromSettings() {
|
||||
|
||||
@@ -0,0 +1,215 @@
|
||||
/*
|
||||
* Copyright (C) 2011 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
|
||||
import libcore.util.MutableInt;
|
||||
|
||||
import com.android.internal.R;
|
||||
|
||||
/***
|
||||
* Manages a number of views inside of the given layout. See below for a list of widgets.
|
||||
*/
|
||||
class KeyguardMessageArea extends TextView {
|
||||
static final int CHARGING_ICON = 0; //R.drawable.ic_lock_idle_charging;
|
||||
static final int BATTERY_LOW_ICON = 0; //R.drawable.ic_lock_idle_low_battery;
|
||||
|
||||
static final int SECURITY_MESSAGE_DURATION = 5000;
|
||||
static final String SEPARATOR = " ";
|
||||
|
||||
// are we showing battery information?
|
||||
boolean mShowingBatteryInfo = false;
|
||||
|
||||
// last known plugged in state
|
||||
boolean mPluggedIn = false;
|
||||
|
||||
// last known battery level
|
||||
int mBatteryLevel = 100;
|
||||
|
||||
KeyguardUpdateMonitor mUpdateMonitor;
|
||||
|
||||
// Timeout before we reset the message to show charging/owner info
|
||||
long mTimeout = SECURITY_MESSAGE_DURATION;
|
||||
|
||||
// Shadowed text values
|
||||
protected boolean mBatteryCharged;
|
||||
protected boolean mBatteryIsLow;
|
||||
|
||||
private Handler mHandler;
|
||||
|
||||
CharSequence mMessage;
|
||||
boolean mShowingMessage;
|
||||
Runnable mClearMessageRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mMessage = null;
|
||||
mShowingMessage = false;
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
public static class Helper implements SecurityMessageDisplay {
|
||||
KeyguardMessageArea mMessageArea;
|
||||
Helper(View v) {
|
||||
mMessageArea = (KeyguardMessageArea) v.findViewById(R.id.keyguard_message_area);
|
||||
if (mMessageArea == null) {
|
||||
throw new RuntimeException("Can't find keyguard_message_area in " + v.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(CharSequence msg, boolean important) {
|
||||
if (!TextUtils.isEmpty(msg) && important) {
|
||||
mMessageArea.mMessage = msg;
|
||||
mMessageArea.securityMessageChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(int resId, boolean important) {
|
||||
if (resId != 0 && important) {
|
||||
mMessageArea.mMessage = mMessageArea.getContext().getResources().getText(resId);
|
||||
mMessageArea.securityMessageChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(int resId, boolean important, Object... formatArgs) {
|
||||
if (resId != 0 && important) {
|
||||
mMessageArea.mMessage = mMessageArea.getContext().getString(resId, formatArgs);
|
||||
mMessageArea.securityMessageChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout(int timeoutMs) {
|
||||
mMessageArea.mTimeout = timeoutMs;
|
||||
}
|
||||
}
|
||||
|
||||
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
|
||||
@Override
|
||||
public void onRefreshBatteryInfo(KeyguardUpdateMonitor.BatteryStatus status) {
|
||||
mShowingBatteryInfo = status.isPluggedIn() || status.isBatteryLow();
|
||||
mPluggedIn = status.isPluggedIn();
|
||||
mBatteryLevel = status.level;
|
||||
mBatteryCharged = status.isCharged();
|
||||
mBatteryIsLow = status.isBatteryLow();
|
||||
update();
|
||||
}
|
||||
};
|
||||
|
||||
public KeyguardMessageArea(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public KeyguardMessageArea(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
// This is required to ensure marquee works
|
||||
setSelected(true);
|
||||
|
||||
// Registering this callback immediately updates the battery state, among other things.
|
||||
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(getContext());
|
||||
mUpdateMonitor.registerCallback(mInfoCallback);
|
||||
mHandler = new Handler(Looper.myLooper());
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
public void securityMessageChanged() {
|
||||
mShowingMessage = true;
|
||||
update();
|
||||
mHandler.removeCallbacks(mClearMessageRunnable);
|
||||
if (mTimeout > 0) {
|
||||
mHandler.postDelayed(mClearMessageRunnable, mTimeout);
|
||||
}
|
||||
announceForAccessibility(getText());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 update() {
|
||||
MutableInt icon = new MutableInt(0);
|
||||
CharSequence status = concat(getChargeInfo(icon), getOwnerInfo(), getCurrentMessage());
|
||||
setCompoundDrawablesWithIntrinsicBounds(icon.value, 0, 0, 0);
|
||||
setText(status);
|
||||
}
|
||||
|
||||
|
||||
private CharSequence concat(Object... args) {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
final Object arg = args[i];
|
||||
if (arg instanceof CharSequence) {
|
||||
b.append((CharSequence)args[i]);
|
||||
b.append(SEPARATOR);
|
||||
} else if (arg instanceof String) {
|
||||
b.append((String)args[i]);
|
||||
b.append(SEPARATOR);
|
||||
}
|
||||
}
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
|
||||
CharSequence getCurrentMessage() {
|
||||
return mShowingMessage ? mMessage : null;
|
||||
}
|
||||
|
||||
String getOwnerInfo() {
|
||||
ContentResolver res = getContext().getContentResolver();
|
||||
final boolean ownerInfoEnabled = Settings.Secure.getIntForUser(res,
|
||||
Settings.Secure.LOCK_SCREEN_OWNER_INFO_ENABLED, 1, UserHandle.USER_CURRENT) != 0;
|
||||
return ownerInfoEnabled && !mShowingMessage ?
|
||||
Settings.Secure.getStringForUser(res, Settings.Secure.LOCK_SCREEN_OWNER_INFO,
|
||||
UserHandle.USER_CURRENT) : null;
|
||||
}
|
||||
|
||||
private CharSequence getChargeInfo(MutableInt icon) {
|
||||
CharSequence string = null;
|
||||
if (mShowingBatteryInfo && !mShowingMessage) {
|
||||
// Battery status
|
||||
if (mPluggedIn) {
|
||||
// Charging, charged or waiting to charge.
|
||||
string = getContext().getString(mBatteryCharged ?
|
||||
com.android.internal.R.string.lockscreen_charged
|
||||
:com.android.internal.R.string.lockscreen_plugged_in, mBatteryLevel);
|
||||
icon.value = CHARGING_ICON;
|
||||
} else if (mBatteryIsLow) {
|
||||
// Battery is low
|
||||
string = getContext().getString(
|
||||
com.android.internal.R.string.lockscreen_low_battery);
|
||||
icon.value = BATTERY_LOW_ICON;
|
||||
}
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.internal.policy.impl.keyguard;
|
||||
|
||||
import android.widget.TextView;
|
||||
|
||||
public class KeyguardNavigationManager implements SecurityMessageDisplay {
|
||||
|
||||
private TextView mMessageArea;
|
||||
|
||||
public KeyguardNavigationManager(TextView messageArea) {
|
||||
if (messageArea != null) {
|
||||
mMessageArea = messageArea;
|
||||
mMessageArea.setSelected(true); // Make marquee work
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(CharSequence msg, boolean important) {
|
||||
if (mMessageArea == null) return;
|
||||
mMessageArea.setText(msg);
|
||||
mMessageArea.announceForAccessibility(mMessageArea.getText());
|
||||
}
|
||||
|
||||
public void setMessage(int resId, boolean important) {
|
||||
if (mMessageArea == null) return;
|
||||
if (resId != 0) {
|
||||
mMessageArea.setText(resId);
|
||||
mMessageArea.announceForAccessibility(mMessageArea.getText());
|
||||
} else {
|
||||
mMessageArea.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
public void setMessage(int resId, boolean important, Object... formatArgs) {
|
||||
if (mMessageArea == null) return;
|
||||
if (resId != 0) {
|
||||
mMessageArea.setText(mMessageArea.getContext().getString(resId, formatArgs));
|
||||
mMessageArea.announceForAccessibility(mMessageArea.getText());
|
||||
} else {
|
||||
mMessageArea.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,13 +33,6 @@ import com.android.internal.R;
|
||||
public class KeyguardPINView extends KeyguardAbsKeyInputView
|
||||
implements KeyguardSecurityView, OnEditorActionListener, TextWatcher {
|
||||
|
||||
// To avoid accidental lockout due to events while the device in in the pocket, ignore
|
||||
// any passwords with length less than or equal to this length.
|
||||
private static final int MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT = 3;
|
||||
|
||||
// Enable this if we want to hide the on-screen PIN keyboard when a physical one is showing
|
||||
private static final boolean ENABLE_HIDE_KEYBOARD = false;
|
||||
|
||||
public KeyguardPINView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
@@ -110,10 +110,6 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
// We always set a dummy NavigationManager to avoid null checks
|
||||
mSecurityMessageDisplay = new KeyguardNavigationManager(null);
|
||||
|
||||
mLockPatternUtils = mLockPatternUtils == null
|
||||
? new LockPatternUtils(mContext) : mLockPatternUtils;
|
||||
|
||||
@@ -139,6 +135,7 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
setFocusableInTouchMode(true);
|
||||
|
||||
maybeEnableFallback(mContext);
|
||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
||||
}
|
||||
|
||||
private void updateFooter(FooterMode mode) {
|
||||
@@ -376,12 +373,6 @@ public class KeyguardPatternView extends LinearLayout implements KeyguardSecurit
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -61,7 +61,9 @@ public interface KeyguardSecurityView {
|
||||
*/
|
||||
KeyguardSecurityCallback getCallback();
|
||||
|
||||
void setSecurityMessageDisplay(SecurityMessageDisplay display);
|
||||
|
||||
/**
|
||||
* Instruct the view to show usability hints, if any.
|
||||
*
|
||||
*/
|
||||
void showUsabilityHint();
|
||||
}
|
||||
|
||||
@@ -118,14 +118,6 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard
|
||||
return (ksv != null) ? ksv.getCallback() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.setSecurityMessageDisplay(display);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
|
||||
@@ -261,8 +261,4 @@ public class KeyguardSelectorView extends LinearLayout implements KeyguardSecuri
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,6 @@ public class KeyguardSimPinView extends LinearLayout
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
// We always set a dummy NavigationManager to avoid null checks
|
||||
mSecurityMessageDisplay = new KeyguardNavigationManager(null);
|
||||
|
||||
mPinEntry = (EditText) findViewById(R.id.sim_pin_entry);
|
||||
mPinEntry.setOnEditorActionListener(this);
|
||||
mPinEntry.addTextChangedListener(this);
|
||||
@@ -103,6 +100,9 @@ public class KeyguardSimPinView extends LinearLayout
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
||||
mSecurityMessageDisplay.setTimeout(0);
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -269,9 +269,4 @@ public class KeyguardSimPinView extends LinearLayout
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,10 +130,6 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
// We always set a dummy NavigationManager to avoid null checks
|
||||
mSecurityMessageDisplay = new KeyguardNavigationManager(null);
|
||||
|
||||
mSimPinEntry = (TextView) findViewById(R.id.sim_pin_entry);
|
||||
mSimPinEntry.setOnEditorActionListener(this);
|
||||
mSimPinEntry.addTextChangedListener(this);
|
||||
@@ -150,6 +146,9 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
|
||||
});
|
||||
mKeyboardHelper.setKeyboardMode(PasswordEntryKeyboardHelper.KEYBOARD_MODE_NUMERIC);
|
||||
mKeyboardHelper.setEnableHaptics(mLockPatternUtils.isTactileFeedbackEnabled());
|
||||
|
||||
mSecurityMessageDisplay = new KeyguardMessageArea.Helper(this);
|
||||
mSecurityMessageDisplay.setTimeout(0); // don't show ownerinfo/charging status by default
|
||||
reset();
|
||||
}
|
||||
|
||||
@@ -338,10 +337,4 @@ public class KeyguardSimPukView extends LinearLayout implements View.OnClickList
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSecurityMessageDisplay(SecurityMessageDisplay display) {
|
||||
mSecurityMessageDisplay = display;
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,4 +326,8 @@ class KeyguardStatusViewManager implements SecurityMessageDisplay {
|
||||
return mContainer.getContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTimeout(int timeout_ms) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,4 +22,6 @@ public interface SecurityMessageDisplay {
|
||||
public void setMessage(int resId, boolean important);
|
||||
|
||||
public void setMessage(int resId, boolean important, Object... formatArgs);
|
||||
|
||||
public void setTimeout(int timeout_ms);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user