Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to open a remote in DocumentsUI #1

Merged
merged 1 commit into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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