diff --git a/app/src/main/java/io/heckel/ntfy/app/Application.kt b/app/src/main/java/io/heckel/ntfy/app/Application.kt index b4b104c..6e4e760 100644 --- a/app/src/main/java/io/heckel/ntfy/app/Application.kt +++ b/app/src/main/java/io/heckel/ntfy/app/Application.kt @@ -1,7 +1,6 @@ package io.heckel.ntfy.app import android.app.Application -import android.content.Context import io.heckel.ntfy.db.Database import io.heckel.ntfy.db.Repository import io.heckel.ntfy.util.Log diff --git a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt index 64baa45..bdd8b01 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt @@ -95,7 +95,7 @@ class ApiService { throw Exception("Unexpected response ${response.code} when polling topic $url") } val body = response.body?.string()?.trim() - if (body == null || body.isEmpty()) return emptyList() + if (body.isNullOrEmpty()) return emptyList() val notifications = body.lines().mapNotNull { line -> parser.parse(line, subscriptionId = subscriptionId, notificationId = 0) // No notification when we poll } @@ -166,7 +166,7 @@ class ApiService { } class UnauthorizedException(val user: User?) : Exception() - class EntityTooLargeException() : Exception() + class EntityTooLargeException : Exception() companion object { val USER_AGENT = "ntfy/${BuildConfig.VERSION_NAME} (${BuildConfig.FLAVOR}; Android ${Build.VERSION.RELEASE}; SDK ${Build.VERSION.SDK_INT})" diff --git a/app/src/main/java/io/heckel/ntfy/msg/DownloadManager.kt b/app/src/main/java/io/heckel/ntfy/msg/DownloadManager.kt index ab0dd2e..83cfb1a 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/DownloadManager.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/DownloadManager.kt @@ -11,7 +11,7 @@ import io.heckel.ntfy.util.Log * Download attachment in the background via WorkManager * * The indirection via WorkManager is required since this code may be executed - * in a doze state and Internet may not be available. It's also best practice apparently. + * in a doze state and Internet may not be available. It's also best practice, apparently. */ object DownloadManager { private const val TAG = "NtfyDownloadManager" diff --git a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt index 8577973..2f59aa6 100644 --- a/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt +++ b/app/src/main/java/io/heckel/ntfy/service/SubscriberService.kt @@ -200,7 +200,7 @@ class SubscriberService : Service() { // retrieve old messages. This is important, so we don't download attachments from old messages. val since = sinceByBaseUrl[connectionId.baseUrl] ?: "none" - val serviceActive = { -> isServiceStarted } + val serviceActive = { isServiceStarted } val user = repository.getUser(connectionId.baseUrl) val connection = if (repository.getConnectionProtocol() == Repository.CONNECTION_PROTOCOL_WS) { val alarmManager = getSystemService(ALARM_SERVICE) as AlarmManager diff --git a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt index b9770fa..8e56bab 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt @@ -5,8 +5,6 @@ import android.app.AlertDialog import android.app.Dialog import android.content.Context import android.os.Bundle -import android.text.Editable -import android.text.TextWatcher import android.view.View import android.view.WindowManager import android.view.inputmethod.InputMethodManager diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt index 9aca884..c3a08fe 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailAdapter.kt @@ -25,16 +25,18 @@ import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.google.android.material.button.MaterialButton import com.stfalcon.imageviewer.StfalconImageViewer -import io.heckel.ntfy.BuildConfig import io.heckel.ntfy.R import io.heckel.ntfy.db.* -import io.heckel.ntfy.msg.DownloadManager import io.heckel.ntfy.msg.DownloadAttachmentWorker +import io.heckel.ntfy.msg.DownloadManager import io.heckel.ntfy.msg.DownloadType import io.heckel.ntfy.msg.NotificationService import io.heckel.ntfy.msg.NotificationService.Companion.ACTION_VIEW import io.heckel.ntfy.util.* -import kotlinx.coroutines.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch class DetailAdapter(private val activity: Activity, private val lifecycleScope: CoroutineScope, private val repository: Repository, private val onClick: (Notification) -> Unit, private val onLongClick: (Notification) -> Unit) : ListAdapter(TopicDiffCallback) { @@ -204,7 +206,7 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope: } private fun maybeRenderActions(context: Context, notification: Notification) { - if (notification.actions != null && notification.actions.isNotEmpty()) { + if (!notification.actions.isNullOrEmpty()) { actionsWrapperView.visibility = View.VISIBLE val actionsCount = Math.min(notification.actions.size, 3) // per documentation, only 3 actions are available for (i in 0 until actionsCount) { @@ -220,7 +222,7 @@ class DetailAdapter(private val activity: Activity, private val lifecycleScope: private fun resetCardButtons() { // clear any previously created dynamic buttons - actionsFlow.allViews.forEach { it -> actionsFlow.removeView(it) } + actionsFlow.allViews.forEach { actionsFlow.removeView(it) } actionsWrapperView.removeAllViews() actionsWrapperView.addView(actionsFlow) } diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt index 91b41d1..82a4072 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailSettingsActivity.kt @@ -175,9 +175,8 @@ class DetailSettingsActivity : AppCompatActivity() { return subscription.mutedUntil.toString() } } - pref?.summaryProvider = Preference.SummaryProvider { _ -> - val mutedUntilValue = subscription.mutedUntil - when (mutedUntilValue) { + pref?.summaryProvider = Preference.SummaryProvider { + when (val mutedUntilValue = subscription.mutedUntil) { Repository.MUTED_UNTIL_SHOW_ALL -> getString(R.string.settings_notifications_muted_until_show_all) Repository.MUTED_UNTIL_FOREVER -> getString(R.string.settings_notifications_muted_until_forever) else -> { @@ -258,7 +257,7 @@ class DetailSettingsActivity : AppCompatActivity() { iconSetPref = findPreference(prefId) ?: return iconSetPref.isVisible = subscription.icon == null iconSetPref.preferenceDataStore = object : PreferenceDataStore() { } // Dummy store to protect from accidentally overwriting - iconSetPref.onPreferenceClickListener = Preference.OnPreferenceClickListener { _ -> + iconSetPref.onPreferenceClickListener = Preference.OnPreferenceClickListener { iconSetLauncher.launch("image/*") true } @@ -269,7 +268,7 @@ class DetailSettingsActivity : AppCompatActivity() { iconRemovePref = findPreference(prefId) ?: return iconRemovePref.isVisible = subscription.icon != null iconRemovePref.preferenceDataStore = object : PreferenceDataStore() { } // Dummy store to protect from accidentally overwriting - iconRemovePref.onPreferenceClickListener = Preference.OnPreferenceClickListener { _ -> + iconRemovePref.onPreferenceClickListener = Preference.OnPreferenceClickListener { iconRemovePref.isVisible = false iconSetPref.isVisible = true deleteIcon(subscription.icon) diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt b/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt index 4d95d0e..f2a9ea6 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainAdapter.kt @@ -1,9 +1,7 @@ package io.heckel.ntfy.ui import android.content.Context -import android.graphics.BitmapFactory import android.graphics.Color -import android.net.Uri import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -17,10 +15,8 @@ import io.heckel.ntfy.R import io.heckel.ntfy.db.ConnectionState import io.heckel.ntfy.db.Repository import io.heckel.ntfy.db.Subscription -import io.heckel.ntfy.msg.NotificationService -import io.heckel.ntfy.util.Log -import io.heckel.ntfy.util.readBitmapFromUriOrNull import io.heckel.ntfy.util.displayName +import io.heckel.ntfy.util.readBitmapFromUriOrNull import java.text.DateFormat import java.util.* diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt b/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt index 84857db..19e384c 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt @@ -8,10 +8,8 @@ import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.viewModelScope import io.heckel.ntfy.db.* import io.heckel.ntfy.up.Distributor -import io.heckel.ntfy.util.Log import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -import kotlin.collections.List class SubscriptionsViewModel(private val repository: Repository) : ViewModel() { fun list(): LiveData> { diff --git a/app/src/main/java/io/heckel/ntfy/ui/NotificationFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/NotificationFragment.kt index 8509e8e..2d84879 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/NotificationFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/NotificationFragment.kt @@ -8,7 +8,6 @@ import android.widget.RadioButton import androidx.fragment.app.DialogFragment import androidx.lifecycle.lifecycleScope import io.heckel.ntfy.R -import io.heckel.ntfy.db.Database import io.heckel.ntfy.db.Repository import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.delay diff --git a/app/src/main/java/io/heckel/ntfy/ui/UserFragment.kt b/app/src/main/java/io/heckel/ntfy/ui/UserFragment.kt index d4a7097..6da8304 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/UserFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/UserFragment.kt @@ -3,13 +3,11 @@ package io.heckel.ntfy.ui import android.app.AlertDialog import android.app.Dialog import android.content.Context -import android.os.Build import android.os.Bundle import android.view.View import android.view.WindowManager import android.widget.Button import android.widget.TextView -import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment import com.google.android.material.textfield.TextInputEditText import io.heckel.ntfy.R diff --git a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt index 9119e15..23f1985 100644 --- a/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt +++ b/app/src/main/java/io/heckel/ntfy/up/BroadcastReceiver.kt @@ -10,12 +10,10 @@ import io.heckel.ntfy.service.SubscriberServiceManager import io.heckel.ntfy.util.* import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.sync.Mutex import kotlinx.coroutines.sync.withLock import java.util.* -import kotlin.random.Random /** * This is the UnifiedPush broadcast receiver to handle the distributor actions REGISTER and UNREGISTER. diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 2d4f08c..31f29e3 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -309,7 +309,7 @@ Darstellung Abo-Icon Ein Icon zur Darstellung in Benachrichtigungen auswählen - Abo-Icon (entfernen durch antippen) + Abo-Icon (entfernen durch Antippen) Kann Icon nicht speichern: %1$s Globale Einstellung verwenden globale Einstellung @@ -323,9 +323,9 @@ Service-URL löschen %1$s (Standard) Anzeigename - Gib einen eigenen Anzeigenamen für diese Abo an. Leer lassen für den Standardwert (%1$s). + Gib einen eigenen Anzeigenamen für dieses Abo an. Leer lassen für den Standardwert (%1$s). Themen-URL Über In Zwischenablage kopiert Spenden 💸 - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d26c9d9..f7ac0c1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -318,7 +318,7 @@ Apps cannot receive notifications as broadcasts Record logs Logging (up to 1,000 entries) to device … - Turn on logging so you can share logs later to diagnose issues. + Turn on logging, so you can share logs later to diagnose issues. Copy/upload logs Copy logs to the clipboard, or upload to nopaste.net (owned by the ntfy author). Hostnames and topics can be censored, notifications will never be. Copy to clipboard