mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-28 10:47:46 +00:00
Cleanup backup permissions.
This commit is contained in:
parent
bc3ded29bf
commit
c0785e4da7
@ -152,17 +152,11 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
private class BackupClickListener implements Preference.OnPreferenceClickListener {
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Permissions.with(ChatsPreferenceFragment.this)
|
||||
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
.onAllGranted(() -> {
|
||||
if (!((SwitchPreferenceCompat)preference).isChecked()) {
|
||||
BackupDialog.showEnableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference, backupDirSelector);
|
||||
} else {
|
||||
BackupDialog.showDisableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference);
|
||||
}
|
||||
})
|
||||
.withPermanentDenialDialog(getString(R.string.ChatsPreferenceFragment_signal_requires_external_storage_permission_in_order_to_create_backups))
|
||||
.execute();
|
||||
if (!((SwitchPreferenceCompat)preference).isChecked()) {
|
||||
BackupDialog.showEnableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference, backupDirSelector);
|
||||
} else {
|
||||
BackupDialog.showDisableBackupDialog(getActivity(), (SwitchPreferenceCompat)preference);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -172,16 +166,10 @@ public class ChatsPreferenceFragment extends ListSummaryPreferenceFragment {
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
@Override
|
||||
public boolean onPreferenceClick(Preference preference) {
|
||||
Permissions.with(ChatsPreferenceFragment.this)
|
||||
.request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
.onAllGranted(() -> {
|
||||
Log.i(TAG, "Queing backup...");
|
||||
ApplicationContext.getInstance(getContext())
|
||||
.getJobManager()
|
||||
.add(new LocalBackupJob());
|
||||
})
|
||||
.withPermanentDenialDialog(getString(R.string.ChatsPreferenceFragment_signal_requires_external_storage_permission_in_order_to_create_backups))
|
||||
.execute();
|
||||
Log.i(TAG, "Queuing backup...");
|
||||
ApplicationContext.getInstance(getContext())
|
||||
.getJobManager()
|
||||
.add(new LocalBackupJob());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import java.io.IOException
|
||||
import java.security.SecureRandom
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.jvm.Throws
|
||||
|
||||
object BackupUtil {
|
||||
private const val TAG = "BackupUtil"
|
||||
@ -43,14 +44,10 @@ object BackupUtil {
|
||||
|
||||
@JvmStatic
|
||||
fun generateBackupPassphrase(): Array<String> {
|
||||
val result = arrayOfNulls<String>(6)
|
||||
val random = ByteArray(30)
|
||||
SecureRandom().nextBytes(random)
|
||||
for (i in 0..5) {
|
||||
result[i] = String.format("%05d", ByteUtil.byteArray5ToLong(random, i * 5) % 100000)
|
||||
val random = ByteArray(30).also { SecureRandom().nextBytes(it) }
|
||||
return Array(6) {i ->
|
||||
String.format("%05d", ByteUtil.byteArray5ToLong(random, i * 5) % 100000)
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return result as Array<String>
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
@ -18,9 +18,11 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
import java.lang.ref.WeakReference
|
||||
import java.text.SimpleDateFormat
|
||||
import kotlin.jvm.Throws
|
||||
|
||||
/**
|
||||
* Saves attachment files to an external storage using [MediaStore] API.
|
||||
* Requires [android.Manifest.permission.WRITE_EXTERNAL_STORAGE] on API 28 and below.
|
||||
*/
|
||||
class SaveAttachmentTask : ProgressDialogAsyncTask<SaveAttachmentTask.Attachment, Void, Pair<Int, String?>> {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user