From 3ea762b5d19a0ff279981bf7ce5873f0a47f12b5 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Tue, 15 Feb 2022 19:56:49 -0500 Subject: [PATCH] Add foreground description textview in add dialog --- .../java/io/heckel/ntfy/ui/AddFragment.kt | 12 +++--- .../main/res/layout/fragment_add_dialog.xml | 37 +++++++++++-------- app/src/main/res/values/strings.xml | 13 ++----- 3 files changed, 31 insertions(+), 31 deletions(-) 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 89e8192..e9b2787 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/AddFragment.kt @@ -46,6 +46,7 @@ class AddFragment : DialogFragment() { private lateinit var subscribeInstantDeliveryBox: View private lateinit var subscribeInstantDeliveryCheckbox: CheckBox private lateinit var subscribeInstantDeliveryDescription: View + private lateinit var subscribeForegroundDescription: TextView private lateinit var subscribeProgress: ProgressBar private lateinit var subscribeErrorText: TextView private lateinit var subscribeErrorTextImage: View @@ -98,6 +99,7 @@ class AddFragment : DialogFragment() { subscribeInstantDeliveryDescription = view.findViewById(R.id.add_dialog_subscribe_instant_delivery_description) subscribeUseAnotherServerCheckbox = view.findViewById(R.id.add_dialog_subscribe_use_another_server_checkbox) subscribeUseAnotherServerDescription = view.findViewById(R.id.add_dialog_subscribe_use_another_server_description) + subscribeForegroundDescription = view.findViewById(R.id.add_dialog_subscribe_foreground_description) subscribeProgress = view.findViewById(R.id.add_dialog_subscribe_progress) subscribeErrorText = view.findViewById(R.id.add_dialog_subscribe_error_text) subscribeErrorText.visibility = View.GONE @@ -111,12 +113,8 @@ class AddFragment : DialogFragment() { loginErrorText = view.findViewById(R.id.add_dialog_login_error_text) loginErrorTextImage = view.findViewById(R.id.add_dialog_login_error_text_image) - // Set "Use another server" description based on flavor - subscribeUseAnotherServerDescription.text = if (BuildConfig.FIREBASE_AVAILABLE) { - getString(R.string.add_dialog_use_another_server_description) - } else { - getString(R.string.add_dialog_use_another_server_description_noinstant) - } + // Set foreground description text + subscribeForegroundDescription.text = getString(R.string.add_dialog_foreground_description, shortUrl(appBaseUrl)) // Show/hide based on flavor subscribeInstantDeliveryBox.visibility = instantCheckboxVisible() @@ -209,6 +207,7 @@ class AddFragment : DialogFragment() { validateInputSubscribeView() } subscribeInstantDeliveryBox.visibility = instantCheckboxVisible() + subscribeForegroundDescription.visibility = if (!BuildConfig.FIREBASE_AVAILABLE || subscribeInstantDeliveryBox.visibility == View.VISIBLE) View.GONE else View.VISIBLE // Focus topic text (keyboard is shown too, see above) subscribeTopicText.requestFocus() @@ -346,6 +345,7 @@ class AddFragment : DialogFragment() { } subscribeInstantDeliveryBox.visibility = instantCheckboxVisible() subscribeInstantDeliveryDescription.visibility = if (subscribeInstantDeliveryBox.visibility == View.VISIBLE && subscribeInstantDeliveryCheckbox.isChecked) View.VISIBLE else View.GONE + subscribeForegroundDescription.visibility = if (!BuildConfig.FIREBASE_AVAILABLE || subscribeInstantDeliveryBox.visibility == View.VISIBLE) View.GONE else View.VISIBLE } } } diff --git a/app/src/main/res/layout/fragment_add_dialog.xml b/app/src/main/res/layout/fragment_add_dialog.xml index 9cb21ba..ad0c7d4 100644 --- a/app/src/main/res/layout/fragment_add_dialog.xml +++ b/app/src/main/res/layout/fragment_add_dialog.xml @@ -42,7 +42,7 @@ android:paddingStart="4dp" android:paddingTop="3dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@id/add_dialog_subscribe_title"/> - - + - + Topic name, e.g. phils_alerts Use another server - - You can subscribe to topics from another server. This option requires a foreground service. - - - You can subscribe to topics from another server. Type the server URL below. - + You can subscribe to topics from another server. Type the server URL below. Instant delivery in doze mode - - Ensures that messages are immediately delivered, even if the device is inactive. - This requires a foreground service. - + Ensures that messages are immediately delivered, even if the device is inactive. + Instant delivery is always enabled for hosts other than %1$s. Cancel Subscribe Back