Update quiet hours prefs, bump version

pull/120/head
Alex Baker 11 years ago
parent 0fa4903a9c
commit d8d19e09ae

@ -5,8 +5,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.tasks"
android:versionName="4.6.12"
android:versionCode="326">
android:versionName="4.6.13"
android:versionCode="327">
<!-- widgets, alarms, and services will break if Astrid is installed on SD card -->
<!-- android:installLocation="internalOnly"> -->

@ -8,7 +8,6 @@ package com.todoroo.astrid.reminders;
import android.content.res.Resources;
import android.preference.Preference;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.andlib.utility.TodorooPreferenceActivity;
import org.joda.time.DateTime;
@ -40,21 +39,13 @@ public class ReminderPreferences extends TodorooPreferenceActivity {
preference.setSummary("");
}
} else if(r.getString(R.string.p_rmd_quietStart).equals(preference.getKey())) {
if(Preferences.getBoolean(R.string.p_rmd_enable_quiet, false)) {
int millisOfDay = (int) value;
String setting = DateFormat.getTimeInstance(DateFormat.SHORT).format(new DateTime().withMillisOfDay(millisOfDay).toDate());
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_start_desc, setting));
} else {
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_desc_none));
}
int millisOfDay = (int) value;
String setting = DateFormat.getTimeInstance(DateFormat.SHORT).format(new DateTime().withMillisOfDay(millisOfDay).toDate());
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_start_desc, setting));
} else if(r.getString(R.string.p_rmd_quietEnd).equals(preference.getKey())) {
if(Preferences.getBoolean(R.string.p_rmd_enable_quiet, false)) {
int millisOfDay = (int) value;
String setting = DateFormat.getTimeInstance(DateFormat.SHORT).format(new DateTime().withMillisOfDay(millisOfDay).toDate());
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_end_desc, setting));
} else {
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_desc_none));
}
int millisOfDay = (int) value;
String setting = DateFormat.getTimeInstance(DateFormat.SHORT).format(new DateTime().withMillisOfDay(millisOfDay).toDate());
preference.setSummary(r.getString(R.string.rmd_EPr_quiet_hours_end_desc, setting));
} else if(r.getString(R.string.p_rmd_time).equals(preference.getKey())) {
int millisOfDay = (int) value;
String setting = DateFormat.getTimeInstance(DateFormat.SHORT).format(new DateTime().withMillisOfDay(millisOfDay).toDate());

@ -120,7 +120,6 @@ public final class ReminderService {
Editor editor = prefs.edit();
Resources r = context.getResources();
Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_enable_quiet, false);
Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0);
Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_persistent, true);

@ -14,6 +14,7 @@ import com.todoroo.astrid.data.Task;
import org.joda.time.DateTime;
import org.tasks.R;
import static com.todoroo.andlib.utility.Preferences.setBoolean;
import static com.todoroo.andlib.utility.Preferences.setIntIfUnset;
public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec {
@ -39,7 +40,7 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec {
Preferences.setInt(AstridPreferences.P_SUBTASKS_HELP, 1);
}
}
Preferences.setBoolean(dragDropTestInitialized, true);
setBoolean(dragDropTestInitialized, true);
}
BeastModePreferences.setDefaultOrder(context);
}
@ -90,7 +91,8 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec {
setPreference(prefs, editor, r, R.string.p_hide_plus_button, true);
setPreference(prefs, editor, r, R.string.p_rmd_enable_quiet, true);
setPreference(prefs, editor, r, R.string.p_rmd_quietStart_old, 22); // enable quiet hours by default
setIntIfUnset(prefs, editor, r, R.string.p_rmd_quietStart, r.getInteger(R.integer.default_quiet_hours_start));
setIntIfUnset(prefs, editor, r, R.string.p_rmd_quietEnd, r.getInteger(R.integer.default_quiet_hours_end));
setIntIfUnset(prefs, editor, r, R.string.p_rmd_time, r.getInteger(R.integer.default_remind_time));
@ -103,18 +105,12 @@ public class AstridDefaultPreferenceSpec extends AstridPreferenceSpec {
}
static void migrateToNewQuietHours() {
boolean hasMigrated = Preferences.getBoolean(R.string.p_rmd_hasMigrated, false);
if(!hasMigrated) {
boolean quietHoursEnabled = Preferences.getIntegerFromString(R.string.p_rmd_quietStart_old, -1) >= 0;
Preferences.setBoolean(R.string.p_rmd_enable_quiet, quietHoursEnabled);
if (quietHoursEnabled) {
setTime(R.string.p_rmd_quietStart_old, R.string.p_rmd_quietStart, 22);
setTime(R.string.p_rmd_quietEnd_old, R.string.p_rmd_quietEnd, 10);
}
if(!Preferences.getBoolean(R.string.p_rmd_hasMigrated, false)) {
setBoolean(R.string.p_rmd_enable_quiet, Preferences.getIntegerFromString(R.string.p_rmd_quietStart_old, -1) >= 0);
setTime(R.string.p_rmd_quietStart_old, R.string.p_rmd_quietStart, 22);
setTime(R.string.p_rmd_quietEnd_old, R.string.p_rmd_quietEnd, 10);
setTime(R.string.p_rmd_time_old, R.string.p_rmd_time, 18);
Preferences.setBoolean(R.string.p_rmd_hasMigrated, true);
setBoolean(R.string.p_rmd_hasMigrated, true);
}
}

Loading…
Cancel
Save