mirror of
https://github.com/Aviortheking/Neo-Store.git
synced 2025-06-07 16:29:55 +00:00
Update: Extend AppInfo's view with screenshots section
This commit is contained in:
parent
6e404d3943
commit
ba0b070988
@ -23,18 +23,18 @@ import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.content.res.AppCompatResources
|
||||
import androidx.appcompat.widget.LinearLayoutCompat
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.core.net.toUri
|
||||
import androidx.core.text.HtmlCompat
|
||||
import androidx.core.text.util.LinkifyCompat
|
||||
import androidx.core.view.doOnPreDraw
|
||||
import androidx.core.widget.NestedScrollView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.load
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
import com.google.android.material.circularreveal.CircularRevealFrameLayout
|
||||
import com.google.android.material.divider.MaterialDivider
|
||||
import com.google.android.material.imageview.ShapeableImageView
|
||||
import com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
@ -131,7 +131,12 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
abstract val descriptor: String
|
||||
abstract val viewType: ViewType
|
||||
|
||||
class AppInfoItem(val repository: Repository, val product: Product) : Item() {
|
||||
class AppInfoItem(
|
||||
val repository: Repository,
|
||||
val product: Product,
|
||||
val packageName: String,
|
||||
val screenshots: List<Product.Screenshot>,
|
||||
) : Item() {
|
||||
override val descriptor: String
|
||||
get() = "app_info.${product.name}"
|
||||
|
||||
@ -313,6 +318,12 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
val statusLayout = itemView.findViewById<View>(R.id.status_layout)!!
|
||||
val status = itemView.findViewById<MaterialTextView>(R.id.status)!!
|
||||
val progress = itemView.findViewById<LinearProgressIndicator>(R.id.progress)!!
|
||||
val screenshotsSection =
|
||||
itemView.findViewById<LinearLayoutCompat>(R.id.screenshots_section)!!
|
||||
val screenshotsSectionIcon =
|
||||
itemView.findViewById<ShapeableImageView>(R.id.screenshots_section_icon)!!
|
||||
val screenshotsView = itemView.findViewById<NestedScrollView>(R.id.screenshots_view)!!
|
||||
val screenshotsRecycler = itemView.findViewById<RecyclerView>(R.id.screenshots_recycler)!!
|
||||
|
||||
val progressIcon: Drawable
|
||||
val defaultIcon: Drawable
|
||||
@ -606,7 +617,12 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
items.clear()
|
||||
|
||||
if (productRepository != null) {
|
||||
items += Item.AppInfoItem(productRepository.second, productRepository.first)
|
||||
items += Item.AppInfoItem(
|
||||
productRepository.second,
|
||||
productRepository.first,
|
||||
packageName,
|
||||
productRepository.first.screenshots
|
||||
)
|
||||
|
||||
if (installedItem != null) {
|
||||
items.add(
|
||||
@ -1128,6 +1144,25 @@ class ProductAdapter(private val callbacks: Callbacks, private val columns: Int)
|
||||
iconTint = if (action == Action.CANCEL) holder.actionTintOnCancel
|
||||
else holder.actionTintOnNormal
|
||||
}
|
||||
if (item.screenshots.isEmpty()) {
|
||||
holder.screenshotsSection.visibility = View.GONE
|
||||
holder.screenshotsView.visibility = View.GONE
|
||||
} else {
|
||||
holder.screenshotsSection.visibility = View.VISIBLE
|
||||
holder.screenshotsView.visibility = View.VISIBLE
|
||||
holder.screenshotsSection.setOnClickListener {
|
||||
val isExpanded = holder.screenshotsView.visibility == View.VISIBLE
|
||||
holder.screenshotsSectionIcon.scaleY = if (isExpanded) -1f else 1f
|
||||
holder.screenshotsView.visibility =
|
||||
if (isExpanded) View.GONE else View.VISIBLE
|
||||
}
|
||||
holder.screenshotsRecycler.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
holder.screenshotsRecycler.adapter =
|
||||
ScreenshotsAdapter { callbacks.onScreenshotClick(it) }.apply {
|
||||
setScreenshots(item.repository, item.packageName, item.screenshots)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updateAll || updateStatus) {
|
||||
val status = status
|
||||
|
@ -235,8 +235,54 @@
|
||||
android:layout_height="56dp"
|
||||
android:layout_marginHorizontal="12dp"
|
||||
app:iconGravity="textStart"
|
||||
app:layout_constraintBottom_toTopOf="@id/screenshots_section"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/status_layout"
|
||||
app:shapeAppearanceOverlay="@style/PillShapeAppearance" />
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/screenshots_section"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?android:attr/selectableItemBackground"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/action">
|
||||
|
||||
<com.google.android.material.textview.MaterialTextView
|
||||
android:id="@+id/title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:singleLine="true"
|
||||
android:text="@string/screenshots"
|
||||
android:textColor="?android:colorAccent" />
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/screenshots_section_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_arrow_down"
|
||||
android:tint="?android:colorAccent"
|
||||
tools:ignore="ContentDescription" />
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/screenshots_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/screenshots_section">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/screenshots_recycler"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal" />
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
Loading…
x
Reference in New Issue
Block a user