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

Commit 77e732a1 authored by Sunny Goyal's avatar Sunny Goyal
Browse files

Moving widget background to xml, so that the same constantstate is

used for all entries

This helps reduce launcher memory by avoiding multuple duplicate
drawable generation

Bug: 268646258
Test: Verified on device
Change-Id: I829750f081cfce65063b35a614b903066d9a4bed
parent 5147b1d5
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
       L -> large radius
       s -> small radius
       0 -> no radiuls
    -->

    <!-- MIDDLE : 0 0 s s -->
    <item android:state_middle="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="0dp"
                android:topRightRadius="0dp"
                android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
        </shape>
    </item>

    <!-- LAST : 0 0 L L -->
    <item android:state_last="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="0dp"
                android:topRightRadius="0dp"
                android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
        </shape>
    </item>
</selector>
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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"
    android:insetTop="@dimen/widget_list_entry_spacing" >
    <ripple
        android:color="?android:attr/colorControlHighlight"
        android:paddingTop="@dimen/widget_list_header_view_vertical_padding"
        android:paddingBottom="@dimen/widget_list_header_view_vertical_padding" >
        <item android:id="@android:id/mask"
            android:drawable="@drawable/bg_widgets_header_states" />
        <item android:drawable="@drawable/bg_widgets_header_states" />
    </ripple>
</inset>
 No newline at end of file
+95 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2023 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.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <!--
       L -> large radius
       s -> small radius
       0 -> no radiuls
    -->

    <!-- SINGLE : L L L L -->
    <item android:state_single="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
        </shape>
    </item>

    <!-- FIRST_EXPANDED : L L 0 0 -->
    <item android:state_first="true" android:state_expanded="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomLeftRadius="0dp"
                android:bottomRightRadius="0dp" />
        </shape>
    </item>

    <!-- FIRST : L L s s -->
    <item android:state_first="true" >
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:topRightRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
        </shape>
    </item>

    <!-- MIDDLE_EXPANDED : s s 0 0 -->
    <item android:state_middle="true" android:state_expanded="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_content_corner_radius"
                android:topRightRadius="@dimen/widget_list_content_corner_radius"
                android:bottomLeftRadius="0dp"
                android:bottomRightRadius="0dp" />
        </shape>
    </item>

    <!-- MIDDLE : s s s s -->
    <item android:state_middle="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_content_corner_radius"
                android:topRightRadius="@dimen/widget_list_content_corner_radius"
                android:bottomLeftRadius="@dimen/widget_list_content_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_content_corner_radius" />
        </shape>
    </item>

    <!-- LAST : s s L L -->
    <item android:state_last="true">
        <shape android:shape="rectangle">
            <solid android:color="@color/surface" />
            <corners
                android:topLeftRadius="@dimen/widget_list_content_corner_radius"
                android:topRightRadius="@dimen/widget_list_content_corner_radius"
                android:bottomLeftRadius="@dimen/widget_list_top_bottom_corner_radius"
                android:bottomRightRadius="@dimen/widget_list_top_bottom_corner_radius" />
        </shape>
    </item>
</selector>
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@
     limitations under the License.
-->
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true"
    <item android:state_expanded="true"
        android:drawable="@drawable/ic_expand_less" />
    <item android:state_checked="false"
    <item android:state_expanded="false"
        android:drawable="@drawable/ic_expand_more" />
</selector>
+7 −4
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@
    android:importantForAccessibility="yes"
    android:focusable="true"
    launcher:appIconSize="48dp"
    android:descendantFocusability="afterDescendants">
    android:descendantFocusability="afterDescendants"
    android:background="@drawable/bg_widgets_header" >

    <ImageView
        android:id="@+id/app_icon"
@@ -65,8 +66,11 @@

    <!-- This checkbox is not clickable. The outermost LinearLayout is responsible to handle all
         click event and update the checkbox state. -->
    <CheckBox
    <ImageView
        android:duplicateParentState="true"
        android:id="@+id/toggle"
        android:alpha=".6"
        android:src="@drawable/widgets_tray_expand_button"
        android:layout_marginHorizontal="16dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
@@ -74,7 +78,6 @@
        android:layout_alignParentEnd="true"
        android:enabled="false"
        android:clickable="false"
        android:importantForAccessibility="no"
        android:button="@drawable/widgets_tray_expand_button"/>
        android:importantForAccessibility="no" />

</com.android.launcher3.widget.picker.WidgetsListHeader>
 No newline at end of file
Loading