Compare commits

...

5 commits

Author SHA1 Message Date
Philipp Heckel
2b215059cc CardView 2022-11-25 13:05:17 -05:00
Philipp Heckel
5cd0c0bed7 Slightly better 2022-11-25 12:29:43 -05:00
Philipp Heckel
c6f414813e Working resizing and such 2022-11-25 11:40:58 -05:00
Philipp Heckel
1a828e505e WIP message bar 2022-11-24 14:45:52 -05:00
Philipp Heckel
6841896f92 WIP: Message bar 2022-11-23 22:03:00 -05:00
8 changed files with 167 additions and 54 deletions

View file

@ -38,6 +38,7 @@
<activity <activity
android:name=".ui.DetailActivity" android:name=".ui.DetailActivity"
android:parentActivityName=".ui.MainActivity" android:parentActivityName=".ui.MainActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true"> android:exported="true">
<meta-data <meta-data
android:name="android.support.PARENT_ACTIVITY" android:name="android.support.PARENT_ACTIVITY"

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,34 @@ 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) {
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 // 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

@ -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)

View 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>

View file

@ -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="match_parent" 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">
android:visibility="gone">
<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"
@ -26,13 +25,18 @@
app:layoutManager="LinearLayoutManager"/> app:layoutManager="LinearLayoutManager"/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </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 <LinearLayout
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
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_inner" app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent">
app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<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 +76,69 @@
android:linksClickable="true" android:linksClickable="true"
android:autoLink="web"/> android:autoLink="web"/>
</LinearLayout> </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> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -4,6 +4,7 @@
<color name="black_900">#121212</color> <!-- Main dark mode surface color, as per style guide --> <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_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="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_500">#dddddd</color> <!-- Card selection (light mode) -->
<color name="gray_400">#eeeeee</color> <!-- Item selection (light mode) --> <color name="gray_400">#eeeeee</color> <!-- Item selection (light mode) -->
<color name="white">#ffffffff</color> <color name="white">#ffffffff</color>

View file

@ -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>

View file

@ -30,4 +30,16 @@
<item name="cornerFamily">rounded</item> <item name="cornerFamily">rounded</item>
<item name="cornerSize">5dp</item> <item name="cornerSize">5dp</item>
</style> </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> </resources>