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

Commit 1516c287 authored by Yuri Lin's avatar Yuri Lin
Browse files

Rename RadioButtonPreference to SelectorWithWidgetPreference, and add a checkbox styling option.

This rename makes it slightly less confusing to have both radio and checkbox display options. Functionally, this preference was already equivalent to a checkbox (with checking/unchecking functionality managed by the caller); the reason to use this class for settings checkboxes rather than the base CheckBoxPreference is for the added widget functionality.

This change leaves RadioButtonPreference as-is to make it easier to bring google3 uses in without having to be in lockstep, but RadioButtonPreference will be deleted in a future CL.

Test: SelectorWithWidgetPreferenceTest, RunSettingsLibRoboTests
Bug: 190180868

Change-Id: I0811997b4625f1292b1842ea353a90221159bb50
parent 374ed16b
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ android_library {
        "SettingsLibProgressBar",
        "SettingsLibAdaptiveIcon",
        "SettingsLibRadioButtonPreference",
        "SettingsLibSelectorWithWidgetPreference",
        "SettingsLibDisplayDensityUtils",
        "SettingsLibUtils",
        "SettingsLibEmergencyNumber",
+1 −0
Original line number Diff line number Diff line
@@ -15,6 +15,7 @@ android_library {

    static_libs: [
          "androidx.preference_preference",
          "SettingsLibSelectorWithWidgetPreference",
          "SettingsLibSettingsTheme",
    ],

+6 −0
Original line number Diff line number Diff line
@@ -26,6 +26,10 @@ import androidx.preference.CheckBoxPreference;
import androidx.preference.PreferenceViewHolder;

/**
 * DEPRECATED. Please use SelectorWithWidgetPreference instead.
 *
 * This file has been moved there and will be removed once all callers are updated.
 *
 * Check box preference with check box replaced by radio button.
 *
 * Functionally speaking, it's actually a CheckBoxPreference. We only modified
@@ -37,6 +41,8 @@ import androidx.preference.PreferenceViewHolder;
 *
 * RadioButtonPreference can assign a extraWidgetListener to show a gear icon
 * on the right side that can open another page.
 *
 * @Deprecated
 */
public class RadioButtonPreference extends CheckBoxPreference {

+27 −0
Original line number Diff line number Diff line
package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_base_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_base_license"],
}

android_library {
    name: "SettingsLibSelectorWithWidgetPreference",

    srcs: ["src/**/*.java"],
    resource_dirs: ["res"],

    static_libs: [
        "androidx.preference_preference",
        "SettingsLibSettingsTheme",
    ],

    sdk_version: "system_current",
    min_sdk_version: "21",
    apex_available: [
        "//apex_available:platform",
        "com.android.permission",
    ],
}
+23 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  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.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.android.settingslib.widget">

    <uses-sdk android:minSdkVersion="21" />

</manifest>
Loading