aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt16
-rw-r--r--app/src/main/java/org/pacien/tincapp/activities/configure/BrowseDirectoriesFragment.kt17
2 files changed, 17 insertions, 16 deletions
diff --git a/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt
index 45c6832..d37abdf 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/BaseFragment.kt
@@ -18,11 +18,27 @@
18 18
19package org.pacien.tincapp.activities 19package org.pacien.tincapp.activities
20 20
21import android.content.ActivityNotFoundException
21import androidx.fragment.app.Fragment 22import androidx.fragment.app.Fragment
23import org.pacien.tincapp.R
24import org.pacien.tincapp.storageprovider.BrowseFilesIntents
22 25
23/** 26/**
24 * @author euxane 27 * @author euxane
25 */ 28 */
26abstract class BaseFragment : Fragment() { 29abstract class BaseFragment : Fragment() {
27 protected val parentActivity by lazy { activity as BaseActivity } 30 protected val parentActivity by lazy { activity as BaseActivity }
31
32 fun openDocumentTree(documentId: String) {
33 try {
34 BrowseFilesIntents.openDocumentTree(requireContext(), documentId)
35 } catch (e: ActivityNotFoundException) {
36 parentActivity.runOnUiThread {
37 parentActivity.showErrorDialog(
38 R.string.configure_browse_directories_error_no_file_browser,
39 docTopic = "browse-files",
40 )
41 }
42 }
43 }
28} \ No newline at end of file 44} \ No newline at end of file
diff --git a/app/src/main/java/org/pacien/tincapp/activities/configure/BrowseDirectoriesFragment.kt b/app/src/main/java/org/pacien/tincapp/activities/configure/BrowseDirectoriesFragment.kt
index abc7ffc..7d37f78 100644
--- a/app/src/main/java/org/pacien/tincapp/activities/configure/BrowseDirectoriesFragment.kt
+++ b/app/src/main/java/org/pacien/tincapp/activities/configure/BrowseDirectoriesFragment.kt
@@ -22,10 +22,8 @@ import android.os.Bundle
22import android.view.LayoutInflater 22import android.view.LayoutInflater
23import android.view.View 23import android.view.View
24import android.view.ViewGroup 24import android.view.ViewGroup
25import org.pacien.tincapp.R
26import org.pacien.tincapp.activities.BaseFragment 25import org.pacien.tincapp.activities.BaseFragment
27import org.pacien.tincapp.databinding.ConfigureBrowseDirectoriesFragmentBinding 26import org.pacien.tincapp.databinding.ConfigureBrowseDirectoriesFragmentBinding
28import org.pacien.tincapp.storageprovider.BrowseFilesIntents
29 27
30/** 28/**
31 * @author euxane 29 * @author euxane
@@ -36,17 +34,4 @@ class BrowseDirectoriesFragment : BaseFragment() {
36 binding.openDirectoryTree = { openDocumentTree(it) } 34 binding.openDirectoryTree = { openDocumentTree(it) }
37 return binding.root 35 return binding.root
38 } 36 }
39 37}
40 private fun openDocumentTree(documentId: String) {
41 try {
42 BrowseFilesIntents.openDocumentTree(requireContext(), documentId)
43 } catch (e: RuntimeException) {
44 parentActivity.runOnUiThread {
45 parentActivity.showErrorDialog(
46 R.string.configure_browse_directories_error_no_file_browser,
47 docTopic = "browse-files",
48 )
49 }
50 }
51 }
52} \ No newline at end of file