mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-24 02:12:15 -05:00
add a new quiet time preference
This commit is contained in:
parent
a521d231e6
commit
a75098013a
@ -338,6 +338,13 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
|||||||
<string name="global_settings_privacy_mode_title">Lock-screen notifications</string>
|
<string name="global_settings_privacy_mode_title">Lock-screen notifications</string>
|
||||||
<string name="global_settings_privacy_mode_summary">Don\'t display message subject in notification bar when system is locked</string>
|
<string name="global_settings_privacy_mode_summary">Don\'t display message subject in notification bar when system is locked</string>
|
||||||
|
|
||||||
|
|
||||||
|
<string name="quiet_time">Quiet Time</string>
|
||||||
|
<string name="quiet_time_description">Disable ringing, buzzing and flashing at night</string>
|
||||||
|
<string name="quiet_time_starts">Quiet Time starts</string>
|
||||||
|
<string name="quiet_time_ends">Quiet Time ends</string>
|
||||||
|
|
||||||
|
|
||||||
<string name="account_setup_basics_title">Set up a new account</string>
|
<string name="account_setup_basics_title">Set up a new account</string>
|
||||||
<string name="account_setup_basics_instructions">Enter this account\'s email address:</string>
|
<string name="account_setup_basics_instructions">Enter this account\'s email address:</string>
|
||||||
<string name="account_setup_basics_instructions2_fmt">(You may add <xliff:g id="number_accounts">%d</xliff:g> more accounts.)</string>
|
<string name="account_setup_basics_instructions2_fmt">(You may add <xliff:g id="number_accounts">%d</xliff:g> more accounts.)</string>
|
||||||
|
@ -264,4 +264,29 @@
|
|||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
||||||
|
<PreferenceScreen
|
||||||
|
android:title="@string/notifications_title"
|
||||||
|
android:key="notification_preferences">
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="quiet_time_enabled"
|
||||||
|
android:persistent="false"
|
||||||
|
android:title="@string/quiet_time"
|
||||||
|
android:summary="@string/quiet_time_description"
|
||||||
|
/>
|
||||||
|
<com.fsck.k9.preferences.TimePickerPreference
|
||||||
|
android:key="quiet_time_starts"
|
||||||
|
android:persistent="false"
|
||||||
|
android:dependency="quiet_time_enabled"
|
||||||
|
android:dialogTitle="@string/quiet_time_starts"
|
||||||
|
android:title="@string/quiet_time_starts"
|
||||||
|
/>
|
||||||
|
<com.fsck.k9.preferences.TimePickerPreference
|
||||||
|
android:key="quiet_time_ends"
|
||||||
|
android:dependency="quiet_time_enabled"
|
||||||
|
android:persistent="false"
|
||||||
|
android:dialogTitle="@string/quiet_time_ends"
|
||||||
|
android:title="@string/quiet_time_ends"
|
||||||
|
/>
|
||||||
|
</PreferenceScreen>
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@ -164,6 +164,9 @@ public class K9 extends Application
|
|||||||
private static boolean mCountSearchMessages = true;
|
private static boolean mCountSearchMessages = true;
|
||||||
private static boolean mZoomControlsEnabled = false;
|
private static boolean mZoomControlsEnabled = false;
|
||||||
private static boolean mMobileOptimizedLayout = false;
|
private static boolean mMobileOptimizedLayout = false;
|
||||||
|
private static boolean mQuietTimeEnabled = false;
|
||||||
|
private static String mQuietTimeStarts = null;
|
||||||
|
private static String mQuietTimeEnds = null;
|
||||||
|
|
||||||
private static boolean useGalleryBugWorkaround = false;
|
private static boolean useGalleryBugWorkaround = false;
|
||||||
private static boolean galleryBuggy;
|
private static boolean galleryBuggy;
|
||||||
@ -417,7 +420,9 @@ public class K9 extends Application
|
|||||||
editor.putBoolean("manageBack", mManageBack);
|
editor.putBoolean("manageBack", mManageBack);
|
||||||
editor.putBoolean("zoomControlsEnabled",mZoomControlsEnabled);
|
editor.putBoolean("zoomControlsEnabled",mZoomControlsEnabled);
|
||||||
editor.putBoolean("mobileOptimizedLayout", mMobileOptimizedLayout);
|
editor.putBoolean("mobileOptimizedLayout", mMobileOptimizedLayout);
|
||||||
|
editor.putBoolean("quietTimeEnabled", mQuietTimeEnabled);
|
||||||
|
editor.putString("quietTimeStarts", mQuietTimeStarts);
|
||||||
|
editor.putString("quietTimeEnds", mQuietTimeEnds);
|
||||||
|
|
||||||
editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox);
|
editor.putBoolean("startIntegratedInbox", mStartIntegratedInbox);
|
||||||
editor.putBoolean("measureAccounts", mMeasureAccounts);
|
editor.putBoolean("measureAccounts", mMeasureAccounts);
|
||||||
@ -472,6 +477,10 @@ public class K9 extends Application
|
|||||||
mMobileOptimizedLayout = sprefs.getBoolean("mobileOptimizedLayout", false);
|
mMobileOptimizedLayout = sprefs.getBoolean("mobileOptimizedLayout", false);
|
||||||
mZoomControlsEnabled = sprefs.getBoolean("zoomControlsEnabled",false);
|
mZoomControlsEnabled = sprefs.getBoolean("zoomControlsEnabled",false);
|
||||||
|
|
||||||
|
mQuietTimeEnabled = sprefs.getBoolean("quietTimeEnabled", false);
|
||||||
|
mQuietTimeStarts = sprefs.getString("quietTimeStarts", "21:00" );
|
||||||
|
mQuietTimeEnds= sprefs.getString("quietTimeEnds", "7:00");
|
||||||
|
|
||||||
mShowContactName = sprefs.getBoolean("showContactName", false);
|
mShowContactName = sprefs.getBoolean("showContactName", false);
|
||||||
mChangeContactNameColor = sprefs.getBoolean("changeRegisteredNameColor", false);
|
mChangeContactNameColor = sprefs.getBoolean("changeRegisteredNameColor", false);
|
||||||
mContactNameColor = sprefs.getInt("registeredNameColor", 0xff00008f);
|
mContactNameColor = sprefs.getInt("registeredNameColor", 0xff00008f);
|
||||||
@ -714,9 +723,29 @@ public class K9 extends Application
|
|||||||
mMobileOptimizedLayout = mobileOptimizedLayout;
|
mMobileOptimizedLayout = mobileOptimizedLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getQuietTimeEnabled() {
|
||||||
|
return mQuietTimeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setQuietTimeEnabled(boolean quietTimeEnabled) {
|
||||||
|
mQuietTimeEnabled = quietTimeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getQuietTimeStarts() {
|
||||||
|
return mQuietTimeStarts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setQuietTimeStarts(String quietTimeStarts) {
|
||||||
|
mQuietTimeStarts = quietTimeStarts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getQuietTimeEnds() {
|
||||||
|
return mQuietTimeEnds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setQuietTimeEnds(String quietTimeEnds) {
|
||||||
|
mQuietTimeEnds = quietTimeEnds;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean startIntegratedInbox()
|
public static boolean startIntegratedInbox()
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ import android.preference.ListPreference;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
import android.widget.TimePicker;
|
||||||
|
|
||||||
import com.fsck.k9.K9;
|
import com.fsck.k9.K9;
|
||||||
import com.fsck.k9.Preferences;
|
import com.fsck.k9.Preferences;
|
||||||
@ -24,6 +25,8 @@ import com.fsck.k9.activity.ColorPickerDialog;
|
|||||||
import com.fsck.k9.activity.DateFormatter;
|
import com.fsck.k9.activity.DateFormatter;
|
||||||
import com.fsck.k9.activity.K9PreferenceActivity;
|
import com.fsck.k9.activity.K9PreferenceActivity;
|
||||||
import com.fsck.k9.preferences.CheckBoxListPreference;
|
import com.fsck.k9.preferences.CheckBoxListPreference;
|
||||||
|
import com.fsck.k9.preferences.TimePickerPreference;
|
||||||
|
|
||||||
import com.fsck.k9.service.MailService;
|
import com.fsck.k9.service.MailService;
|
||||||
|
|
||||||
public class Prefs extends K9PreferenceActivity
|
public class Prefs extends K9PreferenceActivity
|
||||||
@ -60,6 +63,11 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
|
|
||||||
private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list";
|
private static final String PREFERENCE_MESSAGEVIEW_RETURN_TO_LIST = "messageview_return_to_list";
|
||||||
private static final String PREFERENCE_MESSAGEVIEW_ZOOM_CONTROLS_ENABLED = "messageview_zoom_controls";
|
private static final String PREFERENCE_MESSAGEVIEW_ZOOM_CONTROLS_ENABLED = "messageview_zoom_controls";
|
||||||
|
private static final String PREFERENCE_QUIET_TIME_ENABLED = "quiet_time_enabled";
|
||||||
|
private static final String PREFERENCE_QUIET_TIME_STARTS = "quiet_time_starts";
|
||||||
|
private static final String PREFERENCE_QUIET_TIME_ENDS = "quiet_time_ends";
|
||||||
|
|
||||||
|
|
||||||
private static final String PREFERENCE_MESSAGEVIEW_MOBILE_LAYOUT = "messageview_mobile_layout";
|
private static final String PREFERENCE_MESSAGEVIEW_MOBILE_LAYOUT = "messageview_mobile_layout";
|
||||||
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
|
private static final String PREFERENCE_BACKGROUND_OPS = "background_ops";
|
||||||
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
|
private static final String PREFERENCE_GALLERY_BUG_WORKAROUND = "use_gallery_bug_workaround";
|
||||||
@ -94,6 +102,11 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
private CheckBoxPreference mDebugLogging;
|
private CheckBoxPreference mDebugLogging;
|
||||||
private CheckBoxPreference mSensitiveLogging;
|
private CheckBoxPreference mSensitiveLogging;
|
||||||
|
|
||||||
|
private CheckBoxPreference mQuietTimeEnabled;
|
||||||
|
private com.fsck.k9.preferences.TimePickerPreference mQuietTimeStarts;
|
||||||
|
private com.fsck.k9.preferences.TimePickerPreference mQuietTimeEnds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void actionPrefs(Context context)
|
public static void actionPrefs(Context context)
|
||||||
{
|
{
|
||||||
@ -241,6 +254,37 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
|
|
||||||
mMobileOptimizedLayout.setChecked(K9.mobileOptimizedLayout());
|
mMobileOptimizedLayout.setChecked(K9.mobileOptimizedLayout());
|
||||||
|
|
||||||
|
mQuietTimeEnabled = (CheckBoxPreference) findPreference(PREFERENCE_QUIET_TIME_ENABLED);
|
||||||
|
mQuietTimeEnabled.setChecked(K9.getQuietTimeEnabled());
|
||||||
|
|
||||||
|
mQuietTimeStarts = (TimePickerPreference) findPreference(PREFERENCE_QUIET_TIME_STARTS);
|
||||||
|
mQuietTimeStarts.setDefaultValue(K9.getQuietTimeStarts());
|
||||||
|
mQuietTimeStarts.setSummary(K9.getQuietTimeStarts());
|
||||||
|
mQuietTimeStarts.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||||
|
{
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||||
|
{
|
||||||
|
final String time = (String) newValue;
|
||||||
|
mQuietTimeStarts.setSummary(time);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mQuietTimeEnds = (TimePickerPreference) findPreference(PREFERENCE_QUIET_TIME_ENDS);
|
||||||
|
mQuietTimeEnds.setSummary(K9.getQuietTimeEnds());
|
||||||
|
mQuietTimeEnds.setDefaultValue(K9.getQuietTimeEnds());
|
||||||
|
mQuietTimeEnds.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||||
|
{
|
||||||
|
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||||
|
{
|
||||||
|
final String time = (String) newValue;
|
||||||
|
mQuietTimeEnds.setSummary(time);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mBackgroundOps = setupListPreference(PREFERENCE_BACKGROUND_OPS, K9.getBackgroundOps().toString());
|
mBackgroundOps = setupListPreference(PREFERENCE_BACKGROUND_OPS, K9.getBackgroundOps().toString());
|
||||||
|
|
||||||
@ -279,6 +323,12 @@ public class Prefs extends K9PreferenceActivity
|
|||||||
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
K9.setMessageViewFixedWidthFont(mFixedWidth.isChecked());
|
||||||
K9.setMessageViewReturnToList(mReturnToList.isChecked());
|
K9.setMessageViewReturnToList(mReturnToList.isChecked());
|
||||||
K9.setMobileOptimizedLayout(mMobileOptimizedLayout.isChecked());
|
K9.setMobileOptimizedLayout(mMobileOptimizedLayout.isChecked());
|
||||||
|
K9.setQuietTimeEnabled(mQuietTimeEnabled.isChecked());
|
||||||
|
|
||||||
|
K9.setQuietTimeStarts(mQuietTimeStarts.getTime());
|
||||||
|
K9.setQuietTimeEnds(mQuietTimeEnds.getTime());
|
||||||
|
|
||||||
|
|
||||||
K9.setZoomControlsEnabled(mZoomControlsEnabled.isChecked());
|
K9.setZoomControlsEnabled(mZoomControlsEnabled.isChecked());
|
||||||
|
|
||||||
boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());
|
boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue());
|
||||||
|
@ -84,7 +84,8 @@ public class TimePickerPreference extends DialogPreference implements
|
|||||||
@Override
|
@Override
|
||||||
public void onTimeChanged(TimePicker view, int hour, int minute) {
|
public void onTimeChanged(TimePicker view, int hour, int minute) {
|
||||||
|
|
||||||
persistString(hour + ":" + minute);
|
persistString(String.format("%02d:%02d",hour,minute));
|
||||||
|
callChangeListener(String.format("%02d:%02d",hour,minute));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -136,5 +137,10 @@ public class TimePickerPreference extends DialogPreference implements
|
|||||||
|
|
||||||
return Integer.valueOf(time.split(":")[1]);
|
return Integer.valueOf(time.split(":")[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTime() {
|
||||||
|
return getPersistedString(this.defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user