From 98ffadd87d8a6118af39fb00b2cb02d075e37951 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Tue, 18 May 2021 10:11:35 +0200 Subject: [PATCH] log exception when file is not a ceb --- .../ui/ImportBackupActivity.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java index 888c75129..a1f4d8d11 100644 --- a/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java +++ b/src/conversations/java/eu/siacs/conversations/ui/ImportBackupActivity.java @@ -6,7 +6,6 @@ import android.content.DialogInterface; import android.content.Intent; import android.content.ServiceConnection; import android.net.Uri; -import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.util.Log; @@ -125,7 +124,8 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo try { final ImportBackupService.BackupFile backupFile = ImportBackupService.BackupFile.read(this, uri); showEnterPasswordDialog(backupFile, finishOnCancel); - } catch (IOException | IllegalArgumentException e) { + } catch (final IOException | IllegalArgumentException e) { + Log.d(Config.LOGTAG, "unable to open backup file " + uri, e); Snackbar.make(binding.coordinator, R.string.not_a_backup_file, Snackbar.LENGTH_LONG).show(); } } @@ -181,6 +181,7 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo @Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { + super.onActivityResult(requestCode, resultCode, intent); if (resultCode == RESULT_OK) { if (requestCode == 0xbac) { openBackupFileFromUri(intent.getData(), false); @@ -225,15 +226,17 @@ public class ImportBackupActivity extends ActionBarActivity implements ServiceCo @Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.action_open_backup_file) { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.setType("*/*"); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { - intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); - } - intent.addCategory(Intent.CATEGORY_OPENABLE); - startActivityForResult(Intent.createChooser(intent, getString(R.string.open_backup)), 0xbac); + openBackupFile(); return true; } return super.onOptionsItemSelected(item); } + + private void openBackupFile() { + final Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("*/*"); + intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); + intent.addCategory(Intent.CATEGORY_OPENABLE); + startActivityForResult(Intent.createChooser(intent, getString(R.string.open_backup)), 0xbac); + } }