Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ff0a189 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Improve layout of MSIM SIM PIN/PUK keyguard views.

Put the SIM name to the right of the SIM icon instead of under it, and
add some reasonable padding.

Change-Id: I7d466b28e1cb3ef27701d387ffd87cf9df408284
parent 3a580aae
Loading
Loading
Loading
Loading
+16 −27
Original line number Diff line number Diff line
@@ -29,43 +29,32 @@
        android:gravity="center_horizontal"
        android:contentDescription="@string/keyguard_accessibility_pin_unlock">

    <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_lockscreen_sim"/>
    <LinearLayout
       android:id="@+id/sim_info_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal"
        android:visibility="gone">
        <TextView
            android:id="@+id/slot_id_name"
        android:orientation="horizontal">

        <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:ellipsize="marquee"
            android:singleLine="true"
            android:textDirection = "locale"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp"
            />
                android:src="@drawable/ic_lockscreen_sim"/>

        <TextView
            android:id="@+id/sub_display_name"
            android:id="@+id/sim_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:ellipsize="middle"
            android:maxWidth="110dip"
            android:layout_gravity="center_vertical"
            android:layout_marginStart="16dp"
            android:visibility="gone"
            android:padding="@dimen/sim_card_name_padding"
            android:singleLine="true"
            android:textDirection = "locale"
            android:ellipsize="marquee"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp"
            />
            android:textColor="?android:attr/textColorPrimary" />

    </LinearLayout>

    <include layout="@layout/keyguard_message_area"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+16 −28
Original line number Diff line number Diff line
@@ -29,44 +29,32 @@
        androidprv:layout_maxHeight="@dimen/keyguard_security_max_height"
        android:gravity="center_horizontal">

    <ImageView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_lockscreen_sim"/>
    <LinearLayout
       android:id="@+id/sim_info_message"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_gravity="center_horizontal"
        android:visibility="gone"
        >
        <TextView
            android:id="@+id/slot_id_name"
        android:orientation="horizontal">

        <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:ellipsize="marquee"
            android:singleLine="true"
            android:textDirection = "locale"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp"
            />
                android:src="@drawable/ic_lockscreen_sim"/>

        <TextView
            android:id="@+id/sub_display_name"
            android:id="@+id/sim_name"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:ellipsize="middle"
            android:maxWidth="110dip"
            android:layout_gravity="center_vertical"
            android:layout_marginStart="16dp"
            android:visibility="gone"
            android:padding="@dimen/sim_card_name_padding"
            android:singleLine="true"
            android:textDirection = "locale"
            android:ellipsize="marquee"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="?android:attr/textColorPrimary"
            android:textSize="16sp"
            />
            android:textColor="?android:attr/textColorPrimary" />

    </LinearLayout>

    <include layout="@layout/keyguard_message_area"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+3 −4
Original line number Diff line number Diff line
@@ -178,8 +178,7 @@

    <!-- The translation for disappearing security views after having solved them. -->
    <dimen name="disappear_y_translation">-32dp</dimen>
    <!-- For SIM card detection info text max width in SIM card changed dialog -->
    <dimen name="sim_card_name_maxwidth">100dip</dimen>
    <!-- For SIM card name padding in SIM pin/puk unlock and SIM card changed dialog -->
    <dimen name="sim_card_name_padding">6dip</dimen>

    <!-- The padding around the SIM card name -->
    <dimen name="sim_card_name_padding">4dip</dimen>
</resources>
+16 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.keyguard;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.KeyEvent;
@@ -211,4 +212,19 @@ public abstract class KeyguardPinBasedInputView extends KeyguardAbsKeyInputView
        }
        return false;
    }

    protected void applyPaddingToView(View view, int paddingDimenResId) {
        final Rect backgroundPadding = new Rect();

        if (view.getBackground() != null) {
            view.getBackground().getPadding(backgroundPadding);
        }

        final Resources res = getContext().getResources();
        final int defaultPadding = res.getDimensionPixelSize(paddingDimenResId);
        view.setPadding(backgroundPadding.left + defaultPadding,
                backgroundPadding.top + defaultPadding,
                backgroundPadding.right + defaultPadding,
                backgroundPadding.bottom + defaultPadding);
    }
}
+19 −35
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.graphics.drawable.Drawable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.AttributeSet;
@@ -55,7 +54,7 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    private AlertDialog mRemainingAttemptsDialog;
    KeyguardUpdateMonitor mKgUpdateMonitor;
    private long mSubId = SubscriptionManager.INVALID_SUB_ID;
    private TextView mSubDisplayName = null;
    private TextView mSubNameView;

    private KeyguardUpdateMonitorCallback mUpdateCallback = new KeyguardUpdateMonitorCallback() {
        @Override
@@ -143,14 +142,10 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    protected void onFinishInflate() {
        super.onFinishInflate();

        mSubDisplayName = (TextView) findViewById(R.id.sub_display_name);
        mSubNameView = (TextView) findViewById(R.id.sim_name);
        mSubId = mKgUpdateMonitor.getSimPinLockSubId();
        if (mKgUpdateMonitor.getNumPhones() > 1) {

            View simInfoMsg = findViewById(R.id.sim_info_message);
            if (simInfoMsg != null) {
                simInfoMsg.setVisibility(View.VISIBLE);
            }
            mSubNameView.setVisibility(View.VISIBLE);
            handleSubInfoChange();
        }

@@ -350,39 +345,28 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
    }

    private void handleSubInfoChange() {
        String displayName = null;
        //get Display Name
        SubInfoRecord info = SubscriptionManager.getSubInfoForSubscriber(mSubId);
        if (null != info) {
        final String displayName;

        if (info != null && info.displayName != null) {
            displayName = info.displayName;
        } else {
            displayName = mContext.getString(R.string.kg_slot_name,
                    SubscriptionManager.getSlotId(mSubId) + 1);
        }

        if (DEBUG) Log.i(TAG, "handleSubInfoChange, mSubId=" + mSubId +
                ", displayName=" + displayName);
        mSubNameView.setText(displayName);

        TextView slotName = (TextView)findViewById(R.id.slot_id_name);
        //Set slot display name
        if (null == displayName) {//display name not yet configured.
            if (DEBUG) Log.d(TAG, "mSubId " + mSubId + ": New Card Inserted");
            slotName.setText(mContext.getString(R.string.kg_slot_name,
                    SubscriptionManager.getSlotId(mSubId) + 1));
            slotName.setVisibility(View.VISIBLE);
            mSubDisplayName.setVisibility(View.GONE);
        if (info != null && info.simIconRes[0] != 0) {
            mSubNameView.setBackgroundResource(info.simIconRes[0]);
        } else {
            if (DEBUG) Log.d(TAG, "handleSubInfoChange, refresh Sub Info for mSubId=" + mSubId);
            Drawable bgDrawable = null;
            if (null != info) {
                if (info.simIconRes[0] > 0) {
                    bgDrawable = getContext().getResources().getDrawable(info.simIconRes[0]);
                }
            }
            mSubDisplayName.setBackground(bgDrawable);
            int simCardNamePadding = getContext().getResources().
                                getDimensionPixelSize(R.dimen.sim_card_name_padding);
            mSubDisplayName.setPadding(simCardNamePadding, 0, simCardNamePadding, 0);
            mSubDisplayName.setText(displayName);
            mSubDisplayName.setVisibility(View.VISIBLE);
            slotName.setVisibility(View.GONE);
            mSubNameView.setBackground(null);
        }
        // Setting the background modifies the padding of the view in case the drawable
        // itself contains padding, so make sure to preserve our padding
        applyPaddingToView(mSubNameView, R.dimen.sim_card_name_padding);
    }

    private void showDefaultMessage() {
Loading