mirror of
https://github.com/moparisthebest/k-9
synced 2025-01-11 13:49:15 -05:00
Fixes Issue 1915
Added the vibrate pattern preference.
This commit is contained in:
parent
98d38d2e8d
commit
3ee3fad3d6
@ -359,5 +359,23 @@
|
||||
<item>48</item>
|
||||
<item>60</item>
|
||||
</string-array>
|
||||
|
||||
|
||||
<string-array name="account_settings_vibrate_pattern_entries">
|
||||
<item>@string/account_settings_vibrate_pattern_default</item>
|
||||
<item>@string/account_settings_vibrate_pattern_1</item>
|
||||
<item>@string/account_settings_vibrate_pattern_2</item>
|
||||
<item>@string/account_settings_vibrate_pattern_3</item>
|
||||
<item>@string/account_settings_vibrate_pattern_4</item>
|
||||
<item>@string/account_settings_vibrate_pattern_5</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="account_settings_vibrate_pattern_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
<item>5</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@ -578,6 +578,14 @@ Welcome to K-9 Mail setup. K-9 is an open source mail client for Android origin
|
||||
<string name="account_settings_ring_summary">Ring when mail arrives</string>
|
||||
<string name="account_settings_vibrate_enable">Vibrate</string>
|
||||
<string name="account_settings_vibrate_summary">Vibrate when mail arrives</string>
|
||||
<string name="account_settings_vibrate_pattern_label">Vibrate patterns</string>
|
||||
<string name="account_settings_vibrate_pattern_default">defaults</string>
|
||||
<string name="account_settings_vibrate_pattern_1">pattern 1</string>
|
||||
<string name="account_settings_vibrate_pattern_2">pattern 2</string>
|
||||
<string name="account_settings_vibrate_pattern_3">pattern 3</string>
|
||||
<string name="account_settings_vibrate_pattern_4">pattern 4</string>
|
||||
<string name="account_settings_vibrate_pattern_5">pattern 5</string>
|
||||
<string name="account_settings_vibrate_times">Number of vibrates</string>
|
||||
<string name="account_settings_ringtone">New mail ringtone</string>
|
||||
<string name="account_settings_servers">Server settings</string>
|
||||
|
||||
|
@ -210,6 +210,21 @@
|
||||
android:defaultValue="false"
|
||||
android:title="@string/account_settings_vibrate_enable"
|
||||
android:summary="@string/account_settings_vibrate_summary" />
|
||||
<ListPreference
|
||||
android:dependency="account_vibrate"
|
||||
android:key="account_vibrate_pattern"
|
||||
android:title="@string/account_settings_vibrate_pattern_label"
|
||||
android:entries="@array/account_settings_vibrate_pattern_entries"
|
||||
android:entryValues="@array/account_settings_vibrate_pattern_values"
|
||||
android:dialogTitle="@string/account_settings_vibrate_pattern_label" />
|
||||
<EditTextPreference
|
||||
android:dependency="account_vibrate"
|
||||
android:key="account_vibrate_times"
|
||||
android:singleLine="true"
|
||||
android:inputType="number"
|
||||
android:title="@string/account_settings_vibrate_times"
|
||||
android:summary=""
|
||||
android:dialogTitle="@string/account_settings_vibrate_times" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="account_notify_sync"
|
||||
|
@ -80,6 +80,8 @@ public class Account implements BaseAccount
|
||||
private FolderMode mFolderTargetMode;
|
||||
private int mAccountNumber;
|
||||
private boolean mVibrate;
|
||||
private int mVibratePattern;
|
||||
private int mVibrateTimes;
|
||||
private boolean mRing;
|
||||
private boolean mSaveAllHeaders;
|
||||
private boolean mPushPollOnConnect;
|
||||
@ -131,6 +133,8 @@ public class Account implements BaseAccount
|
||||
mNotifyNewMail = true;
|
||||
mNotifySync = true;
|
||||
mVibrate = false;
|
||||
mVibratePattern = 0;
|
||||
mVibrateTimes = 5;
|
||||
mRing = true;
|
||||
mNotifySelfNewMail = true;
|
||||
mFolderDisplayMode = FolderMode.NOT_SECOND_CLASS;
|
||||
@ -263,6 +267,10 @@ public class Account implements BaseAccount
|
||||
mLedColor = preferences.getPreferences().getInt(mUuid+".ledColor", mChipColor);
|
||||
|
||||
mVibrate = preferences.getPreferences().getBoolean(mUuid + ".vibrate", false);
|
||||
mVibratePattern = preferences.getPreferences().getInt(mUuid + ".vibratePattern", 0);
|
||||
mVibrateTimes = preferences.getPreferences().getInt(mUuid + ".vibrateTimes", 5);
|
||||
|
||||
|
||||
mRing = preferences.getPreferences().getBoolean(mUuid + ".ring", true);
|
||||
|
||||
try
|
||||
@ -373,6 +381,8 @@ public class Account implements BaseAccount
|
||||
editor.remove(mUuid + ".autoExpandFolderName");
|
||||
editor.remove(mUuid + ".accountNumber");
|
||||
editor.remove(mUuid + ".vibrate");
|
||||
editor.remove(mUuid + ".vibratePattern");
|
||||
editor.remove(mUuid + ".vibrateTimes");
|
||||
editor.remove(mUuid + ".ring");
|
||||
editor.remove(mUuid + ".ringtone");
|
||||
editor.remove(mUuid + ".lastFullSync");
|
||||
@ -460,6 +470,8 @@ public class Account implements BaseAccount
|
||||
editor.putString(mUuid + ".autoExpandFolderName", mAutoExpandFolderName);
|
||||
editor.putInt(mUuid + ".accountNumber", mAccountNumber);
|
||||
editor.putBoolean(mUuid + ".vibrate", mVibrate);
|
||||
editor.putInt(mUuid + ".vibratePattern", mVibratePattern);
|
||||
editor.putInt(mUuid + ".vibrateTimes", mVibrateTimes);
|
||||
editor.putBoolean(mUuid + ".ring", mRing);
|
||||
editor.putString(mUuid + ".hideButtonsEnum", mHideMessageViewButtons.name());
|
||||
editor.putString(mUuid + ".ringtone", mRingtoneUri);
|
||||
@ -681,6 +693,26 @@ public class Account implements BaseAccount
|
||||
mVibrate = vibrate;
|
||||
}
|
||||
|
||||
public synchronized int getVibratePattern()
|
||||
{
|
||||
return mVibratePattern;
|
||||
}
|
||||
|
||||
public synchronized void setVibratePattern(int pattern)
|
||||
{
|
||||
mVibratePattern = pattern;
|
||||
}
|
||||
|
||||
public synchronized int getVibrateTimes()
|
||||
{
|
||||
return mVibrateTimes;
|
||||
}
|
||||
|
||||
public synchronized void setVibrateTimes(int times)
|
||||
{
|
||||
mVibrateTimes = times;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Have we sent a new mail notification on this account */
|
||||
|
@ -38,6 +38,8 @@ public class AccountSettings extends K9PreferenceActivity
|
||||
private static final String PREFERENCE_NOTIFY_SELF = "account_notify_self";
|
||||
private static final String PREFERENCE_NOTIFY_SYNC = "account_notify_sync";
|
||||
private static final String PREFERENCE_VIBRATE = "account_vibrate";
|
||||
private static final String PREFERENCE_VIBRATE_PATTERN = "account_vibrate_pattern";
|
||||
private static final String PREFERENCE_VIBRATE_TIMES = "account_vibrate_times";
|
||||
private static final String PREFERENCE_RINGTONE = "account_ringtone";
|
||||
private static final String PREFERENCE_INCOMING = "incoming";
|
||||
private static final String PREFERENCE_OUTGOING = "outgoing";
|
||||
@ -68,6 +70,8 @@ public class AccountSettings extends K9PreferenceActivity
|
||||
private ListPreference mAccountHideButtons;
|
||||
private CheckBoxPreference mAccountNotifySync;
|
||||
private CheckBoxPreference mAccountVibrate;
|
||||
private ListPreference mAccountVibratePattern;
|
||||
private EditTextPreference mAccountVibrateTimes;
|
||||
private RingtonePreference mAccountRingtone;
|
||||
private ListPreference mDisplayMode;
|
||||
private ListPreference mSyncMode;
|
||||
@ -340,6 +344,36 @@ public class AccountSettings extends K9PreferenceActivity
|
||||
mAccountVibrate = (CheckBoxPreference) findPreference(PREFERENCE_VIBRATE);
|
||||
mAccountVibrate.setChecked(mAccount.isVibrate());
|
||||
|
||||
mAccountVibratePattern = (ListPreference) findPreference(PREFERENCE_VIBRATE_PATTERN);
|
||||
mAccountVibratePattern.setValue(String.valueOf(mAccount.getVibratePattern()));
|
||||
mAccountVibratePattern.setSummary(mAccountVibratePattern.getEntry());
|
||||
mAccountVibratePattern.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String summary = newValue.toString();
|
||||
int index = mAccountVibratePattern.findIndexOfValue(summary);
|
||||
mAccountVibratePattern.setSummary(mAccountVibratePattern.getEntries()[index]);
|
||||
mAccountVibratePattern.setValue(summary);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mAccountVibrateTimes = (EditTextPreference) findPreference(PREFERENCE_VIBRATE_TIMES);
|
||||
mAccountVibrateTimes.setSummary(String.valueOf(mAccount.getVibrateTimes()));
|
||||
mAccountVibrateTimes.setText(String.valueOf(mAccount.getVibrateTimes()));
|
||||
mAccountVibrateTimes.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener()
|
||||
{
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue)
|
||||
{
|
||||
final String value = newValue.toString();
|
||||
mAccountVibrateTimes.setSummary(value);
|
||||
mAccountVibrateTimes.setText(value);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mNotificationOpensUnread = (CheckBoxPreference)findPreference(PREFERENCE_NOTIFICATION_OPENS_UNREAD);
|
||||
mNotificationOpensUnread.setChecked(mAccount.goToUnreadMessageSearch());
|
||||
|
||||
@ -451,6 +485,8 @@ public class AccountSettings extends K9PreferenceActivity
|
||||
mAccount.setDisplayCount(Integer.parseInt(mDisplayCount.getValue()));
|
||||
mAccount.setMaximumPolledMessageAge(Integer.parseInt(mMessageAge.getValue()));
|
||||
mAccount.setVibrate(mAccountVibrate.isChecked());
|
||||
mAccount.setVibratePattern(Integer.parseInt(mAccountVibratePattern.getValue()));
|
||||
mAccount.setVibrateTimes(Integer.parseInt(mAccountVibrateTimes.getText()));
|
||||
mAccount.setGoToUnreadMessageSearch(mNotificationOpensUnread.isChecked());
|
||||
mAccount.setFolderTargetMode(Account.FolderMode.valueOf(mTargetMode.getValue()));
|
||||
mAccount.setDeletePolicy(Integer.parseInt(mDeletePolicy.getValue()));
|
||||
|
@ -4627,7 +4627,33 @@ public class MessagingController implements Runnable
|
||||
}
|
||||
if (account.isVibrate())
|
||||
{
|
||||
notif.defaults |= Notification.DEFAULT_VIBRATE;
|
||||
int times = account.getVibrateTimes();
|
||||
long[] pattern1 = new long[]{100,200};
|
||||
long[] pattern2 = new long[]{100,500};
|
||||
long[] pattern3 = new long[]{200,200};
|
||||
long[] pattern4 = new long[]{200,500};
|
||||
long[] pattern5 = new long[]{500,500};
|
||||
long[] src = null;
|
||||
|
||||
switch (account.getVibratePattern())
|
||||
{
|
||||
case 1: src = pattern1; break;
|
||||
case 2: src = pattern2; break;
|
||||
case 3: src = pattern3; break;
|
||||
case 4: src = pattern4; break;
|
||||
case 5: src = pattern5; break;
|
||||
default:
|
||||
notif.defaults |= Notification.DEFAULT_VIBRATE;
|
||||
break;
|
||||
}
|
||||
|
||||
if (src != null) {
|
||||
long[] dest = new long[src.length * times];
|
||||
for (int n = 0; n < times; n++) {
|
||||
System.arraycopy(src, 0, dest, n * src.length, src.length);
|
||||
}
|
||||
notif.vibrate = dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user