Commit 132dc400 authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Show "Installing" state during app installation

parent 6d1bfc1b
......@@ -451,7 +451,7 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener,
app_size.visibility = View.VISIBLE
app_download_container.visibility = View.GONE
}
State.INSTALLING -> {
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
......@@ -461,6 +461,13 @@ class ApplicationActivity : AppCompatActivity(), ApplicationStateListener,
app_download_progress.progress = 0
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))
......
......@@ -82,6 +82,9 @@ class ApplicationViewHolder(private val activity: Activity, private val view: Vi
installButton.isEnabled =
Common.appHasLaunchActivity(activity, application!!.packageName)
}
State.INSTALLING -> {
installButton.isEnabled = false
}
else -> {
installButton.isEnabled = true
}
......
......@@ -65,6 +65,9 @@ class SmallApplicationViewHolder(private val activity: Activity, private val vie
installButton.isEnabled =
Common.appHasLaunchActivity(activity, application!!.packageName)
}
State.INSTALLING -> {
installButton.isEnabled = false
}
else -> {
installButton.isEnabled = true
}
......
......@@ -69,7 +69,7 @@ class Application(val packageName: String, private val applicationManager: Appli
applicationManager.install(context, this)
}
}
INSTALLING -> {
DOWNLOADING -> {
if (!isInstalling) {
if (downloader != null) {
downloader?.cancelDownload()
......@@ -79,6 +79,8 @@ class Application(val packageName: String, private val applicationManager: Appli
}
return
}
else ->
return
}
checkForStateUpdate(context)
}
......@@ -128,6 +130,7 @@ class Application(val packageName: String, private val applicationManager: Appli
private fun install(context: Context) {
isInstalling = true
checkForStateUpdate(context)
info.install(context, basicData!!, this)
}
......
......@@ -5,6 +5,7 @@ import foundation.e.apps.R
enum class State(val installButtonTextId: Int) {
NOT_DOWNLOADED(R.string.action_install),
NOT_UPDATED(R.string.action_update),
INSTALLING(R.string.action_cancel),
DOWNLOADING(R.string.action_cancel),
INSTALLING(R.string.state_installing),
INSTALLED(R.string.action_launch);
}
......@@ -12,7 +12,9 @@ class StateManager(private val info: ApplicationInfo, private val app: Applicati
private set
fun find(context: Context, basicData: BasicData) {
val state = if (appManager.isInstalling(app)) {
val state = if (appManager.isInstalling(app) && !app.isInstalling) {
State.DOWNLOADING
} else if (appManager.isInstalling(app) && app.isInstalling) {
State.INSTALLING
} else if (info.isLastVersionInstalled(context,
basicData.lastVersionNumber ?: "")) {
......@@ -33,7 +35,7 @@ class StateManager(private val info: ApplicationInfo, private val app: Applicati
fun addListener(listener: ApplicationStateListener) {
listeners.add(listener)
if (state == State.INSTALLING) {
if (state == State.DOWNLOADING) {
app.downloader?.let { listener.downloading(it) }
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment