More refinement

This commit is contained in:
Philipp Heckel 2025-12-26 17:23:22 -05:00
parent a6ffee3939
commit 3191be695d
3 changed files with 28 additions and 27 deletions

View file

@ -20,7 +20,6 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.button.MaterialButton
import com.google.android.material.chip.Chip
import com.google.android.material.chip.ChipGroup
import com.google.android.material.textfield.TextInputEditText
@ -85,8 +84,7 @@ class PublishFragment : DialogFragment() {
private lateinit var phoneCallText: TextInputEditText
// Attach file
private lateinit var attachFileButton: MaterialButton
private lateinit var attachFileName: TextView
private lateinit var attachFileNameText: TextInputEditText
// Progress/Error
private lateinit var progress: ProgressBar
@ -226,8 +224,7 @@ class PublishFragment : DialogFragment() {
phoneCallText = view.findViewById(R.id.publish_dialog_phone_call_text)
// Attach file UI
attachFileButton = view.findViewById(R.id.publish_dialog_attach_file_button)
attachFileName = view.findViewById(R.id.publish_dialog_attach_file_name)
attachFileNameText = view.findViewById(R.id.publish_dialog_attach_file_name)
// Setup chip click listeners
setupChipListeners()
@ -235,11 +232,6 @@ class PublishFragment : DialogFragment() {
// Setup remove button listeners
setupRemoveButtonListeners(view)
// Setup file picker button
attachFileButton.setOnClickListener {
openFilePicker()
}
// Setup docs link
docsLink.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://docs.ntfy.sh/publish/"))
@ -352,7 +344,7 @@ class PublishFragment : DialogFragment() {
} else {
selectedFileUri = null
selectedFileName = ""
attachFileName.text = ""
attachFileNameText.setText("")
}
}
@ -423,7 +415,7 @@ class PublishFragment : DialogFragment() {
}
selectedFileMimeType = requireContext().contentResolver.getType(uri) ?: "application/octet-stream"
attachFileName.text = selectedFileName
attachFileNameText.setText(selectedFileName)
}
override fun onStart() {
@ -499,7 +491,7 @@ class PublishFragment : DialogFragment() {
tags = tags,
delay = delay,
body = body,
filename = selectedFileName,
filename = attachFileNameText.text.toString(),
click = clickUrl,
email = email,
call = phoneCall,
@ -585,7 +577,7 @@ class PublishFragment : DialogFragment() {
attachUrlText.isEnabled = enable
attachFilenameText.isEnabled = enable
phoneCallText.isEnabled = enable
attachFileButton.isEnabled = enable
attachFileNameText.isEnabled = enable
sendMenuItem.isEnabled = enable && messageText.text?.isNotEmpty() == true
}

View file

@ -373,23 +373,31 @@
android:layout_marginTop="10dp"
android:gravity="center_vertical">
<com.google.android.material.button.MaterialButton
android:id="@+id/publish_dialog_attach_file_button"
style="@style/Widget.Material3.Button.OutlinedButton"
<TextView
android:id="@+id/publish_dialog_attach_file_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/publish_dialog_attach_file_button"
app:icon="@drawable/ic_file_document_blue_24dp"/>
android:text="@string/publish_dialog_attach_file_label"
android:textAppearance="@style/TextAppearance.Material3.BodyMedium"
android:textColor="?attr/colorOnSurfaceVariant"/>
<TextView
android:id="@+id/publish_dialog_attach_file_name"
<com.google.android.material.textfield.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginStart="12dp"
android:ellipsize="middle"
android:singleLine="true"
android:textColor="?attr/colorOnSurfaceVariant"/>
android:layout_marginStart="8dp"
style="@style/Widget.Material3.TextInputLayout.OutlinedBox">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/publish_dialog_attach_file_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/publish_dialog_attach_file_name_hint"
android:importantForAutofill="no"
android:maxLines="1"
android:inputType="text"/>
</com.google.android.material.textfield.TextInputLayout>
<ImageButton
android:id="@+id/publish_dialog_attach_file_remove"
@ -455,7 +463,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:chipSpacingVertical="0dp"
app:chipSpacingVertical="-4dp"
app:chipSpacingHorizontal="8dp"
app:singleLine="false">

View file

@ -232,7 +232,8 @@
<string name="publish_dialog_attach_url_hint">Attachment URL</string>
<string name="publish_dialog_attach_filename_hint">Filename</string>
<string name="publish_dialog_phone_call_hint">Phone number to call</string>
<string name="publish_dialog_attach_file_button">Pick file</string>
<string name="publish_dialog_attach_file_label">Attached file:</string>
<string name="publish_dialog_attach_file_name_hint">Filename</string>
<string name="publish_dialog_remove_field">Remove field</string>
<string name="publish_dialog_docs_link">For examples and a detailed description of all send features, please refer to the documentation.</string>