diff --git a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt index 64ff127..1514cd2 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/DetailActivity.kt @@ -189,9 +189,20 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra // Message bar val messageText: TextInputEditText = findViewById(R.id.detail_message_box) val messageSendButton: Button = findViewById(R.id.detail_message_send_button) + messageSendButton.setOnClickListener { lifecycleScope.launch(Dispatchers.IO) { - api.publish(subscriptionBaseUrl, subscriptionTopic, message = messageText.text.toString()) + val message = messageText.text.toString() + if (message.isNotEmpty()) { + api.publish(subscriptionBaseUrl, subscriptionTopic, message = message) + messageText.text?.clear() + } else { + runOnUiThread { + Toast + .makeText(this@DetailActivity, getString(R.string.detail_message_bar_empty_message), Toast.LENGTH_LONG) + .show() + } + } } } 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 1db1c33..108995b 100644 --- a/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt +++ b/app/src/main/java/io/heckel/ntfy/ui/ShareActivity.kt @@ -88,16 +88,8 @@ class ShareActivity : AppCompatActivity() { errorImage = findViewById(R.id.share_error_image) errorImage.visibility = View.GONE - val textWatcher = object : TextWatcher { - override fun afterTextChanged(s: Editable?) { - validateInput() - } - override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { - // Nothing - } - override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { - // Nothing - } + val textWatcher = AfterChangedTextWatcher { + validateInput() } contentText.addTextChangedListener(textWatcher) topicText.addTextChangedListener(textWatcher) diff --git a/app/src/main/res/layout/activity_detail.xml b/app/src/main/res/layout/activity_detail.xml index 79a045c..b82a54c 100644 --- a/app/src/main/res/layout/activity_detail.xml +++ b/app/src/main/res/layout/activity_detail.xml @@ -11,8 +11,7 @@ style="@style/CardViewBackground" android:id="@+id/detail_notification_list_container" android:layout_width="match_parent" - android:layout_height="0dp" - android:visibility="visible" app:layout_constraintBottom_toTopOf="@id/detail_message_box" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent"> + android:visibility="visible" app:layout_constraintBottom_toTopOf="@id/detail_message_bar" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_height="0dp"> - - + + android:layout_height="wrap_content" + app:boxCornerRadiusBottomEnd="24dp" + app:boxCornerRadiusTopEnd="24dp" + app:boxCornerRadiusBottomStart="24dp" + app:boxCornerRadiusTopStart="24dp" + app:boxStrokeWidthFocused="0dp" + app:boxStrokeWidth="0dp" + app:boxBackgroundMode="filled" + app:hintEnabled="false" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toStartOf="@id/detail_message_send_button" + app:startIconDrawable="@drawable/ic_add_black_24dp" + android:layout_marginStart="7dp" + android:layout_marginBottom="1dp" + android:layout_marginEnd="5dp"> + + + + - + app:icon="@drawable/ic_send_white_24dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintStart_toEndOf="@id/detail_message_box_layout" + app:layout_constraintBottom_toBottomOf="parent" + android:layout_marginEnd="7dp" + android:layout_marginBottom="2dp" android:layout_marginTop="3dp"/> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 466cd40..ea2883d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -166,6 +166,10 @@ download failed, link expired download failed, link expires %1$s + + Type a message here + Type a message first + Notifications on Notifications muted diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4f0902d..65047ca 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -30,4 +30,9 @@ rounded 5dp + +