mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 03:18:06 +00:00
Improved empty subject for start/edit group call/conversation
This commit is contained in:
parent
179a6c39ca
commit
6cabf0bdf7
8 changed files with 42 additions and 7 deletions
|
|
@ -226,6 +226,7 @@ class ConversationInfoFragment : SlidingPaneChildFragment() {
|
|||
|
||||
val dialog = DialogUtils.getSetOrEditGroupSubjectDialog(
|
||||
requireContext(),
|
||||
viewLifecycleOwner,
|
||||
model
|
||||
)
|
||||
|
||||
|
|
@ -238,11 +239,17 @@ class ConversationInfoFragment : SlidingPaneChildFragment() {
|
|||
|
||||
model.confirmEvent.observe(viewLifecycleOwner) {
|
||||
it.consume { newSubject ->
|
||||
Log.i(
|
||||
"$TAG Conversation subject edit confirmed, new subject is [$newSubject] (old was [$currentSubject])"
|
||||
)
|
||||
viewModel.updateSubject(newSubject)
|
||||
dialog.dismiss()
|
||||
if (newSubject.isNotEmpty()) {
|
||||
Log.i(
|
||||
"$TAG Conversation subject edit confirmed, new subject is [$newSubject] (old was [$currentSubject])"
|
||||
)
|
||||
viewModel.updateSubject(newSubject)
|
||||
dialog.dismiss()
|
||||
} else {
|
||||
val message = getString(R.string.conversation_invalid_empty_subject_toast)
|
||||
val icon = R.drawable.warning_circle
|
||||
(requireActivity() as GenericActivity).showRedToast(message, icon)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ class StartConversationFragment : GenericAddressPickerFragment() {
|
|||
|
||||
val dialog = DialogUtils.getSetOrEditGroupSubjectDialog(
|
||||
requireContext(),
|
||||
viewLifecycleOwner,
|
||||
model
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
package org.linphone.ui.main.fragment
|
||||
|
||||
import androidx.annotation.UiThread
|
||||
import androidx.lifecycle.MediatorLiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import org.linphone.utils.Event
|
||||
|
||||
|
|
@ -35,7 +36,12 @@ class GroupSetOrEditSubjectDialogModel @UiThread constructor(
|
|||
|
||||
val confirmEvent = MutableLiveData<Event<String>>()
|
||||
|
||||
val emptySubject = MediatorLiveData<Boolean>()
|
||||
|
||||
init {
|
||||
emptySubject.addSource(subject) { subject ->
|
||||
emptySubject.value = subject.isEmpty()
|
||||
}
|
||||
subject.value = initialSubject
|
||||
}
|
||||
|
||||
|
|
@ -46,6 +52,8 @@ class GroupSetOrEditSubjectDialogModel @UiThread constructor(
|
|||
|
||||
@UiThread
|
||||
fun confirm() {
|
||||
confirmEvent.value = Event(subject.value.orEmpty())
|
||||
val newSubject = subject.value.orEmpty()
|
||||
emptySubject.value = newSubject.isEmpty()
|
||||
confirmEvent.value = Event(newSubject)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ class StartCallFragment : GenericAddressPickerFragment() {
|
|||
|
||||
val dialog = DialogUtils.getSetOrEditGroupSubjectDialog(
|
||||
requireContext(),
|
||||
viewLifecycleOwner,
|
||||
model
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ class DialogUtils {
|
|||
@UiThread
|
||||
fun getSetOrEditGroupSubjectDialog(
|
||||
context: Context,
|
||||
lifecycleOwner: LifecycleOwner,
|
||||
viewModel: GroupSetOrEditSubjectDialogModel
|
||||
): Dialog {
|
||||
val binding: DialogSetOrEditGroupSubjectBindingImpl = DataBindingUtil.inflate(
|
||||
|
|
@ -266,6 +267,7 @@ class DialogUtils {
|
|||
null,
|
||||
false
|
||||
)
|
||||
binding.lifecycleOwner = lifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
// For some reason, binding.subject triggers an error on Android Studio...
|
||||
binding.root.findViewById<AppCompatEditText>(R.id.subject)?.requestFocus()
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
android:textSize="14sp"
|
||||
android:textColor="?attr/color_main2_600"
|
||||
android:maxLines="1"
|
||||
android:background="@drawable/edit_text_background"
|
||||
android:background="@{viewModel.emptySubject ? @drawable/shape_edit_text_error_background : @drawable/edit_text_background, default=@drawable/edit_text_background}"
|
||||
android:inputType="text|textCapSentences"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
|
|
@ -76,6 +76,19 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/title"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
style="@style/default_text_style_600"
|
||||
android:id="@+id/subject_error"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/conversation_dialog_subject_cant_be_empty_error"
|
||||
android:textSize="13sp"
|
||||
android:textColor="?attr/color_danger_500"
|
||||
android:visibility="@{viewModel.emptySubject ? View.VISIBLE : View.GONE, default=gone}"
|
||||
app:layout_constraintTop_toBottomOf="@id/subject"
|
||||
app:layout_constraintStart_toStartOf="@id/subject"
|
||||
app:layout_constraintEnd_toEndOf="@id/subject"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{() -> viewModel.dismiss()}"
|
||||
style="@style/secondary_button_label_style"
|
||||
|
|
@ -100,6 +113,7 @@
|
|||
android:layout_marginTop="16dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:enabled="@{!viewModel.emptySubject}"
|
||||
android:text="@string/conversation_dialog_edit_subject_confirm_button"
|
||||
app:layout_constraintStart_toStartOf="@id/dialog_background"
|
||||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
|
|
|
|||
|
|
@ -440,6 +440,7 @@
|
|||
<string name="conversation_maximum_number_of_attachments_reached">Nombre maximum de fichiers atteint !</string>
|
||||
<string name="conversation_dialog_set_subject">Nommer la conversation</string>
|
||||
<string name="conversation_dialog_edit_subject">Renommer la conversation</string>
|
||||
<string name="conversation_dialog_subject_cant_be_empty_error">Un nom est obligatoire</string>
|
||||
<string name="conversation_dialog_subject_hint">Nom de la conversation</string>
|
||||
<string name="conversation_dialog_edit_subject_confirm_button">Confirmer</string>
|
||||
<string name="conversation_dialog_open_or_export_file_title">Ouvrir ou sauvegarder le fichier ?</string>
|
||||
|
|
|
|||
|
|
@ -478,6 +478,7 @@
|
|||
<string name="conversation_maximum_number_of_attachments_reached">Maximum number of attachments reached!</string>
|
||||
<string name="conversation_dialog_set_subject">Set conversation subject</string>
|
||||
<string name="conversation_dialog_edit_subject">Edit conversation subject</string>
|
||||
<string name="conversation_dialog_subject_cant_be_empty_error">Subject is mandatory</string>
|
||||
<string name="conversation_dialog_subject_hint">Conversation subject</string>
|
||||
<string name="conversation_dialog_edit_subject_confirm_button">Confirm</string>
|
||||
<string name="conversation_dialog_open_or_export_file_title">Open or export file?</string>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue