OSDN Git Service

Settings: Make downtime days scrollable.
authorJohn Spurlock <jspurlock@google.com>
Wed, 10 Sep 2014 14:04:44 +0000 (10:04 -0400)
committerJohn Spurlock <jspurlock@google.com>
Wed, 10 Sep 2014 14:04:44 +0000 (10:04 -0400)
Bug:17428288
Change-Id: I389aece9d79d002426a0bcb03d4a523293012892

res/layout/zen_downtime_day.xml
res/values/dimens.xml
src/com/android/settings/notification/ZenModeDowntimeDaysSelection.java

index 076ad4c..8d2fa73 100755 (executable)
@@ -20,6 +20,4 @@
     android:minHeight="?android:attr/listPreferredItemHeightSmall"
     android:textAppearance="?android:attr/textAppearanceMedium"
     android:gravity="center_vertical"
-    android:paddingStart="@dimen/zen_downtime_checkbox_padding"
-    android:layout_marginStart="@dimen/zen_downtime_margin"
-    android:layout_marginEnd="@dimen/zen_downtime_margin" />
+    android:paddingStart="@dimen/zen_downtime_checkbox_padding" />
index f270435..afbd5c6 100755 (executable)
@@ -93,7 +93,7 @@
     <dimen name="notification_app_icon_badge_margin">4dp</dimen>
     <dimen name="zen_mode_dropdown_width">160dp</dimen>
     <dimen name="zen_downtime_checkbox_padding">7dp</dimen>
-    <dimen name="zen_downtime_margin">10dp</dimen>
+    <dimen name="zen_downtime_margin">17dp</dimen>
 
     <!-- Default text size for caption preview samples. Uses dp rather than sp because captions are not scaled. -->
     <dimen name="caption_preview_text_size">48dp</dimen>
index 74dae9e..a380c27 100644 (file)
@@ -22,6 +22,7 @@ import android.util.SparseBooleanArray;
 import android.view.LayoutInflater;
 import android.widget.CheckBox;
 import android.widget.CompoundButton;
+import android.widget.ScrollView;
 import android.widget.CompoundButton.OnCheckedChangeListener;
 import android.widget.LinearLayout;
 
@@ -30,7 +31,7 @@ import com.android.settings.R;
 import java.text.SimpleDateFormat;
 import java.util.Calendar;
 
-public class ZenModeDowntimeDaysSelection extends LinearLayout {
+public class ZenModeDowntimeDaysSelection extends ScrollView {
     private static final int[] DAYS = {
         Calendar.MONDAY, Calendar.TUESDAY, Calendar.WEDNESDAY, Calendar.THURSDAY, Calendar.FRIDAY,
         Calendar.SATURDAY, Calendar.SUNDAY
@@ -38,16 +39,21 @@ public class ZenModeDowntimeDaysSelection extends LinearLayout {
     private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("EEEE");
 
     private final SparseBooleanArray mDays = new SparseBooleanArray();
+    private final LinearLayout mLayout;
 
     public ZenModeDowntimeDaysSelection(Context context, String mode) {
         super(context);
+        mLayout = new LinearLayout(mContext);
+        final int hPad = context.getResources().getDimensionPixelSize(R.dimen.zen_downtime_margin);
+        mLayout.setPadding(hPad, 0, hPad, 0);
+        addView(mLayout);
         final int[] days = ZenModeConfig.tryParseDays(mode);
         if (days != null) {
             for (int i = 0; i < days.length; i++) {
                 mDays.put(days[i], true);
             }
         }
-        setOrientation(VERTICAL);
+        mLayout.setOrientation(LinearLayout.VERTICAL);
         final Calendar c = Calendar.getInstance();
         final LayoutInflater inflater = LayoutInflater.from(context);
         for (int i = 0; i < DAYS.length; i++) {
@@ -64,7 +70,7 @@ public class ZenModeDowntimeDaysSelection extends LinearLayout {
                     onChanged(getMode());
                 }
             });
-            addView(checkBox);
+            mLayout.addView(checkBox);
         }
     }