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

Commit 19ae4ca5 authored by Fabrice Di Meglio's avatar Fabrice Di Meglio
Browse files

Fix SeekBarPreference Theming

- make the layout a Theme attribute and use it
- make a specific Material version of the layout for matching
what we have in the Settings App

See bug: #15414236 Define a framework theme for system settings

and #15384992 Setting Dashboard - padding updates

Change-Id: I69c90523fab112fecf26d89de8fc35dd62430c06
parent b69fc083
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -40,11 +40,19 @@ public class SeekBarPreference extends Preference
            Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);

        final TypedArray a = context.obtainStyledAttributes(
        TypedArray a = context.obtainStyledAttributes(
                attrs, com.android.internal.R.styleable.ProgressBar, defStyleAttr, defStyleRes);
        setMax(a.getInt(com.android.internal.R.styleable.ProgressBar_max, mMax));
        a.recycle();
        setLayoutResource(com.android.internal.R.layout.preference_widget_seekbar);

        a = context.obtainStyledAttributes(attrs,
                com.android.internal.R.styleable.SeekBarPreference, defStyleAttr, defStyleRes);
        final int layoutResId = a.getResourceId(
                com.android.internal.R.styleable.SeekBarPreference_layout,
                com.android.internal.R.layout.preference_widget_seekbar);
        a.recycle();

        setLayoutResource(layoutResId);
    }

    public SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -52,7 +60,7 @@ public class SeekBarPreference extends Preference
    }

    public SeekBarPreference(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
        this(context, attrs, com.android.internal.R.attr.seekBarPreferenceStyle);
    }

    public SeekBarPreference(Context context) {
+1 −3
Original line number Diff line number Diff line
@@ -14,9 +14,7 @@
     limitations under the License.
-->

<!-- Layout for a Preference in a PreferenceActivity. The
     Preference is able to place a specific widget for its particular
     type in the "widget_frame" layout. -->
<!-- Layout used by SeekBarPreference for the seekbar widget style. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
+86 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2014 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.
-->

<!-- Layout used by SeekBarPreference for the seekbar widget style. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:gravity="center_vertical"
    android:paddingStart="?attr/listPreferredItemPaddingStart"
    android:paddingEnd="?attr/listPreferredItemPaddingEnd">

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:gravity="center"
        android:minWidth="@dimen/preference_icon_minWidth"
        android:orientation="horizontal">
        <ImageView
            android:id="@+android:id/icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:minWidth="48dp"
            />
    </LinearLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dip"
        android:layout_marginEnd="8dip"
        android:layout_marginTop="6dip"
        android:layout_marginBottom="6dip"
        android:layout_weight="1">

        <TextView android:id="@+android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:singleLine="true"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:ellipsize="marquee"
            android:fadingEdge="horizontal" />

        <TextView android:id="@+android:id/summary"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/title"
            android:layout_alignStart="@android:id/title"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="?android:attr/textColorSecondary"
            android:maxLines="4" />

        <!-- 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:layout_below="@android:id/summary"
            android:layout_alignStart="@android:id/title"
            android:minWidth="@dimen/preference_widget_width"
            android:gravity="center"
            android:orientation="vertical" />

        <SeekBar android:id="@+android:id/seekbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@android:id/summary"
            android:layout_toEndOf="@android:id/widget_frame"
            android:layout_alignParentEnd="true" />

    </RelativeLayout>

</LinearLayout>
+6 −0
Original line number Diff line number Diff line
@@ -834,6 +834,8 @@
        <attr name="preferenceFragmentPaddingSide" format="dimension" />
        <!-- Default style for switch preferences. -->
        <attr name="switchPreferenceStyle" format="reference" />
        <!-- Default style for seekbar preferences. -->
        <attr name="seekBarPreferenceStyle" format="reference" />

        <!-- ============================ -->
        <!-- Text selection handle styles -->
@@ -6607,6 +6609,10 @@
        <attr name="disableDependentsState" />
    </declare-styleable>

    <declare-styleable name="SeekBarPreference">
        <attr name="layout" />
    </declare-styleable>

    <!-- Use <code>tts-engine</code> as the root tag of the XML resource that
         describes a text to speech engine implemented as a subclass of
         {@link android.speech.tts.TextToSpeechService}.
+8 −0
Original line number Diff line number Diff line
@@ -980,6 +980,10 @@ please see styles_device_defaults.xml.
        <item name="android:switchTextOff">@android:string/capital_off</item>
    </style>

    <style name="Preference.SeekBarPreference">
        <item name="android:layout">@android:layout/preference_widget_seekbar</item>
    </style>

    <style name="Preference.PreferenceScreen">
    </style>

@@ -1035,6 +1039,10 @@ please see styles_device_defaults.xml.
        <item name="android:switchTextOff">@android:string/capital_off</item>
    </style>

    <style name="Preference.Holo.SeekBarPreference">
        <item name="android:layout">@android:layout/preference_widget_seekbar</item>
    </style>

    <style name="Preference.Holo.PreferenceScreen">
    </style>

Loading