android/app/src/main/java/org/libreoffice/androidapp/storage/external/BrowserSelectorActivity.java
 |   31 +++++++---
 1 file changed, 23 insertions(+), 8 deletions(-)

New commits:
commit 7aae12a0cc9a6df7da40b04d8c5d36ecf3f6c451
Author:     Jan Holesovsky <ke...@collabora.com>
AuthorDate: Thu Jan 2 17:21:20 2020 +0100
Commit:     Jan Holesovsky <ke...@collabora.com>
CommitDate: Thu Jan 2 18:08:58 2020 +0100

    android: Remove some sub-Android-5-specific code.
    
    We don't target anything below Android 5 any more.
    
    Change-Id: Ic6bb8b0fbd64af6a061dba1422cafc144509c67a
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86136
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git 
a/android/app/src/main/java/org/libreoffice/androidapp/storage/external/BrowserSelectorActivity.java
 
b/android/app/src/main/java/org/libreoffice/androidapp/storage/external/BrowserSelectorActivity.java
index e992a0860..d4c2e830c 100644
--- 
a/android/app/src/main/java/org/libreoffice/androidapp/storage/external/BrowserSelectorActivity.java
+++ 
b/android/app/src/main/java/org/libreoffice/androidapp/storage/external/BrowserSelectorActivity.java
@@ -1,3 +1,12 @@
+/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
 package org.libreoffice.androidapp.storage.external;
 
 import android.annotation.TargetApi;
@@ -9,6 +18,7 @@ import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
 import android.preference.PreferenceManager;
+import android.provider.DocumentsContract;
 import android.util.Log;
 
 import org.libreoffice.androidapp.R;
@@ -55,11 +65,7 @@ public class BrowserSelectorActivity extends 
AppCompatActivity {
     }
 
     private void findSDCard() {
-        if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            useDocumentTreeBrowser();
-        } else {
-            useInternalBrowser(DocumentProviderFactory.EXTSD_PROVIDER_INDEX);
-        }
+        useDocumentTreeBrowser(DocumentProviderFactory.EXTSD_PROVIDER_INDEX);
     }
 
     private void useInternalBrowser(int providerIndex) {
@@ -67,18 +73,25 @@ public class BrowserSelectorActivity extends 
AppCompatActivity {
                 (IExternalDocumentProvider) 
DocumentProviderFactory.getInstance()
                         .getProvider(providerIndex);
         String previousDirectoryPath = preferences.getString(preferenceKey, 
provider.guessRootURI(this));
+
         Intent i = new Intent(this, DirectoryBrowserActivity.class);
         i.putExtra(DirectoryBrowserActivity.DIRECTORY_PATH_EXTRA, 
previousDirectoryPath);
         startActivityForResult(i, REQUEST_INTERNAL_BROWSER);
     }
 
-    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
-    private void useDocumentTreeBrowser() {
+    private void useDocumentTreeBrowser(int providerIndex) {
+        IExternalDocumentProvider provider =
+                (IExternalDocumentProvider) 
DocumentProviderFactory.getInstance()
+                        .getProvider(providerIndex);
+        String previousDirectoryPath = preferences.getString(preferenceKey, 
provider.guessRootURI(this));
+
         Intent i = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
+        i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+        i.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
+        i.putExtra(DocumentsContract.EXTRA_INITIAL_URI, previousDirectoryPath);
         startActivityForResult(i, REQUEST_DOCUMENT_TREE);
     }
 
-    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent 
data) {
         //listeners are registered here as onActivityResult is called before 
onResume
@@ -152,3 +165,5 @@ public class BrowserSelectorActivity extends 
AppCompatActivity {
         }
     }
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to