Skip to content

Commit

Permalink
Merge pull request #1 from chenxiaolong/open
Browse files Browse the repository at this point in the history
Add option to open a remote in DocumentsUI
  • Loading branch information
chenxiaolong authored Mar 31, 2023
2 parents 4c31998 + 4770cc1 commit 3bcf97c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/java/com/chiller3/rsaf/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="dialog_edit_remote_actions">
<item>@string/dialog_edit_remote_open_in_documentsui</item>
<item>@string/dialog_edit_remote_action_configure</item>
<item>@string/dialog_edit_remote_action_rename</item>
<item>@string/dialog_edit_remote_action_duplicate</item>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<string name="dialog_authorize_title">Waiting for authorization</string>
<string name="dialog_authorize_message_loading">Waiting for rclone webserver to start.</string>
<string name="dialog_authorize_message_url">Open the following link to authorize rclone for access to the backend. Once authorized, the token will be automatically inserted in the previous screen.</string>
<string name="dialog_edit_remote_open_in_documentsui">Open in DocumentsUI</string>
<string name="dialog_edit_remote_action_configure">Configure remote</string>
<string name="dialog_edit_remote_action_rename">Rename remote</string>
<string name="dialog_edit_remote_action_duplicate">Duplicate remote</string>
Expand Down

0 comments on commit 3bcf97c

Please sign in to comment.