Loading app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +26 −4 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { text = getString(R.string.retry) enableInstallButton(R.string.retry) setOnClickListener { applicationIcon?.let { mainActivityViewModel.getApplication(fusedApp, it) Loading Loading @@ -504,7 +504,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB: RelativeLayout, appSize: MaterialTextView ) { installButton.isEnabled = false installButton.disableInstallButton(R.string.installing) downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } Loading @@ -516,6 +516,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.cancel) text = getString(R.string.cancel) setOnClickListener { mainActivityViewModel.cancelDownload(fusedApp) Loading @@ -539,6 +540,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE installButton.apply { enableInstallButton(R.string.cancel) text = getString(R.string.cancel) setOnClickListener { mainActivityViewModel.cancelDownload(fusedApp) Loading @@ -553,6 +555,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.install) text = when { mainActivityViewModel.checkUnsupportedApplication(fusedApp) -> getString(R.string.not_available) Loading @@ -565,6 +568,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } applicationIcon?.let { if (fusedApp.isFree) { disableInstallButton(R.string.cancel) installApplication(fusedApp, it) } else { if (!mainActivityViewModel.shouldShowPaidAppsSnackBar(fusedApp)) { Loading @@ -590,6 +594,24 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize.visibility = View.VISIBLE } private fun MaterialButton.disableInstallButton(buttonStringID: Int) { isEnabled = false text = context.getString(buttonStringID) strokeColor = ContextCompat.getColorStateList(context, R.color.light_grey) setTextColor(context.getColor(R.color.light_grey)) backgroundTintList = ContextCompat.getColorStateList(context, android.R.color.transparent) } private fun MaterialButton.enableInstallButton(buttonStringID: Int) { isEnabled = true text = context.getString(buttonStringID) strokeColor = ContextCompat.getColorStateList(context, R.color.colorAccent) setTextColor(context.getColor(R.color.colorAccent)) backgroundTintList = ContextCompat.getColorStateList(context, android.R.color.transparent) } private fun installApplication( fusedApp: FusedApp, it: ImageView Loading @@ -616,6 +638,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.not_available) text = if (mainActivityViewModel.checkUnsupportedApplication(fusedApp)) getString(R.string.not_available) else getString(R.string.update) Loading Loading @@ -645,8 +668,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE installButton.apply { isEnabled = true text = getString(R.string.open) enableInstallButton(R.string.open) setTextColor(Color.WHITE) backgroundTintList = ContextCompat.getColorStateList(view.context, R.color.colorAccent) Loading Loading
app/src/main/java/foundation/e/apps/application/ApplicationFragment.kt +26 −4 Original line number Diff line number Diff line Loading @@ -468,7 +468,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { text = getString(R.string.retry) enableInstallButton(R.string.retry) setOnClickListener { applicationIcon?.let { mainActivityViewModel.getApplication(fusedApp, it) Loading Loading @@ -504,7 +504,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB: RelativeLayout, appSize: MaterialTextView ) { installButton.isEnabled = false installButton.disableInstallButton(R.string.installing) downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } Loading @@ -516,6 +516,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.cancel) text = getString(R.string.cancel) setOnClickListener { mainActivityViewModel.cancelDownload(fusedApp) Loading @@ -539,6 +540,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE installButton.apply { enableInstallButton(R.string.cancel) text = getString(R.string.cancel) setOnClickListener { mainActivityViewModel.cancelDownload(fusedApp) Loading @@ -553,6 +555,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.install) text = when { mainActivityViewModel.checkUnsupportedApplication(fusedApp) -> getString(R.string.not_available) Loading @@ -565,6 +568,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } applicationIcon?.let { if (fusedApp.isFree) { disableInstallButton(R.string.cancel) installApplication(fusedApp, it) } else { if (!mainActivityViewModel.shouldShowPaidAppsSnackBar(fusedApp)) { Loading @@ -590,6 +594,24 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize.visibility = View.VISIBLE } private fun MaterialButton.disableInstallButton(buttonStringID: Int) { isEnabled = false text = context.getString(buttonStringID) strokeColor = ContextCompat.getColorStateList(context, R.color.light_grey) setTextColor(context.getColor(R.color.light_grey)) backgroundTintList = ContextCompat.getColorStateList(context, android.R.color.transparent) } private fun MaterialButton.enableInstallButton(buttonStringID: Int) { isEnabled = true text = context.getString(buttonStringID) strokeColor = ContextCompat.getColorStateList(context, R.color.colorAccent) setTextColor(context.getColor(R.color.colorAccent)) backgroundTintList = ContextCompat.getColorStateList(context, android.R.color.transparent) } private fun installApplication( fusedApp: FusedApp, it: ImageView Loading @@ -616,6 +638,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { enableInstallButton(R.string.not_available) text = if (mainActivityViewModel.checkUnsupportedApplication(fusedApp)) getString(R.string.not_available) else getString(R.string.update) Loading Loading @@ -645,8 +668,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE installButton.apply { isEnabled = true text = getString(R.string.open) enableInstallButton(R.string.open) setTextColor(Color.WHITE) backgroundTintList = ContextCompat.getColorStateList(view.context, R.color.colorAccent) Loading