Create SettingsLibTwoTargetPreference
Bug: 180156703 Test: robotest Change-Id: I4a9958efa47ac24f88e06c8fdb1c9d0a5542e360
This commit is contained in:
@@ -17,8 +17,8 @@ android_library {
|
||||
|
||||
// TODO(b/149540986): revert this change.
|
||||
static_libs: [
|
||||
// All other dependent components should be put in
|
||||
// "SettingsLibDependenciesWithoutWifiTracker".
|
||||
// All other dependent components should be put in
|
||||
// "SettingsLibDependenciesWithoutWifiTracker".
|
||||
"WifiTrackerLib",
|
||||
],
|
||||
|
||||
@@ -27,7 +27,10 @@ android_library {
|
||||
|
||||
resource_dirs: ["res"],
|
||||
|
||||
srcs: ["src/**/*.java", "src/**/*.kt"],
|
||||
srcs: [
|
||||
"src/**/*.java",
|
||||
"src/**/*.kt",
|
||||
],
|
||||
|
||||
min_sdk_version: "21",
|
||||
|
||||
@@ -67,6 +70,7 @@ java_defaults {
|
||||
"SettingsLibFooterPreference",
|
||||
"SettingsLibUsageProgressBarPreference",
|
||||
"SettingsLibCollapsingToolbarBaseActivity",
|
||||
"SettingsLibTwoTargetPreference",
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
13
packages/SettingsLib/TwoTargetPreference/Android.bp
Normal file
13
packages/SettingsLib/TwoTargetPreference/Android.bp
Normal file
@@ -0,0 +1,13 @@
|
||||
android_library {
|
||||
name: "SettingsLibTwoTargetPreference",
|
||||
|
||||
srcs: ["src/**/*.java"],
|
||||
resource_dirs: ["res"],
|
||||
|
||||
static_libs: [
|
||||
"androidx.annotation_annotation",
|
||||
"androidx.preference_preference",
|
||||
],
|
||||
sdk_version: "system_current",
|
||||
min_sdk_version: "21",
|
||||
}
|
||||
23
packages/SettingsLib/TwoTargetPreference/AndroidManifest.xml
Normal file
23
packages/SettingsLib/TwoTargetPreference/AndroidManifest.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
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.
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2017 The Android Open Source Project
|
||||
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.
|
||||
@@ -0,0 +1,21 @@
|
||||
<?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
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<dimen name="two_target_pref_small_icon_size">24dp</dimen>
|
||||
<dimen name="two_target_pref_medium_icon_size">32dp</dimen>
|
||||
</resources>
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -14,21 +14,24 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settingslib;
|
||||
package com.android.settingslib.widget;
|
||||
|
||||
import android.annotation.IntDef;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* The Base preference with two target areas divided by a vertical divider
|
||||
*/
|
||||
public class TwoTargetPreference extends Preference {
|
||||
|
||||
@IntDef({ICON_SIZE_DEFAULT, ICON_SIZE_MEDIUM, ICON_SIZE_SMALL})
|
||||
@@ -32,9 +32,6 @@
|
||||
<dimen name="user_spinner_padding_sides">20dp</dimen>
|
||||
<dimen name="user_spinner_item_height">56dp</dimen>
|
||||
|
||||
<dimen name="two_target_pref_small_icon_size">24dp</dimen>
|
||||
<dimen name="two_target_pref_medium_icon_size">32dp</dimen>
|
||||
|
||||
<!-- Lock icon for preferences locked by admin -->
|
||||
<dimen name="restricted_icon_padding">4dp</dimen>
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import androidx.core.content.res.TypedArrayUtils;
|
||||
import androidx.preference.PreferenceManager;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.widget.TwoTargetPreference;
|
||||
|
||||
/**
|
||||
* Preference class that supports being disabled by a user restriction
|
||||
* set by a device admin.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
* 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.
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settingslib;
|
||||
package com.android.settingslib.widget;
|
||||
|
||||
import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_DEFAULT;
|
||||
import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_MEDIUM;
|
||||
import static com.android.settingslib.TwoTargetPreference.ICON_SIZE_SMALL;
|
||||
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_DEFAULT;
|
||||
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_MEDIUM;
|
||||
import static com.android.settingslib.widget.TwoTargetPreference.ICON_SIZE_SMALL;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -32,6 +32,8 @@ import android.widget.LinearLayout;
|
||||
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
import com.android.settingslib.R;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
Reference in New Issue
Block a user