Skip to content

Commit

Permalink
- refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobi823 committed Apr 9, 2024
1 parent 27f6558 commit 4a919f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import android.widget.TextView
import androidx.annotation.MainThread
import de.marmaro.krt.ffupdater.DisplayableException
import de.marmaro.krt.ffupdater.R
import de.marmaro.krt.ffupdater.app.App
import de.marmaro.krt.ffupdater.app.entity.InstalledAppStatus
import de.marmaro.krt.ffupdater.app.impl.AppBase
import de.marmaro.krt.ffupdater.crash.CrashReportActivity
import de.marmaro.krt.ffupdater.crash.LogReader
import de.marmaro.krt.ffupdater.crash.ThrowableAndLogs
Expand All @@ -20,8 +20,7 @@ import de.marmaro.krt.ffupdater.settings.ForegroundSettings
import de.marmaro.krt.ffupdater.settings.InstallerSettings
import kotlinx.coroutines.channels.Channel

class GuiHelper(val app: App, val activity: DownloadActivity) {
private val appImpl = app.findImpl()
class GuiHelper(val activity: DownloadActivity) {

fun show(vararg viewIds: Int) {
viewIds.forEach { activity.findViewById<View>(it).visibility = View.VISIBLE }
Expand All @@ -36,7 +35,7 @@ class GuiHelper(val app: App, val activity: DownloadActivity) {
}

@MainThread
fun displayAppInstallationFailure(errorMessage: String, exception: Exception) {
fun displayAppInstallationFailure(errorMessage: String, exception: Exception, appImpl: AppBase) {
show(R.id.install_activity__exception)

setText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import de.marmaro.krt.ffupdater.background.OneTimeWorkMethodResult.Companion.sto
import de.marmaro.krt.ffupdater.background.OneTimeWorkMethodResult.Companion.success
import de.marmaro.krt.ffupdater.device.DeviceSdkTester
import de.marmaro.krt.ffupdater.device.PowerUtil
import de.marmaro.krt.ffupdater.installer.AppInstaller
import de.marmaro.krt.ffupdater.installer.AppInstallerFactory
import de.marmaro.krt.ffupdater.installer.entity.Installer.*
import de.marmaro.krt.ffupdater.installer.exceptions.InstallationFailedException
import de.marmaro.krt.ffupdater.installer.exceptions.UserInteractionIsRequiredException
Expand Down Expand Up @@ -213,8 +213,8 @@ class AppUpdater(context: Context, workerParams: WorkerParameters) :

try {
Log.i(LOG_TAG, "$LOGTAG: Update/install $app.")
val installer = AppInstaller.createBackgroundAppInstaller(app)
installer.startInstallation(applicationContext, file)
val installer = AppInstallerFactory.createBackgroundAppInstaller(app)
installer.startInstallation(applicationContext, file, appImpl)
appImpl.appWasInstalledCallback(applicationContext, installedAppStatus)
if (BackgroundSettings.isDeleteUpdateIfInstallSuccessful) {
appImpl.getApkCacheFolder(applicationContext)
Expand Down

0 comments on commit 4a919f3

Please sign in to comment.