upgrade ktlint plugin to 12.0.3 (#4169)

There are some new rules, I think they mostly make sense, except for the
max line length which I had to disable because we are over it in a lot
of places.

---------

Co-authored-by: Goooler <wangzongler@gmail.com>
This commit is contained in:
Konrad Pozniak 2024-01-04 17:00:55 +01:00 committed by GitHub
commit 5192fb08a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
215 changed files with 2813 additions and 1177 deletions

View file

@ -254,7 +254,10 @@ class ClickableSpanTextView @JvmOverloads constructor(
activeEntry = entry
continue
}
Log.v(TAG, "Overlap: ${(entry.value as URLSpan).url} ${(activeEntry.value as URLSpan).url}")
Log.v(
TAG,
"Overlap: ${(entry.value as URLSpan).url} ${(activeEntry.value as URLSpan).url}"
)
if (isClickOnFirst(entry.key, activeEntry.key, x, y)) {
activeEntry = entry
}

View file

@ -37,7 +37,13 @@ class LicenseCard
init {
val binding = CardLicenseBinding.inflate(LayoutInflater.from(context), this)
setCardBackgroundColor(MaterialColors.getColor(context, com.google.android.material.R.attr.colorSurface, Color.BLACK))
setCardBackgroundColor(
MaterialColors.getColor(
context,
com.google.android.material.R.attr.colorSurface,
Color.BLACK
)
)
val (name, license, link) = context.theme.obtainStyledAttributes(
attrs,

View file

@ -96,11 +96,22 @@ open class MediaPreviewImageView
}
}
override fun onLoadFailed(e: GlideException?, model: Any?, target: Target<Drawable>, isFirstResource: Boolean): Boolean {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>,
isFirstResource: Boolean
): Boolean {
return false
}
override fun onResourceReady(resource: Drawable, model: Any, target: Target<Drawable>?, dataSource: DataSource, isFirstResource: Boolean): Boolean {
override fun onResourceReady(
resource: Drawable,
model: Any,
target: Target<Drawable>?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
recalculateMatrix(width, height, resource)
return false
}

View file

@ -45,7 +45,7 @@ class SliderPreference @JvmOverloads constructor(
* @see Slider.getValue
* @see Slider.setValue
*/
var value: Float = defaultValue
var value: Float = DEFAULT_VALUE
get() = _value
set(v) {
val clamped = max(max(v, valueFrom), min(v, valueTo))
@ -68,7 +68,7 @@ class SliderPreference @JvmOverloads constructor(
* Format string to be applied to values before setting the summary. For more control set
* [SliderPreference.formatter]
*/
var format: String = defaultFormat
var format: String = DEFAULT_FORMAT
/**
* Function that will be used to format the summary. The default formatter formats using the
@ -96,13 +96,18 @@ class SliderPreference @JvmOverloads constructor(
// preference layout to the right of the title and summary.
layoutResource = R.layout.pref_slider
val a = context.obtainStyledAttributes(attrs, R.styleable.SliderPreference, defStyleAttr, defStyleRes)
val a = context.obtainStyledAttributes(
attrs,
R.styleable.SliderPreference,
defStyleAttr,
defStyleRes
)
value = a.getFloat(R.styleable.SliderPreference_android_value, defaultValue)
valueFrom = a.getFloat(R.styleable.SliderPreference_android_valueFrom, defaultValueFrom)
valueTo = a.getFloat(R.styleable.SliderPreference_android_valueTo, defaultValueTo)
stepSize = a.getFloat(R.styleable.SliderPreference_android_stepSize, defaultStepSize)
format = a.getString(R.styleable.SliderPreference_format) ?: defaultFormat
value = a.getFloat(R.styleable.SliderPreference_android_value, DEFAULT_VALUE)
valueFrom = a.getFloat(R.styleable.SliderPreference_android_valueFrom, DEFAULT_VALUE_FROM)
valueTo = a.getFloat(R.styleable.SliderPreference_android_valueTo, DEFAULT_VALUE_TO)
stepSize = a.getFloat(R.styleable.SliderPreference_android_stepSize, DEFAULT_STEP_SIZE)
format = a.getString(R.styleable.SliderPreference_format) ?: DEFAULT_FORMAT
val decrementIconResource = a.getResourceId(R.styleable.SliderPreference_iconStart, -1)
if (decrementIconResource != -1) {
@ -118,11 +123,11 @@ class SliderPreference @JvmOverloads constructor(
}
override fun onGetDefaultValue(a: TypedArray, i: Int): Any {
return a.getFloat(i, defaultValue)
return a.getFloat(i, DEFAULT_VALUE)
}
override fun onSetInitialValue(defaultValue: Any?) {
value = getPersistedFloat((defaultValue ?: Companion.defaultValue) as Float)
value = getPersistedFloat((defaultValue ?: DEFAULT_VALUE) as Float)
}
override fun onBindViewHolder(holder: PreferenceViewHolder) {
@ -179,10 +184,10 @@ class SliderPreference @JvmOverloads constructor(
companion object {
private const val TAG = "SliderPreference"
private const val defaultValueFrom = 0F
private const val defaultValueTo = 1F
private const val defaultValue = 0.5F
private const val defaultStepSize = 0.1F
private const val defaultFormat = "%3.1f"
private const val DEFAULT_VALUE_FROM = 0F
private const val DEFAULT_VALUE_TO = 1F
private const val DEFAULT_VALUE = 0.5F
private const val DEFAULT_STEP_SIZE = 0.1F
private const val DEFAULT_FORMAT = "%3.1f"
}
}