mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-20 08:39:22 +01:00
Local backups upgrade UI.
This commit is contained in:
committed by
Greyson Parrelli
parent
2e70ed14dd
commit
6c30f3d573
@@ -17,6 +17,7 @@ import org.signal.core.util.logging.Log;
|
||||
import org.signal.libsignal.protocol.util.ByteUtil;
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.backup.BackupPassphrase;
|
||||
import org.thoughtcrime.securesms.backup.v2.local.ArchiveFileSystem;
|
||||
import org.thoughtcrime.securesms.database.NoExternalStorageException;
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
@@ -69,6 +70,38 @@ public class BackupUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean canUserAccessUnifiedBackupDirectory(@NonNull Context context) {
|
||||
if (isUserSelectionRequired(context)) {
|
||||
Uri backupDirectoryUri = Uri.parse(SignalStore.backup().getNewLocalBackupsDirectory());
|
||||
if (backupDirectoryUri == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DocumentFile backupDirectory = DocumentFile.fromTreeUri(context, backupDirectoryUri);
|
||||
return backupDirectory != null && backupDirectory.exists() && backupDirectory.canRead() && backupDirectory.canWrite();
|
||||
} else {
|
||||
return Permissions.hasAll(context, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteUnifiedBackups(@NonNull Context context, @Nullable String backupDirectoryPath) {
|
||||
if (backupDirectoryPath != null) {
|
||||
Uri backupDirectoryUri = Uri.parse(backupDirectoryPath);
|
||||
DocumentFile backupDirectory = DocumentFile.fromTreeUri(context, backupDirectoryUri);
|
||||
|
||||
if (backupDirectory == null || !backupDirectory.exists() || !backupDirectory.canRead() || !backupDirectory.canWrite()) {
|
||||
Log.w(TAG, "Backup directory is inaccessible. Cannot delete backups.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (DocumentFile file : backupDirectory.listFiles()) {
|
||||
if (file.isDirectory() && Objects.equals(file.getName(), ArchiveFileSystem.MAIN_DIRECTORY_NAME)) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static @Nullable BackupInfo getLatestBackup() throws NoExternalStorageException {
|
||||
List<BackupInfo> backups = getAllBackupsNewestFirst();
|
||||
|
||||
|
||||
@@ -1238,5 +1238,16 @@ object RemoteConfig {
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
/**
|
||||
* Whether or not the new UX for unified local backups is enabled
|
||||
*/
|
||||
@JvmStatic
|
||||
@get:JvmName("unifiedLocalBackups")
|
||||
val unifiedLocalBackups: Boolean by remoteBoolean(
|
||||
key = "android.unifiedLocalBackups",
|
||||
defaultValue = false,
|
||||
hotSwappable = true
|
||||
)
|
||||
|
||||
// endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user