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