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

Commit 9e121293 authored by Michael W's avatar Michael W Committed by Michael Bestas
Browse files

DeskClock: Properly align settings

* The alarm volume setting doesn't look as it should
* Copied "preference_volume_slider" from Settings (used in Settings->
  Sound) and stripped by stuff we don't need (suppression_text,
  widget_frame)
* Looks like without providing an initial icon, the layout would not
  inflate the space for it properly, so provide the default one

Test: manual - Tested the DeskClock UI manually and checked that
alarm volume preference is aligned to the rest of the preferences

Change-Id: Ib1e36c36c8fb5c91992dc8163fe84564b647bdbd
parent ce0af26b
Loading
Loading
Loading
Loading
+52 −30
Original line number Diff line number Diff line
@@ -18,43 +18,65 @@
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="?attr/selectableItemBackground"
    android:clipToPadding="false"
    android:focusable="true"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:gravity="center_vertical"
    android:minHeight="?attr/listPreferredItemHeightSmall"
    android:orientation="vertical"
    android:paddingBottom="16dp"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart"
    android:paddingTop="16dp">
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:clickable="false"
    android:orientation="horizontal">

    <LinearLayout
        android:id="@+id/icon_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:minWidth="44dp"
        android:gravity="start|center_vertical"
        android:orientation="horizontal"
        android:paddingEnd="12dp"
        android:paddingTop="4dp"
        android:paddingBottom="4dp">
        <androidx.preference.internal.PreferenceImageView
            android:id="@android:id/icon"
            android:layout_width="24dp"
            android:layout_height="24dp"/>
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <TextView
                android:id="@android:id/title"
        android:layout_width="wrap_content"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
        android:ellipsize="marquee"
                android:layout_weight="1"
                android:paddingStart="12dp"
                android:singleLine="true"
        android:textAppearance="?android:attr/textAppearanceListItem" />
                android:textAppearance="@*android:style/TextAppearance.DeviceDefault.Subhead"
                android:textColor="?android:attr/textColorPrimary"
                android:ellipsize="marquee"
                android:fadingEdge="horizontal"/>
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
        android:layout_height="@dimen/touch_target_min_size">

        <ImageView
            android:id="@+id/alarm_icon"
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:importantForAccessibility="no" />
            android:layout_height="wrap_content"
            android:orientation="vertical">

        <!-- Specify maxHeight to properly set the track height on API < 23 -->
            <SeekBar
            android:id="@+id/alarm_volume_slider"
            android:layout_width="0dp"
            android:layout_height="match_parent"
                android:id="@+id/seekbar"
                android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:maxHeight="@dimen/touch_target_min_size" />
                android:paddingStart="12dp"
                android:layout_width="match_parent"
                android:layout_height="48dp"/>

        </LinearLayout>

    </LinearLayout>

+2 −1
Original line number Diff line number Diff line
@@ -68,7 +68,8 @@
        <com.android.deskclock.settings.AlarmVolumePreference
            android:key="volume_setting"
            android:layout="@layout/alarm_volume_preference"
            android:title="@string/alarm_volume_title" />
            android:title="@string/alarm_volume_title"
            android:icon="@drawable/ic_alarm_small" />

        <ListPreference
            android:defaultValue="0"
+3 −2
Original line number Diff line number Diff line
@@ -61,10 +61,11 @@ public class AlarmVolumePreference extends Preference {
        // Disable click feedback for this preference.
        holder.itemView.setClickable(false);

        mSeekbar = (SeekBar) holder.findViewById(R.id.alarm_volume_slider);
        mSeekbar = (SeekBar) holder.findViewById(R.id.seekbar);
        mSeekbar.setMax(audioManager.getStreamMaxVolume(STREAM_ALARM));
        mSeekbar.setProgress(audioManager.getStreamVolume(STREAM_ALARM));
        mAlarmIcon = (ImageView) holder.findViewById(R.id.alarm_icon);
        mAlarmIcon = (ImageView) holder.findViewById(android.R.id.icon);

        onSeekbarChanged();

        final ContentObserver volumeObserver = new ContentObserver(mSeekbar.getHandler()) {