Fix self update issues
This commit is contained in:
@@ -45,7 +45,6 @@ import com.aurora.gplayapi.data.models.AuthData
|
|||||||
import com.aurora.store.data.model.SelfUpdate
|
import com.aurora.store.data.model.SelfUpdate
|
||||||
import com.aurora.store.data.network.HttpClient
|
import com.aurora.store.data.network.HttpClient
|
||||||
import com.aurora.store.data.providers.AuthProvider
|
import com.aurora.store.data.providers.AuthProvider
|
||||||
import com.aurora.store.data.service.SelfUpdateService
|
|
||||||
import com.aurora.store.databinding.ActivityMainBinding
|
import com.aurora.store.databinding.ActivityMainBinding
|
||||||
import com.aurora.store.util.CertUtil.isFDroidApp
|
import com.aurora.store.util.CertUtil.isFDroidApp
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
@@ -59,6 +58,7 @@ import com.aurora.store.view.ui.downloads.DownloadActivity
|
|||||||
import com.aurora.store.view.ui.preferences.SettingsActivity
|
import com.aurora.store.view.ui.preferences.SettingsActivity
|
||||||
import com.aurora.store.view.ui.sale.AppSalesActivity
|
import com.aurora.store.view.ui.sale.AppSalesActivity
|
||||||
import com.aurora.store.view.ui.search.SearchSuggestionActivity
|
import com.aurora.store.view.ui.search.SearchSuggestionActivity
|
||||||
|
import com.aurora.store.view.ui.sheets.SelfUpdateSheet
|
||||||
import com.aurora.store.view.ui.spoof.SpoofActivity
|
import com.aurora.store.view.ui.spoof.SpoofActivity
|
||||||
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView
|
import com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
@@ -277,10 +277,10 @@ class MainActivity : BaseActivity() {
|
|||||||
if (it.versionCode > BuildConfig.VERSION_CODE) {
|
if (it.versionCode > BuildConfig.VERSION_CODE) {
|
||||||
if (isFDroidApp(this, BuildConfig.APPLICATION_ID)) {
|
if (isFDroidApp(this, BuildConfig.APPLICATION_ID)) {
|
||||||
if (it.fdroidBuild.isNotEmpty()) {
|
if (it.fdroidBuild.isNotEmpty()) {
|
||||||
showUpdatesDialog(it)
|
showUpdatesSheet(it)
|
||||||
}
|
}
|
||||||
} else if (it.auroraBuild.isNotEmpty()) {
|
} else if (it.auroraBuild.isNotEmpty()) {
|
||||||
showUpdatesDialog(it)
|
showUpdatesSheet(it)
|
||||||
} else {
|
} else {
|
||||||
Log.i(getString(R.string.details_no_updates))
|
Log.i(getString(R.string.details_no_updates))
|
||||||
}
|
}
|
||||||
@@ -294,27 +294,11 @@ class MainActivity : BaseActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showUpdatesDialog(selfUpdate: SelfUpdate) {
|
private fun showUpdatesSheet(selfUpdate: SelfUpdate) {
|
||||||
val messages: List<String> = listOf(
|
if (!supportFragmentManager.isDestroyed) {
|
||||||
selfUpdate.versionCode.toString(),
|
val sheet = SelfUpdateSheet.newInstance(selfUpdate)
|
||||||
if (selfUpdate.changelog.isEmpty())
|
sheet.isCancelable = false
|
||||||
getString(R.string.details_changelog_unavailable)
|
sheet.show(supportFragmentManager, SelfUpdateSheet.TAG)
|
||||||
else
|
}
|
||||||
selfUpdate.changelog,
|
|
||||||
getString(R.string.dialog_desc_self_update)
|
|
||||||
)
|
|
||||||
|
|
||||||
showDialog(
|
|
||||||
getString(R.string.dialog_title_self_update),
|
|
||||||
messages.joinToString(separator = "\n"),
|
|
||||||
{ _, _ ->
|
|
||||||
val intent = Intent(this, SelfUpdateService::class.java)
|
|
||||||
intent.putExtra(Constants.STRING_EXTRA, gson.toJson(selfUpdate))
|
|
||||||
startService(intent)
|
|
||||||
},
|
|
||||||
{ dialog, _ ->
|
|
||||||
dialog.dismiss()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import com.aurora.store.BuildConfig
|
|||||||
import com.aurora.store.R
|
import com.aurora.store.R
|
||||||
import com.aurora.store.data.downloader.DownloadManager
|
import com.aurora.store.data.downloader.DownloadManager
|
||||||
import com.aurora.store.data.downloader.RequestBuilder.buildRequest
|
import com.aurora.store.data.downloader.RequestBuilder.buildRequest
|
||||||
import com.aurora.store.data.installer.AppInstaller
|
import com.aurora.store.data.installer.NativeInstaller
|
||||||
import com.aurora.store.data.model.SelfUpdate
|
import com.aurora.store.data.model.SelfUpdate
|
||||||
import com.aurora.store.util.CertUtil.isFDroidApp
|
import com.aurora.store.util.CertUtil.isFDroidApp
|
||||||
import com.aurora.store.util.Log
|
import com.aurora.store.util.Log
|
||||||
@@ -144,10 +144,15 @@ class SelfUpdateService : Service() {
|
|||||||
override fun onCompleted(groupId: Int, download: Download, fetchGroup: FetchGroup) {
|
override fun onCompleted(groupId: Int, download: Download, fetchGroup: FetchGroup) {
|
||||||
if (groupId == app.id && fetchGroup.groupDownloadProgress == 100) {
|
if (groupId == app.id && fetchGroup.groupDownloadProgress == 100) {
|
||||||
Log.d("Calling installer ${app.displayName}")
|
Log.d("Calling installer ${app.displayName}")
|
||||||
AppInstaller(this@SelfUpdateService).getPreferredInstaller().install(
|
|
||||||
BuildConfig.APPLICATION_ID,
|
try {
|
||||||
listOf(download.file)
|
NativeInstaller(this@SelfUpdateService).install(
|
||||||
)
|
app.packageName,
|
||||||
|
fetchGroup.downloads.map { it.file }
|
||||||
|
)
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Log.e("Self update : ${e.stackTraceToString()}")
|
||||||
|
}
|
||||||
|
|
||||||
task {
|
task {
|
||||||
TimeUnit.SECONDS.sleep(10)
|
TimeUnit.SECONDS.sleep(10)
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class DownloadActivity : BaseActivity() {
|
|||||||
fetch.getDownloads { downloads ->
|
fetch.getDownloads { downloads ->
|
||||||
updateController(
|
updateController(
|
||||||
downloads
|
downloads
|
||||||
|
.filter { it.id == BuildConfig.APPLICATION_ID.hashCode() }
|
||||||
.sortedWith { o1, o2 -> o2.created.compareTo(o1.created) }
|
.sortedWith { o1, o2 -> o2.created.compareTo(o1.created) }
|
||||||
.map { DownloadFile(it) }
|
.map { DownloadFile(it) }
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,101 @@
|
|||||||
|
/*
|
||||||
|
* 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.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
|
import com.aurora.Constants
|
||||||
|
import com.aurora.store.R
|
||||||
|
import com.aurora.store.data.model.SelfUpdate
|
||||||
|
import com.aurora.store.data.service.SelfUpdateService
|
||||||
|
import com.aurora.store.databinding.SheetSelfUpdateBinding
|
||||||
|
|
||||||
|
class SelfUpdateSheet : BaseBottomSheet() {
|
||||||
|
|
||||||
|
private lateinit var B: SheetSelfUpdateBinding
|
||||||
|
private lateinit var selfUpdate: SelfUpdate
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
|
||||||
|
const val TAG = "ManualDownloadSheet"
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun newInstance(
|
||||||
|
selfUpdate: SelfUpdate
|
||||||
|
): SelfUpdateSheet {
|
||||||
|
return SelfUpdateSheet().apply {
|
||||||
|
arguments = Bundle().apply {
|
||||||
|
putString(Constants.STRING_EXTRA, gson.toJson(selfUpdate))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreateContentView(
|
||||||
|
inflater: LayoutInflater,
|
||||||
|
container: ViewGroup,
|
||||||
|
savedInstanceState: Bundle?
|
||||||
|
): View {
|
||||||
|
B = SheetSelfUpdateBinding.inflate(inflater)
|
||||||
|
return B.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onContentViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
val bundle = arguments
|
||||||
|
bundle?.let {
|
||||||
|
val rawUpdate = bundle.getString(Constants.STRING_EXTRA, "{}")
|
||||||
|
selfUpdate = gson.fromJson(rawUpdate, SelfUpdate::class.java)
|
||||||
|
if (selfUpdate.versionName.isNotEmpty()) {
|
||||||
|
inflateData()
|
||||||
|
attachActions()
|
||||||
|
} else {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun inflateData() {
|
||||||
|
B.txtLine2.text = ("${selfUpdate.versionName} (${selfUpdate.versionCode})")
|
||||||
|
|
||||||
|
val messages: String = if (selfUpdate.changelog.isEmpty())
|
||||||
|
getString(R.string.details_changelog_unavailable)
|
||||||
|
else
|
||||||
|
selfUpdate.changelog
|
||||||
|
|
||||||
|
B.txtChangelog.text = messages.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun attachActions() {
|
||||||
|
B.btnPrimary.setOnClickListener {
|
||||||
|
val intent = Intent(requireContext(), SelfUpdateService::class.java)
|
||||||
|
intent.putExtra(Constants.STRING_EXTRA, gson.toJson(selfUpdate))
|
||||||
|
requireContext().startService(intent)
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
|
||||||
|
B.btnSecondary.setOnClickListener {
|
||||||
|
dismissAllowingStateLoss()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
119
app/src/main/res/layout/sheet_self_update.xml
Normal file
119
app/src/main/res/layout/sheet_self_update.xml
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<?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"
|
||||||
|
app:srcCompat="@drawable/ic_logo" />
|
||||||
|
|
||||||
|
<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/dialog_title_self_update"
|
||||||
|
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:text="@string/app_name"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.Line1" />
|
||||||
|
|
||||||
|
<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"
|
||||||
|
tools:text="Version" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/txt_changelog"
|
||||||
|
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:layout_marginTop="@dimen/margin_small"
|
||||||
|
android:background="@drawable/bg_outlined_padded"
|
||||||
|
android:textAlignment="viewStart"
|
||||||
|
android:textAppearance="@style/TextAppearance.Aurora.Line2"
|
||||||
|
tools:text="Base version" />
|
||||||
|
</RelativeLayout>
|
||||||
|
</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_ignore" />
|
||||||
|
|
||||||
|
<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_update" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
Reference in New Issue
Block a user