Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a8224d3 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Merge branch 'remove_downloaded_state' into 'master'

Get rid of "DOWNLOADED" state

See merge request e/priv/apps/AppInstaller!13
parents 18562216 5d57f5a7
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -53,7 +53,6 @@ class Application(val packageName: String, private val applicationManager: Appli
    fun buttonClicked(activity: Activity) {
        when (stateManager.state) {
            INSTALLED -> info.launch(activity)
            DOWNLOADED -> applicationManager.install(this)
            NOT_UPDATED, NOT_DOWNLOADED -> applicationManager.download(this)
            INSTALLING -> {
                applicationManager.stopInstalling(this)
+0 −5
Original line number Diff line number Diff line
@@ -36,11 +36,6 @@ class ApplicationInfo(private val packageName: String) {
        return File(context.filesDir, packageName + "-" + data.lastVersionNumber + ".apk")
    }

    fun isDownloaded(context: Context, data: BasicData): Boolean {
        return getApkFile(context, data).exists()
    }


    fun launch(context: Context) {
        context.startActivity(context.packageManager.getLaunchIntentForPackage(packageName))
    }
+0 −1
Original line number Diff line number Diff line
@@ -6,7 +6,6 @@ enum class State(val installButtonTextId: Int) {
    NOT_DOWNLOADED(R.string.action_install),
    NOT_UPDATED(R.string.action_update),
    DOWNLOADING(R.string.state_downloading),
    DOWNLOADED(R.string.action_install),
    INSTALLING(R.string.state_installing),
    INSTALLED(R.string.action_launch);
}
+18 −16
Original line number Diff line number Diff line
@@ -11,22 +11,24 @@ class StateManager(private val info: ApplicationInfo, private val app: Applicati
        private set

    fun find(context: Context, basicData: BasicData) {
        changeState(
        val state: State
        if (appManager.isDownloading(app)) {
                    State.DOWNLOADING
            state = State.DOWNLOADING
        } else if (appManager.isInstalling(app)) {
                    State.INSTALLING
            state = State.INSTALLING
        } else if (info.isLastVersionInstalled(context,
                        basicData.lastVersionNumber ?: "")) {
                    State.INSTALLED
            state = State.INSTALLED
            info.getApkFile(context, basicData).delete()
        } else if (info.isInstalled(context) && !info.isLastVersionInstalled(context,
                        basicData.lastVersionNumber ?: "")) {
                    State.NOT_UPDATED
                } else if (info.isDownloaded(context, basicData)) {
                    State.DOWNLOADED
            state = State.NOT_UPDATED
            info.getApkFile(context, basicData).delete()
        } else {
                    State.NOT_DOWNLOADED
                })
            state = State.NOT_DOWNLOADED
            info.getApkFile(context, basicData).delete()
        }
        changeState(state)
    }

    private fun changeState(state: State) {
+0 −1
Original line number Diff line number Diff line
@@ -13,7 +13,6 @@
    <string name="app_energy_score_content_description">App energy score</string>
    <string name="app_rating_content_description">App rating</string>
    <string name="state_downloading">Cancel</string>
    <string name="state_downloaded">Downloaded</string>
    <string name="action_install">Install</string>
    <string name="state_installing">Installing</string>
    <string name="action_update">Update</string>