summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael W <baddaemon87@gmail.com>2020-06-12 19:02:41 +0200
committerMichael Bestas <mkbestas@lineageos.org>2020-12-08 19:39:12 +0200
commitcae4d4cdbf99311b4deebd8e16a8ba5fa3f30a0d (patch)
treed25fb07bbb32715bb21c31f7726677a6bbfb06ba
parent47af23e4b13a797caa9aaf4a45ef7e8ae0fc071b (diff)
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
-rw-r--r--res/layout/alarm_volume_preference.xml82
-rw-r--r--res/xml/settings.xml3
-rw-r--r--src/com/android/deskclock/settings/AlarmVolumePreference.java5
3 files changed, 57 insertions, 33 deletions
diff --git a/res/layout/alarm_volume_preference.xml b/res/layout/alarm_volume_preference.xml
index 109c7be8b..e8e969f20 100644
--- a/res/layout/alarm_volume_preference.xml
+++ b/res/layout/alarm_volume_preference.xml
@@ -18,44 +18,66 @@
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">
- <TextView
- android:id="@android:id/title"
+ <LinearLayout
+ android:id="@+id/icon_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
- android:ellipsize="marquee"
- android:singleLine="true"
- android:textAppearance="?android:attr/textAppearanceListItem" />
+ 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="@dimen/touch_target_min_size">
-
- <ImageView
- android:id="@+id/alarm_icon"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:importantForAccessibility="no" />
-
- <!-- 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:layout_gravity="center_vertical"
- android:layout_weight="1"
- android:maxHeight="@dimen/touch_target_min_size" />
+ 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="0dp"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:paddingStart="12dp"
+ android:singleLine="true"
+ 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="wrap_content"
+ android:orientation="vertical">
+
+ <SeekBar
+ android:id="@+id/seekbar"
+ android:layout_gravity="center_vertical"
+ android:paddingStart="12dp"
+ android:layout_width="match_parent"
+ android:layout_height="48dp"/>
+
+ </LinearLayout>
</LinearLayout>
-</LinearLayout> \ No newline at end of file
+</LinearLayout>
diff --git a/res/xml/settings.xml b/res/xml/settings.xml
index e4e6f32b0..6e65a3e25 100644
--- a/res/xml/settings.xml
+++ b/res/xml/settings.xml
@@ -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"
diff --git a/src/com/android/deskclock/settings/AlarmVolumePreference.java b/src/com/android/deskclock/settings/AlarmVolumePreference.java
index b1eb8cea0..c6510db1a 100644
--- a/src/com/android/deskclock/settings/AlarmVolumePreference.java
+++ b/src/com/android/deskclock/settings/AlarmVolumePreference.java
@@ -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()) {