From ce1ab6d964c92d53ebc46bf90a941bdd0d748d29 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 7 Mar 2020 22:19:45 -0500 Subject: [PATCH] Label Kitsu login field as email address instead of username --- .../ui/setting/SettingsTrackingController.kt | 2 +- .../widget/preference/LoginDialogPreference.kt | 12 ++++++++++-- .../tachiyomi/widget/preference/TrackLoginDialog.kt | 13 +++++++------ app/src/main/res/layout/pref_account_login.xml | 1 + app/src/main/res/values/strings.xml | 1 + 5 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt index e213d685ea..0f94f90453 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsTrackingController.kt @@ -50,7 +50,7 @@ class SettingsTrackingController : SettingsController(), } trackPreference(trackManager.kitsu) { onClick { - val dialog = TrackLoginDialog(trackManager.kitsu) + val dialog = TrackLoginDialog(trackManager.kitsu, context.getString(R.string.email)) dialog.targetController = this@SettingsTrackingController dialog.showDialog(router) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt index 24b14eae0b..296a7a5c12 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/LoginDialogPreference.kt @@ -13,11 +13,15 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.widget.SimpleTextWatcher -import kotlinx.android.synthetic.main.pref_account_login.view.* +import kotlinx.android.synthetic.main.pref_account_login.view.login +import kotlinx.android.synthetic.main.pref_account_login.view.password +import kotlinx.android.synthetic.main.pref_account_login.view.show_password +import kotlinx.android.synthetic.main.pref_account_login.view.username_label import rx.Subscription import uy.kohesive.injekt.injectLazy -abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(bundle) { +abstract class LoginDialogPreference(private val usernameLabel: String? = null, bundle: Bundle? = null) : + DialogController(bundle) { var v: View? = null private set @@ -53,6 +57,10 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController( password.transformationMethod = PasswordTransformationMethod() } + if (!usernameLabel.isNullOrEmpty()) { + username_label.text = usernameLabel + } + login.setMode(ActionProcessButton.Mode.ENDLESS) login.setOnClickListener { checkLogin() } diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt index baf6806eaf..0ba66ba40a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/TrackLoginDialog.kt @@ -6,22 +6,23 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.util.system.toast -import kotlinx.android.synthetic.main.pref_account_login.view.dialog_title -import kotlinx.android.synthetic.main.pref_account_login.view.login -import kotlinx.android.synthetic.main.pref_account_login.view.password -import kotlinx.android.synthetic.main.pref_account_login.view.username +import kotlinx.android.synthetic.main.pref_account_login.view.* import rx.android.schedulers.AndroidSchedulers import rx.schedulers.Schedulers import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.api.get -class TrackLoginDialog(bundle: Bundle? = null) : LoginDialogPreference(bundle) { +class TrackLoginDialog(usernameLabel: String? = null, bundle: Bundle? = null) : + LoginDialogPreference(usernameLabel, bundle) { private val service = Injekt.get().getService(args.getInt("key"))!! override var canLogout = true - constructor(service: TrackService) : this(Bundle().apply { putInt("key", service.id) }) + constructor(service: TrackService) : this(service, null) + + constructor(service: TrackService, usernameLabel: String?) : + this(usernameLabel, Bundle().apply { putInt("key", service.id) }) override fun setCredentialsOnView(view: View) = with(view) { dialog_title.text = context.getString(R.string.login_title, service.name) diff --git a/app/src/main/res/layout/pref_account_login.xml b/app/src/main/res/layout/pref_account_login.xml index 2065aec0d4..b489a2f364 100644 --- a/app/src/main/res/layout/pref_account_login.xml +++ b/app/src/main/res/layout/pref_account_login.xml @@ -22,6 +22,7 @@ android:background="@color/divider"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de516fde15..663270d442 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -417,6 +417,7 @@ Login for %1$s Username + Email address Password Show password Login