Add back manual downloader from v3
This commit is contained in:
@@ -40,6 +40,11 @@ sealed class BusEvent {
|
|||||||
var email: String = String(),
|
var email: String = String(),
|
||||||
var aasToken: String = String()
|
var aasToken: String = String()
|
||||||
) : BusEvent()
|
) : BusEvent()
|
||||||
|
|
||||||
|
data class ManualDownload(
|
||||||
|
var packageName: String,
|
||||||
|
var versionCode: Int
|
||||||
|
) : BusEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class InstallerEvent {
|
sealed class InstallerEvent {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ object PackageUtil {
|
|||||||
return try {
|
return try {
|
||||||
val packageInfo = getPackageInfo(context, packageName)
|
val packageInfo = getPackageInfo(context, packageName)
|
||||||
if (packageInfo != null) {
|
if (packageInfo != null) {
|
||||||
"${packageInfo.versionName}.${packageInfo.versionCode}"
|
"${packageInfo.versionName} (${packageInfo.versionCode})"
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ import com.aurora.store.databinding.ActivityDetailsBinding
|
|||||||
import com.aurora.store.util.*
|
import com.aurora.store.util.*
|
||||||
import com.aurora.store.view.ui.downloads.DownloadActivity
|
import com.aurora.store.view.ui.downloads.DownloadActivity
|
||||||
import com.aurora.store.view.ui.sheets.InstallErrorDialogSheet
|
import com.aurora.store.view.ui.sheets.InstallErrorDialogSheet
|
||||||
|
import com.aurora.store.view.ui.sheets.ManualDownloadSheet
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||||
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback
|
||||||
@@ -116,6 +117,12 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
attachActions()
|
attachActions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
is BusEvent.ManualDownload -> {
|
||||||
|
if (app.packageName == event.packageName) {
|
||||||
|
app.versionCode = event.versionCode
|
||||||
|
purchase()
|
||||||
|
}
|
||||||
|
}
|
||||||
is InstallerEvent.Failed -> {
|
is InstallerEvent.Failed -> {
|
||||||
if (app.packageName == event.packageName) {
|
if (app.packageName == event.packageName) {
|
||||||
InstallErrorDialogSheet.newInstance(
|
InstallErrorDialogSheet.newInstance(
|
||||||
@@ -206,6 +213,12 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
uninstallApp()
|
uninstallApp()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
R.id.menu_download_manual -> {
|
||||||
|
val sheet = ManualDownloadSheet.newInstance(app)
|
||||||
|
sheet.isCancelable = false
|
||||||
|
sheet.show(supportFragmentManager, ManualDownloadSheet.TAG)
|
||||||
|
return true
|
||||||
|
}
|
||||||
R.id.menu_download_manager -> {
|
R.id.menu_download_manager -> {
|
||||||
open(DownloadActivity::class.java)
|
open(DownloadActivity::class.java)
|
||||||
return true
|
return true
|
||||||
@@ -327,7 +340,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
app
|
app
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
txtLine3.text = ("v${app.versionName}.${app.versionCode}")
|
txtLine3.text = ("${app.versionName} (${app.versionCode})")
|
||||||
|
|
||||||
val tags = mutableListOf<String>()
|
val tags = mutableListOf<String>()
|
||||||
if (app.isFree)
|
if (app.isFree)
|
||||||
@@ -546,7 +559,7 @@ class AppDetailsActivity : BaseDetailsActivity() {
|
|||||||
|
|
||||||
if (isUpdatable) {
|
if (isUpdatable) {
|
||||||
B.layoutDetailsApp.txtLine3.text =
|
B.layoutDetailsApp.txtLine3.text =
|
||||||
("$installedVersion > ${app.versionName}.${app.versionCode}")
|
("$installedVersion > ${app.versionName} (${app.versionCode})")
|
||||||
btn.setText(R.string.action_update)
|
btn.setText(R.string.action_update)
|
||||||
btn.addOnClickListener { startDownload() }
|
btn.addOnClickListener { startDownload() }
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -0,0 +1,132 @@
|
|||||||
|
/*
|
||||||
|
* Aurora Store
|
||||||
|
* Copyright (C) 2019, Rahul Kumar Patel <whyorean@gmail.com>
|
||||||
|
*
|
||||||
|
* Aurora Store is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Aurora Store is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.aurora.store.view.ui.sheets
|
||||||
|
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.aurora.Constants
|
||||||
|
import com.aurora.extensions.load
|
||||||
|
import com.aurora.extensions.toast
|
||||||
|
import com.aurora.gplayapi.data.models.App
|
||||||
|
import com.aurora.gplayapi.data.models.AuthData
|
||||||
|
import com.aurora.gplayapi.helpers.PurchaseHelper
|
||||||
|
import com.aurora.store.R
|
||||||
|
import com.aurora.store.data.event.BusEvent
|
||||||
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
|
import com.aurora.store.databinding.SheetManualDownloadBinding
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
|
import nl.komponents.kovenant.task
|
||||||
|
import nl.komponents.kovenant.ui.failUi
|
||||||
|
import nl.komponents.kovenant.ui.successUi
|
||||||
|
import org.greenrobot.eventbus.EventBus
|
||||||
|
|
||||||
|
class ManualDownloadSheet : BaseBottomSheet() {
|
||||||
|
|
||||||
|
private lateinit var B: SheetManualDownloadBinding
|
||||||
|
private lateinit var app: App
|
||||||
|
private lateinit var authData: AuthData
|
||||||
|
private lateinit var purchaseHelper: PurchaseHelper
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
const val TAG = "ManualDownloadSheet"
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun newInstance(
|
||||||
|
app: App
|
||||||
|
): ManualDownloadSheet {
|
||||||
|
return ManualDownloadSheet().apply {
|
||||||
|
arguments = Bundle().apply {
|
||||||
|
putString(Constants.STRING_APP, gson.toJson(app))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateContentView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
B = SheetManualDownloadBinding.inflate(inflater)
|
||||||
|
authData = AuthProvider.with(requireContext()).getAuthData()
|
||||||
|
purchaseHelper = PurchaseHelper(authData)
|
||||||
|
return B.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onContentViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val bundle = arguments
|
||||||
|
bundle?.let {
|
||||||
|
val rawApp = bundle.getString(Constants.STRING_APP, "{}")
|
||||||
|
app = gson.fromJson(rawApp, App::class.java)
|
||||||
|
if (app.packageName.isNotEmpty()) {
|
||||||
|
inflateData()
|
||||||
|
attachActions()
|
||||||
|
} else {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun inflateData() {
|
||||||
|
B.imgIcon.load(app.iconArtwork.url) {
|
||||||
|
placeholder(R.drawable.bg_placeholder)
|
||||||
|
transform(RoundedCorners(32))
|
||||||
|
}
|
||||||
|
|
||||||
|
B.txtLine1.text = app.displayName
|
||||||
|
B.txtLine2.text = app.packageName
|
||||||
|
B.txtLine3.text = ("${app.versionName} (${app.versionCode})")
|
||||||
|
|
||||||
|
B.versionCodeLayout.hint = "${app.versionCode}"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun attachActions() {
|
||||||
|
B.btnPrimary.setOnClickListener {
|
||||||
|
val customVersionString = (B.versionCodeInp.text).toString()
|
||||||
|
if (customVersionString.isEmpty())
|
||||||
|
B.versionCodeInp.error = "Enter version code"
|
||||||
|
else {
|
||||||
|
val customVersion = customVersionString.toInt()
|
||||||
|
|
||||||
|
task {
|
||||||
|
purchaseHelper.purchase(app.packageName, customVersion, app.offerType)
|
||||||
|
} successUi {
|
||||||
|
if (it.isNotEmpty()) {
|
||||||
|
toast(R.string.toast_manual_available)
|
||||||
|
EventBus.getDefault().post(BusEvent.ManualDownload(app.packageName, customVersion))
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
} else {
|
||||||
|
toast(R.string.toast_manual_unavailable)
|
||||||
|
}
|
||||||
|
} failUi {
|
||||||
|
toast(R.string.toast_manual_unavailable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
B.btnSecondary.setOnClickListener {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
134
app/src/main/res/layout/sheet_manual_download.xml
Normal file
134
app/src/main/res/layout/sheet_manual_download.xml
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
~ Aurora Store
|
||||||
|
~ Copyright (C) 2021, Rahul Kumar Patel <whyorean@gmail.com>
|
||||||
|
~
|
||||||
|
~ Aurora Store is free software: you can redistribute it and/or modify
|
||||||
|
~ it under the terms of the GNU General Public License as published by
|
||||||
|
~ the Free Software Foundation, either version 2 of the License, or
|
||||||
|
~ (at your option) any later version.
|
||||||
|
~
|
||||||
|
~ Aurora Store is distributed in the hope that it will be useful,
|
||||||
|
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
~ GNU General Public License for more details.
|
||||||
|
~
|
||||||
|
~ You should have received a copy of the GNU General Public License
|
||||||
|
~ along with Aurora Store. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
~
|
||||||
|
-->
|
||||||
|
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:divider="@drawable/divider"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="@dimen/padding_large"
|
||||||
|
android:showDividers="middle">
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.AppCompatImageView
|
||||||
|
android:id="@+id/img_icon"
|
||||||
|
android:layout_width="@dimen/icon_size_category"
|
||||||
|
android:layout_height="@dimen/icon_size_category"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
tools:src="@drawable/bg_circle" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginStart="@dimen/margin_normal"
|
||||||
|
android:layout_marginBottom="@dimen/margin_normal"
|
||||||
|
android:layout_toEndOf="@id/img_icon"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:text="@string/title_manual_download"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.SubTitle" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_line1"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:maxLines="2"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.Line1"
|
||||||
|
tools:text="App Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_line2"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/txt_line1"
|
||||||
|
android:layout_alignStart="@id/txt_line1"
|
||||||
|
android:layout_alignEnd="@id/txt_line1"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.Line2"
|
||||||
|
android:textColor="?colorAccent"
|
||||||
|
tools:text="Package Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_line3"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/txt_line2"
|
||||||
|
android:layout_alignStart="@id/txt_line1"
|
||||||
|
android:layout_alignEnd="@id/txt_line1"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.Line3"
|
||||||
|
tools:text="Base version" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputLayout
|
||||||
|
android:id="@+id/version_code_layout"
|
||||||
|
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:helperText="Enter version code you wish to download">
|
||||||
|
|
||||||
|
<com.google.android.material.textfield.TextInputEditText
|
||||||
|
android:id="@+id/version_code_inp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:imeOptions="actionDone"
|
||||||
|
android:inputType="number" />
|
||||||
|
|
||||||
|
</com.google.android.material.textfield.TextInputLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:weightSum="2">
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_secondary"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@dimen/height_button"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/action_cancel" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/btn_primary"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.TextButton.Dialog.Flush"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="@dimen/height_button"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="@string/action_check" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
@@ -28,6 +28,10 @@
|
|||||||
android:id="@+id/action_uninstall"
|
android:id="@+id/action_uninstall"
|
||||||
android:title="@string/action_uninstall" />
|
android:title="@string/action_uninstall" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/menu_download_manual"
|
||||||
|
android:title="@string/title_manual_download" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/menu_download_manager"
|
android:id="@+id/menu_download_manager"
|
||||||
android:title="@string/title_download_manager" />
|
android:title="@string/title_download_manager" />
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
<string name="action_blacklist_add">"Add to Blacklist"</string>
|
<string name="action_blacklist_add">"Add to Blacklist"</string>
|
||||||
<string name="action_buy">"Buy"</string>
|
<string name="action_buy">"Buy"</string>
|
||||||
<string name="action_cancel">"Cancel"</string>
|
<string name="action_cancel">"Cancel"</string>
|
||||||
|
<string name="action_check">"Check"</string>
|
||||||
<string name="action_clear">"Clear"</string>
|
<string name="action_clear">"Clear"</string>
|
||||||
<string name="action_clear_all">"Clear all"</string>
|
<string name="action_clear_all">"Clear all"</string>
|
||||||
<string name="action_clear_restart">"Clear data"</string>
|
<string name="action_clear_restart">"Clear data"</string>
|
||||||
@@ -341,6 +342,7 @@
|
|||||||
<string name="title_settings">"Settings"</string>
|
<string name="title_settings">"Settings"</string>
|
||||||
<string name="title_spoof_manager">"Spoof manager"</string>
|
<string name="title_spoof_manager">"Spoof manager"</string>
|
||||||
<string name="title_updates">"Updates"</string>
|
<string name="title_updates">"Updates"</string>
|
||||||
|
<string name="title_manual_download">"Manual download"</string>
|
||||||
<string name="toast_abandon_sessions">"Old installation sessions abandoned"</string>
|
<string name="toast_abandon_sessions">"Old installation sessions abandoned"</string>
|
||||||
<string name="toast_anonymous_restriction">"Not available on anonymous accounts"</string>
|
<string name="toast_anonymous_restriction">"Not available on anonymous accounts"</string>
|
||||||
<string name="toast_apk_blacklisted">"Blacklisted"</string>
|
<string name="toast_apk_blacklisted">"Blacklisted"</string>
|
||||||
@@ -352,4 +354,6 @@
|
|||||||
<string name="toast_permission_granted">"Permission granted"</string>
|
<string name="toast_permission_granted">"Permission granted"</string>
|
||||||
<string name="toast_spoof_applied">"Device spoof applied successfully."</string>
|
<string name="toast_spoof_applied">"Device spoof applied successfully."</string>
|
||||||
<string name="toast_purchase_blocked">"App purchases not available on Anonymous accounts."</string>
|
<string name="toast_purchase_blocked">"App purchases not available on Anonymous accounts."</string>
|
||||||
|
<string name="toast_manual_unavailable">"The version code you are requesting is unavailable."</string>
|
||||||
|
<string name="toast_manual_available">"Congrats, requested version code is available, downloading now."</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user