Commit b6bca2fe authored by Michael W's avatar Michael W
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

Change-Id: I31d103cd0b0a6f096d376af2026702a0a4754671
parent 58f3edcd
...@@ -18,43 +18,65 @@ ...@@ -18,43 +18,65 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:clipToPadding="false"
android:focusable="true"
android:gravity="center_vertical" 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: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">
<com.android.internal.widget.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 <TextView
android:id="@android:id/title" android:id="@android:id/title"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="marquee" android:layout_weight="1"
android:paddingStart="12dp"
android:singleLine="true" 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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/touch_target_min_size"> android:layout_height="wrap_content"
android:orientation="vertical">
<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 <SeekBar
android:id="@+id/alarm_volume_slider" android:id="@*android:id/seekbar"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_weight="1" android:paddingStart="12dp"
android:maxHeight="@dimen/touch_target_min_size" /> android:layout_width="match_parent"
android:layout_height="48dp"/>
</LinearLayout>
</LinearLayout> </LinearLayout>
......
...@@ -68,7 +68,8 @@ ...@@ -68,7 +68,8 @@
<com.android.deskclock.settings.AlarmVolumePreference <com.android.deskclock.settings.AlarmVolumePreference
android:key="volume_setting" android:key="volume_setting"
android:layout="@layout/alarm_volume_preference" 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 <ListPreference
android:defaultValue="0" android:defaultValue="0"
......
...@@ -61,10 +61,11 @@ public class AlarmVolumePreference extends Preference { ...@@ -61,10 +61,11 @@ public class AlarmVolumePreference extends Preference {
// Disable click feedback for this preference. // Disable click feedback for this preference.
holder.itemView.setClickable(false); holder.itemView.setClickable(false);
mSeekbar = (SeekBar) holder.findViewById(R.id.alarm_volume_slider); mSeekbar = (SeekBar) holder.findViewById(com.android.internal.R.id.seekbar);
mSeekbar.setMax(audioManager.getStreamMaxVolume(STREAM_ALARM)); mSeekbar.setMax(audioManager.getStreamMaxVolume(STREAM_ALARM));
mSeekbar.setProgress(audioManager.getStreamVolume(STREAM_ALARM)); mSeekbar.setProgress(audioManager.getStreamVolume(STREAM_ALARM));
mAlarmIcon = (ImageView) holder.findViewById(R.id.alarm_icon); mAlarmIcon = (ImageView) holder.findViewById(com.android.internal.R.id.icon);
onSeekbarChanged(); onSeekbarChanged();
final ContentObserver volumeObserver = new ContentObserver(mSeekbar.getHandler()) { final ContentObserver volumeObserver = new ContentObserver(mSeekbar.getHandler()) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment