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

Commit 0c364308 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Redesign app download progress bar

parent ad201c19
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -125,6 +125,7 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener {
        appTitle.visibility = View.GONE
        appAuthor.visibility = View.GONE
        appCategory.visibility = View.GONE
        app_download_container.visibility = View.GONE
        appSize.visibility = View.GONE
        appDescriptionContainer.visibility = View.GONE
        app_screenshots_container.visibility = View.GONE
@@ -318,7 +319,11 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener {
    @SuppressLint("SetTextI18n")
    override fun downloading(downloader: Downloader) {
        downloader.addListener { count, total ->
            app_install.text = "${toMiB(count)}/${toMiB(total)} MiB"
            app_download_mb.text = "${toMiB(count)}/${toMiB(total)} MiB"
            app_download_percentage.text =
                    ((toMiB(count) / toMiB(total)) * 100).toInt().toString() + "%"
            app_download_progress.max = total
            app_download_progress.progress = count
        }
    }

@@ -329,7 +334,29 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener {
    override fun stateChanged(state: State) {
        Execute({}, {
            app_install.text = resources.getString(state.installButtonTextId)
            app_install.isEnabled = state.isInstallButtonEnabled
            when (state) {
                State.DOWNLOADING -> {
                    app_install.setBackgroundResource(R.drawable.app_install_border_simple)
                    app_install.setTextColor(resources.getColor(android.R.color.primary_text_light))
                    app_install.isEnabled = true
                    app_size.visibility = View.GONE
                    app_download_container.visibility = View.VISIBLE
                }
                State.INSTALLING -> {
                    app_install.setBackgroundResource(R.drawable.app_install_border)
                    app_install.setTextColor(resources.getColor(android.R.color.primary_text_dark))
                    app_install.isEnabled = false
                    app_size.visibility = View.VISIBLE
                    app_download_container.visibility = View.GONE
                }
                else -> {
                    app_install.setBackgroundResource(R.drawable.app_install_border)
                    app_install.setTextColor(resources.getColor(android.R.color.primary_text_dark))
                    app_install.isEnabled = true
                    app_size.visibility = View.VISIBLE
                    app_download_container.visibility = View.GONE
                }
            }
        })
    }

+9 −4
Original line number Diff line number Diff line
@@ -18,8 +18,6 @@ import io.eelo.appinstaller.utils.Common.toMiB
import io.eelo.appinstaller.utils.Execute
import kotlinx.android.synthetic.main.application_list_item.view.*
import kotlinx.android.synthetic.main.install_button_layout.view.*
import java.text.DecimalFormat
import kotlin.math.roundToInt

class ApplicationViewHolder(private val activity: Activity, private val view: View) : RecyclerView.ViewHolder(view), ApplicationStateListener {

@@ -65,8 +63,15 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi

    override fun stateChanged(state: State) {
        Execute({}, {
            installButton.text = view.context.resources.getString(state.installButtonTextId)
            installButton.isEnabled = state.isInstallButtonEnabled
            installButton.text = activity.getString(state.installButtonTextId)
            when (state) {
                State.INSTALLING -> {
                    installButton.isEnabled = false
                }
                else -> {
                    installButton.isEnabled = true
                }
            }
        })
    }

+9 −2
Original line number Diff line number Diff line
@@ -49,8 +49,15 @@ class SmallApplicationViewHolder(private val activity: Activity, private val vie

    override fun stateChanged(state: State) {
        Execute({}, {
            installButton.text = view.context.resources.getString(state.installButtonTextId)
            installButton.isEnabled = state.isInstallButtonEnabled
            installButton.text = activity.getString(state.installButtonTextId)
            when (state) {
                State.INSTALLING -> {
                    installButton.isEnabled = false
                }
                else -> {
                    installButton.isEnabled = true
                }
            }
        })
    }

+1 −0
Original line number Diff line number Diff line
@@ -59,6 +59,7 @@ class Application(val packageName: String, private val installManager: InstallMa
                }
            }
            DOWNLOADING -> {
                // TODO Cancel APK download
            }
            INSTALLING -> {
            }
+7 −7
Original line number Diff line number Diff line
@@ -2,11 +2,11 @@ package io.eelo.appinstaller.application.model

import io.eelo.appinstaller.R

enum class State(val installButtonTextId: Int, val isInstallButtonEnabled: Boolean) {
    NOT_DOWNLOADED(R.string.action_install, true),
    NOT_UPDATED(R.string.action_update, true),
    DOWNLOADING(R.string.state_downloading, false),
    DOWNLOADED(R.string.action_install, true),
    INSTALLING(R.string.state_installing, false),
    INSTALLED(R.string.action_launch, true);
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);
}
Loading