diff --git a/app/src/main/res/values/home_setup.xml b/app/src/main/res/values/home_setup.xml index c401b221a..275a93d10 100644 --- a/app/src/main/res/values/home_setup.xml +++ b/app/src/main/res/values/home_setup.xml @@ -33,17 +33,21 @@ IconShowcase An App + An App It is the old version of this awesome dashboard This is an app + This is market url ic_na_launcher ic_na_launcher + ic_na_launcher https://github.com/jahirfiquitiva/Blueprint https://play.google.com/store/apps/details?id=com.android.settings + market://details?id=com.example.package \ No newline at end of file diff --git a/library/src/main/kotlin/dev/jahir/blueprint/data/viewmodels/HomeViewModel.kt b/library/src/main/kotlin/dev/jahir/blueprint/data/viewmodels/HomeViewModel.kt index dfd6a45d7..13f0910ec 100644 --- a/library/src/main/kotlin/dev/jahir/blueprint/data/viewmodels/HomeViewModel.kt +++ b/library/src/main/kotlin/dev/jahir/blueprint/data/viewmodels/HomeViewModel.kt @@ -2,6 +2,7 @@ package dev.jahir.blueprint.data.viewmodels import android.app.Application import android.content.Intent +import android.net.Uri import androidx.lifecycle.AndroidViewModel import androidx.lifecycle.LifecycleOwner import androidx.lifecycle.MutableLiveData @@ -63,19 +64,21 @@ class HomeViewModel(application: Application) : AndroidViewModel(application) { titles.mapIndexed { i, s -> DefHomeItem(s, descriptions[i], icons[i], urls[i]) } .distinctBy { it.url } .map { - val isAnApp = - it.url.lower().startsWith(PLAY_STORE_LINK_PREFIX) || - it.url.lower().startsWith("market://details?id=") + val isMarketUrl = it.url.lower().startsWith("market://details?id=") + val isAnApp = isMarketUrl || it.url.lower().startsWith(PLAY_STORE_LINK_PREFIX) var isInstalled = false var intent: Intent? = null if (isAnApp) { + val packageName = it.url.substring(it.url.lastIndexOf("=") + 1) try { - val packageName = it.url.substring(it.url.lastIndexOf("=") + 1) isInstalled = context.isAppInstalled(packageName) intent = context.packageManager.getLaunchIntentForPackage(packageName) } catch (e: Exception) { } + if (intent == null && isMarketUrl) { + intent = Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=$packageName")) + } } val openIcon = if (isAnApp) if (isInstalled) R.drawable.ic_open_app else R.drawable.ic_download