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

Commit b634e142 authored by Jamie Garside's avatar Jamie Garside Committed by Automerger Merge Worker
Browse files

Merge "Make KeyguardBouncer react to device config changes." into sc-dev am: c5b1339d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13776618

Change-Id: I2f910c61500d018785d143811a781fff3111cd29
parents e8f29730 c5b1339d
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@
    android:clipToPadding="false">

    <include
        style="@style/BouncerSecurityContainer"
        layout="@layout/keyguard_host_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
+9 −7
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2014 The Android Open Source Project
  ~ Copyright (C) 2021 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.
@@ -11,11 +12,12 @@
  ~ 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
  ~ limitations under the License.
  -->

<resources>
    <style name="BouncerSecurityContainer">
        <item name="android:layout_gravity">center</item>
    </style>
    <!-- This needs to be specified in an integer, rather than a style, as it can change in response
         to device config changes, and we need to be able to change it without re-inflation.

         0x11 = center -->
    <integer name="keyguard_host_view_gravity">0x11</integer>
</resources>
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2021 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.
  -->
<resources>
    <!-- This needs to be specified in an integer, rather than a style, as it can change in response
         to device config changes, and we need to be able to change it without re-inflation.

         0x50 = bottom, 0x01 = center_horizontal -->
    <integer name="keyguard_host_view_gravity">0x51</integer>
</resources>
+0 −4
Original line number Diff line number Diff line
@@ -100,10 +100,6 @@
        <item name="android:shadowRadius">?attr/shadowRadius</item>
    </style>

    <style name="BouncerSecurityContainer">
        <item name="android:layout_gravity">center_horizontal|bottom</item>
    </style>

    <style name="PasswordTheme" parent="Theme.SystemUI">
        <item name="android:textColor">?android:attr/textColorPrimary</item>
        <item name="android:colorControlNormal">?android:attr/textColorPrimary</item>
+21 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;

import com.android.keyguard.KeyguardSecurityContainer.SecurityCallback;
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
@@ -180,6 +181,7 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
    /** Initialize the Controller. */
    public void onInit() {
        mKeyguardSecurityContainerController.init();
        updateResources();
    }

    @Override
@@ -467,5 +469,23 @@ public class KeyguardHostViewController extends ViewController<KeyguardHostView>
        mSecurityCallback.finish(strongAuth, currentUser);
    }

    /**
     * Apply keyguard configuration from the currently active resources. This can be called when the
     * device configuration changes, to re-apply some resources that are qualified on the device
     * configuration.
     */
    public void updateResources() {
        int gravity = mView.getResources().getInteger(R.integer.keyguard_host_view_gravity);

        // Android SysUI uses a FrameLayout as the top-level, but Auto uses RelativeLayout.
        // We're just changing the gravity here though (which can't be applied to RelativeLayout),
        // so only attempt the update if mView is inside a FrameLayout.
        if (mView.getLayoutParams() instanceof FrameLayout.LayoutParams) {
            FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mView.getLayoutParams();
            if (lp.gravity != gravity) {
                lp.gravity = gravity;
                mView.setLayoutParams(lp);
            }
        }
    }
}
Loading