diff --git a/app/src/main/java/protect/card_locker/ImportExportActivity.java b/app/src/main/java/protect/card_locker/ImportExportActivity.java index d700f14b8..463e372d9 100644 --- a/app/src/main/java/protect/card_locker/ImportExportActivity.java +++ b/app/src/main/java/protect/card_locker/ImportExportActivity.java @@ -50,7 +50,6 @@ public class ImportExportActivity extends CatimaAppCompatActivity { private ActivityResultLauncher fileCreateLauncher; private ActivityResultLauncher fileOpenLauncher; - private ActivityResultLauncher filePickerLauncher; final private TaskHandler mTasks = new TaskHandler(); @@ -67,7 +66,7 @@ public class ImportExportActivity extends CatimaAppCompatActivity { Intent fileIntent = getIntent(); if (fileIntent != null && fileIntent.getType() != null) { - chooseImportType(false, fileIntent.getData()); + chooseImportType(fileIntent.getData()); } // would use ActivityResultContracts.CreateDocument() but mime type cannot be set @@ -105,19 +104,6 @@ public class ImportExportActivity extends CatimaAppCompatActivity { } openFileForImport(result, null); }); - filePickerLauncher = registerForActivityResult(new ActivityResultContracts.StartActivityForResult(), result -> { - Intent intent = result.getData(); - if (intent == null) { - Log.e(TAG, "Activity returned NULL data"); - return; - } - Uri uri = intent.getData(); - if (uri == null) { - Log.e(TAG, "Activity returned NULL uri"); - return; - } - openFileForImport(intent.getData(), null); - }); // Check that there is a file manager available final Intent intentCreateDocumentAction = new Intent(Intent.ACTION_CREATE_DOCUMENT); @@ -160,11 +146,7 @@ public class ImportExportActivity extends CatimaAppCompatActivity { // Check that there is a file manager available Button importFilesystem = binding.importOptionFilesystemButton; - importFilesystem.setOnClickListener(v -> chooseImportType(false, null)); - - // Check that there is an app that data can be imported from - Button importApplication = binding.importOptionApplicationButton; - importApplication.setOnClickListener(v -> chooseImportType(true, null)); + importFilesystem.setOnClickListener(v -> chooseImportType(null)); // FIXME: The importer/exporter is currently quite broken // To prevent the screen from turning off during import/export and some devices killing Catima as it's no longer foregrounded, force the screen to stay on here @@ -189,8 +171,7 @@ public class ImportExportActivity extends CatimaAppCompatActivity { }.start(); } - private void chooseImportType(boolean choosePicker, - @Nullable Uri fileData) { + private void chooseImportType(@Nullable Uri fileData) { List betaImportOptions = new ArrayList<>(); betaImportOptions.add("Fidme"); @@ -251,20 +232,12 @@ public class ImportExportActivity extends CatimaAppCompatActivity { new MaterialAlertDialogBuilder(this) .setTitle(importAlertTitle) .setMessage(importAlertMessage) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - try { - if (choosePicker) { - final Intent intentPickAction = new Intent(Intent.ACTION_PICK); - filePickerLauncher.launch(intentPickAction); - } else { - fileOpenLauncher.launch("*/*"); - } - } catch (ActivityNotFoundException e) { - Toast.makeText(getApplicationContext(), R.string.failedOpeningFileManager, Toast.LENGTH_LONG).show(); - Log.e(TAG, "No activity found to handle intent", e); - } + .setPositiveButton(R.string.ok, (dialog1, which1) -> { + try { + fileOpenLauncher.launch("*/*"); + } catch (ActivityNotFoundException e) { + Toast.makeText(getApplicationContext(), R.string.failedOpeningFileManager, Toast.LENGTH_LONG).show(); + Log.e(TAG, "No activity found to handle intent", e); } }) .setNegativeButton(R.string.cancel, null) diff --git a/app/src/main/res/layout/import_export_activity.xml b/app/src/main/res/layout/import_export_activity.xml index 6512e304f..e24a49660 100644 --- a/app/src/main/res/layout/import_export_activity.xml +++ b/app/src/main/res/layout/import_export_activity.xml @@ -97,36 +97,6 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="8dp" android:text="@string/importOptionFilesystemButton" /> - - - - - - - -