Label Kitsu login field as email address instead of username

This commit is contained in:
arkon 2020-03-07 22:19:45 -05:00 committed by Jay
parent 0d37dd9a95
commit ce1ab6d964
5 changed files with 20 additions and 9 deletions

View File

@ -50,7 +50,7 @@ class SettingsTrackingController : SettingsController(),
} }
trackPreference(trackManager.kitsu) { trackPreference(trackManager.kitsu) {
onClick { onClick {
val dialog = TrackLoginDialog(trackManager.kitsu) val dialog = TrackLoginDialog(trackManager.kitsu, context.getString(R.string.email))
dialog.targetController = this@SettingsTrackingController dialog.targetController = this@SettingsTrackingController
dialog.showDialog(router) dialog.showDialog(router)
} }

View File

@ -13,11 +13,15 @@ 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.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.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 rx.Subscription
import uy.kohesive.injekt.injectLazy 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 var v: View? = null
private set private set
@ -53,6 +57,10 @@ abstract class LoginDialogPreference(bundle: Bundle? = null) : DialogController(
password.transformationMethod = PasswordTransformationMethod() password.transformationMethod = PasswordTransformationMethod()
} }
if (!usernameLabel.isNullOrEmpty()) {
username_label.text = usernameLabel
}
login.setMode(ActionProcessButton.Mode.ENDLESS) login.setMode(ActionProcessButton.Mode.ENDLESS)
login.setOnClickListener { checkLogin() } login.setOnClickListener { checkLogin() }

View File

@ -6,22 +6,23 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.track.TrackManager import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.data.track.TrackService import eu.kanade.tachiyomi.data.track.TrackService
import eu.kanade.tachiyomi.util.system.toast 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.*
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 rx.android.schedulers.AndroidSchedulers import rx.android.schedulers.AndroidSchedulers
import rx.schedulers.Schedulers import rx.schedulers.Schedulers
import uy.kohesive.injekt.Injekt import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get 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<TrackManager>().getService(args.getInt("key"))!! private val service = Injekt.get<TrackManager>().getService(args.getInt("key"))!!
override var canLogout = true 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) { override fun setCredentialsOnView(view: View) = with(view) {
dialog_title.text = context.getString(R.string.login_title, service.name) dialog_title.text = context.getString(R.string.login_title, service.name)

View File

@ -22,6 +22,7 @@
android:background="@color/divider"/> android:background="@color/divider"/>
<TextView <TextView
android:id="@+id/username_label"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/username"/> android:text="@string/username"/>

View File

@ -417,6 +417,7 @@
<!-- Login dialog --> <!-- Login dialog -->
<string name="login_title">Login for %1$s</string> <string name="login_title">Login for %1$s</string>
<string name="username">Username</string> <string name="username">Username</string>
<string name="email">Email address</string>
<string name="password">Password</string> <string name="password">Password</string>
<string name="show_password">Show password</string> <string name="show_password">Show password</string>
<string name="login">Login</string> <string name="login">Login</string>