diff --git a/AndroidManifest.xml b/AndroidManifest.xml index de6848098..bf987e168 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -5,10 +5,6 @@ android:versionCode="23020" android:versionName="5.102"> - - diff --git a/build.gradle b/build.gradle index 1aeda0139..25176a138 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:0.12.2' + classpath 'com.android.tools.build:gradle:1.0.0-rc1' classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0' } } @@ -27,7 +27,8 @@ dependencies { compile 'commons-io:commons-io:2.0.1' compile 'com.jcraft:jzlib:1.0.7' compile 'com.beetstra.jutf7:jutf7:1.0.0' - compile 'com.android.support:support-v13:19.1.0' + compile 'com.android.support:support-v4:21.0.2' + compile 'com.android.support:support-v13:21.0.2' compile 'net.sourceforge.htmlcleaner:htmlcleaner:2.2' } @@ -43,7 +44,7 @@ subprojects { } android { - compileSdkVersion 19 + compileSdkVersion 21 buildToolsVersion '20.0.0' defaultConfig { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 09a4e3c6b..eeab65ea7 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jun 14 01:43:40 CEST 2014 +#Sun Nov 30 16:02:23 PST 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/images/drawable-src/ic_action_delete.svg b/images/drawable-src/ic_action_delete.svg new file mode 100644 index 000000000..8f745143f --- /dev/null +++ b/images/drawable-src/ic_action_delete.svg @@ -0,0 +1,11 @@ + + + + + + + diff --git a/images/drawable-src/ic_action_mark_as_read.svg b/images/drawable-src/ic_action_mark_as_read.svg new file mode 100644 index 000000000..a6b7d252a --- /dev/null +++ b/images/drawable-src/ic_action_mark_as_read.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/images/drawable-src/ic_action_single_message_options.svg b/images/drawable-src/ic_action_single_message_options.svg new file mode 100644 index 000000000..0655775e5 --- /dev/null +++ b/images/drawable-src/ic_action_single_message_options.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/res/drawable-nodpi-v21/ic_action_delete_dark_vector.xml b/res/drawable-nodpi-v21/ic_action_delete_dark_vector.xml new file mode 100644 index 000000000..816e5f0d2 --- /dev/null +++ b/res/drawable-nodpi-v21/ic_action_delete_dark_vector.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/res/drawable-nodpi-v21/ic_action_mark_as_read_dark_vector.xml b/res/drawable-nodpi-v21/ic_action_mark_as_read_dark_vector.xml new file mode 100644 index 000000000..a32ab6ff7 --- /dev/null +++ b/res/drawable-nodpi-v21/ic_action_mark_as_read_dark_vector.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/res/drawable-nodpi-v21/ic_action_single_message_options_dark_vector.xml b/res/drawable-nodpi-v21/ic_action_single_message_options_dark_vector.xml new file mode 100644 index 000000000..25e2125c3 --- /dev/null +++ b/res/drawable-nodpi-v21/ic_action_single_message_options_dark_vector.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/res/drawable-nodpi-v21/ic_notify_new_mail_vector.xml b/res/drawable-nodpi-v21/ic_notify_new_mail_vector.xml new file mode 100644 index 000000000..fff71a3ee --- /dev/null +++ b/res/drawable-nodpi-v21/ic_notify_new_mail_vector.xml @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/res/values-ca/strings.xml b/res/values-ca/strings.xml index e502dded3..4dadb926c 100644 --- a/res/values-ca/strings.xml +++ b/res/values-ca/strings.xml @@ -158,7 +158,9 @@ Si us plau, envia\'ns els errors, contribueix a millorar-lo a S\'està netejant el compte \"%s\" S\'està creant un compte \"%s\" Nou correu - %d missatges nous + + %d missatges nous + %d no llegit(s) (%s) i %d més a %s Respon diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml index 1a7cebe0c..fc5eccac5 100644 --- a/res/values-cs/strings.xml +++ b/res/values-cs/strings.xml @@ -159,7 +159,9 @@ Posílejte prosím chybová hlášení, přispívejte novými funkcemi a ptejte Čistím účet \"%s\" Obnovuji účet \"%s\" Nová zpráva - %d nových zpráv + + %d nových zpráv + %d Nepřečteno (%s) + %d více v %s Odpovědět diff --git a/res/values-da/strings.xml b/res/values-da/strings.xml index 84ab860cc..03427f897 100644 --- a/res/values-da/strings.xml +++ b/res/values-da/strings.xml @@ -155,7 +155,9 @@ Vær venlig at sende fejlrapporter, anmodning om nye funktioner, og spørgsmål Renser konto \"%s\" Genskaber konto \"%s\" Ny mail - %d nye meddelelser + + %d nye meddelelser + %d ulæst(e) (%s) + %d yderligere på %s Svar diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 8479cd434..47edaf961 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -158,7 +158,9 @@ Um Fehler zu melden, neue Funktionen vorzuschlagen oder Fragen zu stellen, besuc Konto \'%s\' wird bereinigt Konto \"%s\' wird wieder hergestellt Neue Nachricht - %d neue Nachrichten + + %d neue Nachrichten + %d Ungelesen (%s) und %d weitere (%s) Antworten diff --git a/res/values-el/strings.xml b/res/values-el/strings.xml index 873ac62c8..48030480f 100644 --- a/res/values-el/strings.xml +++ b/res/values-el/strings.xml @@ -157,7 +157,9 @@ Καθαρισμός λογαριασμού \'%s\' Ανακατασκευή λογαριασμού \'%s\' Νέο μήνυμα - %d νέα μηνύματα + + %d νέα μηνύματα + %d μη αναγνωσμένα (%s) + %d περισσότερα στον %s Απάντηση diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index 203fd9edf..7fc0b4a64 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -157,7 +157,9 @@ Por favor, envía los errores detectados, contribuye con nuevas funcionalidades Limpiando cuenta \"%s\" Recreando cuenta \"%s\" Correo nuevo - %d mensajes nuevos + + %d mensajes nuevos + %d Sin Leer (%s) + %d más en %s Responder diff --git a/res/values-et/strings.xml b/res/values-et/strings.xml index 247ad5f89..db47e4b3e 100644 --- a/res/values-et/strings.xml +++ b/res/values-et/strings.xml @@ -159,7 +159,9 @@ Palun saada infot probleemidest, soovitavatest lisafunktsioonidest ja küsi küs Puhastab kontot \"%s\" Taasloob kontot \"%s\" Uus meilisõnum - %d uued sõnumid + + %d uued sõnumid + %d Lugemata (%s) + %d rohkemat %s Vasta diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml index 42b719d08..c9194e694 100644 --- a/res/values-eu/strings.xml +++ b/res/values-eu/strings.xml @@ -157,7 +157,9 @@ Arazoen berri emateko, ezaugarri berriak gehitzeko eta galderak egiteko \"%s\" kontua garbitzen \"%s\" kontua birsortzen Eposta berria - %d mezu berri + + %d mezu berri + %d irakurgabe (%s) + %d gehiago %s kontuan Erantzun diff --git a/res/values-fi/strings.xml b/res/values-fi/strings.xml index 4f2020a55..f4310709e 100644 --- a/res/values-fi/strings.xml +++ b/res/values-fi/strings.xml @@ -159,7 +159,9 @@ Virheraportit, osallistuminen projektiin ja kysymykset: Mene osoitteeseen Tyhjennetään tiliä \"%s\" Luodaan uudelleen tiliä \"%s\" Uusi sähköpostiviesti - %d uutta viestiä + + %d uutta viestiä + %d lukematonta (%s) + %d viestiä lisää tilillä %s Vastaa diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml index 508723594..c8ed8d14e 100644 --- a/res/values-fr/strings.xml +++ b/res/values-fr/strings.xml @@ -157,7 +157,9 @@ jusqu\'à %d de plus Effacement du compte «\u00A0%s\u00A0» Recréation du compte «\u00A0%s\u00A0» Nouveau courriel - %d nouveaux messages + + %d nouveaux messages + %d non lu(s) (%s) + %d de plus sur %s Répondre diff --git a/res/values-gl-rES/strings.xml b/res/values-gl-rES/strings.xml index 8424dbbc0..036eaaa87 100644 --- a/res/values-gl-rES/strings.xml +++ b/res/values-gl-rES/strings.xml @@ -156,7 +156,9 @@ Envía informes de erro, contribúe con novas funcionalidades e pregunta o que d A limpar a conta \"%s\" Volvendo crear a conta \"%s\" Correo novo - %d mensaxes novas + + %d mensaxes novas + %d sen ler (%s) + %d máis en %s Responder diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index 01a09c822..deec6e93b 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -156,7 +156,9 @@ Hibajelentéseivel hozzájárul az újabb verziók tökéletesítéséhez, kérd Fiók takarítása \"%s\" A \"%s\" újbóli létrehozása Új levél - %d új üzenet + + %d új üzenet + %d Olvasatlan (%s) + %d érkezett ide: %s Válasz diff --git a/res/values-it/strings.xml b/res/values-it/strings.xml index 3ab66231f..485a491f5 100644 --- a/res/values-it/strings.xml +++ b/res/values-it/strings.xml @@ -158,7 +158,9 @@ Invia le tue segnalazioni, suggerisci nuove funzionalità e chiedi informazioni Rimozione account \"%s\" Ricrea account \"%s\" Nuova posta - %d nuovi messaggi + + %d nuovi messaggi + %d non letti (%s) + %d altri su %s Rispondi diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 944684123..800c3bc35 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -157,7 +157,9 @@ K-9 は大多数のメールクライアントと同様に、ほとんどのフ アカウント \"%s\" をクリアしています アカウント \"%s\" を再作成しています 新着メール - %d 件の新着メッセージ + + %d 件の新着メッセージ + %d 未読 (%s) + %d more on %s 返信 diff --git a/res/values-ko/strings.xml b/res/values-ko/strings.xml index 36498b88d..92653136c 100644 --- a/res/values-ko/strings.xml +++ b/res/values-ko/strings.xml @@ -156,7 +156,9 @@ K-9 메일은 대부분의 무료 hotmail 계정을 지원하지 않으며, 다 계정 비우기 \"%s\" 계정 재생성 \"%s\" 새 메일 - %d 통의 새 메일 + + %d 통의 새 메일 + %d 통의 읽지 않은 메일 (%s) + %d 통의 메일 추가됨 (%s) 답장 diff --git a/res/values-lt/strings.xml b/res/values-lt/strings.xml index 63d846e0b..727314c8c 100644 --- a/res/values-lt/strings.xml +++ b/res/values-lt/strings.xml @@ -157,7 +157,9 @@ Praneškite apie klaidas, pridėkite naujų galimybių ir užduokite klausimus m Išvaloma paskyra \"%s\" Iš naujo kuriama paskyra \"%s\" Naujas laiškas - %d naujų laiškų + + %d naujų laiškų + %d Neskaitytų (%s) + %d daugiau %s Atsakyti diff --git a/res/values-lv/strings.xml b/res/values-lv/strings.xml index 1f938d02f..1014726b8 100644 --- a/res/values-lv/strings.xml +++ b/res/values-lv/strings.xml @@ -160,7 +160,9 @@ pat %d vairāk Iztukšot kontu \"%s\" Atjaunot kontu \"%s\" Jauna vēstule - %d jaunas vēstules + + %d jaunas vēstules + %d Nelasītas (%s) + %d vairāk %s Atbildēt diff --git a/res/values-nb/strings.xml b/res/values-nb/strings.xml index b2e90c59f..287474d0c 100644 --- a/res/values-nb/strings.xml +++ b/res/values-nb/strings.xml @@ -159,7 +159,9 @@ til %d flere Renser konto \"%s\" Gjenskaper konto \"%s\" Ny e-post - %d ny(e) melding(er) + + %d ny(e) melding(er) + %d Ulest(e) (%s) + %d flere på %s Svar diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml index ec8ed7a95..f38e68cbf 100644 --- a/res/values-nl/strings.xml +++ b/res/values-nl/strings.xml @@ -157,7 +157,9 @@ Graag foutrapporten, bijdrage nieuwe functies en vragen stellen op Account \"%s\" wissen Account \"%s\" opnieuw instellen Nieuwe mail - %d nieuwe berichten + + %d nieuwe berichten + %d Ongelezen (%s) + %d meer op %s Antwoorden diff --git a/res/values-pl/strings.xml b/res/values-pl/strings.xml index c20525f89..c12bc3148 100644 --- a/res/values-pl/strings.xml +++ b/res/values-pl/strings.xml @@ -157,7 +157,9 @@ Wszelkie zgłoszenia usterek, zapytania oraz nowe pomysły prosimy przesyłać z Czyszczę konto \"%s\" Odtwarzam konto \"%s\" Nowa wiadomość - Nowych wiadomości: %d + + Nowych wiadomości: %d + Nowe: %d (%s) + %d więcej na %s Odpowiedz diff --git a/res/values-pt-rBR/strings.xml b/res/values-pt-rBR/strings.xml index bfcd29914..eb8546786 100644 --- a/res/values-pt-rBR/strings.xml +++ b/res/values-pt-rBR/strings.xml @@ -156,7 +156,9 @@ Por favor, nos envie relatórios de bugs, contribua para novas melhorias e faça Limpando conta \"%s\" Recriando conta \"%s\" Novo e-mail - %d novas mensagens + + %d novas mensagens + %d não lidos (%s) + %d mais em %s Responder diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index aa573b580..86191181e 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -158,7 +158,9 @@ K-9 Mail — почтовый клиент для Android. Очистка ящика \"%s\" Пересоздание ящика \"%s\" Новая почта - %d новых + + %d новых + %d новых (%s) + %d в %s Ответить diff --git a/res/values-sk/strings.xml b/res/values-sk/strings.xml index c7143eb5b..3316105c6 100644 --- a/res/values-sk/strings.xml +++ b/res/values-sk/strings.xml @@ -158,7 +158,9 @@ Prosím, nahlasujte prípadné chyby, prispievajte novými funkciami a pýtajte Čistenie účtu \"%s\" Obnovovanie účtu \"%s\" Nová správa - Počet nových správ: %d + + Počet nových správ: %d + Počet neprečítaných správ: %d v %s + ďalších %d v %s Odpovedať diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml index 2dff1941f..387be8a13 100644 --- a/res/values-sv/strings.xml +++ b/res/values-sv/strings.xml @@ -158,7 +158,9 @@ Anmäl fel, hjälp till med nya funktioner och ställ frågor på Rensar konto \"%s\" Återskapar konto \"%s\" Ny e-post - %d nya meddelanden + + %d nya meddelanden + %d olästa (%s) + %d ytterligare på %s Svara diff --git a/res/values-tr/strings.xml b/res/values-tr/strings.xml index 689006cc0..d85b23162 100644 --- a/res/values-tr/strings.xml +++ b/res/values-tr/strings.xml @@ -157,7 +157,9 @@ Lütfen hata raporlarınızı, istediğiniz yeni özellikleri ve sorularınızı Hesap temizleme \"%s\" Hesap yenileme \"%s\" Yeni posta - %d yeni mesaj + + %d yeni mesaj + %d Okunmadı (%s) %d daha fazla %s Yanıtla diff --git a/res/values-uk/strings.xml b/res/values-uk/strings.xml index 2e00ef7c2..f4af452ca 100644 --- a/res/values-uk/strings.xml +++ b/res/values-uk/strings.xml @@ -156,7 +156,9 @@ K-9 Mail це поштовий клієнт з відкритим вихідни Очищення скриньки \"%s\" Відновлення облікового запису\"%s\" Нова пошта - %d нові повідомлення + + %d нові повідомлення + %d Непрочитане (%s) + %d більше на %s Відповісти diff --git a/res/values-v21/styles.xml b/res/values-v21/styles.xml new file mode 100644 index 000000000..f4066afaf --- /dev/null +++ b/res/values-v21/styles.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml index 9e0dba3c5..bee136bdf 100644 --- a/res/values-zh-rCN/strings.xml +++ b/res/values-zh-rCN/strings.xml @@ -156,7 +156,9 @@ K-9改进的功能包括: 正在清理账户“%s 正在重建账户“%s 您有新邮件 - %d 新邮件 + + %d 新邮件 + 您有%d封未读邮件(%s 再加载 %d 条信息, 账户 %s 回复 diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml index 982b26705..3244ba521 100644 --- a/res/values-zh-rTW/strings.xml +++ b/res/values-zh-rTW/strings.xml @@ -128,7 +128,9 @@ 正在清理帳戶「%s 正在重建帳戶「%s 您有新郵件 - %d 新訊息 + + %d 新訊息 + 您有%d封未讀郵件(%s + 來自%s已超過%d則訊息 回覆 diff --git a/res/values/arrays.xml b/res/values/arrays.xml index 4a55df480..63eb2eeac 100644 --- a/res/values/arrays.xml +++ b/res/values/arrays.xml @@ -727,6 +727,22 @@ ALWAYS + + @string/global_settings_lock_screen_notification_visibility_nothing + @string/global_settings_lock_screen_notification_visibility_app_name + @string/global_settings_lock_screen_notification_visibility_message_count + @string/global_settings_lock_screen_notification_visibility_senders + @string/global_settings_lock_screen_notification_visibility_everything + + + + NOTHING + APP_NAME + MESSAGE_COUNT + SENDERS + EVERYTHING + + @string/global_settings_splitview_always @string/global_settings_splitview_never diff --git a/res/values/strings.xml b/res/values/strings.xml index 37771b244..9a8f8c61a 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -200,7 +200,10 @@ Please submit bug reports, contribute new features and ask questions at Recreating account \"%s\" New mail - %d new messages + + %d new message + %d new messages + %d Unread (%s) + %d more on %s @@ -339,6 +342,13 @@ Please submit bug reports, contribute new features and ask questions at Always Show a button in the notification that allows quick message deletion + Lock Screen Notifications + No lock screen notifications + Application name + Unread message count + Message count and senders + Same as unlocked notification + Quiet Time Disable ringing, buzzing and flashing at night Quiet Time starts diff --git a/res/xml/global_preferences.xml b/res/xml/global_preferences.xml index f06afa116..be892ad93 100644 --- a/res/xml/global_preferences.xml +++ b/res/xml/global_preferences.xml @@ -328,6 +328,14 @@ android:summary="@string/global_settings_notification_quick_delete_description" /> + + + * If you're adding a preference here, odds are you'll need to add it to + * {@link com.fsck.k9.preferences.GlobalSettings}, too. + * + * @param editor Preferences to save into + */ public static void save(SharedPreferences.Editor editor) { editor.putBoolean("enableDebugLogging", K9.DEBUG); editor.putBoolean("enableSensitiveLogging", K9.DEBUG_SENSITIVE); @@ -523,6 +543,7 @@ public class K9 extends Application { editor.putString("notificationHideSubject", sNotificationHideSubject.toString()); editor.putString("notificationQuickDelete", sNotificationQuickDelete.toString()); + editor.putString("lockScreenNotificationVisibility", sLockScreenNotificationVisibility.toString()); editor.putString("attachmentdefaultpath", mAttachmentDefaultPath); editor.putBoolean("useBackgroundAsUnreadIndicator", sUseBackgroundAsUnreadIndicator); @@ -675,6 +696,14 @@ public class K9 extends Application { } } + /** + * Load preferences into our statics. + * + * If you're adding a preference here, odds are you'll need to add it to + * {@link com.fsck.k9.preferences.GlobalSettings}, too. + * + * @param prefs Preferences to load + */ public static void loadPrefs(Preferences prefs) { SharedPreferences sprefs = prefs.getPreferences(); DEBUG = sprefs.getBoolean("enableDebugLogging", false); @@ -745,6 +774,11 @@ public class K9 extends Application { sNotificationQuickDelete = NotificationQuickDelete.valueOf(notificationQuickDelete); } + String lockScreenNotificationVisibility = sprefs.getString("lockScreenNotificationVisibility", null); + if(lockScreenNotificationVisibility != null) { + sLockScreenNotificationVisibility = LockScreenNotificationVisibility.valueOf(lockScreenNotificationVisibility); + } + String splitViewMode = sprefs.getString("splitViewMode", null); if (splitViewMode != null) { sSplitViewMode = SplitViewMode.valueOf(splitViewMode); @@ -1197,6 +1231,14 @@ public class K9 extends Application { sNotificationQuickDelete = mode; } + public static LockScreenNotificationVisibility getLockScreenNotificationVisibility() { + return sLockScreenNotificationVisibility; + } + + public static void setLockScreenNotificationVisibility(final LockScreenNotificationVisibility visibility) { + sLockScreenNotificationVisibility = visibility; + } + public static boolean wrapFolderNames() { return mWrapFolderNames; } diff --git a/src/com/fsck/k9/activity/setup/Prefs.java b/src/com/fsck/k9/activity/setup/Prefs.java index f2d574557..96d34846d 100644 --- a/src/com/fsck/k9/activity/setup/Prefs.java +++ b/src/com/fsck/k9/activity/setup/Prefs.java @@ -82,6 +82,7 @@ public class Prefs extends K9PreferenceActivity { 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_NOTIF_QUICK_DELETE = "notification_quick_delete"; + private static final String PREFERENCE_LOCK_SCREEN_NOTIFICATION_VISIBILITY = "lock_screen_notification_visibility"; private static final String PREFERENCE_HIDE_USERAGENT = "privacy_hide_useragent"; private static final String PREFERENCE_HIDE_TIMEZONE = "privacy_hide_timezone"; @@ -144,6 +145,7 @@ public class Prefs extends K9PreferenceActivity { private com.fsck.k9.preferences.TimePickerPreference mQuietTimeStarts; private com.fsck.k9.preferences.TimePickerPreference mQuietTimeEnds; private ListPreference mNotificationQuickDelete; + private ListPreference mLockScreenNotificationVisibility; private Preference mAttachmentPathPreference; private CheckBoxPreference mBackgroundAsUnreadIndicator; @@ -337,6 +339,14 @@ public class Prefs extends K9PreferenceActivity { mNotificationQuickDelete = null; } + mLockScreenNotificationVisibility = setupListPreference(PREFERENCE_LOCK_SCREEN_NOTIFICATION_VISIBILITY, + K9.getLockScreenNotificationVisibility().toString()); + if (!MessagingController.platformSupportsLockScreenNotifications()) { + ((PreferenceScreen) findPreference("notification_preferences")) + .removePreference(mLockScreenNotificationVisibility); + mLockScreenNotificationVisibility = null; + } + mBackgroundOps = setupListPreference(PREFERENCE_BACKGROUND_OPS, K9.getBackgroundOps().name()); mDebugLogging = (CheckBoxPreference)findPreference(PREFERENCE_DEBUG_LOGGING); @@ -484,6 +494,11 @@ public class Prefs extends K9PreferenceActivity { NotificationQuickDelete.valueOf(mNotificationQuickDelete.getValue())); } + if(mLockScreenNotificationVisibility != null) { + K9.setLockScreenNotificationVisibility( + K9.LockScreenNotificationVisibility.valueOf(mLockScreenNotificationVisibility.getValue())); + } + K9.setSplitViewMode(SplitViewMode.valueOf(mSplitViewMode.getValue())); K9.setAttachmentDefaultPath(mAttachmentPathPreference.getSummary().toString()); boolean needsRefresh = K9.setBackgroundOps(mBackgroundOps.getValue()); diff --git a/src/com/fsck/k9/controller/MessagingController.java b/src/com/fsck/k9/controller/MessagingController.java index 07f2f5e05..9ece56ee5 100644 --- a/src/com/fsck/k9/controller/MessagingController.java +++ b/src/com/fsck/k9/controller/MessagingController.java @@ -2,7 +2,6 @@ package com.fsck.k9.controller; import java.io.CharArrayWriter; import java.io.PrintWriter; -import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -13,6 +12,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -2633,13 +2633,16 @@ public class MessagingController implements Runnable { R.string.notification_certificate_error_title, account.getDescription()); final NotificationCompat.Builder builder = new NotificationCompat.Builder(context); - builder.setSmallIcon(R.drawable.ic_notify_new_mail); + builder.setSmallIcon(platformSupportsLockScreenNotifications() + ? R.drawable.ic_notify_new_mail_vector + : R.drawable.ic_notify_new_mail); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(true); builder.setTicker(title); builder.setContentTitle(title); builder.setContentText(context.getString(R.string.notification_certificate_error_text)); builder.setContentIntent(pi); + builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); configureNotification(builder, null, null, K9.NOTIFICATION_LED_FAILURE_COLOR, @@ -3343,6 +3346,7 @@ public class MessagingController implements Runnable { TaskStackBuilder stack = buildMessageListBackStack(mApplication, account, account.getInboxFolderName()); builder.setContentIntent(stack.getPendingIntent(0, 0)); + builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (K9.NOTIFICATION_LED_WHILE_SYNCING) { configureNotification(builder, null, null, @@ -3377,7 +3381,9 @@ public class MessagingController implements Runnable { (NotificationManager) mApplication.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.Builder builder = new NotificationCompat.Builder(mApplication); - builder.setSmallIcon(R.drawable.ic_notify_new_mail); + builder.setSmallIcon(platformSupportsLockScreenNotifications() + ? R.drawable.ic_notify_new_mail_vector + : R.drawable.ic_notify_new_mail); builder.setWhen(System.currentTimeMillis()); builder.setAutoCancel(true); builder.setTicker(mApplication.getString(R.string.send_failure_subject)); @@ -3386,6 +3392,7 @@ public class MessagingController implements Runnable { TaskStackBuilder stack = buildFolderListBackStack(mApplication, account); builder.setContentIntent(stack.getPendingIntent(0, 0)); + builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); configureNotification(builder, null, null, K9.NOTIFICATION_LED_FAILURE_COLOR, K9.NOTIFICATION_LED_BLINK_FAST, true); @@ -3424,6 +3431,7 @@ public class MessagingController implements Runnable { TaskStackBuilder stack = buildMessageListBackStack(mApplication, account, account.getInboxFolderName()); builder.setContentIntent(stack.getPendingIntent(0, 0)); + builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); if (K9.NOTIFICATION_LED_WHILE_SYNCING) { configureNotification(builder, null, null, @@ -4769,6 +4777,10 @@ public class MessagingController implements Runnable { return Build.VERSION.SDK_INT >= 16; } + public static boolean platformSupportsLockScreenNotifications() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; + } + private Message findNewestMessageForNotificationLocked(Context context, Account account, NotificationData data) { if (!data.messages.isEmpty()) { @@ -4793,6 +4805,9 @@ public class MessagingController implements Runnable { } } + // Maximum number of senders to display in a lock screen notification. + private static final int NUM_SENDERS_IN_LOCK_SCREEN_NOTIFICATION = 5; + private void notifyAccountWithDataLocked(Context context, Account account, Message message, NotificationData data) { boolean updateSilently = false; @@ -4858,7 +4873,8 @@ public class MessagingController implements Runnable { style.setSummaryText(context.getString(R.string.notification_additional_messages, data.droppedMessages.size(), accountDescr)); } - String title = context.getString(R.string.notification_new_messages_title, newMessages); + final String title = context.getResources().getQuantityString( + R.plurals.notification_new_messages_title, newMessages, newMessages); style.setBigContentTitle(title); builder.setContentTitle(title); builder.setSubText(accountDescr); @@ -4875,14 +4891,20 @@ public class MessagingController implements Runnable { builder.setContentTitle(sender); builder.setStyle(style); - builder.addAction(R.drawable.ic_action_single_message_options_dark, - context.getString(R.string.notification_action_reply), - NotificationActionService.getReplyIntent(context, account, message.makeMessageReference())); + builder.addAction( + platformSupportsExtendedNotifications() + ? R.drawable.ic_action_single_message_options_dark_vector + : R.drawable.ic_action_single_message_options_dark, + context.getString(R.string.notification_action_reply), + NotificationActionService.getReplyIntent(context, account, message.makeMessageReference())); } - builder.addAction(R.drawable.ic_action_mark_as_read_dark, - context.getString(R.string.notification_action_mark_as_read), - NotificationActionService.getReadAllMessagesIntent(context, account, allRefs)); + builder.addAction( + platformSupportsLockScreenNotifications() + ? R.drawable.ic_action_mark_as_read_dark_vector + : R.drawable.ic_action_mark_as_read_dark, + context.getString(R.string.notification_action_mark_as_read), + NotificationActionService.getReadAllMessagesIntent(context, account, allRefs)); NotificationQuickDelete deleteOption = K9.getNotificationQuickDeleteBehaviour(); boolean showDeleteAction = deleteOption == NotificationQuickDelete.ALWAYS || @@ -4891,9 +4913,12 @@ public class MessagingController implements Runnable { if (showDeleteAction) { // we need to pass the action directly to the activity, otherwise the // status bar won't be pulled up and we won't see the confirmation (if used) - builder.addAction(R.drawable.ic_action_delete_dark, - context.getString(R.string.notification_action_delete), - NotificationDeleteConfirmation.getIntent(context, account, allRefs)); + builder.addAction( + platformSupportsLockScreenNotifications() + ? R.drawable.ic_action_delete_dark_vector + : R.drawable.ic_action_delete_dark, + context.getString(R.string.notification_action_delete), + NotificationDeleteConfirmation.getIntent(context, account, allRefs)); } } else { String accountNotice = context.getString(R.string.notification_new_one_account_fmt, @@ -4952,6 +4977,8 @@ public class MessagingController implements Runnable { NotificationSetting n = account.getNotificationSetting(); + configureLockScreenNotification(builder, context, account, newMessages, unreadCount, accountDescr, sender, data.messages); + configureNotification( builder, (n.shouldRing()) ? n.getRingtone() : null, @@ -5064,6 +5091,78 @@ public class MessagingController implements Runnable { } } + /** + * Configure lock screen notifications on platforms that support it + * + * @param builder Unlocked notification + * @param context Context + * @param account Account being notified + * @param newMessages Number of new messages being notified for + * @param unreadCount Total number of unread messages in this account + * @param accountDescription Formatted account name for display + * @param formattedSender Formatted sender name for display + * @param messages List of messages if notifying for multiple messages. Null otherwise. + */ + private void configureLockScreenNotification(NotificationCompat.Builder builder, + Context context, + Account account, + int newMessages, + int unreadCount, + CharSequence accountDescription, + CharSequence formattedSender, + List messages) { + if (!platformSupportsLockScreenNotifications()) { + return; + } + + builder.setSmallIcon(R.drawable.ic_notify_new_mail_vector); + builder.setColor(account.getChipColor()); + + NotificationCompat.Builder publicNotification = new NotificationCompat.Builder(context); + publicNotification.setSmallIcon(R.drawable.ic_notify_new_mail_vector); + publicNotification.setColor(account.getChipColor()); + publicNotification.setNumber(unreadCount); + final String title = context.getResources().getQuantityString( + R.plurals.notification_new_messages_title, newMessages, newMessages); + publicNotification.setContentTitle(title); + + switch (K9.getLockScreenNotificationVisibility()) { + case NOTHING: + builder.setVisibility(NotificationCompat.VISIBILITY_SECRET); + break; + case APP_NAME: + // This is the Android default, but we should be explicit in case that changes in the future. + builder.setVisibility(NotificationCompat.VISIBILITY_PRIVATE); + break; + case SENDERS: + if (newMessages == 1) { + publicNotification.setContentText(formattedSender); + } else { + // Use a LinkedHashSet so that we preserve ordering (newest to oldest), but still remove duplicates + Set senders = new LinkedHashSet<>(NUM_SENDERS_IN_LOCK_SCREEN_NOTIFICATION); + for (Message message : messages) { + senders.add(getMessageSender(context, account, message)); + if (senders.size() == NUM_SENDERS_IN_LOCK_SCREEN_NOTIFICATION) { + break; + } + } + publicNotification.setContentText(TextUtils.join(", ", senders)); + } + + builder.setPublicVersion(publicNotification.build()); + break; + case EVERYTHING: + builder.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); + break; + case MESSAGE_COUNT: + default: + publicNotification.setContentText(accountDescription); + + builder.setPublicVersion(publicNotification.build()); + break; + } + } + /** Cancel a notification of new email messages */ public void notifyAccountCancel(Context context, Account account) { NotificationManager notifMgr = diff --git a/src/com/fsck/k9/preferences/GlobalSettings.java b/src/com/fsck/k9/preferences/GlobalSettings.java index 38d134a8f..88e0e2a3f 100644 --- a/src/com/fsck/k9/preferences/GlobalSettings.java +++ b/src/com/fsck/k9/preferences/GlobalSettings.java @@ -23,6 +23,8 @@ import com.fsck.k9.R; import com.fsck.k9.Account.SortType; import com.fsck.k9.preferences.Settings.*; +import static com.fsck.k9.K9.LockScreenNotificationVisibility; + public class GlobalSettings { public static final Map> SETTINGS; public static final Map UPGRADERS; @@ -249,6 +251,9 @@ public class GlobalSettings { s.put("hideTimeZone", Settings.versions( new V(32, new BooleanSetting(false)) )); + s.put("lockScreenNotificationVisibility", Settings.versions( + new V(37, new EnumSetting<>(LockScreenNotificationVisibility.class, LockScreenNotificationVisibility.MESSAGE_COUNT)) + )); SETTINGS = Collections.unmodifiableMap(s); diff --git a/src/com/fsck/k9/preferences/Settings.java b/src/com/fsck/k9/preferences/Settings.java index f915141cc..0b814091b 100644 --- a/src/com/fsck/k9/preferences/Settings.java +++ b/src/com/fsck/k9/preferences/Settings.java @@ -35,7 +35,7 @@ public class Settings { * * @see SettingsExporter */ - public static final int VERSION = 36; + public static final int VERSION = 37; public static Map validate(int version, Map> settings,