From 06394df5b3faed40c4dce755accf26b99ad55c6c Mon Sep 17 00:00:00 2001 From: Antoan Angelov Date: Wed, 18 Mar 2026 01:01:59 -0400 Subject: [PATCH 1/4] Create dynamic shortcuts for topics for quicker sharing This commit updates MainActivity to create dynamic shortcuts as the subscriptions are observed. These shortcuts are shown in the share sheet whenever the user shares content with the supported mime types (text, images, audio, video). Relevant notes: - The subscription shortcuts use the display name of the subscription (if set) or the topic name - The subscription shortcuts use the subscription icon if set - When deleting a subscription, the dynamic shortcut is removed immediately - When the user shares through a dynamic shortcut, ShareActivity is pre-filled with the topic name --- app/src/main/AndroidManifest.xml | 3 + .../java/io/heckel/ntfy/ui/MainActivity.kt | 3 + .../java/io/heckel/ntfy/ui/MainViewModel.kt | 1 + .../java/io/heckel/ntfy/ui/ShareActivity.kt | 23 ++++++ .../io/heckel/ntfy/ui/ShareTargetHelper.kt | 71 +++++++++++++++++++ app/src/main/res/xml/shortcuts.xml | 11 +++ 6 files changed, 112 insertions(+) create mode 100644 app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt create mode 100644 app/src/main/res/xml/shortcuts.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6ca9d3c00..91cf094ab 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -41,6 +41,9 @@ + diff --git a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt index 251a4ba0e..6c5c9aca5 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainActivity.kt @@ -227,6 +227,9 @@ class MainActivity : AppCompatActivity(), AddFragment.SubscribeListener, Notific showHideBatteryBanner(subscriptions) showHideWebSocketBanner(subscriptions) showHideWebSocketReconnectBanner() + + // Update share targets in the system share sheet + ShareTargetHelper.update(this@MainActivity, subscriptions) } } 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 d9bcc31b9..c6735a97c 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/MainViewModel.kt @@ -32,6 +32,7 @@ class SubscriptionsViewModel(private val repository: Repository) : ViewModel() { val distributor = Distributor(context) distributor.sendUnregistered(subscription.upAppId, subscription.upConnectorToken) } + ShareTargetHelper.remove(context, subscription) repository.removeSubscription(subscription) if (subscription.icon != null) { val resolver = context.applicationContext.contentResolver diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt index a7a627f37..e5905b7a0 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -31,6 +31,9 @@ class ShareActivity : AppCompatActivity() { // File to share private var fileUri: Uri? = null + // Topic pre-selected via sharing shortcut (may be null) + private var shortcutTopicUrl: String? = null + // Context-dependent things private lateinit var appBaseUrl: String private var defaultBaseUrl: String? = null @@ -60,6 +63,11 @@ class ShareActivity : AppCompatActivity() { Log.init(this) // Init logs in all entry points Log.d(TAG, "Create $this with intent $intent") + // If launched from a sharing shortcut, extract the pre-selected topic + intent?.getStringExtra(Intent.EXTRA_SHORTCUT_ID)?.let { shortcutId -> + shortcutTopicUrl = ShareTargetHelper.topicUrlFromShortcutId(shortcutId) + } + // Action bar val toolbarLayout = findViewById(R.id.app_bar_drawer) val dynamicColors = repository.getDynamicColorsEnabled() @@ -183,6 +191,21 @@ class ShareActivity : AppCompatActivity() { baseUrls.count() == 1 } baseUrlLayout.visibility = if (useAnotherServerCheckbox.isChecked) View.VISIBLE else View.GONE + + // Override defaults if launched from a sharing shortcut + shortcutTopicUrl?.let { url -> + try { + val (baseUrl, topic) = splitTopicUrl(url) + val defaultUrl = defaultBaseUrl ?: appBaseUrl + topicText.text = topic + useAnotherServerCheckbox.isChecked = baseUrl != defaultUrl + if (baseUrl != defaultUrl) baseUrlText.setText(baseUrl) + baseUrlLayout.visibility = if (useAnotherServerCheckbox.isChecked) View.VISIBLE else View.GONE + validateInput() + } catch (_: Exception) { + // Ignore malformed shortcut IDs + } + } } } diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt new file mode 100644 index 000000000..fbd864f70 --- /dev/null +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt @@ -0,0 +1,71 @@ +package io.heckel.ntfy.ui + +import android.content.Context +import android.content.Intent +import androidx.core.content.pm.ShortcutInfoCompat +import androidx.core.content.pm.ShortcutManagerCompat +import androidx.core.graphics.drawable.IconCompat +import io.heckel.ntfy.R +import io.heckel.ntfy.db.Subscription +import io.heckel.ntfy.util.readBitmapFromUriOrNull +import io.heckel.ntfy.util.topicUrl + +object ShareTargetHelper { + private const val CATEGORY_SHARE_TARGET = "io.heckel.ntfy.SHARE_TARGET" + private const val SHORTCUT_ID_PREFIX = "share_" + + private const val TAG = "ShareTargetHelper" + + /** + * Publishes one dynamic sharing shortcut per subscription so that topics appear + * as direct-share targets in the system share sheet (Android 10+). + */ + fun update(context: Context, subscriptions: List) { + val max = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context) + val shortcuts = subscriptions + .sortedByDescending { it.lastActive } + .take(max) + .map { sub -> buildShortcut(context, sub) } + try { + val success = ShortcutManagerCompat.setDynamicShortcuts(context, shortcuts) + android.util.Log.i( + TAG, + "setDynamicShortcuts returned $success" + ) + } catch (e: Exception) { + android.util.Log.e(TAG, "setDynamicShortcuts returned failed", e) + } + } + + /** + * Removes the dynamic sharing shortcut for a single subscription. + */ + fun remove(context: Context, subscription: Subscription) { + val id = SHORTCUT_ID_PREFIX + topicUrl(subscription.baseUrl, subscription.topic) + ShortcutManagerCompat.removeDynamicShortcuts(context, listOf(id)) + } + + /** + * Returns the topicUrl encoded in a shortcut ID, or null if the ID doesn't belong to us. + */ + fun topicUrlFromShortcutId(shortcutId: String): String? { + if (!shortcutId.startsWith(SHORTCUT_ID_PREFIX)) return null + return shortcutId.removePrefix(SHORTCUT_ID_PREFIX) + } + + private fun buildShortcut(context: Context, sub: Subscription): ShortcutInfoCompat { + val label = sub.displayName ?: sub.topic + val url = topicUrl(sub.baseUrl, sub.topic) + val icon = sub.icon?.let { IconCompat.createWithAdaptiveBitmapContentUri(it) } + ?: IconCompat.createWithResource(context, R.mipmap.ic_launcher) + return ShortcutInfoCompat.Builder(context, SHORTCUT_ID_PREFIX + url) + .setShortLabel(label) + .setIcon(icon) + .setCategories(setOf(CATEGORY_SHARE_TARGET)) + .setIntent(Intent(context, ShareActivity::class.java).apply { + action = Intent.ACTION_VIEW + }) + .setLongLived(true) + .build() + } +} diff --git a/app/src/main/res/xml/shortcuts.xml b/app/src/main/res/xml/shortcuts.xml new file mode 100644 index 000000000..c52c0cbc0 --- /dev/null +++ b/app/src/main/res/xml/shortcuts.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + From 3af2ebeebaf7eb81819426e51b3c8aff219dfb8b Mon Sep 17 00:00:00 2001 From: Antoan Angelov Date: Thu, 19 Mar 2026 02:33:57 -0400 Subject: [PATCH 2/4] Gracefully handle the shortcuts when opened from the launcher app menu The dynamic shortcuts that were added for the share sheet also appear when long-pressing on the app in the launcher. These launcher shortcuts start ShareActivity as well, but with the ACTION_VIEW action instead of ACTION_SEND. Since it does not make sense to start a sharing activity from a launcher-level shortcut, this case is handled gracefully by re-routing ShareActivity to DetailActivity. --- .../java/io/heckel/ntfy/ui/ShareActivity.kt | 63 +++++++++++++++++-- .../io/heckel/ntfy/ui/ShareTargetHelper.kt | 15 +++-- 2 files changed, 69 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt index e5905b7a0..45b62a1c5 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -1,5 +1,6 @@ package io.heckel.ntfy.ui +import android.app.TaskStackBuilder import android.content.Intent import android.net.Uri import android.os.Bundle @@ -10,6 +11,7 @@ import android.view.* import android.widget.* import androidx.activity.enableEdgeToEdge import androidx.appcompat.app.AppCompatActivity +import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.view.WindowInsetsControllerCompat import androidx.lifecycle.lifecycleScope import androidx.recyclerview.widget.RecyclerView @@ -23,6 +25,14 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import androidx.core.view.size import androidx.core.view.get +import io.heckel.ntfy.db.Subscription +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_BASE_URL +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_DISPLAY_NAME +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_ID +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_INSTANT +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_MUTED_UNTIL +import io.heckel.ntfy.ui.MainActivity.Companion.EXTRA_SUBSCRIPTION_TOPIC +import io.heckel.ntfy.ui.ShareTargetHelper.EXTRA_TOPIC_URL class ShareActivity : AppCompatActivity() { private val repository by lazy { (application as Application).repository } @@ -31,9 +41,6 @@ class ShareActivity : AppCompatActivity() { // File to share private var fileUri: Uri? = null - // Topic pre-selected via sharing shortcut (may be null) - private var shortcutTopicUrl: String? = null - // Context-dependent things private lateinit var appBaseUrl: String private var defaultBaseUrl: String? = null @@ -64,8 +71,14 @@ class ShareActivity : AppCompatActivity() { Log.d(TAG, "Create $this with intent $intent") // If launched from a sharing shortcut, extract the pre-selected topic - intent?.getStringExtra(Intent.EXTRA_SHORTCUT_ID)?.let { shortcutId -> - shortcutTopicUrl = ShareTargetHelper.topicUrlFromShortcutId(shortcutId) + val shortcutTopicUrl = intent?.getStringExtra(ShortcutManagerCompat.EXTRA_SHORTCUT_ID) + ?.let { ShareTargetHelper.topicUrlFromShortcutId(it) } + ?: intent?.getStringExtra(EXTRA_TOPIC_URL) + + // If this activity was opened from the launcher shortcut, reroute to DetailActivity instead. + if (intent.action == Intent.ACTION_VIEW) { + openDetailActivityAndFinish(shortcutTopicUrl) + return } // Action bar @@ -222,6 +235,46 @@ class ShareActivity : AppCompatActivity() { } } + private fun openDetailActivityAndFinish(shortcutTopicUrl: String?) { + if (shortcutTopicUrl == null) { + finish() + return + } + lifecycleScope.launch(Dispatchers.IO) { + try { + val (baseUrl, topic) = splitTopicUrl(shortcutTopicUrl) + val subscription = repository.getSubscription(baseUrl, topic) + startDetailActivityAndFinish(subscription) + } catch (e: Exception) { + Log.e(TAG, "Failed to get subscription to start DetailActivity", e) + withContext(Dispatchers.Main) { finish() } + } + } + } + + private suspend fun startDetailActivityAndFinish(subscription: Subscription?) = + withContext(Dispatchers.Main) { + if (subscription != null) { + TaskStackBuilder.create(this@ShareActivity) + .addNextIntentWithParentStack(createDetailActivityIntent(subscription)) + .startActivities() + } + finish() + } + + private fun createDetailActivityIntent(subscription: Subscription): Intent = + Intent(this, DetailActivity::class.java).apply { + putExtra(EXTRA_SUBSCRIPTION_ID, subscription.id) + putExtra(EXTRA_SUBSCRIPTION_BASE_URL, subscription.baseUrl) + putExtra(EXTRA_SUBSCRIPTION_TOPIC, subscription.topic) + putExtra( + EXTRA_SUBSCRIPTION_DISPLAY_NAME, + subscription.displayName ?: subscription.topic + ) + putExtra(EXTRA_SUBSCRIPTION_INSTANT, subscription.instant) + putExtra(EXTRA_SUBSCRIPTION_MUTED_UNTIL, subscription.mutedUntil) + } + private fun handleSendText(intent: Intent) { val text = intent.getStringExtra(Intent.EXTRA_TEXT) ?: "(no text)" Log.d(TAG, "Shared content is text: $text") diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt index fbd864f70..2145bb658 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareTargetHelper.kt @@ -7,10 +7,12 @@ import androidx.core.content.pm.ShortcutManagerCompat import androidx.core.graphics.drawable.IconCompat import io.heckel.ntfy.R import io.heckel.ntfy.db.Subscription -import io.heckel.ntfy.util.readBitmapFromUriOrNull import io.heckel.ntfy.util.topicUrl object ShareTargetHelper { + + const val EXTRA_TOPIC_URL = "EXTRA_TOPIC_URL" + private const val CATEGORY_SHARE_TARGET = "io.heckel.ntfy.SHARE_TARGET" private const val SHORTCUT_ID_PREFIX = "share_" @@ -58,13 +60,18 @@ object ShareTargetHelper { val url = topicUrl(sub.baseUrl, sub.topic) val icon = sub.icon?.let { IconCompat.createWithAdaptiveBitmapContentUri(it) } ?: IconCompat.createWithResource(context, R.mipmap.ic_launcher) + val intent = Intent(context, ShareActivity::class.java).apply { + action = Intent.ACTION_VIEW + // When ShareActivity is started using the shortcut from the launcher, its intent + // doesn't include the SHORTCUT_ID extra. That's why we pass the topic URL here. + putExtra(EXTRA_TOPIC_URL, url) + addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) + } return ShortcutInfoCompat.Builder(context, SHORTCUT_ID_PREFIX + url) .setShortLabel(label) .setIcon(icon) .setCategories(setOf(CATEGORY_SHARE_TARGET)) - .setIntent(Intent(context, ShareActivity::class.java).apply { - action = Intent.ACTION_VIEW - }) + .setIntent(intent) .setLongLived(true) .build() } From ac20b31972b6183b6c9c7cbafa86f9baec923e0c Mon Sep 17 00:00:00 2001 From: Antoan Angelov Date: Fri, 20 Mar 2026 02:34:36 -0400 Subject: [PATCH 3/4] Auto-publish when sharing content directly to a topic This change introduces a new boolean preference in the global app settings, which allows users to automatically publish the shared content when it's shared directly to a topic from the share sheet. It's false by default. When the setting is true and there is valid content to share (text or file), ShareActivity automatically calls the publish API without the user having to tap the publish button. --- .../main/java/io/heckel/ntfy/db/Repository.kt | 11 ++++++++ .../io/heckel/ntfy/ui/SettingsActivity.kt | 26 +++++++++++++++++++ .../java/io/heckel/ntfy/ui/ShareActivity.kt | 8 +++++- app/src/main/res/values/strings.xml | 4 +++ app/src/main/res/values/values.xml | 2 ++ app/src/main/res/xml/main_preferences.xml | 9 +++++++ 6 files changed, 59 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/heckel/ntfy/db/Repository.kt b/app/src/main/java/io/heckel/ntfy/db/Repository.kt index a6716c742..275d17b78 100644 --- a/app/src/main/java/io/heckel/ntfy/db/Repository.kt +++ b/app/src/main/java/io/heckel/ntfy/db/Repository.kt @@ -400,6 +400,16 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database) } } + fun isSharingAutoSendEnabled(): Boolean { + return sharedPrefs.getBoolean(SHARED_PREFS_SHARING_AUTO_SEND, false) // Disabled by default + } + + fun setSharingAutoSendEnabled(enabled: Boolean) { + sharedPrefs.edit { + putBoolean(SHARED_PREFS_SHARING_AUTO_SEND, enabled) + } + } + fun getMessageBarEnabled(): Boolean { return sharedPrefs.getBoolean(SHARED_PREFS_MESSAGE_BAR_ENABLED, true) // Enabled by default } @@ -642,6 +652,7 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database) const val SHARED_PREFS_CONNECTION_ALERT_SNOOZE_UNTIL = "ConnectionAlertSnoozeUntil" const val CONNECTION_ALERT_SNOOZE_UNTIL_DEFAULT = 0L const val CONNECTION_ALERT_NEVER_SHOW = Long.MAX_VALUE + const val SHARED_PREFS_SHARING_AUTO_SEND = "SharingAutoSend" const val SHARED_PREFS_LAST_TOPICS = "LastTopics" private const val LAST_TOPICS_COUNT = 3 diff --git a/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt index 8ebf2f874..75ca97c50 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt @@ -715,6 +715,32 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere // Update "Exact alarms" preference to match system setting updateExactAlarmsPref() + // Sharing: auto-send (Android 10+ only) + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + val sharingHeaderPrefId = context?.getString(R.string.settings_sharing_header_key) ?: return + val sharingHeader: PreferenceCategory? = findPreference(sharingHeaderPrefId) + sharingHeader?.isVisible = true + + val sharingAutoSendPrefId = context?.getString(R.string.settings_sharing_auto_send_key) ?: return + val sharingAutoSend: SwitchPreferenceCompat? = findPreference(sharingAutoSendPrefId) + sharingAutoSend?.isChecked = repository.isSharingAutoSendEnabled() + sharingAutoSend?.preferenceDataStore = object : PreferenceDataStore() { + override fun putBoolean(key: String?, value: Boolean) { + repository.setSharingAutoSendEnabled(value) + } + override fun getBoolean(key: String?, defValue: Boolean): Boolean { + return repository.isSharingAutoSendEnabled() + } + } + sharingAutoSend?.summaryProvider = Preference.SummaryProvider { pref -> + if (pref.isChecked) { + getString(R.string.settings_sharing_auto_send_summary_enabled) + } else { + getString(R.string.settings_sharing_auto_send_summary_disabled) + } + } + } + // Version val versionPrefId = context?.getString(R.string.settings_about_version_key) ?: return val versionPref: Preference? = findPreference(versionPrefId) diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt index 45b62a1c5..7e0e54c3c 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -205,6 +205,8 @@ class ShareActivity : AppCompatActivity() { } baseUrlLayout.visibility = if (useAnotherServerCheckbox.isChecked) View.VISIBLE else View.GONE + handleIncomingIntent() + // Override defaults if launched from a sharing shortcut shortcutTopicUrl?.let { url -> try { @@ -215,14 +217,18 @@ class ShareActivity : AppCompatActivity() { if (baseUrl != defaultUrl) baseUrlText.setText(baseUrl) baseUrlLayout.visibility = if (useAnotherServerCheckbox.isChecked) View.VISIBLE else View.GONE validateInput() + if (repository.isSharingAutoSendEnabled() && (contentText.text.isNotEmpty() || fileUri != null) && topicText.text.isNotEmpty()) { + onShareClick() + } } catch (_: Exception) { // Ignore malformed shortcut IDs } } } } + } - // Incoming intent + private fun handleIncomingIntent() { val intent = intent ?: return val type = intent.type ?: return if (intent.action != Intent.ACTION_SEND) return diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 986a33e4e..085b6a4a2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -414,6 +414,10 @@ Import config, notifications and users Restore successful Restore failed: %1$s + Sharing + Auto-publish when sharing + Items directly shared to a topic are published automatically + Items directly shared to a topic require manual publish Advanced Broadcast messages Apps can receive incoming notifications as broadcasts diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index 0b45baf59..2abc8dbaa 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -36,6 +36,8 @@ ClearLogs ConnectionProtocol ExactAlarms + SharingHeader + SharingAutoSend Version diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 1ef47d3ed..77f3ce63a 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -63,6 +63,15 @@ app:title="@string/settings_general_message_bar_title" app:defaultValue="true"/> + + + Date: Mon, 6 Jul 2026 23:57:54 -0400 Subject: [PATCH 4/4] Remove the preference for toggling auto send Instead of creating a new preference, auto send will be enabled by default. Whenever the user taps on a dynamic target in the share sheet, it will be automatically sent without the user having to tap the send button. --- .../main/java/io/heckel/ntfy/db/Repository.kt | 11 -------- .../io/heckel/ntfy/ui/SettingsActivity.kt | 26 ------------------- .../java/io/heckel/ntfy/ui/ShareActivity.kt | 2 +- app/src/main/res/values/strings.xml | 4 --- app/src/main/res/values/values.xml | 2 -- app/src/main/res/xml/main_preferences.xml | 9 ------- 6 files changed, 1 insertion(+), 53 deletions(-) diff --git a/app/src/main/java/io/heckel/ntfy/db/Repository.kt b/app/src/main/java/io/heckel/ntfy/db/Repository.kt index 275d17b78..a6716c742 100644 --- a/app/src/main/java/io/heckel/ntfy/db/Repository.kt +++ b/app/src/main/java/io/heckel/ntfy/db/Repository.kt @@ -400,16 +400,6 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database) } } - fun isSharingAutoSendEnabled(): Boolean { - return sharedPrefs.getBoolean(SHARED_PREFS_SHARING_AUTO_SEND, false) // Disabled by default - } - - fun setSharingAutoSendEnabled(enabled: Boolean) { - sharedPrefs.edit { - putBoolean(SHARED_PREFS_SHARING_AUTO_SEND, enabled) - } - } - fun getMessageBarEnabled(): Boolean { return sharedPrefs.getBoolean(SHARED_PREFS_MESSAGE_BAR_ENABLED, true) // Enabled by default } @@ -652,7 +642,6 @@ class Repository(private val sharedPrefs: SharedPreferences, database: Database) const val SHARED_PREFS_CONNECTION_ALERT_SNOOZE_UNTIL = "ConnectionAlertSnoozeUntil" const val CONNECTION_ALERT_SNOOZE_UNTIL_DEFAULT = 0L const val CONNECTION_ALERT_NEVER_SHOW = Long.MAX_VALUE - const val SHARED_PREFS_SHARING_AUTO_SEND = "SharingAutoSend" const val SHARED_PREFS_LAST_TOPICS = "LastTopics" private const val LAST_TOPICS_COUNT = 3 diff --git a/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt index 75ca97c50..8ebf2f874 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/SettingsActivity.kt @@ -715,32 +715,6 @@ class SettingsActivity : AppCompatActivity(), PreferenceFragmentCompat.OnPrefere // Update "Exact alarms" preference to match system setting updateExactAlarmsPref() - // Sharing: auto-send (Android 10+ only) - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { - val sharingHeaderPrefId = context?.getString(R.string.settings_sharing_header_key) ?: return - val sharingHeader: PreferenceCategory? = findPreference(sharingHeaderPrefId) - sharingHeader?.isVisible = true - - val sharingAutoSendPrefId = context?.getString(R.string.settings_sharing_auto_send_key) ?: return - val sharingAutoSend: SwitchPreferenceCompat? = findPreference(sharingAutoSendPrefId) - sharingAutoSend?.isChecked = repository.isSharingAutoSendEnabled() - sharingAutoSend?.preferenceDataStore = object : PreferenceDataStore() { - override fun putBoolean(key: String?, value: Boolean) { - repository.setSharingAutoSendEnabled(value) - } - override fun getBoolean(key: String?, defValue: Boolean): Boolean { - return repository.isSharingAutoSendEnabled() - } - } - sharingAutoSend?.summaryProvider = Preference.SummaryProvider { pref -> - if (pref.isChecked) { - getString(R.string.settings_sharing_auto_send_summary_enabled) - } else { - getString(R.string.settings_sharing_auto_send_summary_disabled) - } - } - } - // Version val versionPrefId = context?.getString(R.string.settings_about_version_key) ?: return val versionPref: Preference? = findPreference(versionPrefId) diff --git a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt index 7e0e54c3c..fec1688ab 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -217,7 +217,7 @@ class ShareActivity : AppCompatActivity() { if (baseUrl != defaultUrl) baseUrlText.setText(baseUrl) baseUrlLayout.visibility = if (useAnotherServerCheckbox.isChecked) View.VISIBLE else View.GONE validateInput() - if (repository.isSharingAutoSendEnabled() && (contentText.text.isNotEmpty() || fileUri != null) && topicText.text.isNotEmpty()) { + if ((contentText.text.isNotEmpty() || fileUri != null) && topicText.text.isNotEmpty()) { onShareClick() } } catch (_: Exception) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 085b6a4a2..986a33e4e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -414,10 +414,6 @@ Import config, notifications and users Restore successful Restore failed: %1$s - Sharing - Auto-publish when sharing - Items directly shared to a topic are published automatically - Items directly shared to a topic require manual publish Advanced Broadcast messages Apps can receive incoming notifications as broadcasts diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index 2abc8dbaa..0b45baf59 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -36,8 +36,6 @@ ClearLogs ConnectionProtocol ExactAlarms - SharingHeader - SharingAutoSend Version diff --git a/app/src/main/res/xml/main_preferences.xml b/app/src/main/res/xml/main_preferences.xml index 77f3ce63a..1ef47d3ed 100644 --- a/app/src/main/res/xml/main_preferences.xml +++ b/app/src/main/res/xml/main_preferences.xml @@ -63,15 +63,6 @@ app:title="@string/settings_general_message_bar_title" app:defaultValue="true"/> - - -