Loading app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +37 −23 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package foundation.e.apps.ui.application import android.annotation.SuppressLint import android.content.Intent import android.graphics.Color import android.graphics.drawable.Drawable Loading Loading @@ -782,6 +783,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } } @SuppressLint("SetTextI18n") private fun handleUnavaiable( installButton: MaterialButton, application: Application, Loading @@ -789,23 +791,41 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { installButton.disableInstallButton(R.string.install) installButton.text = "" binding.downloadInclude.progressBarInstall.visibility = View.VISIBLE appInfoFetchViewModel.isAppPurchased(application).observe(viewLifecycleOwner) { binding.downloadInclude.progressBarInstall.visibility = View.GONE enableInstallButton(R.string.install) text = when { mainActivityViewModel.checkUnsupportedApplication(application) -> getString(R.string.not_available) application.isFree -> getString(R.string.install) application.isFree || application.isPurchased -> getString(R.string.install) else -> application.price } } setOnClickListener { if (mainActivityViewModel.checkUnsupportedApplication(application, activity)) { return@setOnClickListener } applicationIcon?.let { if (application.isFree) { if (application.isFree || application.isPurchased) { disableInstallButton(R.string.cancel) installApplication(application) } else { handleInstallClickForPaidApp(application) } } } } downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } private fun handleInstallClickForPaidApp(application: Application) { if (!mainActivityViewModel.shouldShowPaidAppsSnackBar(application)) { ApplicationDialogFragment( title = getString(R.string.dialog_title_paid_app, application.name), Loading @@ -822,12 +842,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { ).show(childFragmentManager, "ApplicationFragment") } } } } } downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } private fun MaterialButton.disableInstallButton(buttonStringID: Int) { isEnabled = false Loading app/src/main/res/layout/fragment_application_download.xml +11 −0 Original line number Diff line number Diff line Loading @@ -93,4 +93,15 @@ app:cornerRadius="4dp" /> <ProgressBar android:id="@+id/progressBarInstall" style="?android:attr/progressBarStyle" android:layout_width="16dp" android:layout_height="16dp" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="@+id/installButton" app:layout_constraintLeft_toLeftOf="@+id/installButton" app:layout_constraintRight_toRightOf="@+id/installButton" app:layout_constraintTop_toTopOf="@+id/installButton" /> </androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file Loading
app/src/main/java/foundation/e/apps/ui/application/ApplicationFragment.kt +37 −23 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package foundation.e.apps.ui.application import android.annotation.SuppressLint import android.content.Intent import android.graphics.Color import android.graphics.drawable.Drawable Loading Loading @@ -782,6 +783,7 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { } } @SuppressLint("SetTextI18n") private fun handleUnavaiable( installButton: MaterialButton, application: Application, Loading @@ -789,23 +791,41 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { appSize: MaterialTextView ) { installButton.apply { installButton.disableInstallButton(R.string.install) installButton.text = "" binding.downloadInclude.progressBarInstall.visibility = View.VISIBLE appInfoFetchViewModel.isAppPurchased(application).observe(viewLifecycleOwner) { binding.downloadInclude.progressBarInstall.visibility = View.GONE enableInstallButton(R.string.install) text = when { mainActivityViewModel.checkUnsupportedApplication(application) -> getString(R.string.not_available) application.isFree -> getString(R.string.install) application.isFree || application.isPurchased -> getString(R.string.install) else -> application.price } } setOnClickListener { if (mainActivityViewModel.checkUnsupportedApplication(application, activity)) { return@setOnClickListener } applicationIcon?.let { if (application.isFree) { if (application.isFree || application.isPurchased) { disableInstallButton(R.string.cancel) installApplication(application) } else { handleInstallClickForPaidApp(application) } } } } downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } private fun handleInstallClickForPaidApp(application: Application) { if (!mainActivityViewModel.shouldShowPaidAppsSnackBar(application)) { ApplicationDialogFragment( title = getString(R.string.dialog_title_paid_app, application.name), Loading @@ -822,12 +842,6 @@ class ApplicationFragment : TimeoutFragment(R.layout.fragment_application) { ).show(childFragmentManager, "ApplicationFragment") } } } } } downloadPB.visibility = View.GONE appSize.visibility = View.VISIBLE } private fun MaterialButton.disableInstallButton(buttonStringID: Int) { isEnabled = false Loading
app/src/main/res/layout/fragment_application_download.xml +11 −0 Original line number Diff line number Diff line Loading @@ -93,4 +93,15 @@ app:cornerRadius="4dp" /> <ProgressBar android:id="@+id/progressBarInstall" style="?android:attr/progressBarStyle" android:layout_width="16dp" android:layout_height="16dp" android:visibility="invisible" app:layout_constraintBottom_toBottomOf="@+id/installButton" app:layout_constraintLeft_toLeftOf="@+id/installButton" app:layout_constraintRight_toRightOf="@+id/installButton" app:layout_constraintTop_toTopOf="@+id/installButton" /> </androidx.constraintlayout.widget.ConstraintLayout> No newline at end of file