Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 21 additions & 28 deletions app/src/main/java/io/i10nstaller/ui/InstallLaunch.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,12 @@ import androidx.fragment.app.FragmentManager
import androidx.lifecycle.ViewModelProvider
import io.i10nstaller.R
import io.i10nstaller.model.InstallAborted
import io.i10nstaller.model.InstallFailed
import io.i10nstaller.model.InstallInstalling
import io.i10nstaller.model.InstallOptions
import io.i10nstaller.model.InstallStage
import io.i10nstaller.model.InstallSuccess
import io.i10nstaller.model.InstallUserAction
import io.i10nstaller.model.PackageUserAction
import io.i10nstaller.ui.fragments.ArchiveConfirmationFragment
import io.i10nstaller.ui.fragments.BaseDialogFragment
import io.i10nstaller.ui.fragments.InstallConfirmationFragment
import io.i10nstaller.ui.fragments.InstallErrorFragment
import io.i10nstaller.ui.fragments.InstallFailedFragment
import io.i10nstaller.ui.fragments.InstallInstallingFragment
import io.i10nstaller.ui.fragments.InstallParseFragment
import io.i10nstaller.ui.fragments.InstallSuccessFragment
import io.i10nstaller.ui.fragments.InstallFlowDialogFragment
import io.i10nstaller.viewmodel.InstallViewModel
import java.lang.reflect.Constructor

Expand Down Expand Up @@ -93,15 +84,13 @@ class InstallLaunch : FragmentActivity() {
showDialogInner(null)
finish()
} else {
val errorDialog = InstallErrorFragment(aborted)
showDialogInner(errorDialog)
showInstallStageDialog(installStage)
}
}

InstallStage.Companion.STAGE_PARSE -> {
if (!silentApkInstall) {
val parseDialog = InstallParseFragment()
showDialogInner(parseDialog)
showInstallStageDialog(installStage)
}
}

Expand All @@ -120,8 +109,7 @@ class InstallLaunch : FragmentActivity() {
)
}
} else {
val actionDialog = InstallConfirmationFragment(uar)
showDialogInner(actionDialog)
showInstallStageDialog(uar)
}
}

Expand All @@ -130,16 +118,12 @@ class InstallLaunch : FragmentActivity() {
failSilentInstall()
return
}
val archive = installStage as PackageUserAction
val archiveDialog = ArchiveConfirmationFragment(archive)
showDialogInner(archiveDialog)
showInstallStageDialog(installStage)
}

InstallStage.Companion.STAGE_INSTALLING -> {
if (!silentApkInstall) {
val installing = installStage as InstallInstalling
val installingDialog = InstallInstallingFragment(installing)
showDialogInner(installingDialog)
showInstallStageDialog(installStage)
}
}

Expand All @@ -148,23 +132,32 @@ class InstallLaunch : FragmentActivity() {
finishSilentInstall()
return
}
val success = installStage as InstallSuccess
val successDialog = InstallSuccessFragment(success)
showDialogInner(successDialog)
showInstallStageDialog(installStage)
}

InstallStage.Companion.STAGE_FAILED -> {
if (silentApkInstall) {
failSilentInstall()
return
}
val failed = installStage as InstallFailed
val failureDialog = InstallFailedFragment(failed)
showDialogInner(failureDialog)
showInstallStageDialog(installStage)
}
}
}

private fun showInstallStageDialog(stage: InstallStage) {
if (fragmentManager.isDestroyed) return
val currentDialog = fragmentManager.findFragmentByTag("dialog")
if (currentDialog is InstallFlowDialogFragment) {
currentDialog.updateStage(stage)
return
}
val transaction = fragmentManager.beginTransaction()
currentDialog?.let(transaction::remove)
transaction.add(InstallFlowDialogFragment(stage), "dialog")
transaction.commitNowAllowingStateLoss()
}

private fun showDialogInner(newDialog: DialogFragment?) {
if (fragmentManager.isDestroyed) return
val currentDialog = fragmentManager.findFragmentByTag("dialog") as DialogFragment?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,16 @@ private boolean handleConfirmationKey(
}
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (negativeButton != null && negativeButton.isEnabled()) {
if (negativeButton != null && negativeButton.isEnabled()
&& !negativeButton.isInTouchMode()) {
negativeButton.requestFocus();
}
return true;
}
}
if (keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (positiveButton.isEnabled()) {
if (positiveButton.isEnabled() && !positiveButton.isInTouchMode()) {
positiveButton.requestFocus();
}
return true;
Expand Down
Loading
Loading