Compare commits
5 commits
main
...
message-ba
Author | SHA1 | Date | |
---|---|---|---|
|
2b215059cc | ||
|
5cd0c0bed7 | ||
|
c6f414813e | ||
|
1a828e505e | ||
|
6841896f92 |
8 changed files with 167 additions and 54 deletions
|
@ -38,6 +38,7 @@
|
|||
<activity
|
||||
android:name=".ui.DetailActivity"
|
||||
android:parentActivityName=".ui.MainActivity"
|
||||
android:windowSoftInputMode="adjustResize"
|
||||
android:exported="true">
|
||||
<meta-data
|
||||
android:name="android.support.PARENT_ACTIVITY"
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.view.ActionMode
|
|||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import android.view.View
|
||||
import android.widget.Button
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.activity.viewModels
|
||||
|
@ -23,6 +24,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.google.android.material.textfield.TextInputEditText
|
||||
import io.heckel.ntfy.BuildConfig
|
||||
import io.heckel.ntfy.R
|
||||
import io.heckel.ntfy.app.Application
|
||||
|
@ -184,6 +186,34 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
|||
howToExample.text = Html.fromHtml(howToText)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
val message = messageText.text.toString()
|
||||
if (message.isNotEmpty()) {
|
||||
try {
|
||||
api.publish(subscriptionBaseUrl, subscriptionTopic, message = message)
|
||||
messageText.text?.clear()
|
||||
} catch (e: Exception) {
|
||||
runOnUiThread {
|
||||
Toast
|
||||
.makeText(this@DetailActivity, getString(R.string.detail_test_message_error, e.message), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
runOnUiThread {
|
||||
Toast
|
||||
.makeText(this@DetailActivity, getString(R.string.detail_message_bar_empty_message), Toast.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Swipe to refresh
|
||||
mainListContainer = findViewById(R.id.detail_notification_list_container)
|
||||
mainListContainer.setOnRefreshListener { refresh() }
|
||||
|
|
|
@ -88,17 +88,9 @@ class ShareActivity : AppCompatActivity() {
|
|||
errorImage = findViewById(R.id.share_error_image)
|
||||
errorImage.visibility = View.GONE
|
||||
|
||||
val textWatcher = object : TextWatcher {
|
||||
override fun afterTextChanged(s: Editable?) {
|
||||
val textWatcher = AfterChangedTextWatcher {
|
||||
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
|
||||
}
|
||||
}
|
||||
contentText.addTextChangedListener(textWatcher)
|
||||
topicText.addTextChangedListener(textWatcher)
|
||||
baseUrlText.addTextChangedListener(textWatcher)
|
||||
|
|
5
app/src/main/res/drawable/ic_edittext_background.xml
Normal file
5
app/src/main/res/drawable/ic_edittext_background.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="@color/white"/>
|
||||
<corners android:radius="5dp"/>
|
||||
</shape>
|
|
@ -11,8 +11,7 @@
|
|||
style="@style/CardViewBackground"
|
||||
android:id="@+id/detail_notification_list_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone">
|
||||
android:visibility="gone" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintEnd_toEndOf="parent" android:layout_height="0dp" app:layout_constraintBottom_toTopOf="@id/detail_message_bar" app:layout_constraintVertical_bias="0.0">
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/detail_notification_list"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -26,13 +25,18 @@
|
|||
app:layoutManager="LinearLayoutManager"/>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/detail_no_notifications"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" android:visibility="visible" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toTopOf="@id/detail_message_bar" app:layout_constraintVertical_bias="1.0">
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/detail_no_notifications" app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent">
|
||||
android:id="@+id/detail_no_notifications_inner" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent">
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_sms_gray_48dp"
|
||||
|
@ -72,5 +76,69 @@
|
|||
android:linksClickable="true"
|
||||
android:autoLink="web"/>
|
||||
</LinearLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
style="@style/MessageBarBackground"
|
||||
android:layout_height="64dp"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/detail_message_bar"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintVertical_weight="1"
|
||||
app:layout_constraintTop_toBottomOf="@+id/detail_no_notifications"
|
||||
app:layout_constraintVertical_bias="1.0"
|
||||
android:elevation="10dp"
|
||||
>
|
||||
<androidx.cardview.widget.CardView
|
||||
style="@style/CardView"
|
||||
android:id="@+id/detail_message_box_layout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="52dp"
|
||||
android:layout_marginStart="7dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:padding="7dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@id/detail_message_send_button"
|
||||
android:outlineAmbientShadowColor="@color/gray_600"
|
||||
android:outlineSpotShadowColor="@color/gray_600"
|
||||
app:cardCornerRadius="5dp"
|
||||
app:cardElevation="1dp"
|
||||
app:cardMaxElevation="1dp"
|
||||
app:cardPreventCornerOverlap="true"
|
||||
app:cardUseCompatPadding="true">
|
||||
<com.google.android.material.textfield.TextInputEditText
|
||||
android:id="@+id/detail_message_box"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inputType="text"
|
||||
style="@style/MessageInputText"
|
||||
android:padding="8dp"
|
||||
android:background="@drawable/ic_edittext_background"
|
||||
android:hint="@string/detail_message_bar_hint"
|
||||
/>
|
||||
|
||||
</androidx.cardview.widget.CardView>
|
||||
<com.google.android.material.button.MaterialButton
|
||||
style="@style/Widget.MaterialComponents.Button.Icon"
|
||||
android:id="@+id/detail_message_send_button"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
app:cornerRadius="30dp"
|
||||
android:insetTop="0dp"
|
||||
android:insetBottom="0dp"
|
||||
android:insetLeft="0dp"
|
||||
android:insetRight="0dp"
|
||||
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"/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<color name="black_900">#121212</color> <!-- Main dark mode surface color, as per style guide -->
|
||||
<color name="black_800b">#1b2023</color> <!-- Action bar & item selection (dark mode); this has a touch of blue! -->
|
||||
<color name="black_700b">#282F33</color> <!-- Card selection (dark mode); this has a touch of blue! -->
|
||||
<color name="gray_600">#aaaaaa</color> <!-- Message box drop shadow (light mode) -->
|
||||
<color name="gray_500">#dddddd</color> <!-- Card selection (light mode) -->
|
||||
<color name="gray_400">#eeeeee</color> <!-- Item selection (light mode) -->
|
||||
<color name="white">#ffffffff</color>
|
||||
|
|
|
@ -166,6 +166,10 @@
|
|||
<string name="detail_item_download_info_download_failed_expired">download failed, link expired</string>
|
||||
<string name="detail_item_download_info_download_failed_expires_x">download failed, link expires %1$s</string>
|
||||
|
||||
<!-- Detail activity: Message bar -->
|
||||
<string name="detail_message_bar_hint">Type a message here</string>
|
||||
<string name="detail_message_bar_empty_message">Type a message first</string>
|
||||
|
||||
<!-- Detail activity: Action bar -->
|
||||
<string name="detail_menu_notifications_enabled">Notifications on</string>
|
||||
<string name="detail_menu_notifications_disabled_forever">Notifications muted</string>
|
||||
|
|
|
@ -30,4 +30,16 @@
|
|||
<item name="cornerFamily">rounded</item>
|
||||
<item name="cornerSize">5dp</item>
|
||||
</style>
|
||||
|
||||
<style name="MessageBarBackground">
|
||||
<item name="android:background">@color/gray_400</item>
|
||||
</style>
|
||||
|
||||
<style name="MessageInputLayout" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
|
||||
<item name="hintTextColor">@color/black_700b</item>
|
||||
</style>
|
||||
|
||||
<style name="MessageInputText" parent="Widget.AppCompat.EditText">
|
||||
<item name="android:textSize">16sp</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue