Add private profile pictures

This commit is contained in:
Samuel Hawksby-Robinson 2021-02-18 16:49:31 +00:00 committed by Andrea Maria Piana
parent 79be879306
commit 5108ae7972
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
9 changed files with 97 additions and 45 deletions

View File

@ -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)

View File

@ -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]

View File

@ -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]

View File

@ -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]]))
[button :t/system :theme-system 0 (= 0 appearance)]]]))

View File

@ -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]]))

View File

@ -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}

View File

@ -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

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
"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"
}

View File

@ -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",