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

Commit 459150e4 authored by Edgar Wang's avatar Edgar Wang
Browse files

[Expressive design] update TwoTargetPreference

Bug: 366340960
Test: manual
Flag: EXEMPT resource only update
Change-Id: I3bcde6b6e4d98e1f5077d81e70817eceb75f39e5
parent 62f02f7b
Loading
Loading
Loading
Loading
+28 −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.
  -->

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="18dp"
    android:height="18dp"
    android:viewportWidth="960"
    android:viewportHeight="960"
    android:tint="@color/settingslib_materialColorOnSurfaceVariant"
    android:autoMirrored="true">
    <path
        android:fillColor="@android:color/white"
        android:pathData="M321,880L250,809L579,480L250,151L321,80L721,480L321,880Z"/>
</vector>
 No newline at end of file
+39 −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.
  -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/two_target_divider"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="start|center_vertical"
    android:orientation="horizontal"
    android:paddingStart="?android:attr/listPreferredItemPaddingEnd"
    android:paddingLeft="?android:attr/listPreferredItemPaddingEnd"
    android:paddingVertical="@dimen/settingslib_expressive_space_extrasmall7">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingEnd="@dimen/settingslib_expressive_space_extrasmall6"
        android:src="@drawable/settingslib_expressive_icon_chevron"/>

    <View
        android:layout_width="1dp"
        android:layout_height="40dp"
        android:background="?android:attr/listDivider" />
</LinearLayout>
 No newline at end of file
+44 −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.
  -->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:gravity="center_vertical"
    android:background="?android:attr/selectableItemBackground"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:clipToPadding="false">

    <include layout="@layout/settingslib_expressive_preference_icon_frame"/>

    <include layout="@layout/settingslib_expressive_preference_text_frame" />

    <include layout="@layout/settingslib_expressive_two_target_divider" />

    <!-- Preference should place its actual preference widget here. -->
    <LinearLayout
        android:id="@android:id/widget_frame"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:minWidth="@dimen/two_target_min_width"
        android:gravity="center"
        android:orientation="vertical" />

</LinearLayout>
+4 −1
Original line number Diff line number Diff line
@@ -72,7 +72,10 @@ public class TwoTargetPreference extends Preference {
    }

    private void init(Context context) {
        setLayoutResource(R.layout.preference_two_target);
        int resID = SettingsThemeHelper.isExpressiveTheme(context)
                ? R.layout.settingslib_expressive_preference_two_target
                : R.layout.preference_two_target;
        setLayoutResource(resID);
        mSmallIconSize = context.getResources().getDimensionPixelSize(
                R.dimen.two_target_pref_small_icon_size);
        mMediumIconSize = context.getResources().getDimensionPixelSize(
+5 −1
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import androidx.preference.PreferenceViewHolder;

import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.core.instrumentation.SettingsJankMonitor;
import com.android.settingslib.widget.SettingsThemeHelper;
import com.android.settingslib.widget.theme.R;

/**
 * A custom preference that provides inline switch toggle. It has a mandatory field for title, and
@@ -62,7 +64,9 @@ public class PrimarySwitchPreference extends RestrictedPreference {

    @Override
    protected int getSecondTargetResId() {
        return androidx.preference.R.layout.preference_widget_switch_compat;
        return SettingsThemeHelper.isExpressiveTheme(getContext())
                ? R.layout.settingslib_expressive_preference_switch
                : androidx.preference.R.layout.preference_widget_switch_compat;
    }

    @Override