]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/activities/ImportExportActivity.java
Switch to using AndroidX's ProxyController. https://redmine.stoutner.com/issues/486
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / activities / ImportExportActivity.java
index bea58d3fe7a7e95542867389ecf2a1fdf5bf490e..1c328c4d07119e759f3fb60b6a01a66781c02fe9 100644 (file)
@@ -25,6 +25,7 @@ import android.content.Intent;
 import android.content.SharedPreferences;
 import android.content.pm.PackageManager;
 import android.media.MediaScannerConnection;
+import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.os.Environment;
@@ -558,7 +559,10 @@ public class ImportExportActivity extends AppCompatActivity implements StoragePe
     }
 
     @Override
-    public void onActivityResult(int requestCode, int resultCode, Intent data) {
+    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+        // Run the default commands.
+        super.onActivityResult(requestCode, resultCode, intent);
+
         switch (requestCode) {
             case (BROWSE_RESULT_CODE):
                 // Don't do anything if the user pressed back from the file picker.
@@ -569,11 +573,17 @@ public class ImportExportActivity extends AppCompatActivity implements StoragePe
                     // Instantiate the file name helper.
                     FileNameHelper fileNameHelper = new FileNameHelper();
 
-                    // Convert the file name URI to a file name path.
-                    String fileNamePath = fileNameHelper.convertUriToFileNamePath(data.getData());
+                    // Get the file path URI from the intent.
+                    Uri filePathUri = intent.getData();
 
-                    // Set the file name path as the text of the file name edit text.
-                    fileNameEditText.setText(fileNamePath);
+                    // Use the file path from the intent if it exists.
+                    if (filePathUri != null) {
+                        // Convert the file name URI to a file name path.
+                        String fileNamePath = fileNameHelper.convertUriToFileNamePath(filePathUri);
+
+                        // Set the file name path as the text of the file name edit text.
+                        fileNameEditText.setText(fileNamePath);
+                    }
                 }
                 break;