From 5108ae79727048f29836937b241b4ec2d52649b4 Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Thu, 18 Feb 2021 16:49:31 +0000 Subject: [PATCH] Add private profile pictures --- src/status_im/constants.cljs | 4 ++ src/status_im/multiaccounts/core.cljs | 5 ++ src/status_im/subs.cljs | 6 ++ .../ui/screens/appearance/views.cljs | 33 +--------- .../privacy_and_security_settings/views.cljs | 64 ++++++++++++++++++- src/status_im/ui/screens/screens.cljs | 7 +- src/status_im/utils/config.cljs | 13 ++-- status-go-version.json | 6 +- translations/en.json | 4 +- 9 files changed, 97 insertions(+), 45 deletions(-) diff --git a/src/status_im/constants.cljs b/src/status_im/constants.cljs index f654ebc5c8..f7aff55977 100644 --- a/src/status_im/constants.cljs +++ b/src/status_im/constants.cljs @@ -59,6 +59,10 @@ (def ^:const command-state-transaction-pending 6) (def ^:const command-state-transaction-sent 7) +(def ^:const profile-pictures-show-to-contacts-only 1) +(def ^:const profile-pictures-show-to-everyone 2) +(def ^:const profile-pictures-show-to-none 3) + (def ^:const profile-pictures-visibility-contacts-only 1) (def ^:const profile-pictures-visibility-everyone 2) (def ^:const profile-pictures-visibility-none 3) diff --git a/src/status_im/multiaccounts/core.cljs b/src/status_im/multiaccounts/core.cljs index 17f0cb1734..36f43f6e4a 100644 --- a/src/status_im/multiaccounts/core.cljs +++ b/src/status_im/multiaccounts/core.cljs @@ -170,6 +170,11 @@ {::switch-theme theme} (multiaccounts.update/multiaccount-update :appearance theme {}))) +(fx/defn switch-profile-picture-show-to + {:events [:multiaccounts.ui/profile-picture-show-to-switched]} + [cofx id] + (multiaccounts.update/multiaccount-update cofx :profile-pictures-show-to id {})) + (fx/defn switch-appearance-profile {:events [:multiaccounts.ui/appearance-profile-switched]} [cofx id] diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index 1ceda1260e..d32918fca9 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -2162,6 +2162,12 @@ (fn [[chat contacts] [_ query-fn]] (contact.db/query-chat-contacts chat contacts query-fn))) +(re-frame/reg-sub + :multiaccount/profile-pictures-show-to + :<- [:multiaccount] + (fn [multiaccount] + (get multiaccount :profile-pictures-show-to))) + (re-frame/reg-sub ::profile-pictures-visibility :<- [:multiaccount] diff --git a/src/status_im/ui/screens/appearance/views.cljs b/src/status_im/ui/screens/appearance/views.cljs index 7283bf1e2d..163bb3c40d 100644 --- a/src/status_im/ui/screens/appearance/views.cljs +++ b/src/status_im/ui/screens/appearance/views.cljs @@ -5,12 +5,7 @@ [status-im.react-native.resources :as resources] [quo.core :as quo] [quo.design-system.colors :as colors] - [status-im.i18n.i18n :as i18n] - [status-im.constants :as constants])) - -(def titles {constants/profile-pictures-visibility-contacts-only (i18n/label :t/recent-recipients) - constants/profile-pictures-visibility-everyone (i18n/label :t/everyone) - constants/profile-pictures-visibility-none (i18n/label :t/none)}) + [status-im.i18n.i18n :as i18n])) (defn button [label icon theme selected?] [react/touchable-highlight @@ -27,33 +22,11 @@ (i18n/label label)]]]) (views/defview appearance [] - (views/letsubs [{:keys [appearance profile-pictures-visibility]} [:multiaccount]] + (views/letsubs [{:keys [appearance]} [:multiaccount]] [:<> [quo/list-header (i18n/label :t/preference)] [react/view {:flex-direction :row :padding-horizontal 8 :justify-content :space-between :margin-vertical 16} [button :t/light :theme-light 1 (= 1 appearance)] [button :t/dark :theme-dark 2 (= 2 appearance)] - [button :t/system :theme-system 0 (= 0 appearance)]] - [quo/list-header (i18n/label :t/chat)] - [quo/list-item - {:title (i18n/label :t/show-profile-pictures) - :accessibility-label :show-profile-pictures - :accessory :text - :accessory-text (get titles profile-pictures-visibility) - :on-press #(re-frame/dispatch [:navigate-to :appearance-profile-pic]) - :chevron true}]])) - -(defn radio-item [id value] - [quo/list-item - {:active (= value id) - :accessory :radio - :title (get titles id) - :on-press #(re-frame/dispatch [:multiaccounts.ui/appearance-profile-switched id])}]) - -(views/defview profile-pic [] - (views/letsubs [{:keys [profile-pictures-visibility]} [:multiaccount]] - [react/view {:margin-top 8} - [radio-item constants/profile-pictures-visibility-everyone profile-pictures-visibility] - [radio-item constants/profile-pictures-visibility-contacts-only profile-pictures-visibility] - [radio-item constants/profile-pictures-visibility-none profile-pictures-visibility]])) \ No newline at end of file + [button :t/system :theme-system 0 (= 0 appearance)]]])) diff --git a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs index 1cdc0d5f81..2d140c9227 100644 --- a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs +++ b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs @@ -9,21 +9,31 @@ [status-im.utils.config :as config] [status-im.multiaccounts.update.core :as multiaccounts.update] [status-im.multiaccounts.biometric.core :as biometric] - [status-im.utils.platform :as platform]) + [status-im.utils.platform :as platform] + [status-im.constants :as constants]) (:require-macros [status-im.utils.views :as views])) (defn separator [] [quo/separator {:style {:margin-vertical 8}}]) +(def titles {constants/profile-pictures-visibility-contacts-only (i18n/label :t/recent-recipients) + constants/profile-pictures-visibility-everyone (i18n/label :t/everyone) + constants/profile-pictures-visibility-none (i18n/label :t/none) + constants/profile-pictures-show-to-contacts-only (i18n/label :t/recent-recipients) + constants/profile-pictures-show-to-everyone (i18n/label :t/everyone) + constants/profile-pictures-show-to-none (i18n/label :t/none)}) + (views/defview privacy-and-security [] (views/letsubs [{:keys [mnemonic preview-privacy? messages-from-contacts-only webview-allow-permission-requests? - opensea-enabled?]} [:multiaccount] + opensea-enabled? + profile-pictures-visibility]} [:multiaccount] supported-biometric-auth [:supported-biometric-auth] keycard? [:keycard-multiaccount?] - auth-method [:auth-method]] + auth-method [:auth-method] + profile-pictures-show-to [:multiaccount/profile-pictures-show-to]] [react/scroll-view {:padding-vertical 8} [quo/list-header (i18n/label :t/security)] [quo/list-item {:size :small @@ -111,6 +121,26 @@ :chevron true :on-press #(re-frame/dispatch [::key-storage/logout-and-goto-key-storage]) :accessibility-label :key-managment}]) + + [separator] + [quo/list-header (i18n/label :t/privacy-photos)] + [quo/list-item + {:size :small + :title (i18n/label :t/show-profile-pictures) + :accessibility-label :show-profile-pictures + :accessory :text + :accessory-text (get titles profile-pictures-visibility) + :on-press #(re-frame/dispatch [:navigate-to :privacy-and-security-profile-pic]) + :chevron true}] + [quo/list-item + {:size :small + :title (i18n/label :t/show-profile-pictures-to) + :accessibility-label :show-profile-pictures-to + :accessory :text + :accessory-text (get titles profile-pictures-show-to) + :on-press #(re-frame/dispatch [:navigate-to :privacy-and-security-profile-pic-show-to]) + :chevron true}] + [separator] [quo/list-item {:size :small @@ -119,3 +149,31 @@ :on-press #(re-frame/dispatch [:navigate-to :delete-profile]) :accessibility-label :dapps-permissions-button :chevron true}]])) + +(defn ppst-radio-item [id value] + [quo/list-item + {:active (= value id) + :accessory :radio + :title (get titles id) + :on-press #(re-frame/dispatch [:multiaccounts.ui/profile-picture-show-to-switched id])}]) + +(views/defview profile-pic-show-to [] + (views/letsubs [{:keys [profile-pictures-show-to]} [:multiaccount]] + [react/view {:margin-top 8} + [ppst-radio-item constants/profile-pictures-show-to-everyone profile-pictures-show-to] + [ppst-radio-item constants/profile-pictures-show-to-contacts-only profile-pictures-show-to] + [ppst-radio-item constants/profile-pictures-show-to-none profile-pictures-show-to]])) + +(defn ppvf-radio-item [id value] + [quo/list-item + {:active (= value id) + :accessory :radio + :title (get titles id) + :on-press #(re-frame/dispatch [:multiaccounts.ui/appearance-profile-switched id])}]) + +(views/defview profile-pic [] + (views/letsubs [{:keys [profile-pictures-visibility]} [:multiaccount]] + [react/view {:margin-top 8} + [ppvf-radio-item constants/profile-pictures-visibility-everyone profile-pictures-visibility] + [ppvf-radio-item constants/profile-pictures-visibility-contacts-only profile-pictures-visibility] + [ppvf-radio-item constants/profile-pictures-visibility-none profile-pictures-visibility]])) \ No newline at end of file diff --git a/src/status_im/ui/screens/screens.cljs b/src/status_im/ui/screens/screens.cljs index e8033e5269..0ff4421039 100644 --- a/src/status_im/ui/screens/screens.cljs +++ b/src/status_im/ui/screens/screens.cljs @@ -466,9 +466,12 @@ {:name :appearance :options {:topBar {:title {:text (i18n/label :t/appearance)}}} :component appearance/appearance} - {:name :appearance-profile-pic + {:name :privacy-and-security-profile-pic-show-to + :options {:topbar {:title {:text (i18n/label :t/show-profile-pictures-to)}}} + :component privacy-and-security/profile-pic-show-to} + {:name :privacy-and-security-profile-pic :options {:topBar {:title {:text (i18n/label :t/show-profile-pictures)}}} - :component appearance/profile-pic} + :component privacy-and-security/profile-pic} {:name :notifications :options {:topBar {:title {:text (i18n/label :t/notification-settings)}}} :component notifications-settings/notifications-settings} diff --git a/src/status_im/utils/config.cljs b/src/status_im/utils/config.cljs index da07b6f0c9..db43809924 100644 --- a/src/status_im/utils/config.cljs +++ b/src/status_im/utils/config.cljs @@ -78,12 +78,13 @@ (def verify-ens-contract-address (get-config :VERIFY_ENS_CONTRACT_ADDRESS ((ethereum/chain-id->chain-keyword verify-ens-chain-id) ens/ens-registries))) (def default-multiaccount - {:preview-privacy? blank-preview? - :wallet/visible-tokens {:mainnet #{:SNT}} - :currency :usd - :appearance 0 - :profile-pictures-visibility 1 - :log-level log-level + {:preview-privacy? blank-preview? + :wallet/visible-tokens {:mainnet #{:SNT}} + :currency :usd + :appearance 0 + :profile-pictures-show-to 1 + :profile-pictures-visibility 1 + :log-level log-level :webview-allow-permission-requests? false :anon-metrics/should-send? false :opensea-enabled? false diff --git a/status-go-version.json b/status-go-version.json index 791cbbaaaa..d872c4841d 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.88.4", - "commit-sha1": "d65494d1f83f6b644b0c5d6dffdbf36c8a2d505a", - "src-sha256": "0gg9izv5hagkmy39g8qiq0zrv6jarhbi725vfv9lv03a77b73h58" + "version": "v0.89.2", + "commit-sha1": "51493d61bdb71cbac06acbd120d23f434082cfa4", + "src-sha256": "080rally5qzv9hji753whx409m6ydl1g184s1myc4xr9fwk1hd6d" } diff --git a/translations/en.json b/translations/en.json index 10f06fcbd8..5e88816d40 100644 --- a/translations/en.json +++ b/translations/en.json @@ -1021,6 +1021,7 @@ "pin-one-attempt-frozen-after": "before your Keycard gets frozen", "preview-privacy": "Preview privacy mode", "privacy": "Privacy", + "privacy-photos": "Profile Photo Privacy", "privacy-and-security": "Privacy and security", "privacy-policy": "Privacy policy", "processing": "Just a moment", @@ -1523,7 +1524,8 @@ "transfer-ma-unknown-error-desc-1": "It looks like your multiaccount was not deleted. Database may have been reset", "transfer-ma-unknown-error-desc-2": "Please check your account list and try again. If the account is not listed go to Access existing keys to recover with seed phrase", "everyone": "Everyone", - "show-profile-pictures": "Show profile pictures of", + "show-profile-pictures": "See profile pictures from", + "show-profile-pictures-to": "Show your profile picture to", "non-archival-node": "RPC endpoint doesn't support archival requests. Your local transfers history might be incomplete.", "custom-node": "You are using custom RPC endpoint. Your local transfers history might be incomplete.", "connection-status": "Connection status",