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

Commit 2c27029b authored by Priyanka Advani (xWF)'s avatar Priyanka Advani (xWF) Committed by Android (Google) Code Review
Browse files

Merge "Revert "Allow update the max lines on the title"" into main

parents 93c28c54 98e9371e
Loading
Loading
Loading
Loading
+0 −22
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ android_library {
    static_libs: [
        "androidx.preference_preference",
        "SettingsLibSettingsTheme",
        "settingslib_selectorwithwidgetpreference_flags_lib",
    ],

    sdk_version: "system_current",
@@ -31,24 +30,3 @@ android_library {
        "com.android.mediaprovider",
    ],
}

aconfig_declarations {
    name: "settingslib_selectorwithwidgetpreference_flags",
    package: "com.android.settingslib.widget.selectorwithwidgetpreference.flags",
    container: "system",
    srcs: [
        "aconfig/selectorwithwidgetpreference.aconfig",
    ],
}

java_aconfig_library {
    name: "settingslib_selectorwithwidgetpreference_flags_lib",
    aconfig_declarations: "settingslib_selectorwithwidgetpreference_flags",

    min_sdk_version: "30",
    apex_available: [
        "//apex_available:platform",
        "com.android.permission",
        "com.android.mediaprovider",
    ],
}
+0 −13
Original line number Diff line number Diff line
package: "com.android.settingslib.widget.selectorwithwidgetpreference.flags"
container: "system"

flag {
    name: "allow_set_title_max_lines"
    namespace: "accessibility"
    description: "Allow changes to the title max lines so it's not always fixed to 2"
    bug: "356726764"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+0 −22
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>
    <declare-styleable name="SelectorWithWidgetPreference">
        <!-- The maximum number of lines for rendering the title. -->
        <attr name="titleMaxLines" format="integer" />
    </declare-styleable>
</resources>
 No newline at end of file
+5 −33
Original line number Diff line number Diff line
@@ -17,21 +17,15 @@
package com.android.settingslib.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.preference.CheckBoxPreference;
import androidx.preference.PreferenceViewHolder;

import com.android.settingslib.widget.preference.selector.R;
import com.android.settingslib.widget.selectorwithwidgetpreference.flags.Flags;

/**
 * Selector preference (checkbox or radio button) with an optional additional widget.
@@ -47,8 +41,6 @@ import com.android.settingslib.widget.selectorwithwidgetpreference.flags.Flags;
 * on the right side that can open another page.
 */
public class SelectorWithWidgetPreference extends CheckBoxPreference {
    @VisibleForTesting
    static final int DEFAULT_MAX_LINES = 2;

    /**
     * Interface definition for a callback to be invoked when the preference is clicked.
@@ -71,8 +63,6 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
    private boolean mIsCheckBox = false;  // whether to display this button as a checkbox

    private View.OnClickListener mExtraWidgetOnClickListener;
    private int mTitleMaxLines;


    /**
     * Perform inflation from XML and apply a class-specific base style.
@@ -84,10 +74,9 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
     *                 resource that supplies default values for the view. Can be 0 to not
     *                 look for defaults.
     */
    public SelectorWithWidgetPreference(@NonNull Context context, @Nullable AttributeSet attrs,
            int defStyle) {
    public SelectorWithWidgetPreference(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init(context, attrs, defStyle, /* defStyleRes= */ 0);
        init();
    }

    /**
@@ -99,7 +88,7 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
     */
    public SelectorWithWidgetPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context, attrs, /* defStyleAttr= */ 0, /* defStyleRes= */ 0);
        init();
    }

    /**
@@ -111,7 +100,7 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
    public SelectorWithWidgetPreference(Context context, boolean isCheckbox) {
        super(context, null);
        mIsCheckBox = isCheckbox;
        init(context, /* attrs= */ null, /* defStyleAttr= */ 0, /* defStyleRes= */ 0);
        init();
    }

    /**
@@ -172,11 +161,6 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
        mExtraWidgetContainer = holder.findViewById(R.id.selector_extra_widget_container);

        setExtraWidgetOnClickListener(mExtraWidgetOnClickListener);

        if (Flags.allowSetTitleMaxLines()) {
            TextView title = (TextView) holder.findViewById(android.R.id.title);
            title.setMaxLines(mTitleMaxLines);
        }
    }

    /**
@@ -216,8 +200,7 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
        return mIsCheckBox;
    }

    private void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr,
            int defStyleRes) {
    private void init() {
        if (mIsCheckBox) {
            setWidgetLayoutResource(R.layout.preference_widget_checkbox);
        } else {
@@ -225,16 +208,5 @@ public class SelectorWithWidgetPreference extends CheckBoxPreference {
        }
        setLayoutResource(R.layout.preference_selector_with_widget);
        setIconSpaceReserved(false);

        if (Flags.allowSetTitleMaxLines()) {
            final TypedArray a =
                    context.obtainStyledAttributes(
                            attrs, R.styleable.SelectorWithWidgetPreference, defStyleAttr,
                            defStyleRes);
            mTitleMaxLines =
                    a.getInt(R.styleable.SelectorWithWidgetPreference_titleMaxLines,
                            DEFAULT_MAX_LINES);
            a.recycle();
        }
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ android_robolectric_test {
        "flag-junit",
        "settingslib_media_flags_lib",
        "settingslib_illustrationpreference_flags_lib",
        "settingslib_selectorwithwidgetpreference_flags_lib",
        "testng", // TODO: remove once JUnit on Android provides assertThrows
    ],
    java_resource_dirs: ["config"],
Loading