Add toast on error, for #233
This commit is contained in:
parent
fc11a5079f
commit
c9643a2173
17 changed files with 26 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
package io.heckel.ntfy.msg
|
||||
|
||||
import android.app.*
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -9,6 +10,7 @@ import android.media.RingtoneManager
|
|||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.widget.Toast
|
||||
import androidx.core.app.NotificationCompat
|
||||
import androidx.core.content.ContextCompat
|
||||
import io.heckel.ntfy.R
|
||||
|
@ -256,7 +258,6 @@ class NotificationService(val context: Context) {
|
|||
}
|
||||
val pendingIntent = PendingIntent.getActivity(context, Random().nextInt(), intent, PendingIntent.FLAG_IMMUTABLE)
|
||||
builder.addAction(NotificationCompat.Action.Builder(0, action.label, pendingIntent).build())
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Unable to add open user action", e)
|
||||
}
|
||||
|
@ -366,7 +367,7 @@ class NotificationService(val context: Context) {
|
|||
class ViewActionWithClearActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Log.d(TAG, "Creating $this")
|
||||
Log.d(TAG, "Created $this")
|
||||
val url = intent.getStringExtra(VIEW_ACTION_EXTRA_URL)
|
||||
val notificationId = intent.getIntExtra(VIEW_ACTION_EXTRA_NOTIFICATION_ID, 0)
|
||||
if (url == null) {
|
||||
|
@ -382,6 +383,10 @@ class NotificationService(val context: Context) {
|
|||
startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Unable to start activity from URL $url", e)
|
||||
val message = if (e is ActivityNotFoundException) url else e.message
|
||||
Toast
|
||||
.makeText(this, getString(R.string.detail_item_cannot_open_url, message), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
|
||||
// Cancel notification
|
||||
|
|
|
@ -589,7 +589,7 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
|||
Log.w(TAG, "Cannot open click URL", e)
|
||||
runOnUiThread {
|
||||
Toast
|
||||
.makeText(this@DetailActivity, getString(R.string.detail_item_cannot_open_click_url, e.message), Toast.LENGTH_LONG)
|
||||
.makeText(this@DetailActivity, getString(R.string.detail_item_cannot_open_url, e.message), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -441,6 +441,10 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope:
|
|||
context.startActivity(intent)
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "Unable to start activity from URL ${action.url}", e)
|
||||
val message = if (e is ActivityNotFoundException) action.url else e.message
|
||||
Toast
|
||||
.makeText(context, context.getString(R.string.detail_item_cannot_open_url, message), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@
|
|||
<string name="detail_item_cannot_open_not_found">Прикаченият файл не може да бъде отворен: Или е премахнат, или липсва приложение, с което да бъде отворен.</string>
|
||||
<string name="detail_item_cannot_save">Прикаченият файл не може да бъде запазен: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Прикаченият файл не може да бъде премахнат: %1$s</string>
|
||||
<string name="detail_item_cannot_open_click_url">Адресът не може да бъде посетен: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Адресът не може да бъде посетен: %1$s</string>
|
||||
<string name="detail_item_download_failed">Прикаченият файл не може да бъде изтеглен: %1$s</string>
|
||||
<string name="detail_item_download_info_not_downloaded">не е изтеглен</string>
|
||||
<string name="detail_item_download_info_not_downloaded_expired">не е изтеглен, препратката е с изтекла валидност</string>
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
<string name="detail_item_saved_successfully">Uloženo jako \"%1$s\" do složky \"Stažené\"</string>
|
||||
<string name="detail_item_cannot_open">Nelze otevřít přílohu: %1$s</string>
|
||||
<string name="detail_item_cannot_open_not_found">Nelze otevřít přílohu: Soubor mohl být smazán nebo jej nemůže otevřít žádná nainstalovaná aplikace.</string>
|
||||
<string name="detail_item_cannot_open_click_url">Nelze otevřít URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Nelze otevřít URL: %1$s</string>
|
||||
<string name="detail_item_cannot_save">Nelze uložit přílohu: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Nelze smazat přílohu: %1$s</string>
|
||||
<string name="detail_item_download_failed">Nepodařilo se stáhnout přílohu: %1$s</string>
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
<string name="detail_item_saved_successfully">Wurde als \"%1$s\" im Downloads-Ordner gespeichert</string>
|
||||
<string name="detail_item_cannot_download">Anhang kann nicht geöffnet oder heruntergeladen werden. Link ist abgelaufen und keine lokale Datei gefunden.</string>
|
||||
<string name="detail_item_cannot_open">Anhang kann nicht geöffnet werden: %1$s</string>
|
||||
<string name="detail_item_cannot_open_click_url">URL kann nicht geöffnet werden: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">URL kann nicht geöffnet werden: %1$s</string>
|
||||
<string name="detail_item_cannot_save">Anhang kann nicht gespeichert werden: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Anhang kann nicht gelöscht werden: %1$s</string>
|
||||
<string name="detail_item_download_failed">Herunterladen des Anhangs fehlgeschlagen: %1$s</string>
|
||||
|
|
|
@ -71,7 +71,7 @@
|
|||
<string name="detail_item_menu_copy_contents_copied">Notificación copiada al portapapeles</string>
|
||||
<string name="detail_item_saved_successfully">Guardado como %1$s en la carpeta de Descargas</string>
|
||||
<string name="detail_item_cannot_open">No se puede abrir el archivo adjunto: %1$s</string>
|
||||
<string name="detail_item_cannot_open_click_url">No se pudo abrir la URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">No se pudo abrir la URL: %1$s</string>
|
||||
<string name="detail_item_cannot_save">No se puede guardar el archivo adjunto: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">No se puede eliminar el archivo adjunto: %1$s</string>
|
||||
<string name="detail_item_download_failed">No se pudo descargar el archivo adjunto: %1$s</string>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<string name="detail_item_menu_download">Télécharger un fichier</string>
|
||||
<string name="detail_item_menu_cancel">Annuler le téléchargement</string>
|
||||
<string name="detail_item_menu_copy_url">Copier l\'URL</string>
|
||||
<string name="detail_item_cannot_open_click_url">Incapable d\'ouvrir l\'URL : %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Incapable d\'ouvrir l\'URL : %1$s</string>
|
||||
<string name="detail_item_download_info_not_downloaded">pas téléchargé</string>
|
||||
<string name="detail_item_download_info_deleted">supprimé</string>
|
||||
<string name="detail_item_download_info_download_failed">échec du téléchargement</string>
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
<string name="user_dialog_base_url_hint">URL Layanan</string>
|
||||
<string name="channel_subscriber_notification_noinstant_text_one">Berlangganan ke satu topik</string>
|
||||
<string name="detail_item_menu_copy_contents_copied">Notifikasi disalin ke papan klip</string>
|
||||
<string name="detail_item_cannot_open_click_url">Tidak dapat membuka URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Tidak dapat membuka URL: %1$s</string>
|
||||
<string name="settings_notifications_min_priority_summary_any">Menampilkan semua notifikasi</string>
|
||||
<string name="settings_notifications_min_priority_summary_x_or_higher">Tampilkan notifikasi jika prioritas adalah %1$d (%2$s) atau di atas</string>
|
||||
<string name="settings_notifications_auto_download_summary_always">Unduh semua lampiran secara otomatis</string>
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
<string name="detail_item_menu_copy_contents_copied">Notifica copiata negli appunti</string>
|
||||
<string name="detail_item_cannot_download">Impossibile aprire o scaricare l\'allegato. Il link è scaduto e nessun file locale è stato trovato.</string>
|
||||
<string name="detail_item_cannot_open">Impossibile aprire l\'allegato: %1$s</string>
|
||||
<string name="detail_item_cannot_open_click_url">Impossibile aprire URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Impossibile aprire URL: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Impossibile eliminare l\'allegato: %1$s</string>
|
||||
<string name="detail_item_download_failed">Impossibile scaricare l\'allegato: %1$s</string>
|
||||
<string name="detail_item_download_info_not_downloaded">non scaricato</string>
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
<string name="detail_item_menu_save_file">ファイルを保存</string>
|
||||
<string name="detail_item_menu_copy_url">URLをコピー</string>
|
||||
<string name="detail_item_cannot_open_not_found">添付ファイルを開けません: ファイルが削除されているか、ファイルを開けるアプリがインストールされていません。</string>
|
||||
<string name="detail_item_cannot_open_click_url">URLを開けません: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">URLを開けません: %1$s</string>
|
||||
<string name="detail_item_cannot_save">添付ファイルを保存できません: %1$s</string>
|
||||
<string name="detail_item_download_failed">添付ファイルをダウンロードできません: %1$s</string>
|
||||
<string name="detail_item_download_info_deleted">削除済</string>
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<string name="detail_item_cannot_download">Kan ikke åpne eller laste ned vedlegg. Lenken utløp og ingen lokal fil ble funnet.</string>
|
||||
<string name="detail_item_cannot_open">Kan ikke åpne vedlegg: %1$s</string>
|
||||
<string name="detail_item_cannot_open_not_found">Kan ikke åpne vedlegg: Filen kan ha blitt slettet, eller så mangler det et program til å åpne filen.</string>
|
||||
<string name="detail_item_cannot_open_click_url">Kan ikke åpne klikkbar nettadresse: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Kan ikke åpne klikkbar nettadresse: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Kan ikke slette vedlegg: %1$s</string>
|
||||
<string name="detail_item_download_info_not_downloaded">ikke nedlastet</string>
|
||||
<string name="detail_item_download_info_downloading_x_percent">%1$d%% nedlastet</string>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<string name="detail_item_menu_copy_contents_copied">Notificação copiada para área de transferência</string>
|
||||
<string name="detail_item_saved_successfully">\"%1$s\" salvo na pasta \"Downloads\"</string>
|
||||
<string name="detail_item_cannot_download">Não foi possível abrir ou baixar o anexo. O link expirou e nenhum arquivo local foi encontrado.</string>
|
||||
<string name="detail_item_cannot_open_click_url">Não foi possível abrir a URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Não foi possível abrir a URL: %1$s</string>
|
||||
<string name="detail_item_cannot_save">Não foi possível salvar o anexo: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Não foi possível remover o anexo: %1$s</string>
|
||||
<string name="detail_item_download_failed">Não foi possível baixar o anexo: %1$s</string>
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
<string name="detail_item_menu_delete">Удалить файл</string>
|
||||
<string name="detail_item_menu_download">Скачать файл</string>
|
||||
<string name="detail_item_menu_cancel">Отменить скачивание</string>
|
||||
<string name="detail_item_cannot_open_click_url">URL-адрес не открывается: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">URL-адрес не открывается: %1$s</string>
|
||||
<string name="notification_popup_action_browse">Выбрать</string>
|
||||
<string name="notification_popup_action_cancel">Отмена</string>
|
||||
<string name="settings_notifications_header">Уведомления</string>
|
||||
|
|
|
@ -79,7 +79,7 @@
|
|||
<string name="detail_item_menu_copy_url_copied">URL panoya kopyalandı</string>
|
||||
<string name="detail_item_menu_copy_contents">Bildirimi kopyala</string>
|
||||
<string name="detail_item_cannot_download">Ek açılamıyor veya indirilemiyor. Bağlantının süresi doldu ve yerel dosya bulunamadı.</string>
|
||||
<string name="detail_item_cannot_open_click_url">URL açılamıyor: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">URL açılamıyor: %1$s</string>
|
||||
<string name="detail_item_cannot_save">Ek kaydedilemiyor: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Ek silinemiyor: %1$s</string>
|
||||
<string name="detail_item_download_failed">Ek indirilemedi: %1$s</string>
|
||||
|
|
|
@ -164,7 +164,7 @@
|
|||
<string name="detail_item_menu_copy_contents_copied">通知已复制到剪贴板</string>
|
||||
<string name="detail_item_cannot_open">无法打开附件:%1$s</string>
|
||||
<string name="detail_item_cannot_open_not_found">无法打开附件:此文件已被删除或无可用打开方式。</string>
|
||||
<string name="detail_item_cannot_open_click_url">无法打开 URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">无法打开 URL: %1$s</string>
|
||||
<string name="detail_item_cannot_save">无法保存附件:%1$s</string>
|
||||
<string name="detail_item_cannot_delete">无法删除附件:%1$s</string>
|
||||
<string name="notification_popup_file">%1$s
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
<string name="detail_item_cannot_download">Cannot open or download attachment. The link expired and no local file could be found.</string>
|
||||
<string name="detail_item_cannot_open">Cannot open attachment: %1$s</string>
|
||||
<string name="detail_item_cannot_open_not_found">Cannot open attachment: The file may have been deleted, or no installed app can open the file.</string>
|
||||
<string name="detail_item_cannot_open_click_url">Cannot open URL: %1$s</string>
|
||||
<string name="detail_item_cannot_open_url">Cannot open URL: %1$s</string>
|
||||
<string name="detail_item_cannot_save">Cannot save attachment: %1$s</string>
|
||||
<string name="detail_item_cannot_delete">Cannot delete attachment: %1$s</string>
|
||||
<string name="detail_item_download_failed">Could not download attachment: %1$s</string>
|
||||
|
|
Loading…
Reference in a new issue