[Bouncer] Add button for esim bouncer.

Refine "Disable esim" button in sim boucner when using an esim.

Fixes: 238190632
Test: Manual on device with dark mode and light mode.
Change-Id: I54c386738735915e8607f58da9b0435beb2a5043
This commit is contained in:
Aaron Liu
2022-09-13 11:15:34 -07:00
parent 6170285a1a
commit a6b99ac672
12 changed files with 124 additions and 76 deletions

View File

@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2022 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.
-->
<inset xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
android:insetTop="6dp"
android:insetBottom="6dp">
<ripple android:color="?android:attr/colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<solid android:color="?android:attr/textColorSecondary"/>
<corners android:radius="24dp"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<corners android:radius="24dp"/>
<solid android:color="@android:color/transparent"/>
<stroke android:color="?androidprv:attr/colorAccentTertiary"
android:width="1dp"
/>
<padding android:left="16dp"
android:top="12dp"
android:right="16dp"
android:bottom="12dp"/>
</shape>
</item>
</ripple>
</inset>

View File

@@ -17,15 +17,17 @@
*/
-->
<!-- This contains disable esim buttonas shared by sim_pin/sim_puk screens -->
<com.android.keyguard.KeyguardEsimArea
xmlns:android="http://schemas.android.com/apk/res/android"
<!-- This contains disable eSim buttons shared by sim_pin/sim_puk screens -->
<com.android.keyguard.KeyguardEsimArea xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyguard_disable_esim"
style="@style/Keyguard.TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/keyguard_disable_esim"
android:visibility="gone"
android:background="@drawable/kg_bouncer_secondary_button"
android:drawablePadding="10dp"
android:drawableStart="@drawable/ic_no_sim"
android:drawableTint="?android:attr/textColorPrimary"
android:text="@string/disable_carrier_button_text"
style="@style/Keyguard.TextView"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/kg_status_line_font_size"
android:textAllCaps="@bool/kg_use_all_caps" />
android:visibility="gone" />

View File

@@ -47,8 +47,7 @@
<include layout="@layout/keyguard_esim_area"
android:id="@+id/keyguard_esim_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eca_overlap" />
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/row0"
android:layout_width="match_parent"

View File

@@ -51,8 +51,7 @@
<include layout="@layout/keyguard_esim_area"
android:id="@+id/keyguard_esim_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/eca_overlap" />
android:layout_height="wrap_content" />
<RelativeLayout
android:id="@+id/row0"

View File

@@ -31,8 +31,4 @@
<!-- Overload default clock widget parameters -->
<dimen name="widget_big_font_size">100dp</dimen>
<dimen name="widget_label_font_size">18sp</dimen>
<!-- EmergencyCarrierArea overlap - amount to overlap the emergency button and carrier text.
Should be 0 on devices with plenty of room (e.g. tablets) -->
<dimen name="eca_overlap">0dip</dimen>
</resources>

View File

@@ -44,10 +44,6 @@
<dimen name="keyguard_eca_top_margin">18dp</dimen>
<dimen name="keyguard_eca_bottom_margin">12dp</dimen>
<!-- EmergencyCarrierArea overlap - amount to overlap the emergency button and carrier text.
Should be 0 on devices with plenty of room (e.g. tablets) -->
<dimen name="eca_overlap">-10dip</dimen>
<!-- Slice header -->
<dimen name="widget_title_font_size">20dp</dimen>
<dimen name="widget_title_line_height">24dp</dimen>

View File

@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="?attr/colorControlNormal">
<path
android:fillColor="@android:color/white"
android:pathData="M20,17.175 L18,15.175V4Q18,4 18,4Q18,4 18,4H10.85L8.85,6L7.4,4.6L10,2H18Q18.825,2 19.413,2.587Q20,3.175 20,4ZM20.5,23.3 L6,8.8V20Q6,20 6,20Q6,20 6,20H18Q18,20 18,20Q18,20 18,20V17.975L20,19.975V20Q20,20.825 19.413,21.413Q18.825,22 18,22H6Q5.175,22 4.588,21.413Q4,20.825 4,20V8L4.6,7.4L0.7,3.5L2.125,2.1L21.9,21.875ZM13.525,10.675Q13.525,10.675 13.525,10.675Q13.525,10.675 13.525,10.675ZM11.65,14.475Q11.65,14.475 11.65,14.475Q11.65,14.475 11.65,14.475Q11.65,14.475 11.65,14.475Q11.65,14.475 11.65,14.475Z"/>
</vector>

View File

@@ -0,0 +1,54 @@
/*
* Copyright (C) 2022 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.keyguard
import android.content.Context
import android.util.AttributeSet
import android.widget.ImageView
import androidx.core.graphics.drawable.DrawableCompat
import com.android.systemui.R
abstract class KeyguardSimInputView(context: Context, attrs: AttributeSet) :
KeyguardPinBasedInputView(context, attrs) {
private var simImageView: ImageView? = null
private var disableESimButton: KeyguardEsimArea? = null
override fun onFinishInflate() {
simImageView = findViewById(R.id.keyguard_sim)
disableESimButton = findViewById(R.id.keyguard_esim_area)
super.onFinishInflate()
}
/** Set UI state based on whether there is a locked eSim card */
fun setESimLocked(isESimLocked: Boolean, subId: Int) {
disableESimButton?.setSubscriptionId(subId)
disableESimButton?.visibility = if (isESimLocked) VISIBLE else GONE
simImageView?.visibility = if (isESimLocked) GONE else VISIBLE
}
override fun reloadColors() {
super.reloadColors()
val customAttrs = intArrayOf(android.R.attr.textColorSecondary)
val a = context.obtainStyledAttributes(customAttrs)
val imageColor = a.getColor(0, 0)
a.recycle()
simImageView?.let {
val wrappedDrawable = DrawableCompat.wrap(it.drawable)
DrawableCompat.setTint(wrappedDrawable, imageColor)
}
}
}

View File

@@ -18,21 +18,14 @@ package com.android.keyguard;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import androidx.core.graphics.drawable.DrawableCompat;
import com.android.systemui.R;
/**
* Displays a PIN pad for unlocking.
*/
public class KeyguardSimPinView extends KeyguardPinBasedInputView {
private ImageView mSimImageView;
public class KeyguardSimPinView extends KeyguardSimInputView {
public static final String TAG = "KeyguardSimPinView";
public KeyguardSimPinView(Context context) {
@@ -43,12 +36,6 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
super(context, attrs);
}
public void setEsimLocked(boolean locked, int subscriptionId) {
KeyguardEsimArea esimButton = findViewById(R.id.keyguard_esim_area);
esimButton.setSubscriptionId(subscriptionId);
esimButton.setVisibility(locked ? View.VISIBLE : View.GONE);
}
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
@@ -68,7 +55,6 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
@Override
protected void onFinishInflate() {
mSimImageView = findViewById(R.id.keyguard_sim);
super.onFinishInflate();
if (mEcaView instanceof EmergencyCarrierArea) {
@@ -86,17 +72,4 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_sim_pin_unlock);
}
@Override
public void reloadColors() {
super.reloadColors();
int[] customAttrs = {android.R.attr.textColorSecondary};
TypedArray a = getContext().obtainStyledAttributes(customAttrs);
int imageColor = a.getColor(0, 0);
a.recycle();
Drawable wrappedDrawable = DrawableCompat.wrap(mSimImageView.getDrawable());
DrawableCompat.setTint(wrappedDrawable, imageColor);
}
}

View File

@@ -105,7 +105,7 @@ public class KeyguardSimPinViewController
showDefaultMessage();
}
mView.setEsimLocked(KeyguardEsimArea.isEsimLocked(mView.getContext(), mSubId), mSubId);
mView.setESimLocked(KeyguardEsimArea.isEsimLocked(mView.getContext(), mSubId), mSubId);
}
@Override

View File

@@ -19,13 +19,8 @@ package com.android.keyguard;
import static com.android.systemui.util.PluralMessageFormaterKt.icuMessageFormat;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
import androidx.core.graphics.drawable.DrawableCompat;
import com.android.systemui.R;
@@ -33,8 +28,7 @@ import com.android.systemui.R;
/**
* Displays a PIN pad for entering a PUK (Pin Unlock Kode) provided by a carrier.
*/
public class KeyguardSimPukView extends KeyguardPinBasedInputView {
private ImageView mSimImageView;
public class KeyguardSimPukView extends KeyguardSimInputView {
private static final boolean DEBUG = KeyguardConstants.DEBUG;
public static final String TAG = "KeyguardSimPukView";
@@ -86,7 +80,6 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
@Override
protected void onFinishInflate() {
mSimImageView = findViewById(R.id.keyguard_sim);
super.onFinishInflate();
if (mEcaView instanceof EmergencyCarrierArea) {
@@ -104,18 +97,4 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
return getContext().getString(
com.android.internal.R.string.keyguard_accessibility_sim_puk_unlock);
}
@Override
public void reloadColors() {
super.reloadColors();
int[] customAttrs = {android.R.attr.textColorSecondary};
TypedArray a = getContext().obtainStyledAttributes(customAttrs);
int imageColor = a.getColor(0, 0);
a.recycle();
Drawable wrappedDrawable = DrawableCompat.wrap(mSimImageView.getDrawable());
DrawableCompat.setTint(wrappedDrawable, imageColor);
}
}

View File

@@ -30,7 +30,6 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageView;
@@ -173,11 +172,9 @@ public class KeyguardSimPukViewController
if (mShowDefaultMessage) {
showDefaultMessage();
}
boolean isEsimLocked = KeyguardEsimArea.isEsimLocked(mView.getContext(), mSubId);
KeyguardEsimArea esimButton = mView.findViewById(R.id.keyguard_esim_area);
esimButton.setSubscriptionId(mSubId);
esimButton.setVisibility(isEsimLocked ? View.VISIBLE : View.GONE);
mView.setESimLocked(KeyguardEsimArea.isEsimLocked(mView.getContext(), mSubId), mSubId);
mPasswordEntry.requestFocus();
}
}