Reformat code using new Kotlin formatting rule
This commit is contained in:
parent
bb07076ba8
commit
5c024dbda9
@ -88,7 +88,8 @@ public class CryptoCloudFactory {
|
||||
case MASTERKEY_SCHEME: {
|
||||
return new MasterkeyCryptoCloudProvider(cloudContentRepository, cryptoCloudContentRepositoryFactory, secureRandom);
|
||||
}
|
||||
default: throw new IllegalStateException(String.format("Provider with scheme %s not supported", unverifiedVaultConfigOptional.get().getKeyId().getScheme()));
|
||||
default:
|
||||
throw new IllegalStateException(String.format("Provider with scheme %s not supported", unverifiedVaultConfigOptional.get().getKeyId().getScheme()));
|
||||
}
|
||||
} else {
|
||||
return new MasterkeyCryptoCloudProvider(cloudContentRepository, cryptoCloudContentRepositoryFactory, secureRandom);
|
||||
|
@ -33,6 +33,30 @@ class S3ClientFactory {
|
||||
return new HttpLoggingInterceptor(message -> Timber.tag("OkHttp").d(message), context);
|
||||
}
|
||||
|
||||
private static Interceptor provideOfflineCacheInterceptor(final Context context) {
|
||||
return chain -> {
|
||||
Request request = chain.request();
|
||||
|
||||
if (isNetworkAvailable(context)) {
|
||||
final CacheControl cacheControl = new CacheControl.Builder() //
|
||||
.maxAge(0, TimeUnit.DAYS) //
|
||||
.build();
|
||||
|
||||
request = request.newBuilder() //
|
||||
.cacheControl(cacheControl) //
|
||||
.build();
|
||||
}
|
||||
|
||||
return chain.proceed(request);
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean isNetworkAvailable(final Context context) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
|
||||
public MinioClient getClient(S3Cloud cloud, Context context) {
|
||||
if (apiClient == null) {
|
||||
apiClient = createApiClient(cloud, context);
|
||||
@ -66,30 +90,6 @@ class S3ClientFactory {
|
||||
.build();
|
||||
}
|
||||
|
||||
private static Interceptor provideOfflineCacheInterceptor(final Context context) {
|
||||
return chain -> {
|
||||
Request request = chain.request();
|
||||
|
||||
if (isNetworkAvailable(context)) {
|
||||
final CacheControl cacheControl = new CacheControl.Builder() //
|
||||
.maxAge(0, TimeUnit.DAYS) //
|
||||
.build();
|
||||
|
||||
request = request.newBuilder() //
|
||||
.cacheControl(cacheControl) //
|
||||
.build();
|
||||
}
|
||||
|
||||
return chain.proceed(request);
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean isNetworkAvailable(final Context context) {
|
||||
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
|
||||
return activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
}
|
||||
|
||||
private String decrypt(String password, Context context) {
|
||||
return CredentialCryptor //
|
||||
.getInstance(context) //
|
||||
|
@ -1,14 +1,7 @@
|
||||
package org.cryptomator.data.cloud.s3;
|
||||
|
||||
public enum S3CloudApiErrorCodes {
|
||||
ACCESS_DENIED("AccessDenied"),
|
||||
ACCOUNT_PROBLEM("AccountProblem"),
|
||||
INTERNAL_ERROR("InternalError"),
|
||||
INVALID_ACCESS_KEY_ID("InvalidAccessKeyId"),
|
||||
INVALID_BUCKET_NAME("InvalidBucketName"),
|
||||
INVALID_OBJECT_STATE("InvalidObjectState"),
|
||||
NO_SUCH_BUCKET("NoSuchBucket"),
|
||||
NO_SUCH_KEY("NoSuchKey");
|
||||
ACCESS_DENIED("AccessDenied"), ACCOUNT_PROBLEM("AccountProblem"), INTERNAL_ERROR("InternalError"), INVALID_ACCESS_KEY_ID("InvalidAccessKeyId"), INVALID_BUCKET_NAME("InvalidBucketName"), INVALID_OBJECT_STATE("InvalidObjectState"), NO_SUCH_BUCKET("NoSuchBucket"), NO_SUCH_KEY("NoSuchKey");
|
||||
|
||||
private final String value;
|
||||
|
||||
|
@ -3,9 +3,7 @@ package org.cryptomator.data.cloud.s3;
|
||||
public class S3CloudApiExceptions {
|
||||
|
||||
public static boolean isAccessProblem(String errorCode) {
|
||||
return errorCode.equals(S3CloudApiErrorCodes.ACCESS_DENIED.getValue())
|
||||
|| errorCode.equals(S3CloudApiErrorCodes.ACCOUNT_PROBLEM.getValue())
|
||||
|| errorCode.equals(S3CloudApiErrorCodes.INVALID_ACCESS_KEY_ID.getValue());
|
||||
return errorCode.equals(S3CloudApiErrorCodes.ACCESS_DENIED.getValue()) || errorCode.equals(S3CloudApiErrorCodes.ACCOUNT_PROBLEM.getValue()) || errorCode.equals(S3CloudApiErrorCodes.INVALID_ACCESS_KEY_ID.getValue());
|
||||
}
|
||||
|
||||
public static boolean isNoSuchBucketException(String errorCode) {
|
||||
|
@ -26,8 +26,7 @@ public class UpdateCheckEntity extends DatabaseEntity {
|
||||
}
|
||||
|
||||
@Generated(hash = 67239496)
|
||||
public UpdateCheckEntity(Long id, String licenseToken, String releaseNote, String version, String urlToApk, String apkSha256,
|
||||
String urlToReleaseNote) {
|
||||
public UpdateCheckEntity(Long id, String licenseToken, String releaseNote, String version, String urlToApk, String apkSha256, String urlToReleaseNote) {
|
||||
this.id = id;
|
||||
this.licenseToken = licenseToken;
|
||||
this.releaseNote = releaseNote;
|
||||
|
@ -182,7 +182,9 @@ public class VaultEntity extends DatabaseEntity {
|
||||
this.position = position;
|
||||
}
|
||||
|
||||
/** called by internal mechanisms, do not call yourself. */
|
||||
/**
|
||||
* called by internal mechanisms, do not call yourself.
|
||||
*/
|
||||
@Generated(hash = 674742652)
|
||||
public void __setDaoSession(DaoSession daoSession) {
|
||||
this.daoSession = daoSession;
|
||||
|
@ -3,4 +3,5 @@ package org.cryptomator.domain.exception.vaultconfig;
|
||||
import org.cryptomator.domain.exception.BackendException;
|
||||
|
||||
public class VaultKeyInvalidException extends BackendException {
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ class ChangePassword {
|
||||
private final Vault vault;
|
||||
private final Optional<UnverifiedVaultConfig> unverifiedVaultConfig;
|
||||
private final String oldPassword;
|
||||
private final String newPassword;;
|
||||
private final String newPassword;
|
||||
;
|
||||
|
||||
public ChangePassword(CloudRepository cloudRepository, //
|
||||
@Parameter Vault vault, //
|
||||
|
@ -14,9 +14,8 @@ class UnlockVaultUsingMasterkey {
|
||||
|
||||
private final CloudRepository cloudRepository;
|
||||
private final VaultOrUnlockToken vaultOrUnlockToken;
|
||||
private Optional<UnverifiedVaultConfig> unverifiedVaultConfig;
|
||||
private final String password;
|
||||
|
||||
private Optional<UnverifiedVaultConfig> unverifiedVaultConfig;
|
||||
private volatile boolean cancelled;
|
||||
private final Flag cancelledFlag = new Flag() {
|
||||
@Override
|
||||
|
@ -67,7 +67,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
private val getCloudsUseCase: GetCloudsUseCase, //
|
||||
private val getUsernameUseCase: GetUsernameUseCase, //
|
||||
private val addExistingVaultWorkflow: AddExistingVaultWorkflow, //
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow) : Presenter<AuthenticateCloudView>(exceptionHandlers) {
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow
|
||||
) : Presenter<AuthenticateCloudView>(exceptionHandlers) {
|
||||
|
||||
private val strategies = arrayOf( //
|
||||
DropboxAuthStrategy(), //
|
||||
@ -182,7 +183,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
getUsernameAndSuceedAuthentication( //
|
||||
DropboxCloud.aCopyOf(cloudModel.toCloud() as DropboxCloud) //
|
||||
.withAccessToken(encrypt(authToken)) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -200,10 +202,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
fun onGoogleDriveAuthenticated(result: ActivityResult, cloud: CloudModel) {
|
||||
if (result.isResultOk) {
|
||||
val accountName = result.intent()?.extras?.getString(AccountManager.KEY_ACCOUNT_NAME)
|
||||
succeedAuthenticationWith(GoogleDriveCloud.aCopyOf(cloud.toCloud() as GoogleDriveCloud) //
|
||||
succeedAuthenticationWith(
|
||||
GoogleDriveCloud.aCopyOf(cloud.toCloud() as GoogleDriveCloud) //
|
||||
.withUsername(accountName) //
|
||||
.withAccessToken(accountName) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
failAuthentication(cloud.name())
|
||||
}
|
||||
@ -247,7 +251,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
getUsernameAndSuceedAuthentication( //
|
||||
OnedriveCloud.aCopyOf(cloud.toCloud() as OnedriveCloud) //
|
||||
.withAccessToken(accessToken) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -267,7 +272,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
Toast.makeText(
|
||||
context(),
|
||||
String.format(getString(R.string.error_authentication_failed_re_authenticate), intent.cloud().username()),
|
||||
Toast.LENGTH_LONG).show()
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
@ -286,9 +292,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
.setClientId(BuildConfig.PCLOUD_CLIENT_ID)
|
||||
.setForceAccessApproval(true)
|
||||
.addPermission("manageshares")
|
||||
.build())
|
||||
requestActivityResult(ActivityResultCallbacks.pCloudReAuthenticationFinished(), //
|
||||
authIntent)
|
||||
.build()
|
||||
)
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.pCloudReAuthenticationFinished(), //
|
||||
authIntent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,10 +347,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
(it as PCloud).username() == cloud.username()
|
||||
}?.let {
|
||||
it as PCloud
|
||||
succeedAuthenticationWith(PCloud.aCopyOf(it) //
|
||||
succeedAuthenticationWith(
|
||||
PCloud.aCopyOf(it) //
|
||||
.withUrl(cloud.url())
|
||||
.withAccessToken(cloud.accessToken())
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} ?: succeedAuthenticationWith(cloud)
|
||||
}
|
||||
})
|
||||
@ -394,9 +405,11 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
val webDavCloudWithAcceptedCert = WebDavCloud.aCopyOf(cloud) //
|
||||
.withCertificate(X509CertificateHelper.convertToPem(certificate)) //
|
||||
.build()
|
||||
finishWithResultAndExtra(cloudModelMapper.toModel(webDavCloudWithAcceptedCert), //
|
||||
finishWithResultAndExtra(
|
||||
cloudModelMapper.toModel(webDavCloudWithAcceptedCert), //
|
||||
WEBDAV_ACCEPTED_UNTRUSTED_CERTIFICATE, //
|
||||
true)
|
||||
true
|
||||
)
|
||||
} catch (e: CertificateEncodingException) {
|
||||
Timber.tag("AuthicateCloudPrester").e(e)
|
||||
throw FatalBackendException(e)
|
||||
@ -423,7 +436,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
Toast.makeText(
|
||||
context(),
|
||||
String.format(getString(R.string.error_authentication_failed), intent.cloud().username()),
|
||||
Toast.LENGTH_LONG).show()
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
@ -454,10 +468,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
|
||||
private fun startAuthentication(cloud: CloudModel) {
|
||||
authenticationStarted = true
|
||||
requestPermissions(PermissionsResultCallbacks.onLocalStorageAuthenticated(cloud), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.onLocalStorageAuthenticated(cloud), //
|
||||
R.string.permission_snackbar_auth_local_vault, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE, //
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,10 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".ui.activity.UnlockVaultActivity"
|
||||
android:theme="@style/TransparentAlertDialogCustom"
|
||||
android:label=""/>
|
||||
<activity
|
||||
android:name=".ui.activity.UnlockVaultActivity"
|
||||
android:label=""
|
||||
android:theme="@style/TransparentAlertDialogCustom" />
|
||||
<activity android:name=".ui.activity.EmptyDirIdFileInfoActivity" />
|
||||
|
||||
<!-- Settings -->
|
||||
|
@ -51,10 +51,12 @@ class CryptomatorApp : MultiDexApplication(), HasComponent<ApplicationComponent>
|
||||
}
|
||||
else -> "Google Play Edition"
|
||||
}
|
||||
Timber.tag("App").i("Cryptomator v%s (%d) \"%s\" started on android %s / API%d using a %s", //
|
||||
Timber.tag("App").i(
|
||||
"Cryptomator v%s (%d) \"%s\" started on android %s / API%d using a %s", //
|
||||
BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE, flavor, //
|
||||
Build.VERSION.RELEASE, Build.VERSION.SDK_INT, //
|
||||
Build.MODEL)
|
||||
Build.MODEL
|
||||
)
|
||||
Timber.tag("App").d("appId %s", BuildConfig.APPLICATION_ID)
|
||||
|
||||
launchServices()
|
||||
@ -108,7 +110,8 @@ class CryptomatorApp : MultiDexApplication(), HasComponent<ApplicationComponent>
|
||||
applicationComponent.cloudContentRepository(), //
|
||||
applicationComponent.fileUtil(), //
|
||||
applicationComponent.contentResolverUtil(), //
|
||||
Companion.applicationContext)
|
||||
Companion.applicationContext
|
||||
)
|
||||
}
|
||||
|
||||
override fun onServiceDisconnected(name: ComponentName) {
|
||||
|
@ -12,10 +12,7 @@ public interface UnlockVaultIntent {
|
||||
VaultAction vaultAction();
|
||||
|
||||
enum VaultAction {
|
||||
UNLOCK,
|
||||
UNLOCK_FOR_BIOMETRIC_AUTH,
|
||||
ENCRYPT_PASSWORD,
|
||||
CHANGE_PASSWORD
|
||||
UNLOCK, UNLOCK_FOR_BIOMETRIC_AUTH, ENCRYPT_PASSWORD, CHANGE_PASSWORD
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,38 +6,52 @@ import org.cryptomator.presentation.R
|
||||
enum class CloudTypeModel(builder: Builder) {
|
||||
|
||||
CRYPTO(Builder("CRYPTO", R.string.cloud_names_crypto)), //
|
||||
DROPBOX(Builder("DROPBOX", R.string.cloud_names_dropbox) //
|
||||
DROPBOX(
|
||||
Builder("DROPBOX", R.string.cloud_names_dropbox) //
|
||||
.withCloudImageResource(R.drawable.dropbox) //
|
||||
.withVaultImageResource(R.drawable.dropbox_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.dropbox_vault_selected)), //
|
||||
GOOGLE_DRIVE(Builder("GOOGLE_DRIVE", R.string.cloud_names_google_drive) //
|
||||
.withVaultSelectedImageResource(R.drawable.dropbox_vault_selected)
|
||||
), //
|
||||
GOOGLE_DRIVE(
|
||||
Builder("GOOGLE_DRIVE", R.string.cloud_names_google_drive) //
|
||||
.withCloudImageResource(R.drawable.google_drive) //
|
||||
.withVaultImageResource(R.drawable.google_drive_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.google_drive_vault_selected)), //
|
||||
ONEDRIVE(Builder("ONEDRIVE", R.string.cloud_names_onedrive) //
|
||||
.withVaultSelectedImageResource(R.drawable.google_drive_vault_selected)
|
||||
), //
|
||||
ONEDRIVE(
|
||||
Builder("ONEDRIVE", R.string.cloud_names_onedrive) //
|
||||
.withCloudImageResource(R.drawable.onedrive) //
|
||||
.withVaultImageResource(R.drawable.onedrive_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.onedrive_vault_selected)), //
|
||||
PCLOUD(Builder("PCLOUD", R.string.cloud_names_pcloud) //
|
||||
.withVaultSelectedImageResource(R.drawable.onedrive_vault_selected)
|
||||
), //
|
||||
PCLOUD(
|
||||
Builder("PCLOUD", R.string.cloud_names_pcloud) //
|
||||
.withCloudImageResource(R.drawable.pcloud) //
|
||||
.withVaultImageResource(R.drawable.pcloud_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.pcloud_vault_selected) //
|
||||
.withMultiInstances()), //
|
||||
WEBDAV(Builder("WEBDAV", R.string.cloud_names_webdav) //
|
||||
.withMultiInstances()
|
||||
), //
|
||||
WEBDAV(
|
||||
Builder("WEBDAV", R.string.cloud_names_webdav) //
|
||||
.withCloudImageResource(R.drawable.webdav) //
|
||||
.withVaultImageResource(R.drawable.webdav_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.webdav_vault_selected) //
|
||||
.withMultiInstances()), //
|
||||
S3(Builder("S3", R.string.cloud_names_s3) //
|
||||
.withMultiInstances()
|
||||
), //
|
||||
S3(
|
||||
Builder("S3", R.string.cloud_names_s3) //
|
||||
.withCloudImageResource(R.drawable.s3) //
|
||||
.withVaultImageResource(R.drawable.s3_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.s3_vault_selected) //
|
||||
.withMultiInstances()), //
|
||||
LOCAL(Builder("LOCAL", R.string.cloud_names_local_storage) //
|
||||
.withMultiInstances()
|
||||
), //
|
||||
LOCAL(
|
||||
Builder("LOCAL", R.string.cloud_names_local_storage) //
|
||||
.withCloudImageResource(R.drawable.local_fs) //
|
||||
.withVaultImageResource(R.drawable.local_fs_vault) //
|
||||
.withVaultSelectedImageResource(R.drawable.local_fs_vault_selected) //
|
||||
.withMultiInstances());
|
||||
.withMultiInstances()
|
||||
);
|
||||
|
||||
val cloudName: String = builder.cloudName
|
||||
val displayNameResource: Int = builder.displayNameResource
|
||||
|
@ -31,21 +31,29 @@ class ProgressStateModelMapper @Inject internal constructor(private val fileUtil
|
||||
|
||||
fun toModel(state: UploadState): ProgressStateModel {
|
||||
return if (state.isUpload) {
|
||||
FileProgressStateModel(state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.UPLOAD, ProgressStateModel.image(R.drawable.ic_file_upload),
|
||||
ProgressStateModel.text(R.string.dialog_progress_upload_file))
|
||||
FileProgressStateModel(
|
||||
state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.UPLOAD, ProgressStateModel.image(R.drawable.ic_file_upload),
|
||||
ProgressStateModel.text(R.string.dialog_progress_upload_file)
|
||||
)
|
||||
} else {
|
||||
FileProgressStateModel(state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.ENCRYPTION, ProgressStateModel.image(R.drawable.ic_lock_closed),
|
||||
ProgressStateModel.text(R.string.dialog_progress_encryption))
|
||||
FileProgressStateModel(
|
||||
state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.ENCRYPTION, ProgressStateModel.image(R.drawable.ic_lock_closed),
|
||||
ProgressStateModel.text(R.string.dialog_progress_encryption)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fun toModel(state: DownloadState): ProgressStateModel {
|
||||
return if (state.isDownload) {
|
||||
FileProgressStateModel(state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.DOWNLOAD, ProgressStateModel.image(R.drawable.ic_file_download),
|
||||
ProgressStateModel.text(R.string.dialog_progress_download_file))
|
||||
FileProgressStateModel(
|
||||
state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.DOWNLOAD, ProgressStateModel.image(R.drawable.ic_file_download),
|
||||
ProgressStateModel.text(R.string.dialog_progress_download_file)
|
||||
)
|
||||
} else {
|
||||
FileProgressStateModel(state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.DECRYPTION, ProgressStateModel.image(R.drawable.ic_lock_open),
|
||||
ProgressStateModel.text(R.string.dialog_progress_decryption))
|
||||
FileProgressStateModel(
|
||||
state.file(), FileIcon.fileIconFor(state.file().name, fileUtil), FileProgressStateModel.DECRYPTION, ProgressStateModel.image(R.drawable.ic_lock_open),
|
||||
ProgressStateModel.text(R.string.dialog_progress_decryption)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class AutoUploadChooseVaultPresenter @Inject constructor( //
|
||||
private val cloudFolderModelMapper: CloudFolderModelMapper, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler, //
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<AutoUploadChooseVaultView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<AutoUploadChooseVaultView>(exceptionMappings) {
|
||||
|
||||
private var selectedVault: VaultModel? = null
|
||||
private var location: CloudFolderModel? = null
|
||||
@ -80,7 +81,8 @@ class AutoUploadChooseVaultPresenter @Inject constructor( //
|
||||
if (!isPaused) {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.vaultUnlockedAutoUpload(), //
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(authenticatedVault)).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK))
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(authenticatedVault)).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,7 +97,6 @@ class AutoUploadChooseVaultPresenter @Inject constructor( //
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun decryptedCloudFor(vault: Vault) {
|
||||
getDecryptedCloudForVaultUseCase //
|
||||
.withVault(vault) //
|
||||
@ -108,7 +109,9 @@ class AutoUploadChooseVaultPresenter @Inject constructor( //
|
||||
if (!authenticationExceptionHandler.handleAuthenticationException( //
|
||||
this@AutoUploadChooseVaultPresenter, //
|
||||
e, //
|
||||
ActivityResultCallbacks.decryptedCloudForAfterAuthInAutoPhotoUpload(vault))) {
|
||||
ActivityResultCallbacks.decryptedCloudForAfterAuthInAutoPhotoUpload(vault)
|
||||
)
|
||||
) {
|
||||
super.onError(e)
|
||||
}
|
||||
}
|
||||
@ -149,7 +152,9 @@ class AutoUploadChooseVaultPresenter @Inject constructor( //
|
||||
.withExtraToolbarIcon(R.drawable.ic_clear) //
|
||||
.withButtonText(context().getString(R.string.screen_file_browser_share_button_text)) //
|
||||
.selectingFolders() //
|
||||
.build()))
|
||||
.build()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
|
@ -26,7 +26,8 @@ class BiometricAuthSettingsPresenter @Inject constructor( //
|
||||
private val saveVaultUseCase: SaveVaultUseCase, //
|
||||
private val lockVaultUseCase: LockVaultUseCase, //
|
||||
exceptionMappings: ExceptionHandlers, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler) : Presenter<BiometricAuthSettingsView>(exceptionMappings) {
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler
|
||||
) : Presenter<BiometricAuthSettingsView>(exceptionMappings) {
|
||||
|
||||
fun loadVaultList() {
|
||||
updateVaultListView()
|
||||
@ -56,7 +57,8 @@ class BiometricAuthSettingsPresenter @Inject constructor( //
|
||||
if (vaultModel.isLocked) {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.vaultUnlockedBiometricAuthPres(vaultModel), //
|
||||
Intents.unlockVaultIntent().withVaultModel(vaultModel).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK_FOR_BIOMETRIC_AUTH))
|
||||
Intents.unlockVaultIntent().withVaultModel(vaultModel).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK_FOR_BIOMETRIC_AUTH)
|
||||
)
|
||||
} else {
|
||||
lockVaultUseCase
|
||||
.withVault(vaultModel.toVault())
|
||||
@ -65,7 +67,8 @@ class BiometricAuthSettingsPresenter @Inject constructor( //
|
||||
super.onSuccess(vault)
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.vaultUnlockedBiometricAuthPres(vaultModel), //
|
||||
Intents.unlockVaultIntent().withVaultModel(vaultModel).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK_FOR_BIOMETRIC_AUTH))
|
||||
Intents.unlockVaultIntent().withVaultModel(vaultModel).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK_FOR_BIOMETRIC_AUTH)
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -79,7 +82,8 @@ class BiometricAuthSettingsPresenter @Inject constructor( //
|
||||
when {
|
||||
result.isResultOk -> requestActivityResult( //
|
||||
ActivityResultCallbacks.encryptVaultPassword(vaultModel), //
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(vault)).withVaultAction(UnlockVaultIntent.VaultAction.ENCRYPT_PASSWORD))
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(vault)).withVaultAction(UnlockVaultIntent.VaultAction.ENCRYPT_PASSWORD)
|
||||
)
|
||||
else -> TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
private val shareFileHelper: ShareFileHelper, //
|
||||
private val downloadFileUtil: DownloadFileUtil, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<BrowseFilesView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<BrowseFilesView>(exceptionMappings) {
|
||||
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler
|
||||
private lateinit var filesForUpload: MutableMap<String, UploadFile>
|
||||
@ -256,9 +257,14 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
}
|
||||
|
||||
private fun readFilesWithProgress(cloudFiles: List<CloudFileModel>, actionAfterDownload: String) {
|
||||
view?.showProgress(cloudFiles, //
|
||||
ProgressModel(progressStateModelMapper.toModel( //
|
||||
DownloadState.download(cloudFiles[0].toCloudNode())), 0))
|
||||
view?.showProgress(
|
||||
cloudFiles, //
|
||||
ProgressModel(
|
||||
progressStateModelMapper.toModel( //
|
||||
DownloadState.download(cloudFiles[0].toCloudNode())
|
||||
), 0
|
||||
)
|
||||
)
|
||||
downloadFilesUseCase //
|
||||
.withDownloadFiles(downloadFileUtil.createDownloadFilesFor(this, cloudFiles)) //
|
||||
.run(object : DefaultProgressAwareResultHandler<List<CloudFile>, DownloadState>() {
|
||||
@ -268,8 +274,10 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
|
||||
override fun onProgress(progress: Progress<DownloadState>) {
|
||||
if (!progress.isOverallComplete) {
|
||||
view?.showProgress(cloudFileModelMapper.toModel(progress.state().file()), //
|
||||
progressModelMapper.toModel(progress))
|
||||
view?.showProgress(
|
||||
cloudFileModelMapper.toModel(progress.state().file()), //
|
||||
progressModelMapper.toModel(progress)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -419,17 +427,23 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
private fun viewFile(cloudFile: CloudFileModel) {
|
||||
val lowerFileName = cloudFile.name.toLowerCase(Locale.getDefault())
|
||||
if (lowerFileName.endsWith(".txt") || lowerFileName.endsWith(".md") || lowerFileName.endsWith(".todo")) {
|
||||
startIntent(Intents.textEditorIntent() //
|
||||
.withTextFile(cloudFile))
|
||||
startIntent(
|
||||
Intents.textEditorIntent() //
|
||||
.withTextFile(cloudFile)
|
||||
)
|
||||
} else if (!lowerFileName.endsWith(".gif") && mimeTypes.fromFilename(cloudFile.name) //
|
||||
.orElse(MimeType.WILDCARD_MIME_TYPE) //
|
||||
.mediatype == "image") {
|
||||
.mediatype == "image"
|
||||
) {
|
||||
val cloudFileNodes = previewCloudFileNodes
|
||||
val imagePreviewStore = ImagePreviewFilesStore( //
|
||||
cloudFileNodes, //
|
||||
cloudFileNodes.indexOf(cloudFile))
|
||||
startIntent(Intents.imagePreviewIntent() //
|
||||
.withWithImagePreviewFiles(fileUtil.storeImagePreviewFiles(imagePreviewStore)))
|
||||
cloudFileNodes.indexOf(cloudFile)
|
||||
)
|
||||
startIntent(
|
||||
Intents.imagePreviewIntent() //
|
||||
.withWithImagePreviewFiles(fileUtil.storeImagePreviewFiles(imagePreviewStore))
|
||||
)
|
||||
} else {
|
||||
viewExternalFile(cloudFile)
|
||||
}
|
||||
@ -443,7 +457,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
openedCloudFileMd5 = calculateDigestFromUri(it)
|
||||
viewFileIntent.setDataAndType( //
|
||||
uriToOpenedFile, //
|
||||
mimeTypes.fromFilename(cloudFile.name).map(MimeType.TO_STRING).orElse(null))
|
||||
mimeTypes.fromFilename(cloudFile.name).map(MimeType.TO_STRING).orElse(null)
|
||||
)
|
||||
viewFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||
if (sharedPreferencesHandler.keepUnlockedWhileEditing()) {
|
||||
openWritableFileNotification = Optional.of(OpenWritableFileNotification(context(), it))
|
||||
@ -627,7 +642,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
|
||||
private fun replacingUploadFile(nodeName: String): UploadFile {
|
||||
return UploadFile.aCopyOf( //
|
||||
filesForUpload[nodeName]) //
|
||||
filesForUpload[nodeName]
|
||||
) //
|
||||
.thatIsReplacing(true) //
|
||||
.build()
|
||||
}
|
||||
@ -717,13 +733,15 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
try {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.pickedLocalStorageLocation(nodesToExport, exportOperation), //
|
||||
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE))
|
||||
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
)
|
||||
} catch (exception: ActivityNotFoundException) {
|
||||
Toast //
|
||||
.makeText( //
|
||||
activity().applicationContext, //
|
||||
context().getText(R.string.screen_cloud_local_error_no_content_provider), //
|
||||
Toast.LENGTH_SHORT) //
|
||||
Toast.LENGTH_SHORT
|
||||
) //
|
||||
.show()
|
||||
Timber.tag("BrowseFilesPresenter").e(exception, "Export file: No ContentProvider on system")
|
||||
}
|
||||
@ -731,23 +749,31 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
|
||||
@Callback
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
fun pickedLocalStorageLocation(result: ActivityResult, //
|
||||
fun pickedLocalStorageLocation(
|
||||
result: ActivityResult, //
|
||||
nodesToExport: ArrayList<CloudNodeModel<*>>, //
|
||||
exportOperation: ExportOperation) {
|
||||
exportOperation: ExportOperation
|
||||
) {
|
||||
val pickedLocalStorageLocation = DocumentsContract.buildChildDocumentsUriUsingTree( //
|
||||
Uri.parse(result.intent().data.toString()), //
|
||||
DocumentsContract.getTreeDocumentId( //
|
||||
Uri.parse(result.intent().data.toString())))
|
||||
collectNodesToExport(pickedLocalStorageLocation, //
|
||||
Uri.parse(result.intent().data.toString())
|
||||
)
|
||||
)
|
||||
collectNodesToExport(
|
||||
pickedLocalStorageLocation, //
|
||||
exportOperation, //
|
||||
nodesToExport)
|
||||
nodesToExport
|
||||
)
|
||||
disableSelectionMode()
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private fun collectNodesToExport(parentUri: Uri, //
|
||||
private fun collectNodesToExport(
|
||||
parentUri: Uri, //
|
||||
exportOperation: ExportOperation, //
|
||||
nodesToExport: List<CloudNodeModel<*>>) {
|
||||
nodesToExport: List<CloudNodeModel<*>>
|
||||
) {
|
||||
val filesToExport: MutableList<CloudFileModel> = ArrayList()
|
||||
val foldersForRecursiveDirListing: MutableList<CloudFolderModel> = ArrayList()
|
||||
nodesToExport.forEach { node ->
|
||||
@ -761,8 +787,10 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
private fun collectFolderContentForExport(parentUri: Uri, exportOperation: ExportOperation, folders: List<CloudFolderModel>, //
|
||||
filesToExport: List<CloudFileModel>) {
|
||||
private fun collectFolderContentForExport(
|
||||
parentUri: Uri, exportOperation: ExportOperation, folders: List<CloudFolderModel>, //
|
||||
filesToExport: List<CloudFileModel>
|
||||
) {
|
||||
view?.showProgress(ProgressModel.GENERIC)
|
||||
getCloudListRecursiveUseCase //
|
||||
.withFolders(cloudFolderModelMapper.fromModels(folders)) //
|
||||
@ -815,7 +843,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
context().contentResolver, //
|
||||
parentUri, //
|
||||
DocumentsContract.Document.MIME_TYPE_DIR, //
|
||||
folderName)
|
||||
folderName
|
||||
)
|
||||
} catch (e: FileNotFoundException) {
|
||||
Timber.tag("BrowseFilesPresenter").e(e)
|
||||
throw IllegalStateException("Creating folder failed")
|
||||
@ -827,8 +856,11 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
return try {
|
||||
DownloadFile.Builder() //
|
||||
.setDownloadFile(file) //
|
||||
.setDataSink(contentResolverUtil.openOutputStream( //
|
||||
createNewDocumentUri(documentUri, file.name))) //
|
||||
.setDataSink(
|
||||
contentResolverUtil.openOutputStream( //
|
||||
createNewDocumentUri(documentUri, file.name)
|
||||
)
|
||||
) //
|
||||
.build()
|
||||
} catch (e: FileNotFoundException) {
|
||||
showError(e)
|
||||
@ -855,7 +887,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
context().contentResolver, //
|
||||
parentUri, //
|
||||
mimeType.toString(), //
|
||||
fileName)
|
||||
fileName
|
||||
)
|
||||
} catch (e: FileNotFoundException) {
|
||||
throw NoSuchCloudFileException(fileName)
|
||||
} ?: throw IllegalFileNameException()
|
||||
@ -863,9 +896,11 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
|
||||
@Callback
|
||||
fun exportFileToUserSelectedLocation(result: ActivityResult, fileToExport: CloudFileModel, exportOperation: ExportOperation) {
|
||||
requestPermissions(PermissionsResultCallbacks.exportFileToUserSelectedLocation(result.intent().dataString, fileToExport, exportOperation), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.exportFileToUserSelectedLocation(result.intent().dataString, fileToExport, exportOperation), //
|
||||
R.string.permission_message_export_file, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
@ -885,9 +920,11 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
|
||||
fun onUploadFilesClicked(folder: CloudFolderModel) {
|
||||
uploadLocation = folder
|
||||
requestPermissions(PermissionsResultCallbacks.selectFiles(), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.selectFiles(), //
|
||||
R.string.permission_message_upload_file, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
|
||||
fun onUploadCanceled() {
|
||||
@ -937,7 +974,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
.withExtraToolbarIcon(R.drawable.ic_clear) //
|
||||
.selectingFoldersNotContaining(sourceNodes.map { node -> node.name }) //
|
||||
.excludingFolder(if (foldersToMove.isEmpty()) null else foldersToMove) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
|
||||
private fun effectiveMoveTitle(): String {
|
||||
@ -961,8 +999,10 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
}
|
||||
|
||||
fun onMoveNodesClicked(parent: CloudFolderModel, nodesToMove: ArrayList<CloudNodeModel<*>>) {
|
||||
requestActivityResult(ActivityResultCallbacks.moveNodes(nodesToMove), //
|
||||
moveIntentFor(parent, nodesToMove))
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.moveNodes(nodesToMove), //
|
||||
moveIntentFor(parent, nodesToMove)
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
@ -987,10 +1027,13 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
val decryptData = downloadFileUtil.createDecryptedDataFor(this, textFile)
|
||||
downloadFilesUseCase //
|
||||
.withDownloadFiles( //
|
||||
listOf(DownloadFile.Builder() //
|
||||
listOf(
|
||||
DownloadFile.Builder() //
|
||||
.setDownloadFile(textFile.toCloudNode()) //
|
||||
.setDataSink(decryptData) //
|
||||
.build())) //
|
||||
.build()
|
||||
)
|
||||
) //
|
||||
.run(object : DefaultProgressAwareResultHandler<List<CloudFile>, DownloadState>() {
|
||||
override fun onProgress(progress: Progress<DownloadState>) {
|
||||
if (!newlyCreated) {
|
||||
@ -1003,8 +1046,10 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
view?.hideProgress(textFile)
|
||||
}
|
||||
if (internalEditor) {
|
||||
startIntent(Intents.textEditorIntent() //
|
||||
.withTextFile(textFile))
|
||||
startIntent(
|
||||
Intents.textEditorIntent() //
|
||||
.withTextFile(textFile)
|
||||
)
|
||||
} else {
|
||||
viewExternalFile(textFile)
|
||||
}
|
||||
@ -1105,7 +1150,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
try {
|
||||
val hashAfterEdit = calculateDigestFromUri(it)
|
||||
if (hashAfterEdit.isPresent && openedCloudFileMd5.isPresent //
|
||||
&& Arrays.equals(hashAfterEdit.get(), openedCloudFileMd5.get())) {
|
||||
&& Arrays.equals(hashAfterEdit.get(), openedCloudFileMd5.get())
|
||||
) {
|
||||
Timber.tag("BrowseFilesPresenter").i("Opened app finished, file not changed")
|
||||
} else {
|
||||
uploadChangedFile()
|
||||
@ -1224,7 +1270,8 @@ class BrowseFilesPresenter @Inject constructor( //
|
||||
renameFolderUseCase, //
|
||||
copyDataUseCase, //
|
||||
moveFilesUseCase, //
|
||||
moveFoldersUseCase)
|
||||
moveFoldersUseCase
|
||||
)
|
||||
this.authenticationExceptionHandler = authenticationExceptionHandler
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ class ChooseCloudServicePresenter @Inject constructor( //
|
||||
private val cloudModelMapper: CloudModelMapper, //
|
||||
private val addExistingVaultWorkflow: AddExistingVaultWorkflow, //
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<ChooseCloudServiceView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<ChooseCloudServiceView>(exceptionMappings) {
|
||||
|
||||
override fun workflows(): Iterable<Workflow<*>> {
|
||||
return listOf(addExistingVaultWorkflow, createNewVaultWorkflow)
|
||||
@ -59,7 +60,8 @@ class ChooseCloudServicePresenter @Inject constructor( //
|
||||
Intents.cloudConnectionListIntent() //
|
||||
.withCloudType(cloudTypeModel) //
|
||||
.withDialogTitle(context().getString(R.string.screen_cloud_connections_title)) //
|
||||
.withFinishOnCloudItemClick(true))
|
||||
.withFinishOnCloudItemClick(true)
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
|
@ -49,7 +49,8 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
private val getVaultListUseCase: GetVaultListUseCase, //
|
||||
private val deleteVaultUseCase: DeleteVaultUseCase, //
|
||||
private val cloudModelMapper: CloudModelMapper, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<CloudConnectionListView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<CloudConnectionListView>(exceptionMappings) {
|
||||
|
||||
private val selectedCloudType = AtomicReference<CloudTypeModel>()
|
||||
private var defaultLocalStorageCloud: LocalStorageCloud? = null
|
||||
@ -130,8 +131,10 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
|
||||
fun onAddConnectionClicked() {
|
||||
when (selectedCloudType.get()) {
|
||||
CloudTypeModel.WEBDAV -> requestActivityResult(ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.webDavAddOrChangeIntent())
|
||||
CloudTypeModel.WEBDAV -> requestActivityResult(
|
||||
ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.webDavAddOrChangeIntent()
|
||||
)
|
||||
CloudTypeModel.PCLOUD -> {
|
||||
val authIntent: Intent = AuthorizationActivity.createIntent(
|
||||
this.context(),
|
||||
@ -140,12 +143,17 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
.setClientId(BuildConfig.PCLOUD_CLIENT_ID)
|
||||
.setForceAccessApproval(true)
|
||||
.addPermission("manageshares")
|
||||
.build())
|
||||
requestActivityResult(ActivityResultCallbacks.pCloudAuthenticationFinished(), //
|
||||
authIntent)
|
||||
.build()
|
||||
)
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.pCloudAuthenticationFinished(), //
|
||||
authIntent
|
||||
)
|
||||
}
|
||||
CloudTypeModel.S3 -> requestActivityResult(ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.s3AddOrChangeIntent())
|
||||
CloudTypeModel.S3 -> requestActivityResult(
|
||||
ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.s3AddOrChangeIntent()
|
||||
)
|
||||
CloudTypeModel.LOCAL -> openDocumentTree()
|
||||
}
|
||||
}
|
||||
@ -155,13 +163,15 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
try {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.pickedLocalStorageLocation(), //
|
||||
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE))
|
||||
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)
|
||||
)
|
||||
} catch (exception: ActivityNotFoundException) {
|
||||
Toast //
|
||||
.makeText( //
|
||||
activity().applicationContext, //
|
||||
context().getText(R.string.screen_cloud_local_error_no_content_provider), //
|
||||
Toast.LENGTH_SHORT) //
|
||||
Toast.LENGTH_SHORT
|
||||
) //
|
||||
.show()
|
||||
Timber.tag("CloudConnListPresenter").e(exception, "No ContentProvider on system")
|
||||
}
|
||||
@ -170,14 +180,18 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
fun onChangeCloudClicked(cloudModel: CloudModel) {
|
||||
when {
|
||||
cloudModel.cloudType() == CloudTypeModel.WEBDAV -> {
|
||||
requestActivityResult(ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.webDavAddOrChangeIntent() //
|
||||
.withWebDavCloud(cloudModel as WebDavCloudModel))
|
||||
.withWebDavCloud(cloudModel as WebDavCloudModel)
|
||||
)
|
||||
}
|
||||
cloudModel.cloudType() == CloudTypeModel.S3 -> {
|
||||
requestActivityResult(ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.addChangeMultiCloud(), //
|
||||
Intents.s3AddOrChangeIntent() //
|
||||
.withS3Cloud(cloudModel as S3CloudModel))
|
||||
.withS3Cloud(cloudModel as S3CloudModel)
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
throw IllegalStateException("Change cloud with type " + cloudModel.cloudType() + " is not supported")
|
||||
@ -240,10 +254,12 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
(it as PCloud).username() == cloud.username()
|
||||
}?.let {
|
||||
it as PCloud
|
||||
saveCloud(PCloud.aCopyOf(it) //
|
||||
saveCloud(
|
||||
PCloud.aCopyOf(it) //
|
||||
.withUrl(cloud.url())
|
||||
.withAccessToken(cloud.accessToken())
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} ?: saveCloud(cloud)
|
||||
}
|
||||
})
|
||||
@ -264,9 +280,11 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
fun pickedLocalStorageLocation(result: ActivityResult) {
|
||||
val rootTreeUriOfLocalStorage = result.intent().data
|
||||
persistUriPermission(rootTreeUriOfLocalStorage)
|
||||
addOrChangeCloudConnectionUseCase.withCloud(LocalStorageCloud.aLocalStorage() //
|
||||
addOrChangeCloudConnectionUseCase.withCloud(
|
||||
LocalStorageCloud.aLocalStorage() //
|
||||
.withRootUri(rootTreeUriOfLocalStorage.toString()) //
|
||||
.build()) //
|
||||
.build()
|
||||
) //
|
||||
.run(object : DefaultResultHandler<Void?>() {
|
||||
override fun onSuccess(void: Void?) {
|
||||
loadCloudList()
|
||||
@ -281,7 +299,8 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
.contentResolver //
|
||||
.takePersistableUriPermission( //
|
||||
it, //
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -291,7 +310,8 @@ class CloudConnectionListPresenter @Inject constructor( //
|
||||
.contentResolver //
|
||||
.releasePersistableUriPermission( //
|
||||
Uri.parse(uri), //
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
||||
Intent.FLAG_GRANT_READ_URI_PERMISSION or Intent.FLAG_GRANT_WRITE_URI_PERMISSION
|
||||
)
|
||||
}
|
||||
|
||||
fun onCloudConnectionClicked(cloudModel: CloudModel) {
|
||||
|
@ -33,14 +33,16 @@ class CloudSettingsPresenter @Inject constructor( //
|
||||
private val getCloudsUseCase: GetCloudsUseCase, //
|
||||
private val logoutCloudUsecase: LogoutCloudUseCase, //
|
||||
private val cloudModelMapper: CloudModelMapper, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<CloudSettingsView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<CloudSettingsView>(exceptionMappings) {
|
||||
|
||||
private val nonSingleLoginClouds: Set<CloudTypeModel> = EnumSet.of( //
|
||||
CloudTypeModel.CRYPTO, //
|
||||
CloudTypeModel.LOCAL, //
|
||||
CloudTypeModel.PCLOUD, //
|
||||
CloudTypeModel.S3, //
|
||||
CloudTypeModel.WEBDAV)
|
||||
CloudTypeModel.WEBDAV
|
||||
)
|
||||
|
||||
fun loadClouds() {
|
||||
getAllCloudsUseCase.run(CloudsSubscriber())
|
||||
@ -87,7 +89,8 @@ class CloudSettingsPresenter @Inject constructor( //
|
||||
Intents.cloudConnectionListIntent() //
|
||||
.withCloudType(cloudTypeModel) //
|
||||
.withDialogTitle(effectiveTitle(cloudTypeModel)) //
|
||||
.withFinishOnCloudItemClick(false))
|
||||
.withFinishOnCloudItemClick(false)
|
||||
)
|
||||
}
|
||||
|
||||
private fun effectiveTitle(cloudTypeModel: CloudTypeModel): String {
|
||||
@ -110,7 +113,8 @@ class CloudSettingsPresenter @Inject constructor( //
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.onCloudAuthenticated(), //
|
||||
Intents.authenticateCloudIntent() //
|
||||
.withCloud(cloudModelMapper.toModel(cloud)))
|
||||
.withCloud(cloudModelMapper.toModel(cloud))
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
|
@ -12,7 +12,8 @@ import javax.inject.Inject
|
||||
@PerView
|
||||
class CreateVaultPresenter @Inject constructor( //
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<CreateVaultView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<CreateVaultView>(exceptionMappings) {
|
||||
|
||||
override fun workflows(): Iterable<Workflow<*>> {
|
||||
return setOf(createNewVaultWorkflow)
|
||||
|
@ -50,7 +50,8 @@ class ImagePreviewPresenter @Inject constructor( //
|
||||
private val deleteNodesUseCase: DeleteNodesUseCase, //
|
||||
private val downloadFileUtil: DownloadFileUtil, //
|
||||
private val fileUtil: FileUtil, //
|
||||
private val cloudFileModelMapper: CloudFileModelMapper) : Presenter<ImagePreviewView>(exceptionMappings) {
|
||||
private val cloudFileModelMapper: CloudFileModelMapper
|
||||
) : Presenter<ImagePreviewView>(exceptionMappings) {
|
||||
|
||||
private var isSystemUiVisible = true
|
||||
|
||||
@ -66,8 +67,10 @@ class ImagePreviewPresenter @Inject constructor( //
|
||||
}
|
||||
|
||||
private fun copyFileToDownloadDirectory(uri: Uri) {
|
||||
requestPermissions(PermissionsResultCallbacks.copyFileToDownloadDirectory(uri.toString()), //
|
||||
R.string.permission_message_export_file, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.copyFileToDownloadDirectory(uri.toString()), //
|
||||
R.string.permission_message_export_file, Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
@ -114,17 +117,21 @@ class ImagePreviewPresenter @Inject constructor( //
|
||||
|
||||
@Callback
|
||||
fun copyFileToUserSelectedLocation(result: ActivityResult, sourceUri: String?) {
|
||||
requestPermissions(PermissionsResultCallbacks.copyFileToUserSelectedLocation(result.intent()?.dataString, sourceUri), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.copyFileToUserSelectedLocation(result.intent()?.dataString, sourceUri), //
|
||||
R.string.permission_message_export_file, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
fun copyFileToUserSelectedLocation(result: PermissionsResult, targetUri: String?, sourceUri: String?) {
|
||||
if (result.granted()) {
|
||||
try {
|
||||
copyFile(contentResolverUtil.openInputStream(Uri.parse(sourceUri)), //
|
||||
contentResolverUtil.openOutputStream(Uri.parse(targetUri)))
|
||||
copyFile(
|
||||
contentResolverUtil.openInputStream(Uri.parse(sourceUri)), //
|
||||
contentResolverUtil.openOutputStream(Uri.parse(targetUri))
|
||||
)
|
||||
} catch (e: FileNotFoundException) {
|
||||
showError(e)
|
||||
}
|
||||
|
@ -13,7 +13,8 @@ import timber.log.Timber
|
||||
class LicenseCheckPresenter @Inject internal constructor(
|
||||
exceptionHandlers: ExceptionHandlers, //
|
||||
private val doLicenseCheckUsecase: DoLicenseCheckUseCase, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler) : Presenter<UpdateLicenseView>(exceptionHandlers) {
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler
|
||||
) : Presenter<UpdateLicenseView>(exceptionHandlers) {
|
||||
|
||||
fun validate(data: Uri?) {
|
||||
data?.let {
|
||||
|
@ -18,7 +18,8 @@ import javax.inject.Inject
|
||||
class S3AddOrChangePresenter @Inject internal constructor( //
|
||||
private val addOrChangeCloudConnectionUseCase: AddOrChangeCloudConnectionUseCase, //
|
||||
private val connectToS3UseCase: ConnectToS3UseCase, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<S3AddOrChangeView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<S3AddOrChangeView>(exceptionMappings) {
|
||||
|
||||
fun checkUserInput(accessKey: String, secretKey: String, bucket: String, endpoint: String?, region: String?, cloudId: Long?, displayName: String) {
|
||||
var statusMessage: String? = null
|
||||
|
@ -11,7 +11,8 @@ import javax.inject.Inject
|
||||
@PerView
|
||||
class SetPasswordPresenter @Inject constructor( //
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<SetPasswordView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<SetPasswordView>(exceptionMappings) {
|
||||
|
||||
override fun workflows(): Iterable<Workflow<*>> {
|
||||
return setOf(createNewVaultWorkflow)
|
||||
|
@ -44,7 +44,8 @@ class SettingsPresenter @Inject internal constructor(
|
||||
private val networkConnectionCheck: NetworkConnectionCheck, //
|
||||
exceptionMappings: ExceptionHandlers, //
|
||||
private val fileUtil: FileUtil, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler) : Presenter<SettingsView>(exceptionMappings) {
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler
|
||||
) : Presenter<SettingsView>(exceptionMappings) {
|
||||
|
||||
fun onSendErrorReportClicked() {
|
||||
view?.showProgress(ProgressModel.GENERIC)
|
||||
@ -86,10 +87,12 @@ class SettingsPresenter @Inject internal constructor(
|
||||
}
|
||||
|
||||
fun grantLocalStoragePermissionForAutoUpload() {
|
||||
requestPermissions(PermissionsResultCallbacks.onLocalStoragePermissionGranted(), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.onLocalStoragePermissionGranted(), //
|
||||
R.string.permission_snackbar_auth_auto_upload, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE, //
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
|
@ -42,7 +42,8 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler, //
|
||||
private val cloudFolderModelMapper: CloudFolderModelMapper, //
|
||||
private val progressModelMapper: ProgressModelMapper, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<SharedFilesView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<SharedFilesView>(exceptionMappings) {
|
||||
|
||||
private val filesForUpload: MutableSet<UploadFile> = HashSet()
|
||||
private val existingFilesForUpload: MutableSet<UploadFile> = HashSet()
|
||||
@ -129,7 +130,8 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
if (!isPaused) {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.vaultUnlockedSharedFiles(), //
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(authenticatedVault)).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK))
|
||||
Intents.unlockVaultIntent().withVaultModel(VaultModel(authenticatedVault)).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -192,9 +194,11 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
this.location = location
|
||||
}
|
||||
|
||||
private fun uploadFiles(nonReplacing: Set<UploadFile>, //
|
||||
private fun uploadFiles(
|
||||
nonReplacing: Set<UploadFile>, //
|
||||
replacing: Set<UploadFile>, //
|
||||
folder: CloudFolder) {
|
||||
folder: CloudFolder
|
||||
) {
|
||||
if (nonReplacing.size + replacing.size == 0) {
|
||||
view?.finish()
|
||||
}
|
||||
@ -266,7 +270,8 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
existingFilesForUpload.add( //
|
||||
UploadFile.aCopyOf(uploadFileWithName.get()) //
|
||||
.thatIsReplacing(true) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
// remove file when name is used by a folder
|
||||
filesForUpload.remove(uploadFileWithName.get())
|
||||
@ -310,9 +315,11 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
view?.showMessage(R.string.error_names_contains_invalid_characters)
|
||||
}
|
||||
else -> {
|
||||
requestPermissions(PermissionsResultCallbacks.saveFilesPermissionCallback(), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.saveFilesPermissionCallback(), //
|
||||
R.string.permission_message_share_file, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -345,7 +352,9 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
.withExtraToolbarIcon(R.drawable.ic_clear) //
|
||||
.withButtonText(context().getString(R.string.screen_file_browser_share_button_text)) //
|
||||
.selectingFolders() //
|
||||
.build()))
|
||||
.build()
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Callback
|
||||
@ -408,6 +417,7 @@ class SharedFilesPresenter @Inject constructor( //
|
||||
getVaultListUseCase, //
|
||||
getDecryptedCloudForVaultUseCase, //
|
||||
uploadFilesUseCase, //
|
||||
getCloudListUseCase)
|
||||
getCloudListUseCase
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,8 @@ class TextEditorPresenter @Inject constructor( //
|
||||
private val fileUtil: FileUtil, //
|
||||
private val contentResolverUtil: ContentResolverUtil, //
|
||||
private val uploadFilesUseCase: UploadFilesUseCase, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<TextEditorView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<TextEditorView>(exceptionMappings) {
|
||||
|
||||
private val textFile = AtomicReference<CloudFileModel>()
|
||||
|
||||
@ -73,13 +74,15 @@ class TextEditorPresenter @Inject constructor( //
|
||||
private fun uploadFile(fileName: String, dataSource: DataSource) {
|
||||
uploadFilesUseCase //
|
||||
.withParent(textFile.get().parent.toCloudNode()) //
|
||||
.andFiles(listOf( //
|
||||
.andFiles(
|
||||
listOf( //
|
||||
UploadFile.anUploadFile() //
|
||||
.withFileName(fileName) //
|
||||
.withDataSource(dataSource) //
|
||||
.thatIsReplacing(true) //
|
||||
.build() //
|
||||
)) //
|
||||
)
|
||||
) //
|
||||
.run(object : DefaultProgressAwareResultHandler<List<CloudFile?>, UploadState>() {
|
||||
override fun onFinished() {
|
||||
view?.showProgress(ProgressModel.COMPLETED)
|
||||
|
@ -50,7 +50,8 @@ class UnlockVaultPresenter @Inject constructor(
|
||||
private val saveVaultUseCase: SaveVaultUseCase,
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler,
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler,
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<UnlockVaultView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<UnlockVaultView>(exceptionMappings) {
|
||||
|
||||
private var startedUsingPrepareUnlock = false
|
||||
private var retryUnlockHandler: Handler? = null
|
||||
@ -317,10 +318,13 @@ class UnlockVaultPresenter @Inject constructor(
|
||||
view?.showProgress(ProgressModel.COMPLETED)
|
||||
view?.showMessage(R.string.screen_vault_list_change_password_successful)
|
||||
if (canUseBiometricOn(vaultModel)) {
|
||||
view?.getEncryptedPasswordWithBiometricAuthentication(VaultModel( //
|
||||
view?.getEncryptedPasswordWithBiometricAuthentication(
|
||||
VaultModel( //
|
||||
Vault.aCopyOf(vaultModel.toVault()) //
|
||||
.withSavedPassword(newPassword) //
|
||||
.build()))
|
||||
.build()
|
||||
)
|
||||
)
|
||||
} else {
|
||||
finishWithResult(vaultModel)
|
||||
}
|
||||
@ -329,7 +333,9 @@ class UnlockVaultPresenter @Inject constructor(
|
||||
override fun onError(e: Throwable) {
|
||||
if (!authenticationExceptionHandler.handleAuthenticationException( //
|
||||
this@UnlockVaultPresenter, e, //
|
||||
ActivityResultCallbacks.changePasswordAfterAuthentication(vaultModel.toVault(), unverifiedVaultConfig, oldPassword, newPassword))) {
|
||||
ActivityResultCallbacks.changePasswordAfterAuthentication(vaultModel.toVault(), unverifiedVaultConfig, oldPassword, newPassword)
|
||||
)
|
||||
) {
|
||||
showError(e)
|
||||
}
|
||||
}
|
||||
@ -417,7 +423,8 @@ class UnlockVaultPresenter @Inject constructor(
|
||||
unlockVaultUsingMasterkeyUseCase, //
|
||||
prepareUnlockUseCase, //
|
||||
removeStoredVaultPasswordsUseCase, //
|
||||
saveVaultUseCase)
|
||||
saveVaultUseCase
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ class VaultListPresenter @Inject constructor( //
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler, //
|
||||
private val cloudFolderModelMapper: CloudFolderModelMapper, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<VaultListView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<VaultListView>(exceptionMappings) {
|
||||
|
||||
private var vaultAction: VaultAction? = null
|
||||
|
||||
@ -214,7 +215,9 @@ class VaultListPresenter @Inject constructor( //
|
||||
override fun onError(e: Throwable) {
|
||||
if (!authenticationExceptionHandler.handleAuthenticationException( //
|
||||
this@VaultListPresenter, e, //
|
||||
ActivityResultCallbacks.renameVaultAfterAuthentication(vaultModel.toVault(), newVaultName))) {
|
||||
ActivityResultCallbacks.renameVaultAfterAuthentication(vaultModel.toVault(), newVaultName)
|
||||
)
|
||||
) {
|
||||
showError(e)
|
||||
}
|
||||
}
|
||||
@ -314,7 +317,8 @@ class VaultListPresenter @Inject constructor( //
|
||||
Intents.cloudConnectionListIntent() //
|
||||
.withCloudType(vault.cloudType) //
|
||||
.withDialogTitle(context().getString(R.string.screen_cloud_connections_title)) //
|
||||
.withFinishOnCloudItemClick(true))
|
||||
.withFinishOnCloudItemClick(true)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +357,8 @@ class VaultListPresenter @Inject constructor( //
|
||||
if (!isPaused) {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.vaultUnlockedVaultList(), //
|
||||
Intents.unlockVaultIntent().withVaultModel(authenticatedVault).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK))
|
||||
Intents.unlockVaultIntent().withVaultModel(authenticatedVault).withVaultAction(UnlockVaultIntent.VaultAction.UNLOCK)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
browseFilesOf(authenticatedVault)
|
||||
@ -495,6 +500,7 @@ class VaultListPresenter @Inject constructor( //
|
||||
moveVaultPositionUseCase, //
|
||||
licenseCheckUseCase, //
|
||||
updateCheckUseCase, //
|
||||
updateUseCase)
|
||||
updateUseCase
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,8 @@ class WebDavAddOrChangePresenter @Inject internal constructor( //
|
||||
private val addOrChangeCloudConnectionUseCase: AddOrChangeCloudConnectionUseCase, //
|
||||
private val connectToWebDavUseCase: ConnectToWebDavUseCase, //
|
||||
private val authenticationExceptionHandler: AuthenticationExceptionHandler, //
|
||||
exceptionMappings: ExceptionHandlers) : Presenter<WebDavAddOrChangeView>(exceptionMappings) {
|
||||
exceptionMappings: ExceptionHandlers
|
||||
) : Presenter<WebDavAddOrChangeView>(exceptionMappings) {
|
||||
|
||||
fun checkUserInput(urlPort: String, username: String, password: String, cloudId: Long?, certificate: String?) {
|
||||
var statusMessage: String? = null
|
||||
|
@ -31,7 +31,8 @@ class AutoUploadNotification(private val context: Context, private val amountOfP
|
||||
val notificationChannel = NotificationChannel( //
|
||||
NOTIFICATION_CHANNEL_ID, //
|
||||
NOTIFICATION_CHANNEL_NAME, //
|
||||
IMPORTANCE_LOW)
|
||||
IMPORTANCE_LOW
|
||||
)
|
||||
notificationManager?.createNotificationChannel(notificationChannel)
|
||||
}
|
||||
|
||||
@ -68,9 +69,12 @@ class AutoUploadNotification(private val context: Context, private val amountOfP
|
||||
builder.setContentIntent(startTheActivity())
|
||||
builder //
|
||||
.setContentText( //
|
||||
String.format(context.getString(R.string.notification_auto_upload_message), //
|
||||
String.format(
|
||||
context.getString(R.string.notification_auto_upload_message), //
|
||||
alreadyUploadedPictures + 1, //
|
||||
amountOfPictures)) //
|
||||
amountOfPictures
|
||||
)
|
||||
) //
|
||||
.setProgress(100, progress, false)
|
||||
show()
|
||||
}
|
||||
|
@ -28,7 +28,8 @@ class OpenWritableFileNotification(private val context: Context, private val uri
|
||||
val notificationChannel = NotificationChannel( //
|
||||
NOTIFICATION_CHANNEL_ID, //
|
||||
NOTIFICATION_CHANNEL_NAME, //
|
||||
IMPORTANCE_LOW)
|
||||
IMPORTANCE_LOW
|
||||
)
|
||||
notificationManager?.createNotificationChannel(notificationChannel)
|
||||
}
|
||||
|
||||
|
@ -75,12 +75,16 @@ class PhotoContentJob : JobService() {
|
||||
private fun getContentResolvers(ids: Set<String>): Array<Cursor?> {
|
||||
val selection = buildSelection(ids)
|
||||
|
||||
var resolvers = arrayOf(contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, PROJECTION_IMAGES, selection, null, null),
|
||||
contentResolver.query(MediaStore.Images.Media.INTERNAL_CONTENT_URI, PROJECTION_IMAGES, selection, null, null))
|
||||
var resolvers = arrayOf(
|
||||
contentResolver.query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, PROJECTION_IMAGES, selection, null, null),
|
||||
contentResolver.query(MediaStore.Images.Media.INTERNAL_CONTENT_URI, PROJECTION_IMAGES, selection, null, null)
|
||||
)
|
||||
|
||||
if (SharedPreferencesHandler(applicationContext).autoPhotoUploadIncludingVideos()) {
|
||||
resolvers += arrayOf(contentResolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, PROJECTION_VIDEOS, selection, null, null),
|
||||
contentResolver.query(MediaStore.Video.Media.INTERNAL_CONTENT_URI, PROJECTION_VIDEOS, selection, null, null))
|
||||
resolvers += arrayOf(
|
||||
contentResolver.query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, PROJECTION_VIDEOS, selection, null, null),
|
||||
contentResolver.query(MediaStore.Video.Media.INTERNAL_CONTENT_URI, PROJECTION_VIDEOS, selection, null, null)
|
||||
)
|
||||
}
|
||||
|
||||
return resolvers
|
||||
|
@ -377,7 +377,8 @@ abstract class BaseActivity : AppCompatActivity(), View, ActivityCompat.OnReques
|
||||
val enter: Int,
|
||||
val exit: Int,
|
||||
val popEnter: Int,
|
||||
val popExit: Int) {
|
||||
val popExit: Int
|
||||
) {
|
||||
|
||||
NAVIGATE_IN_TO_FOLDER(R.animator.enter_from_right, R.animator.exit_to_left, R.animator.enter_from_left, R.animator.exit_to_right), //
|
||||
NAVIGATE_OUT_OF_FOLDER(R.animator.enter_from_left, R.animator.exit_to_right, R.animator.enter_from_right, R.animator.exit_to_left)
|
||||
|
@ -97,8 +97,10 @@ class BrowseFilesActivity : BaseActivity(), //
|
||||
get() = browseFilesFragment().folder
|
||||
|
||||
override fun createFragment(): Fragment =
|
||||
BrowseFilesFragment.newInstance(browseFilesIntent.folder(),
|
||||
browseFilesIntent.chooseCloudNodeSettings())
|
||||
BrowseFilesFragment.newInstance(
|
||||
browseFilesIntent.folder(),
|
||||
browseFilesIntent.chooseCloudNodeSettings()
|
||||
)
|
||||
|
||||
override fun onBackPressed() {
|
||||
browseFilesPresenter.onBackPressed()
|
||||
@ -160,14 +162,17 @@ class BrowseFilesActivity : BaseActivity(), //
|
||||
true
|
||||
}
|
||||
R.id.action_move_items -> {
|
||||
browseFilesPresenter.onMoveNodesClicked(folder, //
|
||||
browseFilesFragment().selectedCloudNodes as ArrayList<CloudNodeModel<*>>)
|
||||
browseFilesPresenter.onMoveNodesClicked(
|
||||
folder, //
|
||||
browseFilesFragment().selectedCloudNodes as ArrayList<CloudNodeModel<*>>
|
||||
)
|
||||
true
|
||||
}
|
||||
R.id.action_export_items -> {
|
||||
browseFilesPresenter.onExportNodesClicked( //
|
||||
browseFilesFragment().selectedCloudNodes as ArrayList<CloudNodeModel<*>>, //
|
||||
BrowseFilesPresenter.EXPORT_TRIGGERED_BY_USER)
|
||||
BrowseFilesPresenter.EXPORT_TRIGGERED_BY_USER
|
||||
)
|
||||
true
|
||||
}
|
||||
R.id.action_share_items -> {
|
||||
@ -398,9 +403,13 @@ class BrowseFilesActivity : BaseActivity(), //
|
||||
}
|
||||
|
||||
override fun navigateTo(folder: CloudFolderModel) {
|
||||
replaceFragment(BrowseFilesFragment.newInstance(folder,
|
||||
browseFilesIntent.chooseCloudNodeSettings()),
|
||||
FragmentAnimation.NAVIGATE_IN_TO_FOLDER)
|
||||
replaceFragment(
|
||||
BrowseFilesFragment.newInstance(
|
||||
folder,
|
||||
browseFilesIntent.chooseCloudNodeSettings()
|
||||
),
|
||||
FragmentAnimation.NAVIGATE_IN_TO_FOLDER
|
||||
)
|
||||
}
|
||||
|
||||
override fun showAddContentDialog() {
|
||||
@ -484,10 +493,14 @@ class BrowseFilesActivity : BaseActivity(), //
|
||||
}
|
||||
|
||||
private fun createBackStackFor(sourceParent: CloudFolderModel) {
|
||||
replaceFragment(BrowseFilesFragment.newInstance(sourceParent,
|
||||
browseFilesIntent.chooseCloudNodeSettings()),
|
||||
replaceFragment(
|
||||
BrowseFilesFragment.newInstance(
|
||||
sourceParent,
|
||||
browseFilesIntent.chooseCloudNodeSettings()
|
||||
),
|
||||
FragmentAnimation.NAVIGATE_OUT_OF_FOLDER,
|
||||
false)
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
override fun onRenameCloudNodeClicked(cloudNodeModel: CloudNodeModel<*>, newCloudNodeName: String) {
|
||||
|
@ -24,8 +24,10 @@ class EmptyDirIdFileInfoActivity : BaseActivity(), EmptyDirFileView {
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
toolbar.title = getString(R.string.screen_empty_dir_file_info_title,
|
||||
emptyDirIdFileInfoIntent.dirName())
|
||||
toolbar.title = getString(
|
||||
R.string.screen_empty_dir_file_info_title,
|
||||
emptyDirIdFileInfoIntent.dirName()
|
||||
)
|
||||
setSupportActionBar(toolbar)
|
||||
}
|
||||
|
||||
|
@ -45,10 +45,12 @@ import kotlinx.android.synthetic.main.view_cloud_folder_content.view.cloudFolder
|
||||
import kotlinx.android.synthetic.main.view_cloud_folder_content.view.cloudFolderText
|
||||
|
||||
class BrowseFilesAdapter @Inject
|
||||
constructor(private val dateHelper: DateHelper, //
|
||||
constructor(
|
||||
private val dateHelper: DateHelper, //
|
||||
private val fileSizeHelper: FileSizeHelper, //
|
||||
private val fileUtil: FileUtil, //
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler) : RecyclerViewBaseAdapter<CloudNodeModel<*>, BrowseFilesAdapter.ItemClickListener, VaultContentViewHolder>(CloudNodeModelNameAZComparator()), FastScrollRecyclerView.SectionedAdapter {
|
||||
private val sharedPreferencesHandler: SharedPreferencesHandler
|
||||
) : RecyclerViewBaseAdapter<CloudNodeModel<*>, BrowseFilesAdapter.ItemClickListener, VaultContentViewHolder>(CloudNodeModelNameAZComparator()), FastScrollRecyclerView.SectionedAdapter {
|
||||
|
||||
private var chooseCloudNodeSettings: ChooseCloudNodeSettings? = null
|
||||
private var navigationMode: ChooseCloudNodeSettings.NavigationMode? = null
|
||||
|
@ -7,4 +7,5 @@ import org.cryptomator.presentation.ui.dialog.CloudNodeRenameDialog
|
||||
import org.cryptomator.presentation.ui.dialog.CreateFolderDialog
|
||||
import org.cryptomator.presentation.ui.dialog.FileTypeNotSupportedDialog
|
||||
|
||||
interface BrowseFilesCallback : CreateFolderDialog.Callback, VaultContentActionBottomSheet.Callback, FileSettingsBottomSheet.Callback, FolderSettingsBottomSheet.Callback, CloudNodeRenameDialog.Callback, FileTypeNotSupportedDialog.Callback
|
||||
interface BrowseFilesCallback : CreateFolderDialog.Callback, VaultContentActionBottomSheet.Callback, FileSettingsBottomSheet.Callback, FolderSettingsBottomSheet.Callback, CloudNodeRenameDialog.Callback,
|
||||
FileTypeNotSupportedDialog.Callback
|
||||
|
@ -35,13 +35,18 @@ class ChangePasswordDialog : BaseProgressErrorDialog<ChangePasswordDialog.Callba
|
||||
changePasswordButton?.setOnClickListener {
|
||||
val vaultModel = requireArguments().getSerializable(VAULT_ARG) as VaultModel
|
||||
val unverifiedVaultConfig = requireArguments().getSerializable(VAULT_CONFIG_ARG) as UnverifiedVaultConfig?
|
||||
if (valid(et_old_password.text.toString(), //
|
||||
if (valid(
|
||||
et_old_password.text.toString(), //
|
||||
et_new_password.text.toString(), //
|
||||
et_new_retype_password.text.toString())) {
|
||||
callback?.onChangePasswordClick(vaultModel, //
|
||||
et_new_retype_password.text.toString()
|
||||
)
|
||||
) {
|
||||
callback?.onChangePasswordClick(
|
||||
vaultModel, //
|
||||
unverifiedVaultConfig, //
|
||||
et_old_password.text.toString(), //
|
||||
et_new_password.text.toString())
|
||||
et_new_password.text.toString()
|
||||
)
|
||||
onWaitForResponse(et_old_password)
|
||||
} else {
|
||||
hideKeyboard(et_old_password)
|
||||
@ -58,10 +63,12 @@ class ChangePasswordDialog : BaseProgressErrorDialog<ChangePasswordDialog.Callba
|
||||
registerOnEditorDoneActionAndPerformButtonClick(et_new_retype_password) { changePasswordButton }
|
||||
|
||||
PasswordStrengthUtil() //
|
||||
.startUpdatingPasswordStrengthMeter(et_new_password, //
|
||||
.startUpdatingPasswordStrengthMeter(
|
||||
et_new_password, //
|
||||
progressBarPwStrengthIndicator, //
|
||||
textViewPwStrengthIndicator, //
|
||||
changePasswordButton)
|
||||
changePasswordButton
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,9 +22,11 @@ class EnrollSystemBiometricDialog : BaseDialog<EnrollSystemBiometricDialog.Callb
|
||||
override fun setupDialog(builder: AlertDialog.Builder): android.app.Dialog {
|
||||
builder //
|
||||
.setTitle(getString(R.string.dialog_no_biometric_auth_set_up_title)) //
|
||||
.setPositiveButton(getString(R.string.dialog_unable_to_share_positive_button) //
|
||||
.setPositiveButton(
|
||||
getString(R.string.dialog_unable_to_share_positive_button) //
|
||||
) { _: DialogInterface, _: Int -> callback?.onSetupBiometricAuthInSystemClicked() }
|
||||
.setNegativeButton(getString(R.string.dialog_button_cancel) //
|
||||
.setNegativeButton(
|
||||
getString(R.string.dialog_button_cancel) //
|
||||
) { _: DialogInterface?, _: Int -> callback?.onCancelSetupBiometricAuthInSystemClicked() }
|
||||
return builder.create()
|
||||
}
|
||||
|
@ -38,9 +38,11 @@ class ExportCloudFilesDialog : BaseProgressErrorDialog<ExportCloudFilesDialog.Ca
|
||||
}
|
||||
|
||||
private fun effectiveTitle(seenFiles: Int): String {
|
||||
return String.format(getString(R.string.dialog_export_file_title), //
|
||||
return String.format(
|
||||
getString(R.string.dialog_export_file_title), //
|
||||
seenFiles, //
|
||||
requireArguments().getInt(ARG_NUMBER_OF_FILES))
|
||||
requireArguments().getInt(ARG_NUMBER_OF_FILES)
|
||||
)
|
||||
}
|
||||
|
||||
override fun setupView() {}
|
||||
|
@ -32,7 +32,8 @@ class WebDavAskForHttpDialog : BaseDialog<WebDavAskForHttpDialog.Callback>() {
|
||||
certificate = requireArguments().getString(CERTIFICATE_ARG)
|
||||
builder //
|
||||
.setTitle(R.string.dialog_http_security_title) //
|
||||
.setNeutralButton(getString(R.string.dialog_unable_to_share_positive_button)
|
||||
.setNeutralButton(
|
||||
getString(R.string.dialog_unable_to_share_positive_button)
|
||||
) { _: DialogInterface, _: Int -> callback?.onAksForHttpFinished(username, password, uriWithDesiredProtocol(cb_select_http.isChecked), cloudId, certificate) }
|
||||
return builder.create()
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ class S3AddOrChangeFragment : BaseFragment() {
|
||||
endpointEditText.text.toString().trim(), //
|
||||
regionEditText.text.toString().trim(), //
|
||||
cloudId, //
|
||||
displayName)
|
||||
displayName
|
||||
)
|
||||
}
|
||||
|
||||
fun hideKeyboard() {
|
||||
|
@ -29,10 +29,12 @@ class SetPasswordFragment : BaseFragment() {
|
||||
}
|
||||
false
|
||||
}
|
||||
passwordStrengthUtil.startUpdatingPasswordStrengthMeter(passwordEditText, //
|
||||
passwordStrengthUtil.startUpdatingPasswordStrengthMeter(
|
||||
passwordEditText, //
|
||||
progressBarPwStrengthIndicator, //
|
||||
textViewPwStrengthIndicator, //
|
||||
createVaultButton)
|
||||
createVaultButton
|
||||
)
|
||||
|
||||
passwordEditText.requestFocus()
|
||||
}
|
||||
|
@ -104,7 +104,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_STRONG)
|
||||
|
||||
if (biometricAuthenticationAvailable != BiometricManager.BIOMETRIC_SUCCESS
|
||||
&& biometricAuthenticationAvailable != BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED) {
|
||||
&& biometricAuthenticationAvailable != BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED
|
||||
) {
|
||||
val preference = findPreference(BIOMETRIC_AUTHENTICATION_ITEM_KEY) as Preference?
|
||||
val generalCategory = findPreference(getString(R.string.screen_settings_section_general)) as PreferenceCategory?
|
||||
generalCategory?.removePreference(preference)
|
||||
@ -120,7 +121,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
val versionName = SpannableString(BuildConfig.VERSION_NAME)
|
||||
versionName.setSpan( //
|
||||
ForegroundColorSpan(ContextCompat.getColor(activity(), R.color.textColorLight)), //
|
||||
0, versionName.length, 0)
|
||||
0, versionName.length, 0
|
||||
)
|
||||
preference?.summary = versionName
|
||||
}
|
||||
|
||||
@ -145,7 +147,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
lruCacheSize.setSpan( //
|
||||
ForegroundColorSpan(ContextCompat.getColor(activity(), R.color.textColorLight)), //
|
||||
0, lruCacheSize.length, 0)
|
||||
0, lruCacheSize.length, 0
|
||||
)
|
||||
preference?.summary = lruCacheSize
|
||||
}
|
||||
|
||||
@ -188,7 +191,8 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
||||
|
||||
date.setSpan( //
|
||||
ForegroundColorSpan(ContextCompat.getColor(activity(), R.color.textColorLight)), //
|
||||
0, date.length, 0)
|
||||
0, date.length, 0
|
||||
)
|
||||
preference?.summary = date
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,8 @@ class TextEditorFragment : BaseFragment() {
|
||||
BackgroundColorSpan(ContextCompat.getColor(context(), R.color.colorPrimaryTransparent)),
|
||||
index,
|
||||
index + it.length,
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
)
|
||||
|
||||
textEditorPresenter.lastFilterLocation = index
|
||||
|
||||
|
@ -79,10 +79,12 @@ class BiometricAuthentication(val callback: Callback, val context: Context, val
|
||||
biometricAuthCryptor.decrypt(cipher, vaultModel.password)
|
||||
}
|
||||
|
||||
val vaultModelPasswordAware = VaultModel(Vault //
|
||||
val vaultModelPasswordAware = VaultModel(
|
||||
Vault //
|
||||
.aCopyOf(vaultModel.toVault()) //
|
||||
.withSavedPassword(transformedPassword) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
|
||||
callback.onBiometricAuthenticated(vaultModelPasswordAware)
|
||||
}
|
||||
@ -109,7 +111,8 @@ class BiometricAuthentication(val callback: Callback, val context: Context, val
|
||||
|
||||
biometricPrompt.authenticate(
|
||||
promptInfo,
|
||||
BiometricPrompt.CryptoObject(cryptoCipher))
|
||||
BiometricPrompt.CryptoObject(cryptoCipher)
|
||||
)
|
||||
} catch (e: KeyPermanentlyInvalidatedException) {
|
||||
callback.onBiometricKeyInvalidated(vaultModel)
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ class FileSizeHelper @Inject constructor(private val context: Context) {
|
||||
context.getString(R.string.file_size_unit_kilo_bytes), //
|
||||
context.getString(R.string.file_size_unit_mega_bytes), //
|
||||
context.getString(R.string.file_size_unit_giga_bytes), //
|
||||
context.getString(R.string.file_size_unit_tera_bytes))
|
||||
context.getString(R.string.file_size_unit_tera_bytes)
|
||||
)
|
||||
|
||||
fun getFormattedFileSize(size: Optional<Long>): Optional<String> {
|
||||
return when {
|
||||
|
@ -13,7 +13,8 @@ import timber.log.Timber
|
||||
class ShareFileHelper @Inject constructor( //
|
||||
private val fileUtil: FileUtil, //
|
||||
private val mimeTypes: MimeTypes, //
|
||||
private val contentResolverUtil: ContentResolverUtil) {
|
||||
private val contentResolverUtil: ContentResolverUtil
|
||||
) {
|
||||
|
||||
fun shareFile(activityHolder: ActivityHolder, cloudFile: CloudFileModel) {
|
||||
shareFile(activityHolder, fileUtil.contentUriFor(cloudFile), mimeTypeFromFileName(cloudFile.name))
|
||||
|
@ -40,6 +40,7 @@ public abstract class Workflow<State extends Serializable> {
|
||||
this.presenter = presenter;
|
||||
setStateFrom(intent);
|
||||
}
|
||||
|
||||
private boolean setStateFrom(Intent intent) {
|
||||
Serializable stateExtra = intent.getSerializableExtra(WORKFLOW_STATE_EXTRA);
|
||||
Serializable callbackExtra = intent.getSerializableExtra(WORKFLOW_CALLBACK_EXTRA);
|
||||
|
@ -70,7 +70,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
private val getCloudsUseCase: GetCloudsUseCase, //
|
||||
private val getUsernameUseCase: GetUsernameUseCase, //
|
||||
private val addExistingVaultWorkflow: AddExistingVaultWorkflow, //
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow) : Presenter<AuthenticateCloudView>(exceptionHandlers) {
|
||||
private val createNewVaultWorkflow: CreateNewVaultWorkflow
|
||||
) : Presenter<AuthenticateCloudView>(exceptionHandlers) {
|
||||
|
||||
private val strategies = arrayOf( //
|
||||
DropboxAuthStrategy(), //
|
||||
@ -186,7 +187,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
getUsernameAndSuceedAuthentication( //
|
||||
DropboxCloud.aCopyOf(cloudModel.toCloud() as DropboxCloud) //
|
||||
.withAccessToken(encrypt(authToken)) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -223,7 +225,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
try {
|
||||
requestActivityResult( //
|
||||
ActivityResultCallbacks.onGoogleDriveAuthenticated(cloud), //
|
||||
chooseAccountIntent)
|
||||
chooseAccountIntent
|
||||
)
|
||||
} catch (e: ActivityNotFoundException) {
|
||||
view?.showMessage(R.string.error_play_services_not_available)
|
||||
finish()
|
||||
@ -244,10 +247,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
fun onGoogleDriveAuthenticated(result: ActivityResult, cloud: CloudModel) {
|
||||
if (result.isResultOk) {
|
||||
val accountName = result.intent()?.extras?.getString(AccountManager.KEY_ACCOUNT_NAME)
|
||||
succeedAuthenticationWith(GoogleDriveCloud.aCopyOf(cloud.toCloud() as GoogleDriveCloud) //
|
||||
succeedAuthenticationWith(
|
||||
GoogleDriveCloud.aCopyOf(cloud.toCloud() as GoogleDriveCloud) //
|
||||
.withUsername(accountName) //
|
||||
.withAccessToken(accountName) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} else {
|
||||
failAuthentication(cloud.name())
|
||||
}
|
||||
@ -291,7 +296,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
getUsernameAndSuceedAuthentication( //
|
||||
OnedriveCloud.aCopyOf(cloud.toCloud() as OnedriveCloud) //
|
||||
.withAccessToken(accessToken) //
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +317,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
Toast.makeText(
|
||||
context(),
|
||||
String.format(getString(R.string.error_authentication_failed_re_authenticate), intent.cloud().username()),
|
||||
Toast.LENGTH_LONG).show()
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
@ -330,9 +337,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
.setClientId(BuildConfig.PCLOUD_CLIENT_ID)
|
||||
.setForceAccessApproval(true)
|
||||
.addPermission("manageshares")
|
||||
.build())
|
||||
requestActivityResult(ActivityResultCallbacks.pCloudReAuthenticationFinished(), //
|
||||
authIntent)
|
||||
.build()
|
||||
)
|
||||
requestActivityResult(
|
||||
ActivityResultCallbacks.pCloudReAuthenticationFinished(), //
|
||||
authIntent
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,10 +392,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
(it as PCloud).username() == cloud.username()
|
||||
}?.let {
|
||||
it as PCloud
|
||||
succeedAuthenticationWith(PCloud.aCopyOf(it) //
|
||||
succeedAuthenticationWith(
|
||||
PCloud.aCopyOf(it) //
|
||||
.withUrl(cloud.url())
|
||||
.withAccessToken(cloud.accessToken())
|
||||
.build())
|
||||
.build()
|
||||
)
|
||||
} ?: succeedAuthenticationWith(cloud)
|
||||
}
|
||||
})
|
||||
@ -438,9 +450,11 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
val webDavCloudWithAcceptedCert = WebDavCloud.aCopyOf(cloud) //
|
||||
.withCertificate(X509CertificateHelper.convertToPem(certificate)) //
|
||||
.build()
|
||||
finishWithResultAndExtra(cloudModelMapper.toModel(webDavCloudWithAcceptedCert), //
|
||||
finishWithResultAndExtra(
|
||||
cloudModelMapper.toModel(webDavCloudWithAcceptedCert), //
|
||||
WEBDAV_ACCEPTED_UNTRUSTED_CERTIFICATE, //
|
||||
true)
|
||||
true
|
||||
)
|
||||
} catch (e: CertificateEncodingException) {
|
||||
Timber.tag("AuthicateCloudPrester").e(e)
|
||||
throw FatalBackendException(e)
|
||||
@ -467,7 +481,8 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
Toast.makeText(
|
||||
context(),
|
||||
String.format(getString(R.string.error_authentication_failed), intent.cloud().username()),
|
||||
Toast.LENGTH_LONG).show()
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
@ -498,10 +513,12 @@ class AuthenticateCloudPresenter @Inject constructor( //
|
||||
|
||||
private fun startAuthentication(cloud: CloudModel) {
|
||||
authenticationStarted = true
|
||||
requestPermissions(PermissionsResultCallbacks.onLocalStorageAuthenticated(cloud), //
|
||||
requestPermissions(
|
||||
PermissionsResultCallbacks.onLocalStorageAuthenticated(cloud), //
|
||||
R.string.permission_snackbar_auth_local_vault, //
|
||||
Manifest.permission.READ_EXTERNAL_STORAGE, //
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user