WIP message bar
This commit is contained in:
parent
6841896f92
commit
1a828e505e
5 changed files with 68 additions and 24 deletions
|
@ -189,9 +189,20 @@ class DetailActivity : AppCompatActivity(), ActionMode.Callback, NotificationFra
|
||||||
// Message bar
|
// Message bar
|
||||||
val messageText: TextInputEditText = findViewById(R.id.detail_message_box)
|
val messageText: TextInputEditText = findViewById(R.id.detail_message_box)
|
||||||
val messageSendButton: Button = findViewById(R.id.detail_message_send_button)
|
val messageSendButton: Button = findViewById(R.id.detail_message_send_button)
|
||||||
|
|
||||||
messageSendButton.setOnClickListener {
|
messageSendButton.setOnClickListener {
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
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()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,17 +88,9 @@ class ShareActivity : AppCompatActivity() {
|
||||||
errorImage = findViewById(R.id.share_error_image)
|
errorImage = findViewById(R.id.share_error_image)
|
||||||
errorImage.visibility = View.GONE
|
errorImage.visibility = View.GONE
|
||||||
|
|
||||||
val textWatcher = object : TextWatcher {
|
val textWatcher = AfterChangedTextWatcher {
|
||||||
override fun afterTextChanged(s: Editable?) {
|
|
||||||
validateInput()
|
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)
|
contentText.addTextChangedListener(textWatcher)
|
||||||
topicText.addTextChangedListener(textWatcher)
|
topicText.addTextChangedListener(textWatcher)
|
||||||
baseUrlText.addTextChangedListener(textWatcher)
|
baseUrlText.addTextChangedListener(textWatcher)
|
||||||
|
|
|
@ -11,8 +11,7 @@
|
||||||
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="0dp"
|
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: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"
|
||||||
|
@ -72,22 +71,49 @@
|
||||||
android:linksClickable="true"
|
android:linksClickable="true"
|
||||||
android:autoLink="web"/>
|
android:autoLink="web"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
style="@style/CardViewBackground"
|
style="@style/CardViewBackground"
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:id="@+id/detail_message_bar"
|
android:id="@+id/detail_message_bar"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
android:layout_marginStart="3dp" android:layout_marginBottom="3dp" android:layout_marginEnd="3dp">
|
app:layout_constraintTop_toBottomOf="@+id/detail_notification_list_container">
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
style="@style/MessageInputBox"
|
||||||
|
android:id="@+id/detail_message_box_layout"
|
||||||
|
android:layout_width="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">
|
||||||
|
|
||||||
<com.google.android.material.textfield.TextInputEditText
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
android:id="@+id/detail_message_box"
|
android:id="@+id/detail_message_box"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="48dp" android:hint="Type a message here"
|
android:layout_height="wrap_content"
|
||||||
android:inputType="text|textNoSuggestions"
|
android:inputType="text"
|
||||||
android:gravity="start|top" android:layout_weight="1"/>
|
android:textColor="#000000"
|
||||||
|
android:padding="3dp"
|
||||||
|
android:textColorLink="#FFFFFF"
|
||||||
|
android:hint="@string/detail_message_bar_hint"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
<com.google.android.material.button.MaterialButton
|
<com.google.android.material.button.MaterialButton
|
||||||
style="@style/Widget.MaterialComponents.Button.Icon"
|
style="@style/Widget.MaterialComponents.Button.Icon"
|
||||||
android:id="@+id/detail_message_send_button"
|
android:id="@+id/detail_message_send_button"
|
||||||
|
@ -98,8 +124,14 @@
|
||||||
android:insetBottom="0dp"
|
android:insetBottom="0dp"
|
||||||
android:insetLeft="0dp"
|
android:insetLeft="0dp"
|
||||||
android:insetRight="0dp"
|
android:insetRight="0dp"
|
||||||
app:icon="@drawable/ic_send_white_24dp"/>
|
app:icon="@drawable/ic_send_white_24dp"
|
||||||
</LinearLayout>
|
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>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
|
@ -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_expired">download failed, link expired</string>
|
||||||
<string name="detail_item_download_info_download_failed_expires_x">download failed, link expires %1$s</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 -->
|
<!-- Detail activity: Action bar -->
|
||||||
<string name="detail_menu_notifications_enabled">Notifications on</string>
|
<string name="detail_menu_notifications_enabled">Notifications on</string>
|
||||||
<string name="detail_menu_notifications_disabled_forever">Notifications muted</string>
|
<string name="detail_menu_notifications_disabled_forever">Notifications muted</string>
|
||||||
|
|
|
@ -30,4 +30,9 @@
|
||||||
<item name="cornerFamily">rounded</item>
|
<item name="cornerFamily">rounded</item>
|
||||||
<item name="cornerSize">5dp</item>
|
<item name="cornerSize">5dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="MessageInputBox" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
|
||||||
|
<item name="boxBackgroundColor">@color/white</item>
|
||||||
|
<item name="boxStrokeColor">@color/white</item>
|
||||||
|
</style>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue