Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ class AppDetailAdapter(private val callbacks: Callbacks) :

private class InstallButtonViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val button = itemView.findViewById<MaterialButton>(R.id.action)!!
val incompatibleText = itemView.findViewById<TextView>(R.id.incompatible_text)!!

val actionTintNormal = button.context.getColorFromAttr(android.R.attr.colorPrimary)
val actionTintOnNormal = button.context.getColorFromAttr(MaterialR.attr.colorOnPrimary)
Expand Down Expand Up @@ -1120,6 +1121,15 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
field = value
}

var incompatibilityReason: CharSequence? = null
set(value) {
if (field != value) {
field = value
val index = items.indexOf(Item.InstallButtonItem)
if (index > 0) notifyItemChanged(index)
}
}

var status: Status = Status.Idle
set(value) {
if (field != value) {
Expand Down Expand Up @@ -1437,6 +1447,10 @@ class AppDetailAdapter(private val callbacks: Callbacks) :
ViewType.INSTALL_BUTTON -> {
holder as InstallButtonViewHolder
item as Item.InstallButtonItem

holder.incompatibleText.isVisible = incompatibilityReason != null
holder.incompatibleText.text = incompatibilityReason ?: ""

val action = action
holder.button.apply {
isEnabled = action != null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import com.looker.droidify.utility.common.extension.isSystemApplication
import com.looker.droidify.utility.common.extension.systemBarsPadding
import com.looker.droidify.utility.common.extension.updateAsMutable
import com.looker.droidify.utility.common.shareUrl
import com.looker.droidify.utility.extension.android.Android.name
import com.looker.droidify.utility.extension.android.Android.primaryPlatform
import com.looker.droidify.utility.extension.mainActivity
import com.looker.droidify.utility.extension.startUpdate
import com.stfalcon.imageviewer.StfalconImageViewer
Expand Down Expand Up @@ -249,6 +251,40 @@ class AppDetailFragment() : ScreenFragment(), AppDetailAdapter.Callbacks {
val canLaunch =
product != null && installed != null && installed.launcherActivities.isNotEmpty()

val incompatibilityReason = if (product != null) {
val selectedRelease = product.selectedReleases.firstOrNull()
val incompatibility = selectedRelease?.incompatibilities?.firstOrNull()
val installedItem = installed?.installedItem

when {
incompatibility != null -> {
when (incompatibility) {
is Release.Incompatibility.MinSdk,
is Release.Incompatibility.MaxSdk -> getString(
stringRes.incompatible_with_FORMAT,
name
)
is Release.Incompatibility.Platform -> getString(
stringRes.incompatible_with_FORMAT,
primaryPlatform ?: getString(stringRes.unknown)
)
is Release.Incompatibility.Feature -> getString(
stringRes.requires_FORMAT,
incompatibility.feature
)
}
}
installedItem != null && selectedRelease != null && installedItem.signature != selectedRelease.signature -> {
getString(stringRes.incompatible_signature_DESC)
}
else -> null
}
} else {
null
}

(recyclerView?.adapter as? AppDetailAdapter)?.incompatibilityReason = incompatibilityReason

val actions = buildSet {
if (canInstall) add(Action.INSTALL)
if (canUpdate) add(Action.UPDATE)
Expand Down
32 changes: 26 additions & 6 deletions app/src/main/res/layout/install_button.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/action"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginHorizontal="12dp"
app:iconGravity="textStart" />
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp">

<TextView
android:id="@+id/incompatible_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:text="@string/incompatible_version"
android:textColor="?attr/colorError"
android:textAppearance="?attr/textAppearanceBodyMedium"
android:visibility="gone" />

<com.google.android.material.button.MaterialButton xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/action"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginHorizontal="12dp"
app:iconGravity="textStart" />

</LinearLayout>