From 2bd4957569a9fbf23296e4fb061faedf61197db6 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Thu, 2 Sep 2021 11:33:13 +0300 Subject: [PATCH] - seed-phrase field should not enable autofill - make hide/show password work on Android Signed-off-by: Michele Balistreri --- src/quo/components/text_input.cljs | 31 +++++++++++++------ .../ui/screens/multiaccounts/views.cljs | 1 + .../ui/screens/onboarding/phrase/view.cljs | 1 + .../ui/screens/profile/seed/views.cljs | 2 +- .../ui/screens/wallet/add_new/views.cljs | 4 +-- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/quo/components/text_input.cljs b/src/quo/components/text_input.cljs index 63bdf8f269..27457c25ac 100644 --- a/src/quo/components/text_input.cljs +++ b/src/quo/components/text_input.cljs @@ -146,7 +146,7 @@ (fn [{:keys [label multiline error style input-style keyboard-type before after cancel-label on-focus on-blur show-cancel accessibility-label bottom-value secure-text-entry container-style get-ref on-cancel - monospace] + monospace auto-complete-type auto-correct] :or {cancel-label "Cancel"} :as props}] {:pre [(check-spec ::text-input props)]} @@ -164,19 +164,30 @@ :on-press #(reset! visible true)} :else after) - secure (and (true? secure-text-entry) - (or platform/android? (not @visible))) + secure (and secure-text-entry (not @visible)) + auto-complete (cond + (= keyboard-type :visible-password) + :off + + secure-text-entry + :password + + :else + auto-complete-type) + auto-correct (and (not= keyboard-type :visible-password) (not secure-text-entry) auto-correct) on-cancel (fn [] (when on-cancel (on-cancel)) (blur)) keyboard-type (cond - (and platform/ios? (= keyboard-type "visible-password")) - "default" + (and platform/ios? (= keyboard-type :visible-password)) + :default - ;; NOTE: Now switching dynamically brakes android input - (and platform/android? secure-text-entry @visible) - "visible-password" + ; the correct approach on Android would be keep secure-text-entry on set keyboard type + ; to visible-password. But until https://github.com/facebook/react-native/issues/27946 + ; is solved that's the second best way. + (and platform/android? secure-text-entry) + :default :else keyboard-type)] @@ -200,6 +211,8 @@ :underline-color-android :transparent :auto-capitalize :none :secure-text-entry secure + :auto-correct auto-correct + :auto-complete-type auto-complete :on-focus (fn [evt] (when on-focus (on-focus evt)) (when show-cancel @@ -215,7 +228,7 @@ {:clear-button-mode :while-editing}) (dissoc props :style :keyboard-type :on-focus :on-blur - :secure-text-entry :ref :get-ref))] + :secure-text-entry :ref :get-ref :auto-correct :auto-complete-type))] (when after [accessory-element after])] (when (and show-cancel diff --git a/src/status_im/ui/screens/multiaccounts/views.cljs b/src/status_im/ui/screens/multiaccounts/views.cljs index a670279dd6..fca1e9b8a1 100644 --- a/src/status_im/ui/screens/multiaccounts/views.cljs +++ b/src/status_im/ui/screens/multiaccounts/views.cljs @@ -64,6 +64,7 @@ [quo/text-input {:show-cancel false :auto-correct false + :keyboard-type :visible-password :placeholder (i18n/label :t/seed-phrase-placeholder) :monospace true :multiline true diff --git a/src/status_im/ui/screens/onboarding/phrase/view.cljs b/src/status_im/ui/screens/onboarding/phrase/view.cljs index ff561485db..253e0978da 100644 --- a/src/status_im/ui/screens/onboarding/phrase/view.cljs +++ b/src/status_im/ui/screens/onboarding/phrase/view.cljs @@ -94,6 +94,7 @@ :bottom-value 40 :multiline true :auto-correct false + :keyboard-type :visible-password :monospace true}] [react/view {:align-items :flex-end} [react/view {:flex-direction :row diff --git a/src/status_im/ui/screens/profile/seed/views.cljs b/src/status_im/ui/screens/profile/seed/views.cljs index b782b19ee6..3cd55e7272 100644 --- a/src/status_im/ui/screens/profile/seed/views.cljs +++ b/src/status_im/ui/screens/profile/seed/views.cljs @@ -104,7 +104,7 @@ (i18n/label :t/word-n {:number (inc idx)})]] :auto-focus true :auto-correct false - :keyboard-type "visible-password" + :keyboard-type :visible-password :monospace true :on-change-text #(re-frame/dispatch [:set-in [:my-profile/seed :word] %]) :on-submit-editing next-handler diff --git a/src/status_im/ui/screens/wallet/add_new/views.cljs b/src/status_im/ui/screens/wallet/add_new/views.cljs index 5501995db1..92fc84878b 100644 --- a/src/status_im/ui/screens/wallet/add_new/views.cljs +++ b/src/status_im/ui/screens/wallet/add_new/views.cljs @@ -87,7 +87,7 @@ :auto-focus false :placeholder (i18n/label :t/multiaccounts-recover-enter-phrase-title) :auto-correct false - :keyboard-type "visible-password" + :keyboard-type :visible-password :multiline true :height 95 :error account-error @@ -104,7 +104,7 @@ :auto-focus false :placeholder (i18n/label :t/enter-a-private-key) :auto-correct false - :keyboard-type "visible-password" + :keyboard-type :visible-password :error account-error :secure-text-entry true :accessibility-label :add-account-enter-private-key