1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-30 05:02:26 -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_width="fill_parent"
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
android:layout_width="fill_parent"
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_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_ringtone_label">Play a sound when email arrives.</string>
<!-- Number of displayed messages, also used in account_settings_* -->
<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_label">Default account</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_notify_label">Email notifications</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_mail_check_frequency_label">Email check frequency</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:defaultValue="true"
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
android:layout="?android:attr/preferenceLayoutChild"

View File

@ -33,6 +33,7 @@ public class Account implements Serializable {
int mDisplayCount;
long mLastAutomaticCheckTime;
boolean mNotifyNewMail;
boolean mNotifyRingtone;
String mDraftsFolderName;
String mSentFolderName;
String mTrashFolderName;
@ -58,6 +59,7 @@ public class Account implements Serializable {
mDisplayCount = -1;
mAccountNumber = -1;
mNotifyNewMail = true;
mNotifyRingtone = false;
mSignature = "Sent from my Android phone with K-9. Please excuse my brevity.";
mVibrate = false;
mRingtoneUri = "content://settings/system/notification_sound";
@ -89,6 +91,8 @@ public class Account implements Serializable {
+ ".lastAutomaticCheckTime", 0);
mNotifyNewMail = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyNewMail",
false);
mNotifyRingtone = preferences.mSharedPreferences.getBoolean(mUuid + ".notifyRingtone",
false);
mDeletePolicy = preferences.mSharedPreferences.getInt(mUuid + ".deletePolicy", 0);
mDraftsFolderName = preferences.mSharedPreferences.getString(mUuid + ".draftsFolderName",
"Drafts");
@ -265,6 +269,7 @@ public class Account implements Serializable {
editor.putInt(mUuid + ".displayCount", mDisplayCount);
editor.putLong(mUuid + ".lastAutomaticCheckTime", mLastAutomaticCheckTime);
editor.putBoolean(mUuid + ".notifyNewMail", mNotifyNewMail);
editor.putBoolean(mUuid + ".notifyRingtone", mNotifyRingtone);
editor.putInt(mUuid + ".deletePolicy", mDeletePolicy);
editor.putString(mUuid + ".draftsFolderName", mDraftsFolderName);
editor.putString(mUuid + ".sentFolderName", mSentFolderName);
@ -332,6 +337,15 @@ public class Account implements Serializable {
this.mLastAutomaticCheckTime = lastAutomaticCheckTime;
}
public boolean isNotifyRingtone() {
return mNotifyRingtone;
}
public void setNotifyRingtone(boolean notifyRingtone) {
this.mNotifyRingtone = notifyRingtone;
}
public boolean isNotifyNewMail() {
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_DEFAULT = "account_default";
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_RINGTONE = "account_ringtone";
private static final String PREFERENCE_INCOMING = "incoming";
@ -40,6 +41,7 @@ public class AccountSettings extends PreferenceActivity {
private ListPreference mDisplayCount;
private CheckBoxPreference mAccountDefault;
private CheckBoxPreference mAccountNotify;
private CheckBoxPreference mAccountNotifyRingtone;
private CheckBoxPreference mAccountVibrate;
private RingtonePreference mAccountRingtone;
@ -106,6 +108,9 @@ public class AccountSettings extends PreferenceActivity {
mAccountNotify = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY);
mAccountNotify.setChecked(mAccount.isNotifyNewMail());
mAccountNotifyRingtone = (CheckBoxPreference) findPreference(PREFERENCE_NOTIFY_RINGTONE);
mAccountNotifyRingtone.setChecked(mAccount.isNotifyRingtone());
mAccountRingtone = (RingtonePreference) findPreference(PREFERENCE_RINGTONE);
// 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.setNotifyNewMail(mAccountNotify.isChecked());
mAccount.setNotifyRingtone(mAccountNotifyRingtone.isChecked());
mAccount.setAutomaticCheckIntervalMinutes(Integer.parseInt(mCheckFrequency.getValue()));
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
mAccount.setVibrate(mAccountVibrate.isChecked());

View File

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

View File

@ -160,7 +160,7 @@ public class MailService extends Service {
if (accountsWithNewMail.size() > 1) {
for (Account account1 : accountsWithNewMail.keySet()) {
if (account1.isVibrate()) vibrate = true;
ringtone = account1.getRingtone();
if (account1.isNotifyRingtone()) ringtone = account1.getRingtone();
}
Intent i = new Intent(context, Accounts.class);
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,
account1.getDescription()), pi);
vibrate = account1.isVibrate();
ringtone = account1.getRingtone();
if (account1.isNotifyRingtone()) ringtone = account1.getRingtone();
}
notif.defaults = Notification.DEFAULT_LIGHTS;
notif.sound = TextUtils.isEmpty(ringtone) ? null : Uri.parse(ringtone);