mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-15 11:59:19 +00:00
Update: Rounded Icons
Update: Use ShapeableImageView
This commit is contained in:
@ -23,10 +23,15 @@ import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.text.util.LinkifyCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.content.ProductPreferences
|
||||
@ -304,7 +309,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
private enum class Payload { REFRESH, STATUS }
|
||||
|
||||
private class HeaderViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val icon = itemView.findViewById<ImageView>(R.id.icon)!!
|
||||
val icon = itemView.findViewById<ShapeableImageView>(R.id.icon)!!
|
||||
val name = itemView.findViewById<TextView>(R.id.name)!!
|
||||
val version = itemView.findViewById<TextView>(R.id.version)!!
|
||||
val packageName = itemView.findViewById<TextView>(R.id.package_name)!!
|
||||
@ -331,7 +336,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
|
||||
private class SwitchViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val title = itemView.findViewById<TextView>(R.id.title)!!
|
||||
val enabled = itemView.findViewById<Switch>(R.id.enabled)!!
|
||||
val enabled = itemView.findViewById<SwitchMaterial>(R.id.enabled)!!
|
||||
|
||||
val statefulViews: Sequence<View>
|
||||
get() = sequenceOf(itemView, title, enabled)
|
||||
@ -339,7 +344,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
|
||||
private class SectionViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val title = itemView.findViewById<TextView>(R.id.title)!!
|
||||
val icon = itemView.findViewById<ImageView>(R.id.icon)!!
|
||||
val icon = itemView.findViewById<ShapeableImageView>(R.id.icon)!!
|
||||
}
|
||||
|
||||
private class ExpandViewHolder(context: Context) : RecyclerView.ViewHolder(TextView(context)) {
|
||||
@ -352,7 +357,11 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
itemView.setTextSizeScaled(14)
|
||||
itemView.setTextColor(itemView.context.getColorFromAttr(android.R.attr.textColor))
|
||||
itemView.background =
|
||||
itemView.resources.getDrawable(R.drawable.background_border, context.theme)
|
||||
ResourcesCompat.getDrawable(
|
||||
itemView.resources,
|
||||
R.drawable.background_border,
|
||||
context.theme
|
||||
)
|
||||
itemView.gravity = Gravity.CENTER
|
||||
itemView.isAllCaps = true
|
||||
itemView.layoutParams = RecyclerView.LayoutParams(
|
||||
@ -400,7 +409,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
private val measurement = Measurement<Int>()
|
||||
}
|
||||
|
||||
val icon = itemView.findViewById<ImageView>(R.id.icon)!!
|
||||
val icon = itemView.findViewById<ShapeableImageView>(R.id.icon)!!
|
||||
val text = itemView.findViewById<TextView>(R.id.text)!!
|
||||
val link = itemView.findViewById<TextView>(R.id.link)!!
|
||||
|
||||
@ -424,7 +433,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
private val measurement = Measurement<Int>()
|
||||
}
|
||||
|
||||
val icon = itemView.findViewById<ImageView>(R.id.icon)!!
|
||||
val icon = itemView.findViewById<ShapeableImageView>(R.id.icon)!!
|
||||
val text = itemView.findViewById<TextView>(R.id.text)!!
|
||||
|
||||
init {
|
||||
@ -443,7 +452,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
|
||||
private class ScreenshotViewHolder(context: Context) :
|
||||
RecyclerView.ViewHolder(FrameLayout(context)) {
|
||||
val image: ImageView
|
||||
val image: AppCompatImageView
|
||||
|
||||
val placeholder: Drawable
|
||||
|
||||
@ -461,13 +470,12 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
val primaryColor =
|
||||
itemView.context.getColorFromAttr(android.R.attr.textColor).defaultColor
|
||||
|
||||
image = object : ImageView(context) {
|
||||
image = object : AppCompatImageView(context) {
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||
setMeasuredDimension(measuredWidth, measuredWidth)
|
||||
}
|
||||
}
|
||||
image.scaleType = ImageView.ScaleType.CENTER_CROP
|
||||
image.setBackgroundColor(ColorUtils.blendARGB(backgroundColor, accentColor, 0.1f))
|
||||
itemView.addView(
|
||||
image,
|
||||
@ -1124,6 +1132,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
item.product.icon, item.product.metadataIcon, item.repository
|
||||
)
|
||||
) {
|
||||
transformations(RoundedCornersTransformation(4.toPx))
|
||||
placeholder(holder.progressIcon)
|
||||
error(holder.defaultIcon)
|
||||
}
|
||||
@ -1328,6 +1337,7 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
item.screenshot
|
||||
)
|
||||
) {
|
||||
transformations(RoundedCornersTransformation(4.toPx))
|
||||
placeholder(holder.placeholder)
|
||||
error(holder.placeholder)
|
||||
size(cellSize)
|
||||
|
@ -8,10 +8,11 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.animation.AnimationUtils
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.transform.RoundedCornersTransformation
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.database.Database
|
||||
import com.looker.droidify.entity.ProductItem
|
||||
@ -32,7 +33,7 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) :
|
||||
val name = itemView.findViewById<TextView>(R.id.name)!!
|
||||
val status = itemView.findViewById<TextView>(R.id.status)!!
|
||||
val summary = itemView.findViewById<TextView>(R.id.summary)!!
|
||||
val icon = itemView.findViewById<ImageView>(R.id.icon)!!
|
||||
val icon = itemView.findViewById<ShapeableImageView>(R.id.icon)!!
|
||||
|
||||
val progressIcon: Drawable
|
||||
val defaultIcon: Drawable
|
||||
@ -151,6 +152,7 @@ class ProductsAdapter(private val onClick: (ProductItem) -> Unit) :
|
||||
productItem.icon, productItem.metadataIcon, repository
|
||||
)
|
||||
) {
|
||||
transformations(RoundedCornersTransformation(4.toPx))
|
||||
placeholder(holder.progressIcon)
|
||||
error(holder.defaultIcon)
|
||||
}
|
||||
|
@ -2,9 +2,9 @@ package com.looker.droidify.screen
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Switch
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.database.Database
|
||||
import com.looker.droidify.entity.Repository
|
||||
@ -20,7 +20,7 @@ class RepositoriesAdapter(
|
||||
|
||||
private class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
val name = itemView.findViewById<TextView>(R.id.name)!!
|
||||
val enabled = itemView.findViewById<Switch>(R.id.enabled)!!
|
||||
val enabled = itemView.findViewById<SwitchMaterial>(R.id.enabled)!!
|
||||
|
||||
var listenSwitch = true
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.looker.droidify.R
|
||||
import com.looker.droidify.content.Preferences
|
||||
import com.looker.droidify.database.Database
|
||||
@ -53,7 +54,7 @@ class TabsFragment : ScreenFragment() {
|
||||
val sectionLayout = view.findViewById<ViewGroup>(R.id.section_layout)!!
|
||||
val sectionChange = view.findViewById<View>(R.id.section_change)!!
|
||||
val sectionName = view.findViewById<TextView>(R.id.section_name)!!
|
||||
val sectionIcon = view.findViewById<ImageView>(R.id.section_icon)!!
|
||||
val sectionIcon = view.findViewById<ShapeableImageView>(R.id.section_icon)!!
|
||||
}
|
||||
|
||||
private var searchMenuItem: MenuItem? = null
|
||||
|
@ -29,6 +29,13 @@ object TypefaceExtra {
|
||||
val light = Typeface.create("sans-serif-light", Typeface.NORMAL)!!
|
||||
}
|
||||
|
||||
val Number.toPx
|
||||
get() = TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
this.toFloat(),
|
||||
Resources.getSystem().displayMetrics
|
||||
)
|
||||
|
||||
fun Context.getDrawableCompat(resId: Int): Drawable {
|
||||
val drawable = if (!Android.sdk(24)) {
|
||||
val fileName = TypedValue().apply { resources.getValue(resId, this, true) }.string
|
||||
@ -92,10 +99,6 @@ fun ViewGroup.inflate(layoutResId: Int): View {
|
||||
return LayoutInflater.from(context).inflate(layoutResId, this, false)
|
||||
}
|
||||
|
||||
fun ImageView.load(uri: String, builder: ImageRequest.Builder.() -> Unit = {}) {
|
||||
this.load(uri = uri, builder = builder)
|
||||
}
|
||||
|
||||
fun ImageView.load(uri: Uri, builder: ImageRequest.Builder.() -> Unit = {}) {
|
||||
this.load(uri = uri, builder = builder)
|
||||
}
|
||||
|
Reference in New Issue
Block a user