diff options
10 files changed, 81 insertions, 16 deletions
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp index f2a0e1cb83bd..68ce7d963242 100644 --- a/packages/SettingsLib/Android.bp +++ b/packages/SettingsLib/Android.bp @@ -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", ], } diff --git a/packages/SettingsLib/TwoTargetPreference/Android.bp b/packages/SettingsLib/TwoTargetPreference/Android.bp new file mode 100644 index 000000000000..f2e79b9ab53b --- /dev/null +++ b/packages/SettingsLib/TwoTargetPreference/Android.bp @@ -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", +} diff --git a/packages/SettingsLib/TwoTargetPreference/AndroidManifest.xml b/packages/SettingsLib/TwoTargetPreference/AndroidManifest.xml new file mode 100644 index 000000000000..120b0859a70a --- /dev/null +++ b/packages/SettingsLib/TwoTargetPreference/AndroidManifest.xml @@ -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> diff --git a/packages/SettingsLib/res/layout/preference_two_target.xml b/packages/SettingsLib/TwoTargetPreference/res/layout/preference_two_target.xml index ff6a22d5523c..21fcedcc01b6 100644 --- a/packages/SettingsLib/res/layout/preference_two_target.xml +++ b/packages/SettingsLib/TwoTargetPreference/res/layout/preference_two_target.xml @@ -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. diff --git a/packages/SettingsLib/res/layout/preference_two_target_divider.xml b/packages/SettingsLib/TwoTargetPreference/res/layout/preference_two_target_divider.xml index b81dd83d2586..bd477f8068ff 100644 --- a/packages/SettingsLib/res/layout/preference_two_target_divider.xml +++ b/packages/SettingsLib/TwoTargetPreference/res/layout/preference_two_target_divider.xml @@ -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. diff --git a/packages/SettingsLib/TwoTargetPreference/res/values/dimens.xml b/packages/SettingsLib/TwoTargetPreference/res/values/dimens.xml new file mode 100644 index 000000000000..32a865905267 --- /dev/null +++ b/packages/SettingsLib/TwoTargetPreference/res/values/dimens.xml @@ -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> diff --git a/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java b/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java index 02895a479352..9130662021d5 100644 --- a/packages/SettingsLib/src/com/android/settingslib/TwoTargetPreference.java +++ b/packages/SettingsLib/TwoTargetPreference/src/com/android/settingslib/widget/TwoTargetPreference.java @@ -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}) diff --git a/packages/SettingsLib/res/values/dimens.xml b/packages/SettingsLib/res/values/dimens.xml index ef4b97f7743f..9d5b23166190 100644 --- a/packages/SettingsLib/res/values/dimens.xml +++ b/packages/SettingsLib/res/values/dimens.xml @@ -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> diff --git a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java index ad7e995412aa..fc8b5879c5fa 100644 --- a/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java +++ b/packages/SettingsLib/src/com/android/settingslib/RestrictedPreference.java @@ -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. diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/TwoTargetPreferenceTest.java index 3f0ba13ce50a..aaec909aa335 100644 --- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/TwoTargetPreferenceTest.java +++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/widget/TwoTargetPreferenceTest.java @@ -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; |