1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-27 11:42:16 -05:00

Allow notification without ringtone

This commit is contained in:
Jesse Vincent 2008-12-11 19:13:55 +00:00
parent 1d6fa64d51
commit f961cac9ac
7 changed files with 40 additions and 3 deletions

View File

@ -34,6 +34,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:text="@string/account_setup_options_notify_label" /> android:text="@string/account_setup_options_notify_label" />
<CheckBox
android:id="@+id/account_notify_ringtone"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:text="@string/account_setup_options_notify_ringtone_label" />
<View <View
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="0px" android:layout_height="0px"

View File

@ -216,6 +216,7 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
<string name="account_setup_options_mail_check_frequency_1hour">Every hour</string> <string name="account_setup_options_mail_check_frequency_1hour">Every hour</string>
<string name="account_setup_options_default_label">Send email from this account by default.</string> <string name="account_setup_options_default_label">Send email from this account by default.</string>
<string name="account_setup_options_notify_label">Notify me when email arrives.</string> <string name="account_setup_options_notify_label">Notify me when email arrives.</string>
<string name="account_setup_options_notify_ringtone_label">Play a sound when email arrives.</string>
<!-- Number of displayed messages, also used in account_settings_* --> <!-- Number of displayed messages, also used in account_settings_* -->
<string name="account_setup_options_mail_display_count_label">Number of emails to display</string> <string name="account_setup_options_mail_display_count_label">Number of emails to display</string>
@ -234,9 +235,11 @@ Welcome to K-9 Mail setup. K-9 is an open source email client for Android based
<string name="account_settings_default">Default account</string> <string name="account_settings_default">Default account</string>
<string name="account_settings_default_label">Default account</string> <string name="account_settings_default_label">Default account</string>
<string name="account_settings_default_summary">Send email from this account by default</string> <string name="account_settings_default_summary">Send email from this account by default</string>
<string name="account_settings_notify_label">Email notifications</string>
<string name="account_settings_email_label">Your email address</string> <string name="account_settings_email_label">Your email address</string>
<string name="account_settings_notify_label">Email notifications</string>
<string name="account_settings_notify_summary">Notify in status bar when email arrives</string> <string name="account_settings_notify_summary">Notify in status bar when email arrives</string>
<string name="account_settings_notify_ringtone_label">Ringtone notifications</string>
<string name="account_settings_notify_ringtone_summary">Play a sound when email arrives</string>
<string name="account_settings_show_combined_label">Show combined Inbox</string> <string name="account_settings_show_combined_label">Show combined Inbox</string>
<string name="account_settings_mail_check_frequency_label">Email check frequency</string> <string name="account_settings_mail_check_frequency_label">Email check frequency</string>
<string name="account_settings_mail_display_count_label">Number of emails to display</string> <string name="account_settings_mail_display_count_label">Number of emails to display</string>

View File

@ -54,6 +54,11 @@
android:title="@string/account_settings_notify_label" android:title="@string/account_settings_notify_label"
android:defaultValue="true" android:defaultValue="true"
android:summary="@string/account_settings_notify_summary" /> android:summary="@string/account_settings_notify_summary" />
<CheckBoxPreference
android:key="account_notify_ringtone"
android:title="@string/account_settings_notify_ringtone_label"
android:defaultValue="true"
android:summary="@string/account_settings_notify_ringtone_summary" />
<RingtonePreference <RingtonePreference
android:layout="?android:attr/preferenceLayoutChild" android:layout="?android:attr/preferenceLayoutChild"

View File

@ -33,6 +33,7 @@ public class Account implements Serializable {
int mDisplayCount; int mDisplayCount;
long mLastAutomaticCheckTime; long mLastAutomaticCheckTime;
boolean mNotifyNewMail; boolean mNotifyNewMail;
boolean mNotifyRingtone;
String mDraftsFolderName; String mDraftsFolderName;
String mSentFolderName; String mSentFolderName;
String mTrashFolderName; String mTrashFolderName;
@ -58,6 +59,7 @@ public class Account implements Serializable {
mDisplayCount = -1; mDisplayCount = -1;
mAccountNumber = -1; mAccountNumber = -1;
mNotifyNewMail = true; mNotifyNewMail = true;
mNotifyRingtone = false;
mSignature = "Sent from my Android phone with K-9. Please excuse my brevity."; mSignature = "Sent from my Android phone with K-9. Please excuse my brevity.";
mVibrate = false; mVibrate = false;
mRingtoneUri = "content://settings/system/notification_sound"; mRingtoneUri = "content://settings/system/notification_sound";
@ -89,6 +91,8 @@ public class Account implements Serializable {
+ ".lastAutomaticCheckTime", 0); + ".lastAutomaticCheckTime", 0);
mNotifyNewMail = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyNewMail", mNotifyNewMail = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyNewMail",
false); false);
mNotifyRingtone = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyRingtone",
false);
mDeletePolicy = preferences.mSharedPreferences.getInt(mUuid + ".deletePolicy", 0); mDeletePolicy = preferences.mSharedPreferences.getInt(mUuid + ".deletePolicy", 0);
mDraftsFolderName = preferences.mSharedPreferences.getString(mUuid + ".draftsFolderName", mDraftsFolderName = preferences.mSharedPreferences.getString(mUuid + ".draftsFolderName",
"Drafts"); "Drafts");
@ -265,6 +269,7 @@ public class Account implements Serializable {
editor.putInt(mUuid + ".displayCount", mDisplayCount); editor.putInt(mUuid + ".displayCount", mDisplayCount);
editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime); editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail); editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
editor.putBoolean(mUuid + ".notifyRingtone", mNotifyRingtone);
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy); editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName); editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
editor.putString(mUuid + ".sentFolderName", mSentFolderName); editor.putString(mUuid + ".sentFolderName", mSentFolderName);
@ -332,6 +337,15 @@ public class Account implements Serializable {
this.mLastAutomaticCheckTime = lastAutomaticCheckTime; this.mLastAutomaticCheckTime = lastAutomaticCheckTime;
} }
public boolean isNotifyRingtone() {
return mNotifyRingtone;
}
public void setNotifyRingtone(boolean notifyRingtone) {
this.mNotifyRingtone = notifyRingtone;
}
public boolean isNotifyNewMail() { public boolean isNotifyNewMail() {
return mNotifyNewMail; return mNotifyNewMail;
} }

View File

@ -28,6 +28,7 @@ public class AccountSettings extends PreferenceActivity {
private static final String PREFERENCE_DISPLAY_COUNT = "account_display_count"; private static final String PREFERENCE_DISPLAY_COUNT = "account_display_count";
private static final String PREFERENCE_DEFAULT = "account_default"; private static final String PREFERENCE_DEFAULT = "account_default";
private static final String PREFERENCE_NOTIFY = "account_notify"; private static final String PREFERENCE_NOTIFY = "account_notify";
private static final String PREFERENCE_NOTIFY_RINGTONE = "account_notify_ringtone";
private static final String PREFERENCE_VIBRATE = "account_vibrate"; private static final String PREFERENCE_VIBRATE = "account_vibrate";
private static final String PREFERENCE_RINGTONE = "account_ringtone"; private static final String PREFERENCE_RINGTONE = "account_ringtone";
private static final String PREFERENCE_INCOMING = "incoming"; private static final String PREFERENCE_INCOMING = "incoming";
@ -40,6 +41,7 @@ public class AccountSettings extends PreferenceActivity {
private ListPreference mDisplayCount; private ListPreference mDisplayCount;
private CheckBoxPreference mAccountDefault; private CheckBoxPreference mAccountDefault;
private CheckBoxPreference mAccountNotify; private CheckBoxPreference mAccountNotify;
private CheckBoxPreference mAccountNotifyRingtone;
private CheckBoxPreference mAccountVibrate; private CheckBoxPreference mAccountVibrate;
private RingtonePreference mAccountRingtone; private RingtonePreference mAccountRingtone;
@ -106,6 +108,9 @@ public class AccountSettings extends PreferenceActivity {
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY); mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
mAccountNotify.setChecked(mAccount.isNotifyNewMail()); mAccountNotify.setChecked(mAccount.isNotifyNewMail());
mAccountNotifyRingtone = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_RINGTONE);
mAccountNotifyRingtone.setChecked(mAccount.isNotifyRingtone());
mAccountRingtone = (RingtonePreference) findPreference(PREFERENCE_RINGTONE); mAccountRingtone = (RingtonePreference) findPreference(PREFERENCE_RINGTONE);
// XXX: The following two lines act as a workaround for the RingtonePreference // XXX: The following two lines act as a workaround for the RingtonePreference
@ -154,6 +159,7 @@ public class AccountSettings extends PreferenceActivity {
} }
mAccount.setDescription(mAccountDescription.getText()); mAccount.setDescription(mAccountDescription.getText());
mAccount.setNotifyNewMail(mAccountNotify.isChecked()); mAccount.setNotifyNewMail(mAccountNotify.isChecked());
mAccount.setNotifyRingtone(mAccountNotifyRingtone.isChecked());
mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue())); mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue())); mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
mAccount.setVibrate(mAccountVibrate.isChecked()); mAccount.setVibrate(mAccountVibrate.isChecked());

View File

@ -28,6 +28,7 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
private CheckBox mDefaultView; private CheckBox mDefaultView;
private CheckBox mNotifyView; private CheckBox mNotifyView;
private CheckBox mNotifyRingtoneView;
private Account mAccount; private Account mAccount;
@ -47,6 +48,7 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
mDisplayCountView = (Spinner)findViewById(R.id.account_display_count); mDisplayCountView = (Spinner)findViewById(R.id.account_display_count);
mDefaultView = (CheckBox)findViewById(R.id.account_default); mDefaultView = (CheckBox)findViewById(R.id.account_default);
mNotifyView = (CheckBox)findViewById(R.id.account_notify); mNotifyView = (CheckBox)findViewById(R.id.account_notify);
mNotifyRingtoneView = (CheckBox)findViewById(R.id.account_notify_ringtone);
findViewById(R.id.next).setOnClickListener(this); findViewById(R.id.next).setOnClickListener(this);
@ -94,6 +96,7 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
mDefaultView.setChecked(true); mDefaultView.setChecked(true);
} }
mNotifyView.setChecked(mAccount.isNotifyNewMail()); mNotifyView.setChecked(mAccount.isNotifyNewMail());
mNotifyRingtoneView.setChecked(mAccount.isNotifyRingtone());
SpinnerOption.setSpinnerOptionValue(mCheckFrequencyView, mAccount SpinnerOption.setSpinnerOptionValue(mCheckFrequencyView, mAccount
.getAutomaticCheckIntervalMinutes()); .getAutomaticCheckIntervalMinutes());
SpinnerOption.setSpinnerOptionValue(mDisplayCountView, mAccount SpinnerOption.setSpinnerOptionValue(mDisplayCountView, mAccount
@ -103,6 +106,7 @@ public class AccountSetupOptions extends Activity implements OnClickListener {
private void onDone() { private void onDone() {
mAccount.setDescription(mAccount.getEmail()); mAccount.setDescription(mAccount.getEmail());
mAccount.setNotifyNewMail(mNotifyView.isChecked()); mAccount.setNotifyNewMail(mNotifyView.isChecked());
mAccount.setNotifyRingtone(mNotifyRingtoneView.isChecked());
mAccount.setAutomaticCheckIntervalMinutes((Integer)((SpinnerOption)mCheckFrequencyView mAccount.setAutomaticCheckIntervalMinutes((Integer)((SpinnerOption)mCheckFrequencyView
.getSelectedItem()).value); .getSelectedItem()).value);
mAccount.setDisplayCount((Integer)((SpinnerOption)mDisplayCountView mAccount.setDisplayCount((Integer)((SpinnerOption)mDisplayCountView

View File

@ -160,7 +160,7 @@ public class MailService extends Service {
if (accountsWithNewMail.size() > 1) { if (accountsWithNewMail.size() > 1) {
for (Account account1 : accountsWithNewMail.keySet()) { for (Account account1 : accountsWithNewMail.keySet()) {
if (account1.isVibrate()) vibrate = true; if (account1.isVibrate()) vibrate = true;
ringtone = account1.getRingtone(); if (account1.isNotifyRingtone()) ringtone = account1.getRingtone();
} }
Intent i = new Intent(context, Accounts.class); Intent i = new Intent(context, Accounts.class);
PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0); PendingIntent pi = PendingIntent.getActivity(context, 0, i, 0);
@ -176,7 +176,7 @@ public class MailService extends Service {
getString(R.string.notification_new_one_account_fmt, totalNewMails, getString(R.string.notification_new_one_account_fmt, totalNewMails,
account1.getDescription()), pi); account1.getDescription()), pi);
vibrate = account1.isVibrate(); vibrate = account1.isVibrate();
ringtone = account1.getRingtone(); if (account1.isNotifyRingtone()) ringtone = account1.getRingtone();
} }
notif.defaults = Notification.DEFAULT_LIGHTS; notif.defaults = Notification.DEFAULT_LIGHTS;
notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone); notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);