Linting fixes
This commit is contained in:
@@ -5,7 +5,7 @@ import android.util.AttributeSet
|
||||
import androidx.preference.ListPreference
|
||||
|
||||
class IntListPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
ListPreference(context, attrs) {
|
||||
ListPreference(context, attrs) {
|
||||
|
||||
override fun persistString(value: String?): Boolean {
|
||||
return value != null && persistInt(value.toInt())
|
||||
|
||||
@@ -36,8 +36,8 @@ abstract class LoginDialogPreference(
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
var dialog = MaterialDialog(activity!!)
|
||||
.customView(R.layout.pref_account_login)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.customView(R.layout.pref_account_login)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
|
||||
if (titleRes != null) {
|
||||
dialog = dialog.title(text = activity!!.getString(titleRes, titleFormatArgs))
|
||||
@@ -51,10 +51,11 @@ abstract class LoginDialogPreference(
|
||||
fun onViewCreated(view: View) {
|
||||
v = view.apply {
|
||||
show_password.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked)
|
||||
if (isChecked) {
|
||||
password.transformationMethod = null
|
||||
else
|
||||
} else {
|
||||
password.transformationMethod = PasswordTransformationMethod()
|
||||
}
|
||||
}
|
||||
|
||||
if (usernameLabelRes != null) {
|
||||
|
||||
@@ -8,7 +8,7 @@ import eu.kanade.tachiyomi.R
|
||||
import kotlinx.android.synthetic.main.pref_widget_imageview.view.image_view
|
||||
|
||||
class LoginPreference @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
Preference(context, attrs) {
|
||||
Preference(context, attrs) {
|
||||
|
||||
init {
|
||||
widgetLayoutResource = R.layout.pref_widget_imageview
|
||||
@@ -17,10 +17,13 @@ class LoginPreference @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
||||
super.onBindViewHolder(holder)
|
||||
|
||||
holder.itemView.image_view.setImageResource(if (getPersistedString("").isNullOrEmpty())
|
||||
android.R.color.transparent
|
||||
else
|
||||
R.drawable.ic_done_green_24dp)
|
||||
holder.itemView.image_view.setImageResource(
|
||||
if (getPersistedString("").isNullOrEmpty()) {
|
||||
android.R.color.transparent
|
||||
} else {
|
||||
R.drawable.ic_done_green_24dp
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
public override fun notifyChanged() {
|
||||
|
||||
+10
-6
@@ -20,8 +20,9 @@ class SwitchPreferenceCategory @JvmOverloads constructor(
|
||||
PreferenceCategory(
|
||||
context,
|
||||
attrs,
|
||||
R.attr.switchPreferenceCompatStyle),
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
R.attr.switchPreferenceCompatStyle
|
||||
),
|
||||
CompoundButton.OnCheckedChangeListener {
|
||||
|
||||
private var mChecked = false
|
||||
|
||||
@@ -114,9 +115,12 @@ class SwitchPreferenceCategory @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onSetInitialValue(restoreValue: Boolean, defaultValue: Any?) {
|
||||
setChecked(if (restoreValue)
|
||||
getPersistedBoolean(mChecked)
|
||||
else
|
||||
defaultValue as Boolean)
|
||||
setChecked(
|
||||
if (restoreValue) {
|
||||
getPersistedBoolean(mChecked)
|
||||
} else {
|
||||
defaultValue as Boolean
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ class TrackLoginDialog(
|
||||
constructor(service: TrackService) : this(service, null)
|
||||
|
||||
constructor(service: TrackService, @StringRes usernameLabelRes: Int?) :
|
||||
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
|
||||
this(R.string.login_title, service.name, usernameLabelRes, Bundle().apply { putInt("key", service.id) })
|
||||
|
||||
override fun setCredentialsOnView(view: View) = with(view) {
|
||||
username.setText(service.getUsername())
|
||||
@@ -38,24 +38,28 @@ class TrackLoginDialog(
|
||||
requestSubscription?.unsubscribe()
|
||||
|
||||
v?.apply {
|
||||
if (username.text.isNullOrEmpty() || password.text.isNullOrEmpty())
|
||||
if (username.text.isNullOrEmpty() || password.text.isNullOrEmpty()) {
|
||||
return
|
||||
}
|
||||
|
||||
login.progress = 1
|
||||
val user = username.text.toString()
|
||||
val pass = password.text.toString()
|
||||
|
||||
requestSubscription = service.login(user, pass)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
dialog?.dismiss()
|
||||
context.toast(R.string.login_success)
|
||||
}, { error ->
|
||||
},
|
||||
{ error ->
|
||||
login.progress = -1
|
||||
login.setText(R.string.unknown_error)
|
||||
error.message?.let { context.toast(it) }
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,13 +19,13 @@ class TrackLogoutDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
||||
|
||||
override fun onCreateDialog(savedViewState: Bundle?): Dialog {
|
||||
return MaterialDialog(activity!!)
|
||||
.title(R.string.logout_title, service.name)
|
||||
.positiveButton(R.string.logout) {
|
||||
service.logout()
|
||||
(targetController as? Listener)?.trackLogoutDialogClosed(service)
|
||||
activity?.toast(R.string.logout_success)
|
||||
}
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.title(R.string.logout_title, service.name)
|
||||
.positiveButton(R.string.logout) {
|
||||
service.logout()
|
||||
(targetController as? Listener)?.trackLogoutDialogClosed(service)
|
||||
activity?.toast(R.string.logout_success)
|
||||
}
|
||||
.negativeButton(android.R.string.cancel)
|
||||
}
|
||||
|
||||
interface Listener {
|
||||
|
||||
Reference in New Issue
Block a user