Add ability to download/install from intent
This commit is contained in:
@@ -81,6 +81,8 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
private var isNone = false
|
private var isNone = false
|
||||||
private var status = Status.NONE
|
private var status = Status.NONE
|
||||||
private var isInstalled: Boolean = false
|
private var isInstalled: Boolean = false
|
||||||
|
private var autoDownload: Boolean = false
|
||||||
|
private var downloadOnly: Boolean = false
|
||||||
|
|
||||||
override fun onConnected() {
|
override fun onConnected() {
|
||||||
|
|
||||||
@@ -97,6 +99,9 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
EventBus.getDefault().register(this)
|
EventBus.getDefault().register(this)
|
||||||
|
if (autoDownload) {
|
||||||
|
purchase()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStop() {
|
override fun onStop() {
|
||||||
@@ -169,13 +174,20 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
|
|
||||||
if (intent.scheme != null && (intent.scheme == "market" || intent.scheme == "http" || intent.scheme == "https")) {
|
if (intent.scheme != null && (intent.scheme == "market" || intent.scheme == "http" || intent.scheme == "https")) {
|
||||||
val packageName = intent.data!!.getQueryParameter("id")
|
val packageName = intent.data!!.getQueryParameter("id")
|
||||||
|
val packageVersion = intent.data!!.getQueryParameter("v")
|
||||||
if (packageName.isNullOrEmpty()) {
|
if (packageName.isNullOrEmpty()) {
|
||||||
close()
|
close()
|
||||||
} else {
|
} else {
|
||||||
isExternal = true
|
isExternal = true
|
||||||
app = App(packageName)
|
app = App(packageName)
|
||||||
|
if (!packageVersion.isNullOrEmpty()) {
|
||||||
|
app.versionCode = packageVersion.toInt()
|
||||||
|
}
|
||||||
fetchCompleteApp()
|
fetchCompleteApp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
autoDownload = intent.data!!.getBooleanQueryParameter("download", false)
|
||||||
|
downloadOnly = !intent.data!!.getBooleanQueryParameter("install", false)
|
||||||
} else {
|
} else {
|
||||||
val rawApp: String? = intent.getStringExtra(Constants.STRING_EXTRA)
|
val rawApp: String? = intent.getStringExtra(Constants.STRING_EXTRA)
|
||||||
if (rawApp != null) {
|
if (rawApp != null) {
|
||||||
@@ -263,6 +275,9 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun verifyAndInstall(files: List<Download>) {
|
private fun verifyAndInstall(files: List<Download>) {
|
||||||
|
if (downloadOnly)
|
||||||
|
return
|
||||||
|
|
||||||
var filesExist = true
|
var filesExist = true
|
||||||
|
|
||||||
files.forEach { download ->
|
files.forEach { download ->
|
||||||
@@ -340,6 +355,10 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
attachBottomSheet()
|
attachBottomSheet()
|
||||||
attachFetch()
|
attachFetch()
|
||||||
attachActions()
|
attachActions()
|
||||||
|
|
||||||
|
if (autoDownload) {
|
||||||
|
purchase()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user