Added Proper logout button to tracker login dialog

This commit is contained in:
Jay 2020-04-11 01:04:11 -04:00
parent f4ce43787c
commit 34692cdc93
2 changed files with 17 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import com.dd.processbutton.iml.ActionProcessButton
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import eu.kanade.tachiyomi.util.view.visible
import eu.kanade.tachiyomi.widget.SimpleTextWatcher import eu.kanade.tachiyomi.widget.SimpleTextWatcher
import kotlinx.android.synthetic.main.pref_account_login.view.* import kotlinx.android.synthetic.main.pref_account_login.view.*
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
@ -42,9 +43,6 @@ abstract class LoginDialogPreference(
val dialog = MaterialDialog(activity!!).apply { val dialog = MaterialDialog(activity!!).apply {
customView(R.layout.pref_account_login, scrollable = false) customView(R.layout.pref_account_login, scrollable = false)
positiveButton(android.R.string.cancel) positiveButton(android.R.string.cancel)
if (canLogout) {
negativeButton(R.string.logout) { logout() }
}
} }
onViewCreated(dialog.view) onViewCreated(dialog.view)
@ -72,6 +70,11 @@ abstract class LoginDialogPreference(
setCredentialsOnView(this) setCredentialsOnView(this)
if (canLogout && !username.text.isNullOrEmpty()) {
logout.visible()
logout.setOnClickListener { logout() }
}
show_password.isEnabled = password.text.isNullOrEmpty() show_password.isEnabled = password.text.isNullOrEmpty()
password.addTextChangedListener(object : SimpleTextWatcher() { password.addTextChangedListener(object : SimpleTextWatcher() {

View File

@ -63,4 +63,15 @@
app:pb_textError="@string/could_not_log_in" app:pb_textError="@string/could_not_log_in"
app:pb_textProgress="@string/loading"/> app:pb_textProgress="@string/loading"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/logout"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:background="@color/md_grey_800"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/logout"
android:textColor="?colorAccent"/>
</LinearLayout> </LinearLayout>