From 68bb87c04bb8d0991fd86addbbe89509b06c3180 Mon Sep 17 00:00:00 2001 From: Julian Raufelder Date: Wed, 2 Jun 2021 15:20:18 +0200 Subject: [PATCH] #319 show hint when blocked cause of obscured while entering the license Need to manually handle this in case of dialogs as otherwise the onFilterTouchEventForSecurity method of the ViewGroup isn't called when filterTouchesWhenObscured is set to true in the BaseDialog and in contrast to if set in an Activity --- .../presenter/LicenseCheckPresenter.kt | 13 ++- .../ui/activity/LicenseCheckActivity.kt | 19 ++++- .../presentation/ui/dialog/BaseDialog.kt | 4 +- .../ui/dialog/LicenseConfirmationDialog.kt | 6 +- .../ui/dialog/UpdateLicenseDialog.kt | 17 +++- .../ObscuredAwareDialogCoordinatorLayout.kt | 38 +++++++++ .../main/res/layout/dialog_enter_license.xml | 82 ++++++++++--------- 7 files changed, 126 insertions(+), 53 deletions(-) create mode 100644 presentation/src/main/java/org/cryptomator/presentation/ui/layout/ObscuredAwareDialogCoordinatorLayout.kt diff --git a/presentation/src/main/java/org/cryptomator/presentation/presenter/LicenseCheckPresenter.kt b/presentation/src/main/java/org/cryptomator/presentation/presenter/LicenseCheckPresenter.kt index 7a9a665f..6e69494b 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/presenter/LicenseCheckPresenter.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/presenter/LicenseCheckPresenter.kt @@ -6,13 +6,14 @@ import org.cryptomator.domain.usecases.LicenseCheck import org.cryptomator.domain.usecases.NoOpResultHandler import org.cryptomator.presentation.exception.ExceptionHandlers import org.cryptomator.presentation.ui.activity.view.UpdateLicenseView +import org.cryptomator.presentation.ui.dialog.AppIsObscuredInfoDialog import org.cryptomator.util.SharedPreferencesHandler import javax.inject.Inject import timber.log.Timber class LicenseCheckPresenter @Inject internal constructor( exceptionHandlers: ExceptionHandlers, // - private val doLicenseCheckUsecase: DoLicenseCheckUseCase, // + private val doLicenseCheckUseCase: DoLicenseCheckUseCase, // private val sharedPreferencesHandler: SharedPreferencesHandler ) : Presenter(exceptionHandlers) { @@ -20,18 +21,22 @@ class LicenseCheckPresenter @Inject internal constructor( data?.let { val license = it.fragment ?: it.lastPathSegment ?: "" view?.showOrUpdateLicenseDialog(license) - doLicenseCheckUsecase + doLicenseCheckUseCase .withLicense(license) .run(CheckLicenseStatusSubscriber()) } } fun validateDialogAware(license: String?) { - doLicenseCheckUsecase + doLicenseCheckUseCase .withLicense(license) .run(CheckLicenseStatusSubscriber()) } + fun onFilteredTouchEventForSecurity() { + view?.showDialog(AppIsObscuredInfoDialog.newInstance()) + } + private inner class CheckLicenseStatusSubscriber : NoOpResultHandler() { override fun onSuccess(licenseCheck: LicenseCheck) { @@ -49,6 +54,6 @@ class LicenseCheckPresenter @Inject internal constructor( } init { - unsubscribeOnDestroy(doLicenseCheckUsecase) + unsubscribeOnDestroy(doLicenseCheckUseCase) } } diff --git a/presentation/src/main/java/org/cryptomator/presentation/ui/activity/LicenseCheckActivity.kt b/presentation/src/main/java/org/cryptomator/presentation/ui/activity/LicenseCheckActivity.kt index 2753f76f..f7602a64 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/ui/activity/LicenseCheckActivity.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/ui/activity/LicenseCheckActivity.kt @@ -10,11 +10,13 @@ import org.cryptomator.presentation.presenter.LicenseCheckPresenter import org.cryptomator.presentation.ui.activity.view.UpdateLicenseView import org.cryptomator.presentation.ui.dialog.LicenseConfirmationDialog import org.cryptomator.presentation.ui.dialog.UpdateLicenseDialog +import org.cryptomator.presentation.ui.layout.ObscuredAwareCoordinatorLayout import javax.inject.Inject import kotlin.system.exitProcess +import kotlinx.android.synthetic.main.activity_layout_obscure_aware.activityRootView import kotlinx.android.synthetic.main.toolbar_layout.toolbar -@Activity +@Activity(layout = R.layout.activity_layout_obscure_aware) class LicenseCheckActivity : BaseActivity(), UpdateLicenseDialog.Callback, LicenseConfirmationDialog.Callback, UpdateLicenseView { @Inject @@ -23,11 +25,19 @@ class LicenseCheckActivity : BaseActivity(), UpdateLicenseDialog.Callback, Licen override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - setupToolbar() + activityRootView.setOnFilteredTouchEventForSecurityListener(object : ObscuredAwareCoordinatorLayout.Listener { + override fun onFilteredTouchEventForSecurity() { + licenseCheckPresenter.onFilteredTouchEventForSecurity() + } + }) validate(intent) } + override fun setupView() { + setupToolbar() + } + override fun checkLicenseClicked(license: String?) { licenseCheckPresenter.validateDialogAware(license) } @@ -51,6 +61,11 @@ class LicenseCheckActivity : BaseActivity(), UpdateLicenseDialog.Callback, Licen exitProcess(0) } + override fun appObscuredClosingEnterLicenseDialog() { + closeDialog() + licenseCheckPresenter.onFilteredTouchEventForSecurity() + } + private fun setupToolbar() { toolbar.title = getString(R.string.app_name).uppercase() setSupportActionBar(toolbar) diff --git a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/BaseDialog.kt b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/BaseDialog.kt index cbab7944..2f26a5d5 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/BaseDialog.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/BaseDialog.kt @@ -82,9 +82,7 @@ abstract class BaseDialog : DialogFragment() { get() = requireContext().resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE fun onErrorResponse(view: View?) { - if (view != null) { - view.isFocusableInTouchMode = true - } + view?.let { it.isFocusableInTouchMode = true } allowClosingDialog(true) enableButtons(true) } diff --git a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/LicenseConfirmationDialog.kt b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/LicenseConfirmationDialog.kt index 9c6f908a..031c59eb 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/LicenseConfirmationDialog.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/LicenseConfirmationDialog.kt @@ -16,10 +16,10 @@ class LicenseConfirmationDialog : BaseDialog } public override fun setupDialog(builder: AlertDialog.Builder): android.app.Dialog { - builder // + return builder // .setTitle(getString(R.string.dialog_license_confirmation_title)) // - .setNeutralButton(getText(R.string.dialog_license_confirmation_ok_btn)) { _: DialogInterface, _: Int -> callback?.licenseConfirmationClicked() } - return builder.create() + .setNeutralButton(getText(R.string.dialog_license_confirmation_ok_btn)) { _: DialogInterface, _: Int -> callback?.licenseConfirmationClicked() } // + .create() } public override fun setupView() { diff --git a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/UpdateLicenseDialog.kt b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/UpdateLicenseDialog.kt index fb4955f5..d82c085a 100644 --- a/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/UpdateLicenseDialog.kt +++ b/presentation/src/main/java/org/cryptomator/presentation/ui/dialog/UpdateLicenseDialog.kt @@ -7,6 +7,9 @@ import android.widget.Button import androidx.appcompat.app.AlertDialog import org.cryptomator.generator.Dialog import org.cryptomator.presentation.R +import org.cryptomator.presentation.ui.layout.ObscuredAwareDialogCoordinatorLayout +import org.cryptomator.util.SharedPreferencesHandler +import kotlinx.android.synthetic.main.dialog_enter_license.dssialogRootView import kotlinx.android.synthetic.main.dialog_enter_license.et_license @Dialog(R.layout.dialog_enter_license) @@ -19,6 +22,7 @@ class UpdateLicenseDialog : BaseProgressErrorDialog - - + android:layout_height="match_parent"> - + android:layout_height="match_parent" + android:padding="@dimen/activity_vertical_margin"> - - - - - - + android:layout_marginBottom="5dp" + android:text="@string/dialog_enter_license_content" /> - + - + - - + + + + + + + + + +