浏览代码

enhance(android): Add All Files Access permission UI

leizhe 4 年之前
父节点
当前提交
571d83e6f6
共有 1 个文件被更改,包括 26 次插入2 次删除
  1. 26 2
      src/main/frontend/components/widgets.cljs

+ 26 - 2
src/main/frontend/components/widgets.cljs

@@ -138,6 +138,28 @@
                                "new native filesystem API"]
                               [:span ", please use any Chromium 86+ based browser like Chrome, Vivaldi, Edge, etc. Notice that the API doesn't support mobile browsers at the moment."]]))]]]))]))
 
+(rum/defc android-permission-alert
+  []
+  (when (mobile-util/native-android?)
+    (rum/with-context [[t] i18n/*tongue-context*]
+      [:div.flex.flex-col
+       [:h1.title "Storage access permission"]
+       [:div.text-sm
+        [:div
+         [:p "Logseq needs the permission to access your device storage. Read "
+          [:a {:href "https://developer.android.com/about/versions/11/privacy/storage#all-files-access"
+               :target "_blank"}
+           "more"]
+          "."]
+         [:div
+          (ui/button "Grant Permission"
+                     :on-click #(page-handler/ls-dir-files! shortcut/refresh!))]
+         [:p.mb-1 "Note:"]
+         [:ol
+          [:li "We will never access files outside of your graph folders you choose."]
+          [:li "If you have granted the permission, you don't need to do it again."]]]
+        [:hr]]])))
+
 (rum/defcs add-graph <
   [state & {:keys [graph-types]
             :or {graph-types [:local :github]}
@@ -151,8 +173,10 @@
                            "add-github-repo"))
 
                        :local
-                       (rum/with-key (add-local-directory)
-                         "add-local-directory")
+                       [(rum/with-key (android-permission-alert)
+                          "andoird-permission-alert")
+                        (rum/with-key (add-local-directory)
+                          "add-local-directory")]
 
                        nil))
         available-graph (->> (set graph-types)