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

Commit ee151ae4 authored by Tiger's avatar Tiger Committed by Tiger Huang
Browse files

Let WindowInsetsTests support edge-to-edge

This CL lets the activities handle insets properly because apps
targeting V are forced to go edge-to-edge.

This CL also lets the app support dark theme.

Fix: 329647020
Bug: 309578419
Test: Open each activity with or without dark theme, and see if the
      layout and the color are correct.
Change-Id: I159a042e546a60c33bd0e2fb3b66736501386979
parent 869e636a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.google.android.test.windowinsetstests">

    <application android:label="@string/application_title">
    <application android:label="@string/application_title"
                 android:theme="@style/base">
        <activity android:name=".WindowInsetsTestsMainActivity"
                  android:exported="true">
            <intent-filter>
@@ -29,11 +30,9 @@

        <activity android:name=".ChatActivity"
                  android:label="@string/chat_activity_title"
                  android:theme="@style/chat"
                  android:windowSoftInputMode="adjustResize" />

        <activity android:name=".ControllerActivity"
                  android:label="@string/controller_activity_title"
                  android:theme="@style/controller" />
                  android:label="@string/controller_activity_title" />
    </application>
</manifest>
+101 −83
Original line number Diff line number Diff line
@@ -15,14 +15,29 @@
-->


<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
    />

    <ScrollView
        android:layout_width="match_parent"
            android:layout_height="match_parent">
        android:layout_height="match_parent"
        android:paddingStart="8dp"
        android:paddingEnd="8dp">

        <LinearLayout
            android:id="@+id/content"
            android:layout_width="match_parent"
        android:layout_height="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <Spinner
@@ -37,9 +52,9 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="true"
            android:text="Status Bars Toggle Button"
            android:textOff="Status Bars Invisible"
            android:textOn="Status Bars Visible" />
                android:text="@string/status_bars_toggle_button"
                android:textOff="@string/status_bars_invisible"
                android:textOn="@string/status_bars_visible" />

            <SeekBar
                android:id="@+id/seekBarStatus"
@@ -55,9 +70,9 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="true"
            android:text="Navigation Bars Toggle Button"
            android:textOff="Navigation Bars Invisible"
            android:textOn="Navigation Bars Visible" />
                android:text="@string/navigation_bars_toggle_button"
                android:textOff="@string/navigation_bars_invisible"
                android:textOn="@string/navigation_bars_visible" />

            <SeekBar
                android:id="@+id/seekBarNavigation"
@@ -73,9 +88,9 @@
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:checked="true"
            android:text="IME Toggle Button"
            android:textOff="IME Invisible"
            android:textOn="IME Visible" />
                android:text="@string/ime_toggle_button"
                android:textOff="@string/ime_invisible"
                android:textOn="@string/ime_visible" />

            <SeekBar
                android:id="@+id/seekBarIme"
@@ -97,10 +112,13 @@
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
            android:hint="For testing IME..."
                android:autofillHints="@string/for_testing_ime"
                android:hint="@string/for_testing_ime"
                android:inputType="text"
                android:text="" />

        </LinearLayout>

    </ScrollView>

</LinearLayout>
+27 −11
Original line number Diff line number Diff line
@@ -16,10 +16,24 @@

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
    />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingStart="8dp"
        android:paddingEnd="8dp">

        <Button
            android:id="@+id/chat_button"
            android:layout_width="wrap_content"
@@ -35,3 +49,5 @@
            android:textAllCaps="false"/>

    </LinearLayout>

</LinearLayout>
+43 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2024 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>

    <style name="base" parent="@style/Theme.MaterialComponents">
        <item name="windowActionBar">false</item>
        <item name="windowNoTitle">true</item>

        <item name="colorPrimary">@color/primaryColor</item>
        <item name="colorPrimaryDark">@color/primaryDarkColor</item>
        <item name="colorSecondary">?attr/colorPrimary</item>
        <item name="colorOnSecondary">@color/primaryTextColor</item>

        <!-- Window decor -->
        <item name="android:windowLightStatusBar">false</item>
        <item name="android:windowLightNavigationBar">false</item>

    </style>

    <color name="primaryColor">#639ff9</color>
    <color name="primaryLightColor">#6f6bff</color>
    <color name="primaryDarkColor">#0016bb</color>
    <color name="primaryTextColor">#ffffff</color>

    <color name="bubble">#333333</color>
    <color name="bubble_self">#185abc</color>

</resources>
+10 −0
Original line number Diff line number Diff line
@@ -19,6 +19,16 @@
    <string name="application_title">Window Insets Tests</string>
    <string name="chat_activity_title">New Insets Chat</string>
    <string name="controller_activity_title">Window Insets Controller</string>
    <string name="status_bars_toggle_button">Status Bars Toggle Button</string>
    <string name="status_bars_invisible">Status Bars Invisible</string>
    <string name="status_bars_visible">Status Bars Visible</string>
    <string name="navigation_bars_toggle_button">Navigation Bars Toggle Button</string>
    <string name="navigation_bars_invisible">Navigation Bars Invisible</string>
    <string name="navigation_bars_visible">Navigation Bars Visible</string>
    <string name="ime_toggle_button">IME Bars Toggle Button</string>
    <string name="ime_invisible">IME Bars Invisible</string>
    <string name="ime_visible">IME Bars Visible</string>
    <string name="for_testing_ime">For testing IME&#8230;</string>

    <!-- The item positions should match the flag values respectively. -->
    <string-array name="behaviors">
Loading