AppDetailsFragment: Also show Unarchive as primary action
Show action text as "Unarchive" if the package was archived instead of "Install" Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -40,6 +40,7 @@ import com.aurora.extensions.isHuawei
|
||||
import com.aurora.extensions.isOAndAbove
|
||||
import com.aurora.extensions.isPAndAbove
|
||||
import com.aurora.extensions.isTAndAbove
|
||||
import com.aurora.extensions.isVAndAbove
|
||||
import com.aurora.extensions.isValidApp
|
||||
import com.aurora.store.BuildConfig
|
||||
import com.aurora.store.R
|
||||
@@ -95,6 +96,14 @@ object PackageUtil {
|
||||
}
|
||||
}
|
||||
|
||||
fun isArchived(context: Context, packageName: String): Boolean {
|
||||
return try {
|
||||
isVAndAbove && context.packageManager.getArchivedPackage(packageName) != null
|
||||
} catch (e: PackageManager.NameNotFoundException) {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
fun isSharedLibrary(context: Context, packageName: String): Boolean {
|
||||
return if (isOAndAbove) {
|
||||
getAllSharedLibraries(context).any { it.name == packageName }
|
||||
|
||||
@@ -624,10 +624,16 @@ class AppDetailsFragment : BaseFragment<FragmentDetailsBinding>() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (app.isFree) {
|
||||
binding.layoutDetailsApp.btnPrimaryAction.setText(R.string.action_install)
|
||||
if (PackageUtil.isArchived(requireContext(), app.packageName)) {
|
||||
binding.layoutDetailsApp.btnPrimaryAction.text =
|
||||
getString(R.string.action_unarchive)
|
||||
} else {
|
||||
binding.layoutDetailsApp.btnPrimaryAction.text = app.price
|
||||
if (app.isFree) {
|
||||
binding.layoutDetailsApp.btnPrimaryAction.text =
|
||||
getString(R.string.action_install)
|
||||
} else {
|
||||
binding.layoutDetailsApp.btnPrimaryAction.text = app.price
|
||||
}
|
||||
}
|
||||
|
||||
binding.layoutDetailsApp.btnPrimaryAction.setOnClickListener {
|
||||
|
||||
Reference in New Issue
Block a user