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

Commit 0bb60ada authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Display days of week in locale order.

Change-Id: Id5d5920089a5da1fbdc7802431ca2909f72d7e12
Fixes: 21304061
parent 708c6264
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -32,16 +32,6 @@ import java.util.Arrays;
import java.util.Calendar;

public class ZenModeScheduleDaysSelection extends ScrollView {
    public static final int[] DAYS = {
        Calendar.SUNDAY,
        Calendar.MONDAY,
        Calendar.TUESDAY,
        Calendar.WEDNESDAY,
        Calendar.THURSDAY,
        Calendar.FRIDAY,
        Calendar.SATURDAY,
    };

    // per-instance to ensure we're always using the current locale
    private final SimpleDateFormat mDayFormat = new SimpleDateFormat("EEEE");
    private final SparseBooleanArray mDays = new SparseBooleanArray();
@@ -61,9 +51,10 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
        }
        mLayout.setOrientation(LinearLayout.VERTICAL);
        final Calendar c = Calendar.getInstance();
        int[] daysOfWeek = getDaysOfWeekForLocale(c);
        final LayoutInflater inflater = LayoutInflater.from(context);
        for (int i = 0; i < DAYS.length; i++) {
            final int day = DAYS[i];
        for (int i = 0; i < daysOfWeek.length; i++) {
            final int day = daysOfWeek[i];
            final CheckBox checkBox = (CheckBox) inflater.inflate(R.layout.zen_schedule_rule_day,
                    this, false);
            c.set(Calendar.DAY_OF_WEEK, day);
@@ -95,6 +86,17 @@ public class ZenModeScheduleDaysSelection extends ScrollView {
        return rta;
    }

    protected static int[] getDaysOfWeekForLocale(Calendar c) {
        int[] daysOfWeek = new int[7];
        int currentDay = c.getFirstDayOfWeek();
        for (int i = 0; i < daysOfWeek.length; i++) {
            if (currentDay > 7) currentDay = 1;
            daysOfWeek[i] = currentDay;
            currentDay++;
        }
        return daysOfWeek;
    }

    protected void onChanged(int[] days) {
        // event hook for subclasses
    }
+3 −4
Original line number Diff line number Diff line
@@ -44,8 +44,6 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;

import static com.android.settings.notification.ZenModeScheduleDaysSelection.DAYS;

public class ZenModeScheduleRuleSettings extends ZenModeRuleSettingsBase {
    private static final String KEY_DAYS = "days";
    private static final String KEY_START_TIME = "start_time";
@@ -158,8 +156,9 @@ public class ZenModeScheduleRuleSettings extends ZenModeRuleSettingsBase {
        if (days != null && days.length > 0) {
            final StringBuilder sb = new StringBuilder();
            final Calendar c = Calendar.getInstance();
            for (int i = 0; i < DAYS.length; i++) {
                final int day = DAYS[i];
            int[] daysOfWeek = ZenModeScheduleDaysSelection.getDaysOfWeekForLocale(c);
            for (int i = 0; i < daysOfWeek.length; i++) {
                final int day = daysOfWeek[i];
                for (int j = 0; j < days.length; j++) {
                    if (day == days[j]) {
                        c.set(Calendar.DAY_OF_WEEK, day);