diff --git a/src/status_im/translations/en.cljs b/src/status_im/translations/en.cljs index 3e272b8f17..71d7939f36 100644 --- a/src/status_im/translations/en.cljs +++ b/src/status_im/translations/en.cljs @@ -25,6 +25,8 @@ :add "Add" :yes "Yes" :no "No" + :on "On" + :off "Off" :camera-access-error "To grant the required camera permission, please go to your system settings and make sure that Status > Camera is selected." :photos-access-error "To grant the required photos permission, please go to your system settings and make sure that Status > Photos is selected." @@ -47,6 +49,7 @@ :sign-you-in "Signing you in…" :help-improve "Help improve Status\nby sharing usage patterns" + :help-improve? "Help improve Status?" :help-improve-description "We collect anonymous data to help improve Status." :share-usage-data "Share usage" :dont-want-to-share "No, I don't want to share" diff --git a/src/status_im/ui/screens/accounts/events.cljs b/src/status_im/ui/screens/accounts/events.cljs index 976de5c209..27a48b6a79 100644 --- a/src/status_im/ui/screens/accounts/events.cljs +++ b/src/status_im/ui/screens/accounts/events.cljs @@ -205,7 +205,7 @@ :account-set-name (fn [{{:accounts/keys [create] :as db} :db} _] (-> {:db (assoc-in db [:accounts/create :show-welcome?] true) - :dispatch [:navigate-to-clean :usage-data]} + :dispatch [:navigate-to-clean :usage-data [:account-finalized]]} (account-update {:name (:name create)})))) (handlers/register-handler-fx diff --git a/src/status_im/ui/screens/db.cljs b/src/status_im/ui/screens/db.cljs index f20921635f..c52e1ff842 100644 --- a/src/status_im/ui/screens/db.cljs +++ b/src/status_im/ui/screens/db.cljs @@ -106,13 +106,16 @@ (spec/def :navigation.screen-params.dapp-description/dapp :new/open-dapp) (spec/def :navigation.screen-params/dapp-description map?) +(spec/def :navigation.screen-params/usage-data vector?) + (spec/def :navigation/screen-params (spec/nilable (allowed-keys :opt-un [:navigation.screen-params/network-details :navigation.screen-params/browser :navigation.screen-params/profile-qr-viewer :navigation.screen-params/qr-scanner :navigation.screen-params/group-contacts :navigation.screen-params/edit-contact-group - :navigation.screen-params/dapp-description]))) + :navigation.screen-params/dapp-description + :navigation.screen-params/usage-data]))) (spec/def :desktop/desktop (spec/nilable any?)) diff --git a/src/status_im/ui/screens/navigation.cljs b/src/status_im/ui/screens/navigation.cljs index 3cbc31c30c..07f926df8c 100644 --- a/src/status_im/ui/screens/navigation.cljs +++ b/src/status_im/ui/screens/navigation.cljs @@ -23,10 +23,14 @@ ;; public fns -(defn navigate-to-clean [db view-id] - (-> db - (assoc :navigation-stack (list)) - (push-view view-id))) +(defn navigate-to-clean + ([db view-id] (navigate-to-clean db view-id nil)) + ([db view-id screen-params] + ;; TODO (jeluard) Unify all :navigate-to flavours. Maybe accept a map of parameters? + (let [db (cond-> db + (seq screen-params) + (assoc-in [:navigation/screen-params view-id] screen-params))] + (push-view db view-id)))) (defmulti preload-data! (fn [db [_ view-id]] (or view-id (:view-id db)))) @@ -96,8 +100,8 @@ (register-handler-db :navigate-to-clean - (fn [db [_ view-id]] - (navigate-to-clean db view-id))) + (fn [db [_ & params]] + (apply navigate-to db params))) (register-handler-db :navigate-to-tab diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index 925c4965ca..d6a1c73a8b 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -127,7 +127,8 @@ :action-fn #(handle-logout sharing-usage-data?)}]])) (defview advanced [{:keys [network networks dev-mode?]}] - (letsubs [advanced? [:get :my-profile/advanced?]] + (letsubs [advanced? [:get :my-profile/advanced?] + {:keys [sharing-usage-data?]} [:get-current-account]] [react/view [react/touchable-highlight {:on-press #(re-frame/dispatch [:set :my-profile/advanced? (not advanced?)]) :style styles/advanced-button} @@ -155,7 +156,13 @@ [profile.components/settings-switch-item {:label-kw :t/dev-mode :value dev-mode? - :action-fn #(re-frame/dispatch [:switch-dev-mode %])}]])])) + :action-fn #(re-frame/dispatch [:switch-dev-mode %])}] + [profile.components/settings-item-separator] + [profile.components/settings-item + {:label-kw :t/help-improve? + :value (i18n/label (if sharing-usage-data? :on :off)) + :action-fn #(re-frame/dispatch [:navigate-to :usage-data [:navigate-back]]) + :accessibility-label :help-improve}]])])) (defview my-profile [] (letsubs [{:keys [public-key sharing-usage-data?] :as current-account} [:get-current-account] diff --git a/src/status_im/ui/screens/usage_data/events.cljs b/src/status_im/ui/screens/usage_data/events.cljs index 419aa2edd3..3f2beabe83 100644 --- a/src/status_im/ui/screens/usage_data/events.cljs +++ b/src/status_im/ui/screens/usage_data/events.cljs @@ -4,9 +4,10 @@ (handlers/register-handler-fx :help-improve-handler - (fn [{db :db} [_ yes? address]] - (merge (when yes? - (accounts/account-update {:db db} {:sharing-usage-data? true})) - {:dispatch-n [(when yes? [:register-mixpanel-tracking address]) - [:account-finalized]]}))) + (fn [{db :db} [_ yes? address next]] + (merge (accounts/account-update {:db db} {:sharing-usage-data? yes?}) + {:dispatch-n [(if yes? + [:register-mixpanel-tracking address] + [:unregister-mixpanel-tracking]) + next]}))) diff --git a/src/status_im/ui/screens/usage_data/views.cljs b/src/status_im/ui/screens/usage_data/views.cljs index 18b36a67ca..2c9e044df5 100644 --- a/src/status_im/ui/screens/usage_data/views.cljs +++ b/src/status_im/ui/screens/usage_data/views.cljs @@ -1,15 +1,16 @@ (ns status-im.ui.screens.usage-data.views (:require-macros [status-im.utils.views :as views]) - (:require [status-im.ui.components.react :as react] - [re-frame.core :as re-frame] + (:require [re-frame.core :as re-frame] + [status-im.i18n :as i18n] [status-im.react-native.resources :as resources] [status-im.ui.components.common.common :as components.common] - [status-im.ui.screens.usage-data.styles :as styles] - [status-im.i18n :as i18n] - [status-im.ui.components.status-bar.view :as status-bar])) + [status-im.ui.components.react :as react] + [status-im.ui.components.status-bar.view :as status-bar] + [status-im.ui.screens.usage-data.styles :as styles])) (views/defview usage-data [] - (views/letsubs [account [:get-current-account]] + (views/letsubs [next [:get-screen-params] + account [:get-current-account]] [react/view {:style styles/usage-data-view} [status-bar/status-bar {:flat? true}] [react/view {:style styles/logo-container} @@ -23,9 +24,9 @@ (i18n/label :t/help-improve-description)]] [react/view styles/buttons-container [components.common/button {:style {:flex-direction :row} - :on-press #(re-frame/dispatch [:help-improve-handler true (:address account)]) + :on-press #(re-frame/dispatch [:help-improve-handler true (:address account) next]) :label (i18n/label :t/share-usage-data)}] [react/view styles/bottom-button-container - [components.common/button {:on-press #(re-frame/dispatch [:help-improve-handler false (:address account)]) + [components.common/button {:on-press #(re-frame/dispatch [:help-improve-handler false (:address account) next]) :label (i18n/label :t/dont-want-to-share) :background? false}]]]]))