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

Commit fae27ef2 authored by Alejandro Nijamkin's avatar Alejandro Nijamkin
Browse files

Fancy animation for quick affordance option picker

Building on the companion WallpaperPicker2, this CL achieves a refactor
that allows the UI to actually animate user selection of quick
affordance items.

Part of this CL is a refactor that extracts out an "option item
framework" out into the WallpaperPicker2 code repository (please see the
other CL for thate).

Another part of this CL is a heavy refactor of
KeyguardQuickAffordancePickerViewModel which is the main view-model for
the "shortcuts" full-screen experience. Namely, we had to change it to
emit a stable list of option items (one for each lock screen shortcut)
where the _contents_ of it can change (namely, isSelected, onSelected
have both become flows). This required some careful restructuring of the
logic that populate the quickAffordances flow in that class.

Fix: 266116562
Test: existing view-model integration test updated to match new field
types, still passes without logical changes to the test
Test: manually verified the correctness of the UI in Walpaper & style >
Shortcuts
Test: manually verified animations: they do not happen when switching
tabs, they do not happen on initial load. They do happen when I select a
new affordance (both on the newly-selected one and the
previously-selected one).

Change-Id: I985afdfbbc72d0b98859df3378f2c90d2397e7d4
parent 906d65e2
Loading
Loading
Loading
Loading
+0 −20
Original line number Original line Diff line number Diff line
<!--
     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.
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="20dp" />
    <solid android:color="@color/color_surface_variant" />
</shape>
+0 −48
Original line number Original line Diff line number Diff line
<!--
     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.
-->
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    >

    <item
        android:left="6dp"
        android:top="6dp"
        android:right="6dp"
        android:bottom="6dp"
        >
        <shape
            android:layout_width="wrap_content"
            android:shape="rectangle">

            <solid android:color="@color/color_surface_variant" />

            <corners android:radius="14dp" />

        </shape>
    </item>

    <item>
        <shape android:shape="rectangle" >

            <stroke
                android:width="2dp"
                android:color="@color/text_color_primary" />

            <corners android:radius="20dp" />

        </shape>
    </item>
</layer-list>
+8 −4
Original line number Original line Diff line number Diff line
@@ -18,7 +18,8 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    android:orientation="vertical"
    android:clipChildren="false">


    <FrameLayout
    <FrameLayout
        android:id="@+id/section_header_container"
        android:id="@+id/section_header_container"
@@ -53,7 +54,8 @@
        android:layout_marginBottom="28dp"
        android:layout_marginBottom="28dp"
        android:background="@drawable/picker_fragment_background"
        android:background="@drawable/picker_fragment_background"
        android:paddingTop="22dp"
        android:paddingTop="22dp"
        android:paddingBottom="62dp">
        android:paddingBottom="62dp"
        android:clipChildren="false">


        <FrameLayout
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_width="match_parent"
@@ -91,14 +93,16 @@


        <FrameLayout
        <FrameLayout
            android:layout_width="match_parent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            android:layout_height="wrap_content"
            android:clipChildren="false">


            <androidx.recyclerview.widget.RecyclerView
            <androidx.recyclerview.widget.RecyclerView
                android:id="@id/affordances"
                android:id="@id/affordances"
                android:layout_width="match_parent"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_height="wrap_content"
                android:clipToPadding="false"
                android:clipToPadding="false"
                android:paddingHorizontal="16dp" />
                android:paddingHorizontal="16dp"
                android:clipChildren="false" />


            <!--
            <!--
            This is just an invisible placeholder put in place so that the parent keeps its height
            This is just an invisible placeholder put in place so that the parent keeps its height
+22 −6
Original line number Original line Diff line number Diff line
@@ -22,15 +22,31 @@
    android:layout_width="@dimen/keyguard_quick_affordance_picker_item_width"
    android:layout_width="@dimen/keyguard_quick_affordance_picker_item_width"
    android:layout_height="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:orientation="vertical"
    android:gravity="center_horizontal">
    android:gravity="center_horizontal"
    android:clipChildren="false">


    <FrameLayout
    <FrameLayout
        android:id="@+id/icon_container"
        android:layout_width="@dimen/keyguard_quick_affordance_icon_container_size"
        android:layout_width="@dimen/keyguard_quick_affordance_icon_container_size"
        android:layout_height="@dimen/keyguard_quick_affordance_icon_container_size" >
        android:layout_height="@dimen/keyguard_quick_affordance_icon_container_size"
        android:clipChildren="false">


        <ImageView
        <ImageView
            android:id="@+id/icon"
            android:id="@id/selection_border"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/option_item_border"
            android:alpha="0"
            android:importantForAccessibility="no" />

        <ImageView
            android:id="@id/background"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/option_item_background"
            android:importantForAccessibility="no" />

        <ImageView
            android:id="@id/foreground"
            android:layout_width="@dimen/keyguard_quick_affordance_icon_size"
            android:layout_width="@dimen/keyguard_quick_affordance_icon_size"
            android:layout_height="@dimen/keyguard_quick_affordance_icon_size"
            android:layout_height="@dimen/keyguard_quick_affordance_icon_size"
            android:layout_gravity="center"
            android:layout_gravity="center"
@@ -43,7 +59,7 @@
        android:layout_height="8dp" />
        android:layout_height="8dp" />


    <TextView
    <TextView
        android:id="@+id/name"
        android:id="@id/text"
        android:layout_width="wrap_content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/text_color_primary"
        android:textColor="@color/text_color_primary"
+0 −10
Original line number Original line Diff line number Diff line
@@ -63,16 +63,6 @@ class KeyguardQuickAffordancePickerInteractor(
        snapshotRestorer.get().storeSnapshot()
        snapshotRestorer.get().storeSnapshot()
    }
    }


    /** Unselects an affordance with the given ID from the slot with the given ID. */
    suspend fun unselect(slotId: String, affordanceId: String) {
        client.deleteSelection(
            slotId = slotId,
            affordanceId = affordanceId,
        )

        snapshotRestorer.get().storeSnapshot()
    }

    /** Unselects all affordances from the slot with the given ID. */
    /** Unselects all affordances from the slot with the given ID. */
    suspend fun unselectAll(slotId: String) {
    suspend fun unselectAll(slotId: String) {
        client.deleteAllSelections(
        client.deleteAllSelections(
Loading