WIP: Message bar

This commit is contained in:
Philipp Heckel 2022-11-23 22:03:00 -05:00
parent 4ee2f53bd4
commit 6841896f92
2 changed files with 43 additions and 3 deletions

View file

@ -13,6 +13,7 @@ import android.view.ActionMode
import android.view.Menu import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View import android.view.View
import android.widget.Button
import android.widget.TextView import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.activity.viewModels import androidx.activity.viewModels
@ -23,6 +24,7 @@ import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import com.google.android.material.textfield.TextInputEditText
import io.heckel.ntfy.BuildConfig import io.heckel.ntfy.BuildConfig
import io.heckel.ntfy.R import io.heckel.ntfy.R
import io.heckel.ntfy.app.Application import io.heckel.ntfy.app.Application
@ -184,6 +186,15 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
howToExample.text = Html.fromHtml(howToText) 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) {
api.publish(subscriptionBaseUrl, subscriptionTopic, message = messageText.text.toString())
}
}
// Swipe to refresh // Swipe to refresh
mainListContainer = findViewById(R.id.detail_notification_list_container) mainListContainer = findViewById(R.id.detail_notification_list_container)
mainListContainer.setOnRefreshListener { refresh() } mainListContainer.setOnRefreshListener { refresh() }

View file

@ -11,8 +11,8 @@
style="@style/CardViewBackground" style="@style/CardViewBackground"
android:id="@+id/detail_notification_list_container" android:id="@+id/detail_notification_list_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="0dp"
android:visibility="gone"> 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">
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/detail_notification_list" android:id="@+id/detail_notification_list"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -32,7 +32,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/detail_no_notifications" app:layout_constraintBottom_toBottomOf="parent" android:id="@+id/detail_no_notifications" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"> app:layout_constraintEnd_toEndOf="parent" android:visibility="gone">
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" app:srcCompat="@drawable/ic_sms_gray_48dp" android:layout_height="wrap_content" app:srcCompat="@drawable/ic_sms_gray_48dp"
@ -72,5 +72,34 @@
android:linksClickable="true" android:linksClickable="true"
android:autoLink="web"/> android:autoLink="web"/>
</LinearLayout> </LinearLayout>
<LinearLayout
style="@style/CardViewBackground"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/detail_message_bar"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="3dp" android:layout_marginBottom="3dp" android:layout_marginEnd="3dp">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/detail_message_box"
android:layout_width="0dp"
android:layout_height="48dp" android:hint="Type a message here"
android:inputType="text|textNoSuggestions"
android:gravity="start|top" android:layout_weight="1"/>
<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"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>