2020-07-26 09:59:27 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2020, microG Project Team
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.microg.gms.ui
|
|
|
|
|
|
|
|
import android.content.Context
|
2022-01-26 05:26:56 +00:00
|
|
|
import android.util.AttributeSet
|
2020-07-26 09:59:27 +00:00
|
|
|
import android.util.DisplayMetrics
|
|
|
|
import android.widget.ImageView
|
|
|
|
import androidx.preference.Preference
|
|
|
|
import androidx.preference.PreferenceViewHolder
|
|
|
|
|
2022-01-26 05:26:56 +00:00
|
|
|
class AppIconPreference : Preference {
|
2022-01-31 12:49:59 +00:00
|
|
|
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) : super(
|
|
|
|
context!!, attrs, defStyleAttr, defStyleRes)
|
|
|
|
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context!!, attrs, defStyleAttr)
|
|
|
|
constructor(context: Context?, attrs: AttributeSet?) : super(context!!, attrs)
|
2022-01-26 05:26:56 +00:00
|
|
|
constructor(context: Context) : super(context)
|
|
|
|
|
|
|
|
override fun onBindViewHolder(holder: PreferenceViewHolder) {
|
2020-07-26 09:59:27 +00:00
|
|
|
super.onBindViewHolder(holder)
|
2022-01-26 05:26:56 +00:00
|
|
|
val icon = holder.findViewById(android.R.id.icon)
|
2020-07-26 09:59:27 +00:00
|
|
|
if (icon is ImageView) {
|
|
|
|
icon.adjustViewBounds = true
|
|
|
|
icon.scaleType = ImageView.ScaleType.CENTER_INSIDE
|
|
|
|
icon.maxHeight = (32.0 * context.resources.displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT).toInt()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|