From 4770cc1f47cc306fe6239e934f659202bb38f1d1 Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Fri, 31 Mar 2023 13:17:03 -0400 Subject: [PATCH] Add option to open a remote in DocumentsUI Some Android builds (eg. Samsung OneUI) don't have a convenient way of launching DocumentsUI, so we'll add an option to do that. Signed-off-by: Andrew Gunnerson --- .../java/com/chiller3/rsaf/EditRemoteDialogFragment.kt | 9 +++++---- app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt | 9 +++++++++ app/src/main/res/values/arrays.xml | 1 + app/src/main/res/values/strings.xml | 1 + 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/chiller3/rsaf/EditRemoteDialogFragment.kt b/app/src/main/java/com/chiller3/rsaf/EditRemoteDialogFragment.kt index fd0b7dd..e75289a 100644 --- a/app/src/main/java/com/chiller3/rsaf/EditRemoteDialogFragment.kt +++ b/app/src/main/java/com/chiller3/rsaf/EditRemoteDialogFragment.kt @@ -14,10 +14,11 @@ open class EditRemoteDialogFragment : DialogFragment() { const val RESULT_ACTION = "action" const val RESULT_REMOTE = "remote" // These must match the indexes in R.array.dialog_edit_remote_actions - const val ACTION_CONFIGURE = 0 - const val ACTION_RENAME = 1 - const val ACTION_DUPLICATE = 2 - const val ACTION_DELETE = 3 + const val ACTION_OPEN = 0 + const val ACTION_CONFIGURE = 1 + const val ACTION_RENAME = 2 + const val ACTION_DUPLICATE = 3 + const val ACTION_DELETE = 4 fun newInstance(remote: String): EditRemoteDialogFragment = EditRemoteDialogFragment().apply { diff --git a/app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt b/app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt index b818917..69199bc 100644 --- a/app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt +++ b/app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt @@ -3,6 +3,7 @@ package com.chiller3.rsaf import android.content.Intent import android.net.Uri import android.os.Bundle +import android.provider.DocumentsContract import androidx.activity.result.contract.ActivityResultContracts import androidx.fragment.app.FragmentResultListener import androidx.fragment.app.clearFragmentResult @@ -224,6 +225,14 @@ class SettingsFragment : PreferenceFragmentCompat(), FragmentResultListener, val remote = bundle.getString(EditRemoteDialogFragment.RESULT_REMOTE)!! when (action) { + EditRemoteDialogFragment.ACTION_OPEN -> { + val uri = DocumentsContract.buildRootUri( + BuildConfig.DOCUMENTS_AUTHORITY, remote) + val intent = Intent(Intent.ACTION_VIEW).apply { + setDataAndType(uri, "vnd.android.document/root") + } + startActivity(intent) + } EditRemoteDialogFragment.ACTION_CONFIGURE -> { InteractiveConfigurationDialogFragment.newInstance(remote, false) .show(parentFragmentManager.beginTransaction(), diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 4ecc99b..843b825 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -1,6 +1,7 @@ + @string/dialog_edit_remote_open_in_documentsui @string/dialog_edit_remote_action_configure @string/dialog_edit_remote_action_rename @string/dialog_edit_remote_action_duplicate diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a39ba8f..6005910 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -65,6 +65,7 @@ Waiting for authorization Waiting for rclone webserver to start. Open the following link to authorize rclone for access to the backend. Once authorized, the token will be automatically inserted in the previous screen. + Open in DocumentsUI Configure remote Rename remote Duplicate remote