This commit is contained in:
Mariotaku Lee 2017-09-17 00:35:21 +08:00
parent b1750203c9
commit f644622339
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
34 changed files with 140 additions and 65 deletions

View File

@ -69,6 +69,8 @@ public interface IntentConstants {
String INTENT_ACTION_PEBBLE_NOTIFICATION = "com.getpebble.action.SEND_NOTIFICATION";
String BROADCAST_NOTIFICATION_DELETED = INTENT_PACKAGE_PREFIX + "NOTIFICATION_DELETED";
String BROADCAST_PROMOTIONS_ACCEPTED = INTENT_PACKAGE_PREFIX + "PROMOTIONS_ACCEPTED";
String BROADCAST_PROMOTIONS_DENIED = INTENT_PACKAGE_PREFIX + "PROMOTIONS_DENIED";
String EXTRA_LATITUDE = "latitude";
String EXTRA_LONGITUDE = "longitude";

View File

@ -39,6 +39,7 @@ import android.os.Build
import android.os.Bundle
import android.support.annotation.StringRes
import android.support.v4.app.Fragment
import android.support.v4.app.NotificationCompat
import android.support.v4.view.GravityCompat
import android.support.v4.view.ViewCompat
import android.support.v4.view.ViewPager.OnPageChangeListener
@ -98,6 +99,7 @@ import org.mariotaku.twidere.model.notification.NotificationChannelSpec
import org.mariotaku.twidere.provider.TwidereDataStore.Activities
import org.mariotaku.twidere.provider.TwidereDataStore.Messages.Conversations
import org.mariotaku.twidere.provider.TwidereDataStore.Statuses
import org.mariotaku.twidere.receiver.NotificationReceiver
import org.mariotaku.twidere.service.StreamingService
import org.mariotaku.twidere.util.*
import org.mariotaku.twidere.util.KeyboardShortcutsHandler.KeyboardShortcutCallback
@ -857,6 +859,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
|| promotionsEnabledKey in preferences) {
return
}
val intent = Intent(this, PremiumDashboardActivity::class.java)
val contentIntent = PendingIntent.getActivity(this, 0, intent, 0)
val builder = NotificationChannelSpec.appNotices.notificationBuilder(this)
@ -864,8 +867,21 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
builder.setSmallIcon(R.drawable.ic_stat_gift)
builder.setTicker(getString(R.string.message_ticker_promotions_reward))
builder.setContentTitle(getString(R.string.title_promotions_reward))
builder.setContentText(getString(R.string.message_promotions_reward))
builder.setContentText(getString(R.string.message_ticker_promotions_reward))
builder.setContentIntent(contentIntent)
builder.setStyle(NotificationCompat.BigTextStyle(builder)
.setBigContentTitle(getString(R.string.title_promotions_reward))
.bigText(getString(R.string.message_promotions_reward)))
builder.addAction(R.drawable.ic_action_confirm, getString(R.string.action_enable),
PendingIntent.getBroadcast(this, 0, Intent(this,
NotificationReceiver::class.java).setAction(BROADCAST_PROMOTIONS_ACCEPTED)
.putExtra(EXTRA_NOTIFICATION_ID, NOTIFICATION_ID_PROMOTIONS_OFFER),
PendingIntent.FLAG_ONE_SHOT))
builder.addAction(R.drawable.ic_action_cancel, getString(R.string.action_no_thanks),
PendingIntent.getBroadcast(this, 0, Intent(this,
NotificationReceiver::class.java).setAction(BROADCAST_PROMOTIONS_DENIED)
.putExtra(EXTRA_NOTIFICATION_ID, NOTIFICATION_ID_PROMOTIONS_OFFER),
PendingIntent.FLAG_ONE_SHOT))
notificationManager.notify(NOTIFICATION_ID_PROMOTIONS_OFFER, builder.build())
}
@ -1010,7 +1026,7 @@ class HomeActivity : BaseActivity(), OnClickListener, OnPageChangeListener, Supp
builder.setPositiveButton(android.R.string.ok) { _, _ ->
kPreferences[defaultAutoRefreshKey] = true
}
builder.setNegativeButton(R.string.no_thanks) { _, _ ->
builder.setNegativeButton(R.string.action_no_thanks) { _, _ ->
kPreferences[defaultAutoRefreshKey] = false
}
val dialog = builder.create()

View File

@ -23,11 +23,13 @@ import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import org.mariotaku.abstask.library.TaskStarter
import org.mariotaku.kpreferences.set
import org.mariotaku.ktextension.toLongOr
import org.mariotaku.twidere.TwidereConstants.*
import org.mariotaku.twidere.annotation.NotificationType
import org.mariotaku.twidere.annotation.ReadPositionTag
import org.mariotaku.twidere.constant.IntentConstants.BROADCAST_NOTIFICATION_DELETED
import org.mariotaku.twidere.constant.promotionsEnabledKey
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.task.twitter.message.BatchMarkMessageReadTask
import org.mariotaku.twidere.util.Utils
@ -39,9 +41,20 @@ import org.mariotaku.twidere.util.dagger.DependencyHolder
class NotificationReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val action = intent.action ?: return
when (action) {
when (intent.action) {
BROADCAST_NOTIFICATION_DELETED -> {
handleNotificationDeleted(intent, context)
}
BROADCAST_PROMOTIONS_ACCEPTED -> {
setPromotionsEnabled(context, intent, true)
}
BROADCAST_PROMOTIONS_DENIED -> {
setPromotionsEnabled(context, intent, false)
}
}
}
private fun handleNotificationDeleted(intent: Intent, context: Context) {
val uri = intent.data ?: return
val holder = DependencyHolder.get(context)
@NotificationType
@ -70,7 +83,13 @@ class NotificationReceiver : BroadcastReceiver() {
}
}
}
}
}
private fun setPromotionsEnabled(context: Context, intent: Intent, enabled: Boolean) {
val holder = DependencyHolder.get(context)
holder.preferences[promotionsEnabledKey] = enabled
val notificationId = intent.getIntExtra(EXTRA_NOTIFICATION_ID, -1)
if (notificationId != -1) {
holder.notificationManager.cancel(notificationId)
}
}
}

View File

@ -28,10 +28,7 @@ import okhttp3.Dns
import org.mariotaku.kpreferences.KPreferences
import org.mariotaku.restfu.http.RestHttpClient
import org.mariotaku.twidere.model.DefaultFeatures
import org.mariotaku.twidere.util.ActivityTracker
import org.mariotaku.twidere.util.ExternalThemeManager
import org.mariotaku.twidere.util.ReadStateManager
import org.mariotaku.twidere.util.UserColorNameManager
import org.mariotaku.twidere.util.*
import org.mariotaku.twidere.util.media.MediaPreloader
import org.mariotaku.twidere.util.media.ThumborWrapper
import org.mariotaku.twidere.util.premium.ExtraFeaturesService
@ -91,6 +88,9 @@ class DependencyHolder internal constructor(context: Context) {
@Inject
lateinit var extraFeaturesService: ExtraFeaturesService
internal set
@Inject
lateinit var notificationManager: NotificationManagerWrapper
internal set
init {
GeneralComponent.get(context).inject(this)

View File

@ -365,7 +365,7 @@
<string name="no_status_content_text">لا محتوى</string>
<string name="no_tab">ولا تبويبة</string>
<string name="no_tab_hint">ولا تبويبة</string>
<string name="no_thanks">لا، شكرا</string>
<string name="action_no_thanks">لا، شكرا</string>
<string name="no_user_found">لم أجد مستخدمًا</string>
<string name="none">لا شيء</string>
<string name="notification_direct_message"><xliff:g id="user">%s</xliff:g> راسلك مباشرة.</string>

View File

@ -607,7 +607,7 @@ Convertilu a un tuit normal amiesta una caráuter estra.</string>
<string name="no_status_content_text">Ensin conteníu</string>
<string name="no_tab">Ensin llingüetes</string>
<string name="no_tab_hint">Ensin llingüetes</string>
<string name="no_thanks">Non, gracies</string>
<string name="action_no_thanks">Non, gracies</string>
<string name="no_user_found">Nun s\'alcontró usuariu dalu</string>
<string name="no_version_suffix">Ensin sufixu de versión</string>
<string name="none">Dengún</string>

View File

@ -385,7 +385,7 @@
<string name="no_status_content_text">Sense contingut</string>
<string name="no_tab">No hi ha pestanyes</string>
<string name="no_tab_hint">No hi ha pestanyes</string>
<string name="no_thanks">No, gràcies</string>
<string name="action_no_thanks">No, gràcies</string>
<string name="no_user_found">No s\'ha trobat cap usuari</string>
<string name="no_version_suffix">Versió sense sufix</string>
<string name="none">Cap</string>

View File

@ -221,7 +221,7 @@
<string name="no_location">Poloha není k dispozici</string>
<string name="no_rule">Žádné pravidlo</string>
<string name="no_status_content_text">Žádný obsah</string>
<string name="no_thanks">Ne, děkuji</string>
<string name="action_no_thanks">Ne, děkuji</string>
<string name="no_user_found">Nenalezen žádný uživatel</string>
<string name="notification_light_color">Světlá barva</string>
<!-- Notification method, flashing LED light -->

View File

@ -626,7 +626,7 @@
<string name="no_status_content_text">Kein Inhalt</string>
<string name="no_tab">Kein Tab</string>
<string name="no_tab_hint">Kein Tab</string>
<string name="no_thanks">Nein, danke</string>
<string name="action_no_thanks">Nein, danke</string>
<string name="no_user_found">Kein Benutzer gefunden</string>
<string name="no_version_suffix">Kein Versionszusatz</string>
<string name="none">Nichts</string>

View File

@ -626,7 +626,7 @@
<string name="no_status_content_text">Sin contenido</string>
<string name="no_tab">Sin pestaña</string>
<string name="no_tab_hint">Sin pestañas</string>
<string name="no_thanks">No, gracias</string>
<string name="action_no_thanks">No, gracias</string>
<string name="no_user_found">Ningún usuario encontrado</string>
<string name="no_version_suffix">Sin versión de sufijo</string>
<string name="none">Ninguno</string>

View File

@ -611,7 +611,7 @@
<string name="no_status_content_text">بدون محتوا</string>
<string name="no_tab">بدون زبانه</string>
<string name="no_tab_hint">بدون زبانه</string>
<string name="no_thanks">نه، ممنون</string>
<string name="action_no_thanks">نه، ممنون</string>
<string name="no_user_found">هیچ کاربری پیدا نشد</string>
<string name="no_version_suffix">بدون پسوند نگارش</string>
<string name="none">هیچ‌کدام</string>

View File

@ -376,7 +376,7 @@
<string name="no_status_content_text">Ei sisältöä</string>
<string name="no_tab">Ei välilehteä</string>
<string name="no_tab_hint">Ei välilehteä</string>
<string name="no_thanks">Ei kiitos</string>
<string name="action_no_thanks">Ei kiitos</string>
<string name="no_user_found">Käyttäjää ei löytynyt</string>
<string name="no_version_suffix">Ei versiojälkiliitettä</string>
<string name="none">Ei mitään</string>

View File

@ -626,7 +626,7 @@
<string name="no_status_content_text">Aucun contenu</string>
<string name="no_tab">Aucun onglet</string>
<string name="no_tab_hint">Aucun onglet</string>
<string name="no_thanks">Non, merci</string>
<string name="action_no_thanks">Non, merci</string>
<string name="no_user_found">Aucun utilisateur trouvé</string>
<string name="no_version_suffix">Pas de suffixe de version</string>
<string name="none">Aucun</string>

View File

@ -640,7 +640,7 @@
<string name="no_status_content_text">Sen contido</string>
<string name="no_tab">Sen lapelas</string>
<string name="no_tab_hint">Sen lapelas</string>
<string name="no_thanks">Non, grazas</string>
<string name="action_no_thanks">Non, grazas</string>
<string name="no_user_found">Non se atopou o usuario</string>
<string name="no_version_suffix">Sen sufixo de versión</string>
<string name="none">Ningún</string>

View File

@ -325,7 +325,7 @@
<string name="no_status_content_text">Nema sadržaja</string>
<string name="no_tab">Nema tabova</string>
<string name="no_tab_hint">Nema tabova</string>
<string name="no_thanks">Ne, hvala</string>
<string name="action_no_thanks">Ne, hvala</string>
<string name="no_user_found">Korisnik nije pronađen</string>
<string name="no_version_suffix">Nema sufiksa verzije</string>
<string name="none">Ništa</string>

View File

@ -644,7 +644,7 @@
<string name="no_status_content_text">Nincs tartalom</string>
<string name="no_tab">Nincs fül</string>
<string name="no_tab_hint">Nincs fül</string>
<string name="no_thanks">Köszönöm, nem</string>
<string name="action_no_thanks">Köszönöm, nem</string>
<string name="no_user_found">Nem található felhasználó</string>
<string name="no_version_suffix">Nincs verzió utótag</string>
<string name="none">Semmi</string>

View File

@ -497,7 +497,7 @@
<string name="no_status_content_text">Tidak ada konten</string>
<string name="no_tab">Tidak terdapat tab</string>
<string name="no_tab_hint">Tidak ada tab</string>
<string name="no_thanks">Tidak, terima kasih</string>
<string name="action_no_thanks">Tidak, terima kasih</string>
<string name="no_user_found">Tidak menemukan pengguna</string>
<string name="no_version_suffix">Tidak ada akhiran versi</string>
<string name="none">Tidak ada</string>

View File

@ -378,7 +378,7 @@
<string name="no_status_content_text">Nessun contenuto</string>
<string name="no_tab">Nessun tab</string>
<string name="no_tab_hint">Nessun tab</string>
<string name="no_thanks">No, grazie</string>
<string name="action_no_thanks">No, grazie</string>
<string name="no_user_found">Nessun utente trovato</string>
<string name="no_version_suffix">Nessuna versione supportata</string>
<string name="none">Nessuno</string>

View File

@ -650,7 +650,7 @@
<string name="no_status_content_text">コンテンツなし</string>
<string name="no_tab">タブ無し</string>
<string name="no_tab_hint">タブ無し</string>
<string name="no_thanks">いいえ、結構です</string>
<string name="action_no_thanks">いいえ、結構です</string>
<string name="no_user_found">ユーザーが見つかりません。</string>
<string name="no_version_suffix">バージョンサフィックスなし</string>
<string name="none">なし</string>

View File

@ -597,7 +597,7 @@
<string name="no_status_content_text">내용 없음</string>
<string name="no_tab">탭 없음</string>
<string name="no_tab_hint">탭 없음</string>
<string name="no_thanks">아뇨, 괜찮습니다</string>
<string name="action_no_thanks">아뇨, 괜찮습니다</string>
<string name="no_user_found">사용자를 찾을 수 없음</string>
<string name="no_version_suffix">버전 접미사 없음</string>
<string name="none">없음</string>

View File

@ -390,7 +390,7 @@
<string name="no_status_content_text">Geen inhoud</string>
<string name="no_tab">Geen tabblad</string>
<string name="no_tab_hint">Geen tab</string>
<string name="no_thanks">Nee, bedankt</string>
<string name="action_no_thanks">Nee, bedankt</string>
<string name="no_user_found">Geen gebruiker gevonden</string>
<string name="no_version_suffix">Geen versie-achtervoegsel</string>
<string name="none">Geen</string>

View File

@ -340,7 +340,7 @@
<string name="no_status_content_text">Ingen innhold</string>
<string name="no_tab">Ingen faner</string>
<string name="no_tab_hint">Ingen faner</string>
<string name="no_thanks">Nei, takk</string>
<string name="action_no_thanks">Nei, takk</string>
<string name="no_user_found">Fant ingen bruker</string>
<string name="no_version_suffix">Ingen versjonssuffiks</string>
<string name="none">Ingen</string>

View File

@ -405,7 +405,7 @@
<string name="no_status_content_text">Brak zawartości</string>
<string name="no_tab">Brak kart</string>
<string name="no_tab_hint">Brak kart</string>
<string name="no_thanks">Nie, dziękuję</string>
<string name="action_no_thanks">Nie, dziękuję</string>
<string name="no_version_suffix">Brak przyrostka wersji</string>
<string name="none">Brak</string>
<string name="notification_direct_message"><xliff:g id="user">%s</xliff:g> wysłał/a Ci wiadomość.</string>

View File

@ -462,7 +462,7 @@
<string name="no_status_content_text">Nenhum conteúdo</string>
<string name="no_tab">Sem abas</string>
<string name="no_tab_hint">Sem abas</string>
<string name="no_thanks">Não, obrigado</string>
<string name="action_no_thanks">Não, obrigado</string>
<string name="no_user_found">Nenhum usuário encontrado</string>
<string name="no_version_suffix">Sem sufixo de versão</string>
<string name="none">Nenhum</string>

View File

@ -505,7 +505,7 @@
<string name="no_status_content_text">Нет содержимого</string>
<string name="no_tab">Нет вкладок</string>
<string name="no_tab_hint">Нет вкладок</string>
<string name="no_thanks">Нет, спасибо</string>
<string name="action_no_thanks">Нет, спасибо</string>
<string name="no_user_found">Пользователь не найден</string>
<string name="no_version_suffix">Нет суффикса версии</string>
<string name="none">Никак</string>

View File

@ -590,7 +590,7 @@
<string name="no_status_content_text">Inget innehåll</string>
<string name="no_tab">Ingen flik</string>
<string name="no_tab_hint">Ingen flik</string>
<string name="no_thanks">Nej tack</string>
<string name="action_no_thanks">Nej tack</string>
<string name="no_user_found">Ingen användare hittat</string>
<string name="no_version_suffix">Ingen versionssuffix</string>
<string name="none">Ingen</string>

View File

@ -626,7 +626,7 @@
<string name="no_status_content_text">ไม่มีเนื้อหา</string>
<string name="no_tab">ไม่มีแถบ</string>
<string name="no_tab_hint">ไม่มีแถบ</string>
<string name="no_thanks">ไม่, ขอบคุณ</string>
<string name="action_no_thanks">ไม่, ขอบคุณ</string>
<string name="no_user_found">ไม่พบผู้ใช้</string>
<string name="no_version_suffix">ไม่มีเลขเวอร์ชั่นต่อท้าย</string>
<string name="none">ไม่มี</string>

View File

@ -455,7 +455,7 @@
<string name="no_status_content_text">İçerik yok</string>
<string name="no_tab">Sekme yok</string>
<string name="no_tab_hint">Sekme yok</string>
<string name="no_thanks">Hayır, teşekkürler</string>
<string name="action_no_thanks">Hayır, teşekkürler</string>
<string name="no_user_found">Kullanıcı bulunamadı</string>
<string name="no_version_suffix">Düzeltme yok</string>
<string name="none">Hiçbiri</string>

View File

@ -391,7 +391,7 @@
<string name="no_status_content_text">Немає вмісту</string>
<string name="no_tab">Вкладки відсутні</string>
<string name="no_tab_hint">Нема вкладок</string>
<string name="no_thanks">Ні, дякую</string>
<string name="action_no_thanks">Ні, дякую</string>
<string name="no_user_found">Користувача не знайдено</string>
<string name="no_version_suffix">Без суфіксу версії</string>
<string name="none">Нічого</string>

View File

@ -1,4 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--Generated by crowdin.com-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="account_options">帐号选项</string>
@ -654,7 +673,7 @@
<string name="no_status_content_text">没有内容</string>
<string name="no_tab">没有标签页</string>
<string name="no_tab_hint">没有标签页</string>
<string name="no_thanks">不用了,谢谢</string>
<string name="action_no_thanks">不用了,谢谢</string>
<string name="no_user_found">没有找到用户</string>
<string name="no_version_suffix">没有版本后缀</string>
<string name="none"></string>

View File

@ -1,4 +1,23 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2017 Mariotaku Lee <mariotaku.lee@gmail.com>
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<!--Generated by crowdin.com-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="account_options">帳戶選項</string>
@ -643,7 +662,7 @@
<string name="no_status_content_text">沒有內容</string>
<string name="no_tab">沒有標籤頁</string>
<string name="no_tab_hint">沒有標籤頁</string>
<string name="no_thanks">不用了,謝謝</string>
<string name="action_no_thanks">不用了,謝謝</string>
<string name="no_user_found">沒有找到使用者</string>
<string name="no_version_suffix">沒有版本後綴</string>
<string name="none"></string>

View File

@ -643,7 +643,7 @@
<string name="no_status_content_text">沒有內容</string>
<string name="no_tab">沒有標籤頁</string>
<string name="no_tab_hint">沒有標籤頁</string>
<string name="no_thanks">不用了,謝謝</string>
<string name="action_no_thanks">不用了,謝謝</string>
<string name="no_user_found">沒有找到使用者</string>
<string name="no_version_suffix">沒有版本後綴</string>
<string name="none"></string>

View File

@ -110,7 +110,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/no_thanks"/>
android:text="@string/action_no_thanks"/>
</LinearLayout>
</LinearLayout>

View File

@ -83,6 +83,7 @@
<string name="action_mute_notifications">Mute notifications</string>
<string name="action_name_saved_at_time"><xliff:g id="action">%1$s</xliff:g>, saved at <xliff:g id="time">%2$s</xliff:g></string>
<string name="action_next_step">Next</string>
<string name="action_no_thanks">No, thanks</string>
<string name="action_open_in_browser">Open in browser</string>
<string name="action_pick_color">Pick color</string>
<string name="action_purchase">Purchase</string>
@ -779,7 +780,6 @@
<string name="no_status_content_text">No content</string>
<string name="no_tab">No tab</string>
<string name="no_tab_hint">No tab</string>
<string name="no_thanks">No, thanks</string>
<string name="no_user_found">No user found</string>
<string name="no_version_suffix">No version suffix</string>