Add vibration pattern settings

pull/384/head
Alex Baker 9 years ago
parent 6eeeceef4e
commit 032a7124ec

@ -337,7 +337,7 @@ public class Notifier {
}
if (preferences.getBoolean(R.string.p_rmd_vibrate, true) && soundIntervalOk) {
notification.vibrate = new long[]{0, 1000, 500, 1000, 500, 1000};
notification.vibrate = preferences.getVibrationPattern();
} else {
notification.vibrate = null;
}

@ -7,6 +7,7 @@ import android.os.Environment;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.google.common.primitives.Longs;
import com.todoroo.astrid.activity.BeastModePreferences;
import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.core.SortHelper;
@ -21,6 +22,8 @@ import org.tasks.R;
import org.tasks.injection.ForApplication;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
@ -409,4 +412,18 @@ public class Preferences {
}
return null;
}
public long[] getVibrationPattern() {
int vibrationCount = getIntegerFromString(R.string.p_vibrate_count, 3);
long vibrationDuration = getIntegerFromString(R.string.p_vibrate_duration, 1000);
long vibrationPause = getIntegerFromString(R.string.p_vibrate_pause, 500);
List<Long> pattern = new ArrayList<>(vibrationCount);
pattern.add(0L);
pattern.add(vibrationDuration);
for (int i = 1 ; i < vibrationCount ; i++) {
pattern.add(vibrationPause);
pattern.add(vibrationDuration);
}
return Longs.toArray(pattern);
}
}

@ -210,7 +210,6 @@
<string name="notifications">تنبيهات</string>
<string name="silent">الصمت</string>
<string name="sound">صوت</string>
<string name="vibrate">اهتزاز</string>
<string name="quiet_hours">الساعات الهادئة</string>
<string name="synchronization">التزامن</string>
<string name="enabled">تفعيل</string>

@ -346,7 +346,6 @@
<string name="notifications">Уведомления</string>
<string name="silent">Безшумен</string>
<string name="sound">Звук</string>
<string name="vibrate">Вибрация</string>
<string name="quiet_hours">Тихи часове</string>
<string name="attachment_directory">Директория за прикачени файлове</string>
<string name="backup_directory">Директория за резервни копия</string>

@ -326,7 +326,6 @@
<string name="notifications">Benachrichtigungen</string>
<string name="silent">Ton Aus</string>
<string name="sound">Ton</string>
<string name="vibrate">Vibrieren</string>
<string name="quiet_hours">Ruhezeiten</string>
<string name="attachment_directory">Anhängeordner</string>
<string name="backup_directory">Sicherungsordner</string>

@ -328,7 +328,6 @@
<string name="notifications">Notificaciones</string>
<string name="silent">Silencioso</string>
<string name="sound">Sonido</string>
<string name="vibrate">Vibrar</string>
<string name="quiet_hours">Horario en silencio</string>
<string name="attachment_directory">Directorio de archivos adjuntos</string>
<string name="backup_directory">Directorio de la copia de seguridad</string>

@ -247,7 +247,6 @@
<string name="notifications">اعلان ها</string>
<string name="silent">سکوت</string>
<string name="sound">صدا</string>
<string name="vibrate">ویبره</string>
<string name="quiet_hours">ساعات سکوت</string>
<string name="backup_directory">پشتیبان گیری از پوشه</string>
<string name="miscellaneous">سایر</string>

@ -329,7 +329,6 @@
<string name="widget_transparent_background">Fond transparent</string>
<string name="silent">Silencieux</string>
<string name="sound">Son</string>
<string name="vibrate">Vibrer</string>
<string name="quiet_hours">Heures de repos</string>
<string name="attachment_directory">Dossier pour les fichiers attachés</string>
<string name="backup_directory">Dossier de sauvegarde</string>

@ -340,7 +340,6 @@ Se visualizzi questo errore più volte, ti consigliamo di cancellare tutti i dat
<string name="notifications">Notifiche</string>
<string name="silent">Silente</string>
<string name="sound">Sonoro</string>
<string name="vibrate">Vibrazione</string>
<string name="quiet_hours">Ore di quiete</string>
<string name="attachment_directory">Cartella allegati</string>
<string name="backup_directory">Cartella di Backup</string>

@ -345,7 +345,6 @@
<string name="notifications">通知</string>
<string name="silent">サイレント</string>
<string name="sound">サウンド</string>
<string name="vibrate">振動</string>
<string name="quiet_hours">消音時間</string>
<string name="attachment_directory">添付ディレクトリ</string>
<string name="backup_directory">ディレクトリをバックアップ</string>

@ -347,7 +347,6 @@ Tasks의 백업에서 당신의 일정을 복구하시기 바랍니다.
<string name="notifications">알림</string>
<string name="silent">무음</string>
<string name="sound">소리</string>
<string name="vibrate">진동</string>
<string name="quiet_hours">무음 시간대</string>
<string name="attachment_directory">첨부파일 위치</string>
<string name="backup_directory">백업 위치</string>

@ -341,7 +341,6 @@
<string name="notifications">Notificaties</string>
<string name="silent">Stil</string>
<string name="sound">Geluid</string>
<string name="vibrate">Trillen</string>
<string name="quiet_hours">Rustperiode</string>
<string name="attachment_directory">Bijlage directory</string>
<string name="debug_logging">Fouten loggen</string>

@ -338,7 +338,6 @@ das tarefas através de um backup em Definições-&gt;Sincronização e backup-&
<string name="notifications">Notificações</string>
<string name="silent">Silêncio</string>
<string name="sound">Som</string>
<string name="vibrate">Vibrar</string>
<string name="quiet_hours">Horas de silêncio</string>
<string name="attachment_directory">Diretório do anexo</string>
<string name="backup_directory">Diretório de backup</string>

@ -344,7 +344,6 @@
<string name="notifications">Уведомления</string>
<string name="silent">Без звука</string>
<string name="sound">Звук</string>
<string name="vibrate">Вибрация</string>
<string name="quiet_hours">Тихие часы:</string>
<string name="attachment_directory">Путь к вложениям</string>
<string name="backup_directory">Папка резервных копий</string>

@ -330,7 +330,6 @@
<string name="notifications">Oznámenia</string>
<string name="silent">Tichý</string>
<string name="sound">Zvuk</string>
<string name="vibrate">Vybrácia</string>
<string name="quiet_hours">Tiché hodiny</string>
<string name="attachment_directory">Príloha adresára</string>
<string name="backup_directory">Zalóhovať adresár</string>

@ -1,5 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="vibration_count">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>
<string-array name="vibration_duration">
<item>250</item>
<item>500</item>
<item>750</item>
<item>1000</item>
</string-array>
<string-array name="geofence_radius_values">
<item>75</item>
<item>125</item>

@ -43,7 +43,10 @@
<!-- whether to vibrate phone when reminder fires -->
<string name="p_rmd_vibrate">notif_vibrate</string>
<string name="p_vibrate_count">vibrate_count</string>
<string name="p_vibrate_duration">vibrate_duration</string>
<string name="p_vibrate_pause">vibrate_pause</string>
<!-- ringtone to use for notifications -->
<string name="p_rmd_ringtone">notification_ringtone</string>
@ -276,4 +279,8 @@
<item>-1</item>
</string-array>
<string name="default_vibration_count">3</string>
<string name="default_vibration_duration">1000</string>
<string name="default_vibration_pause">500</string>
</resources>

@ -62,7 +62,7 @@
<string name="notifications">Notifications</string>
<string name="silent">Silent</string>
<string name="sound">Sound</string>
<string name="vibrate">Vibrate</string>
<string name="vibrations">Vibrations</string>
<string name="quiet_hours">Quiet hours</string>
<string name="attachment_directory">Attachment directory</string>
<string name="backup_directory">Backup directory</string>
@ -126,6 +126,9 @@
<string name="default_priority">Default</string>
<string name="low_priority">Low</string>
<string name="notification_priority">Notification Priority</string>
<string name="vibration_count">Number of vibrations</string>
<string name="vibration_duration">Length of each vibration (milliseconds)</string>
<string name="vibration_pause">Pause between vibrations (milliseconds)</string>
<string-array name="sync_SPr_interval_entries">
<!-- sync_SPr_interval_entries: Synchronization Intervals -->

@ -33,11 +33,6 @@
android:showDefault="true"
android:showSilent="true"
android:title="@string/sound" />
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_rmd_vibrate"
android:title="@string/vibrate" />
<com.todoroo.astrid.ui.MultilineCheckboxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
@ -63,6 +58,39 @@
android:summary="@string/rmd_EPr_multiple_maxvolume_desc_true"
android:title="@string/rmd_EPr_multiple_maxvolume_title" />
<PreferenceCategory
android:title="@string/vibrations">
<CheckBoxPreference
android:defaultValue="true"
android:dependency="@string/p_rmd_enabled"
android:key="@string/p_rmd_vibrate"
android:title="@string/enabled" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="3"
android:dependency="@string/p_rmd_vibrate"
android:entries="@array/vibration_count"
android:entryValues="@array/vibration_count"
android:key="@string/p_vibrate_count"
android:title="@string/vibration_count" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="1000"
android:dependency="@string/p_rmd_vibrate"
android:entries="@array/vibration_duration"
android:entryValues="@array/vibration_duration"
android:key="@string/p_vibrate_duration"
android:title="@string/vibration_duration" />
<com.todoroo.astrid.ui.MultilineListPreference
android:defaultValue="500"
android:dependency="@string/p_rmd_vibrate"
android:entries="@array/vibration_duration"
android:entryValues="@array/vibration_duration"
android:key="@string/p_vibrate_pause"
android:title="@string/vibration_pause" />
</PreferenceCategory>
<PreferenceCategory
android:key="@string/geolocation_reminders"
android:title="@string/geolocation_reminders">

Loading…
Cancel
Save