diff options
11 files changed, 316 insertions, 66 deletions
| diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp index 0cb85d8638b0..f70584428eb2 100644 --- a/packages/SettingsLib/Android.bp +++ b/packages/SettingsLib/Android.bp @@ -32,6 +32,7 @@ android_library {          "SettingsLibBannerMessagePreference",          "SettingsLibBarChartPreference",          "SettingsLibButtonPreference", +        "SettingsLibBulletPreference",          "SettingsLibCollapsingToolbarBaseActivity",          "SettingsLibDeviceStateRotationLock",          "SettingsLibDisplayUtils", diff --git a/packages/SettingsLib/BulletPreference/Android.bp b/packages/SettingsLib/BulletPreference/Android.bp new file mode 100644 index 000000000000..3ea0b2b4851e --- /dev/null +++ b/packages/SettingsLib/BulletPreference/Android.bp @@ -0,0 +1,33 @@ +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: "SettingsLibBulletPreference", +    use_resource_processor: true, +    defaults: [ +        "SettingsLintDefaults", +    ], + +    srcs: [ +        "src/**/*.java", +        "src/**/*.kt", +    ], +    resource_dirs: ["res"], + +    static_libs: [ +        "androidx.annotation_annotation", +        "androidx.preference_preference", +        "SettingsLibSettingsTheme", +    ], +    sdk_version: "system_current", +    min_sdk_version: "21", +    apex_available: [ +        "//apex_available:platform", +    ], +} diff --git a/packages/SettingsLib/BulletPreference/AndroidManifest.xml b/packages/SettingsLib/BulletPreference/AndroidManifest.xml new file mode 100644 index 000000000000..c7495eff14d2 --- /dev/null +++ b/packages/SettingsLib/BulletPreference/AndroidManifest.xml @@ -0,0 +1,23 @@ +<?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. +  --> + +<manifest xmlns:android="http://schemas.android.com/apk/res/android" +          package="com.android.settingslib.widget.preference.bullet"> + +    <uses-sdk android:minSdkVersion="21" /> + +</manifest> diff --git a/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_icon_frame.xml b/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_icon_frame.xml new file mode 100644 index 000000000000..030f02430c02 --- /dev/null +++ b/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_icon_frame.xml @@ -0,0 +1,37 @@ +<?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" +    xmlns:app="http://schemas.android.com/apk/res-auto" +    android:id="@+id/icon_frame" +    android:layout_width="wrap_content" +    android:layout_height="wrap_content" +    android:minWidth="@dimen/settingslib_expressive_space_medium4" +    android:gravity="top|start" +    android:layout_marginTop="@dimen/settingslib_expressive_space_small1" +    android:paddingStart="@dimen/settingslib_expressive_space_extrasmall4" +    android:paddingEnd="@dimen/settingslib_expressive_space_small1"> + +    <androidx.preference.internal.PreferenceImageView +        android:id="@android:id/icon" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        app:maxWidth="@dimen/settingslib_expressive_space_small4" +        app:maxHeight="@dimen/settingslib_expressive_space_small4"/> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_preference.xml b/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_preference.xml new file mode 100644 index 000000000000..3f37f6cc00a5 --- /dev/null +++ b/packages/SettingsLib/BulletPreference/res/layout/settingslib_expressive_bullet_preference.xml @@ -0,0 +1,43 @@ +<?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:paddingStart="?android:attr/listPreferredItemPaddingStart" +    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd" +    android:background="?android:attr/selectableItemBackground" +    android:clipToPadding="false" +    android:baselineAligned="false"> + +    <include layout="@layout/settingslib_expressive_bullet_icon_frame"/> + +    <include layout="@layout/settingslib_expressive_preference_text_frame"/> + +    <!-- 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:gravity="end|center_vertical" +        android:paddingStart="@dimen/settingslib_expressive_space_small1" +        android:paddingEnd="0dp" +        android:orientation="vertical"/> + +</LinearLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/BulletPreference/src/com/android/settingslib/widget/BulletPreference.kt b/packages/SettingsLib/BulletPreference/src/com/android/settingslib/widget/BulletPreference.kt new file mode 100644 index 000000000000..45e2e9aaea4b --- /dev/null +++ b/packages/SettingsLib/BulletPreference/src/com/android/settingslib/widget/BulletPreference.kt @@ -0,0 +1,45 @@ +/* + * 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. + */ + +package com.android.settingslib.widget + +import android.content.Context +import android.util.AttributeSet +import androidx.preference.Preference +import androidx.preference.PreferenceViewHolder + +import com.android.settingslib.widget.preference.bullet.R + +/** + * The BulletPreference shows a text which describe a feature. + */ +class BulletPreference @JvmOverloads constructor( +    context: Context, +    attrs: AttributeSet? = null, +    defStyleAttr: Int = 0, +    defStyleRes: Int = 0 +) : Preference(context, attrs, defStyleAttr, defStyleRes) { + +    init { +        layoutResource = R.layout.settingslib_expressive_bullet_preference +    } + +    override fun onBindViewHolder(holder: PreferenceViewHolder) { +        super.onBindViewHolder(holder) +        holder.isDividerAllowedAbove = false +        holder.isDividerAllowedBelow = false +    } +}
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_bullet_start.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_bullet_start.xml new file mode 100644 index 000000000000..9216c9615aaa --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_bullet_start.xml @@ -0,0 +1,26 @@ +<?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="24dp" +    android:height="24dp" +    android:viewportWidth="960" +    android:viewportHeight="960" +    android:tint="?android:attr/colorControlNormal"> +    <path +        android:fillColor="@android:color/white" +        android:pathData="M354,673L480,597L606,674L573,530L684,434L538,421L480,285L422,420L276,433L387,530L354,673ZM233,840L298,559L80,370L368,345L480,80L592,345L880,370L662,559L727,840L480,691L233,840ZM480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490L480,490Z"/> +</vector>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference.xml b/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference.xml index dda7517cc1c3..952562e3d8ea 100644 --- a/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference.xml +++ b/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference.xml @@ -31,37 +31,7 @@      <include layout="@layout/settingslib_icon_frame"/> -    <RelativeLayout -        android:layout_width="0dp" -        android:layout_height="wrap_content" -        android:layout_weight="1" -        android:paddingTop="16dp" -        android:paddingBottom="16dp"> - -        <TextView -            android:id="@android:id/title" -            android:layout_width="wrap_content" -            android:layout_height="wrap_content" -            android:layout_gravity="start" -            android:textAlignment="viewStart" -            android:maxLines="2" -            android:textAppearance="?android:attr/textAppearanceListItem" -            android:ellipsize="marquee"/> - -        <TextView -            android:id="@android:id/summary" -            android:layout_width="wrap_content" -            android:layout_height="wrap_content" -            android:layout_below="@android:id/title" -            android:layout_alignLeft="@android:id/title" -            android:layout_alignStart="@android:id/title" -            android:layout_gravity="start" -            android:textAlignment="viewStart" -            android:textColor="?android:attr/textColorSecondary" -            android:maxLines="10" -            style="@style/PreferenceSummaryTextStyle"/> - -    </RelativeLayout> +    <include layout="@layout/settingslib_preference_frame"/>      <!-- Preference should place its actual preference widget here. -->      <LinearLayout diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference_frame.xml b/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference_frame.xml new file mode 100644 index 000000000000..433d26445c4d --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/layout-v31/settingslib_preference_frame.xml @@ -0,0 +1,51 @@ +<?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. +  --> + +<RelativeLayout +    xmlns:android="http://schemas.android.com/apk/res/android" +    android:layout_width="0dp" +    android:layout_height="wrap_content" +    android:layout_weight="1" +    android:paddingTop="16dp" +    android:paddingBottom="16dp"> + +    <TextView +        android:id="@android:id/title" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_gravity="start" +        android:textAlignment="viewStart" +        android:text="Title" +        android:maxLines="2" +        android:textAppearance="?android:attr/textAppearanceListItem" +        android:ellipsize="marquee"/> + +    <TextView +        android:id="@android:id/summary" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_below="@android:id/title" +        android:layout_alignLeft="@android:id/title" +        android:layout_alignStart="@android:id/title" +        android:text="Summary summary summary" +        android:layout_gravity="start" +        android:textAlignment="viewStart" +        android:textColor="?android:attr/textColorSecondary" +        android:maxLines="10" +        style="@style/PreferenceSummaryTextStyle"/> + +</RelativeLayout>
\ No newline at end of file diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference.xml b/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference.xml index fedcc77ed6b9..4e23b6562e3e 100644 --- a/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference.xml +++ b/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference.xml @@ -31,41 +31,7 @@      <include layout="@layout/settingslib_icon_frame"/> -    <RelativeLayout -        android:layout_width="0dp" -        android:layout_height="wrap_content" -        android:layout_weight="1" -        android:paddingTop="16dp" -        android:paddingBottom="16dp"> - -        <TextView -            android:id="@android:id/title" -            android:layout_width="wrap_content" -            android:layout_height="wrap_content" -            android:layout_gravity="start" -            android:textAlignment="viewStart" -            android:maxLines="2" -            android:hyphenationFrequency="normalFast" -            android:lineBreakWordStyle="phrase" -            android:textAppearance="?android:attr/textAppearanceListItem" -            android:ellipsize="marquee"/> - -        <TextView -            android:id="@android:id/summary" -            android:layout_width="wrap_content" -            android:layout_height="wrap_content" -            android:layout_below="@android:id/title" -            android:layout_alignLeft="@android:id/title" -            android:layout_alignStart="@android:id/title" -            android:layout_gravity="start" -            android:textAlignment="viewStart" -            android:textColor="?android:attr/textColorSecondary" -            android:maxLines="10" -            android:hyphenationFrequency="normalFast" -            android:lineBreakWordStyle="phrase" -            style="@style/PreferenceSummaryTextStyle"/> - -    </RelativeLayout> +    <include layout="@layout/settingslib_preference_frame"/>      <!-- Preference should place its actual preference widget here. -->      <LinearLayout diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference_frame.xml b/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference_frame.xml new file mode 100644 index 000000000000..f93e1b975eb2 --- /dev/null +++ b/packages/SettingsLib/SettingsTheme/res/layout-v33/settingslib_preference_frame.xml @@ -0,0 +1,55 @@ +<?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. +  --> + +<RelativeLayout +    xmlns:android="http://schemas.android.com/apk/res/android" +    android:layout_width="0dp" +    android:layout_height="wrap_content" +    android:layout_weight="1" +    android:paddingTop="16dp" +    android:paddingBottom="16dp"> + +    <TextView +        android:id="@android:id/title" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_gravity="start" +        android:textAlignment="viewStart" +        android:text="Title" +        android:maxLines="2" +        android:hyphenationFrequency="normalFast" +        android:lineBreakWordStyle="phrase" +        android:textAppearance="?android:attr/textAppearanceListItem" +        android:ellipsize="marquee"/> + +    <TextView +        android:id="@android:id/summary" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:layout_below="@android:id/title" +        android:layout_alignLeft="@android:id/title" +        android:layout_alignStart="@android:id/title" +        android:layout_gravity="start" +        android:textAlignment="viewStart" +        android:textColor="?android:attr/textColorSecondary" +        android:maxLines="10" +        android:text="Summary summary summary" +        android:hyphenationFrequency="normalFast" +        android:lineBreakWordStyle="phrase" +        style="@style/PreferenceSummaryTextStyle"/> + +</RelativeLayout>
\ No newline at end of file |