mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-04-23 11:22:12 +00:00
Update: Rounded Icons
Update: Use ShapeableImageView
This commit is contained in:
parent
649055d7f1
commit
7a36d943c0
@ -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)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@
|
||||
android:textSize="16sp"
|
||||
tools:ignore="Autofill,HardcodedText" />
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/address_mirror"
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -16,13 +16,14 @@
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:background="@drawable/background_border" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar_extra"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginHorizontal="10dp" />
|
||||
|
||||
</LinearLayout>
|
||||
@ -33,7 +34,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:background="?android:attr/colorBackground"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingTop="10dp" />
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:layout_marginTop="10dp" />
|
||||
|
||||
</com.looker.droidify.widget.FragmentLinearLayout>
|
||||
|
@ -8,7 +8,7 @@
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
|
@ -8,7 +8,7 @@
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
|
@ -16,7 +16,7 @@
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="64dp"
|
||||
|
@ -9,7 +9,7 @@
|
||||
android:paddingStart="14dp"
|
||||
android:paddingEnd="16dp">
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="44dp"
|
||||
|
@ -2,6 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="54dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
@ -16,10 +17,11 @@
|
||||
android:textColor="?android:attr/textColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Switch
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/enabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:thumbTint="?android:attr/colorPrimary"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp" />
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
android:textColor="?android:attr/textColor"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -2,6 +2,7 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="48dp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
@ -16,10 +17,11 @@
|
||||
android:textColor="?android:attr/textColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<Switch
|
||||
<com.google.android.material.switchmaterial.SwitchMaterial
|
||||
android:id="@+id/enabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
app:thumbTint="?android:attr/colorPrimary"
|
||||
android:clickable="false"
|
||||
android:paddingStart="12dp"
|
||||
android:paddingEnd="12dp" />
|
||||
|
@ -40,7 +40,7 @@
|
||||
android:textColor="?android:attr/textColor"
|
||||
android:textSize="16sp" />
|
||||
|
||||
<ImageView
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/section_icon"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
|
Loading…
x
Reference in New Issue
Block a user