mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-05-07 05:53:07 +00:00
Improved update password dialog layout
This commit is contained in:
parent
4536f917f6
commit
93f1ef1aca
4 changed files with 34 additions and 1 deletions
|
|
@ -21,6 +21,7 @@ package org.linphone.ui.main
|
|||
|
||||
import android.Manifest
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
|
|
@ -85,6 +86,8 @@ class MainActivity : GenericActivity() {
|
|||
|
||||
private lateinit var sharedViewModel: SharedMainViewModel
|
||||
|
||||
private var currentlyDisplayedAuthDialog: Dialog? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// Must be done before the setContentView
|
||||
installSplashScreen()
|
||||
|
|
@ -217,6 +220,9 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
|
||||
override fun onPause() {
|
||||
currentlyDisplayedAuthDialog?.dismiss()
|
||||
currentlyDisplayedAuthDialog = null
|
||||
|
||||
val defaultFragmentId = when (sharedViewModel.currentlyDisplayedFragment.value) {
|
||||
R.id.contactsListFragment -> {
|
||||
CONTACTS_FRAGMENT_ID
|
||||
|
|
@ -625,6 +631,8 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
|
||||
private fun showAuthenticationRequestedDialog(identity: String) {
|
||||
currentlyDisplayedAuthDialog?.dismiss()
|
||||
|
||||
val model = AuthRequestedDialogModel(identity)
|
||||
val dialog = DialogUtils.getAuthRequestedDialog(this, model)
|
||||
|
||||
|
|
@ -642,5 +650,6 @@ class MainActivity : GenericActivity() {
|
|||
}
|
||||
|
||||
dialog.show()
|
||||
currentlyDisplayedAuthDialog = dialog
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,17 +30,25 @@ class AuthRequestedDialogModel @UiThread constructor(identity: String) {
|
|||
|
||||
val password = MutableLiveData<String>()
|
||||
|
||||
val showPassword = MutableLiveData<Boolean>()
|
||||
|
||||
val dismissEvent = MutableLiveData<Event<Boolean>>()
|
||||
|
||||
val confirmEvent = MutableLiveData<Event<String>>()
|
||||
|
||||
init {
|
||||
showPassword.value = false
|
||||
message.value = AppUtils.getFormattedString(
|
||||
R.string.dialog_account_invalid_password_message,
|
||||
identity
|
||||
)
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun toggleShowPassword() {
|
||||
showPassword.value = showPassword.value == false
|
||||
}
|
||||
|
||||
@UiThread
|
||||
fun dismiss() {
|
||||
dismissEvent.value = Event(true)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import android.view.WindowManager
|
|||
import androidx.annotation.UiThread
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.databinding.ViewDataBinding
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import org.linphone.R
|
||||
import org.linphone.databinding.DialogAccountModesExplanationBinding
|
||||
import org.linphone.databinding.DialogAssistantAcceptConditionsAndPolicyBinding
|
||||
|
|
@ -315,6 +316,7 @@ class DialogUtils {
|
|||
false
|
||||
)
|
||||
binding.viewModel = viewModel
|
||||
binding.lifecycleOwner = context as LifecycleOwner
|
||||
|
||||
return getDialog(context, binding)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
<data>
|
||||
<import type="android.view.View" />
|
||||
<import type="android.graphics.Typeface" />
|
||||
<import type="android.text.InputType" />
|
||||
<variable
|
||||
name="viewModel"
|
||||
type="org.linphone.ui.main.fragment.AuthRequestedDialogModel" />
|
||||
|
|
@ -76,7 +77,7 @@
|
|||
android:textColor="?attr/color_main2_600"
|
||||
android:maxLines="1"
|
||||
android:background="@drawable/edit_text_background"
|
||||
android:inputType="text|textCapSentences"
|
||||
android:inputType="@{viewModel.showPassword ? InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD : InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD, default=textPassword}"
|
||||
app:layout_constraintHorizontal_bias="0"
|
||||
app:layout_constraintWidth_max="@dimen/text_input_max_width"
|
||||
app:layout_constraintBottom_toTopOf="@id/cancel"
|
||||
|
|
@ -84,6 +85,19 @@
|
|||
app:layout_constraintEnd_toEndOf="@id/dialog_background"
|
||||
app:layout_constraintTop_toBottomOf="@id/message"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/eye"
|
||||
android:onClick="@{() -> viewModel.toggleShowPassword()}"
|
||||
android:layout_width="@dimen/icon_size"
|
||||
android:layout_height="0dp"
|
||||
android:padding="4dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:src="@{viewModel.showPassword ? @drawable/eye_slash : @drawable/eye, default=@drawable/eye}"
|
||||
app:tint="?attr/color_main2_500"
|
||||
app:layout_constraintEnd_toEndOf="@id/password"
|
||||
app:layout_constraintTop_toTopOf="@id/password"
|
||||
app:layout_constraintBottom_toBottomOf="@id/password" />
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:onClick="@{() -> viewModel.dismiss()}"
|
||||
style="@style/secondary_button_label_style"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue