Show dialog when trying to add a vault in the root folder of the cloud

Fixes #236
This commit is contained in:
Julian Raufelder 2021-10-28 16:20:45 +02:00
parent 810a9877ca
commit 5a890b452b
No known key found for this signature in database
GPG Key ID: 17EE71F6634E381D
4 changed files with 57 additions and 4 deletions

View File

@ -0,0 +1,28 @@
package org.cryptomator.presentation.ui.dialog
import android.app.Activity
import android.content.DialogInterface
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.DialogFragment
import org.cryptomator.generator.Dialog
import org.cryptomator.presentation.R
@Dialog(R.layout.dialog_vault_is_root_folder_of_cloud)
class VaultIsRootFolderOfCloudDialog : BaseDialog<Activity>() {
public override fun setupDialog(builder: AlertDialog.Builder): android.app.Dialog {
return builder //
.setTitle(R.string.dialog_vault_is_root_folder_of_cloud_title) //
.setNeutralButton(R.string.dialog_vaults_removed_during_migration_neutral_button) { dialog: DialogInterface, _: Int -> dialog.dismiss() }
.create()
}
override fun setupView() {}
companion object {
fun newInstance(): DialogFragment {
return VaultIsRootFolderOfCloudDialog()
}
}
}

View File

@ -18,6 +18,7 @@ import org.cryptomator.presentation.model.ProgressModel;
import org.cryptomator.presentation.model.mappers.CloudModelMapper;
import org.cryptomator.presentation.presenter.ChooseCloudServicePresenter;
import org.cryptomator.presentation.presenter.VaultListPresenter;
import org.cryptomator.presentation.ui.dialog.VaultIsRootFolderOfCloudDialog;
import java.io.Serializable;
import java.util.Arrays;
@ -116,9 +117,13 @@ public class AddExistingVaultWorkflow extends Workflow<AddExistingVaultWorkflow.
@Callback
void cryptomatorFileChosen(SerializableResult<CloudFileModel> result) {
CloudFileModel masterkeyFile = result.getResult();
state().masterkeyFile = masterkeyFile.toCloudNode();
presenter().getView().showProgress(ProgressModel.GENERIC);
finish();
if(!masterkeyFile.getPath().equals("/masterkey.cryptomator") && !masterkeyFile.getPath().equals("/vault.cryptomator")) {
state().masterkeyFile = masterkeyFile.toCloudNode();
presenter().getView().showProgress(ProgressModel.GENERIC);
finish();
} else {
presenter().getView().showDialog(VaultIsRootFolderOfCloudDialog.Companion.newInstance());
}
}
@Override

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_vertical_margin">
<TextView
android:id="@+id/tv_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="@string/dialog_vault_is_root_folder_of_cloud_hint" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>

View File

@ -415,11 +415,12 @@
<string name="dialog_app_is_obscured_info_hint">Another app is displaying something on top of Cryptomator (e.g., a blue light filter or night mode app). For security reasons, Cryptomator is disabled.\n\n<a href="https://docs.cryptomator.org/en/1.5/android/settings/#block-app-when-obscured">How to enable Cryptomator</a></string>
<string name="dialog_app_is_obscured_info_neutral_button">Close</string>
<string name="dialog_vaults_removed_during_migration_title">Please re-add vaults for %1s cloud</string>
<string name="dialog_vaults_removed_during_migration_hint">While migrating to this app version we need to remove the following vaults from the app:\n%2s \n\nThose vaults aren\'t removed from the cloud but only from this app. Sorry for the inconvenience and please re-add these vaults to continue working with them.</string>
<string name="dialog_vaults_removed_during_migration_neutral_button" translatable="false">@string/dialog_unable_to_share_positive_button</string>
<string name="dialog_vault_is_root_folder_of_cloud_title">Vault is root folder of the cloud connection</string>
<string name="dialog_vault_is_root_folder_of_cloud_hint">Create a new cloud connection where you select at least the parent folder of this vault folder as the root directory to add this vault.</string>
<string name="dialog_disable_secure_screen_disclaimer_hint">This setting is a security feature and prevents other apps from tricking users into doing things they do not wan\'t to do.\n\nBy disabling, you confirm that you are <a href="https://docs.cryptomator.org/en/1.5/android/settings/#screen-security">aware of the risks</a>.</string>