Add messages from contacts only

This commit is contained in:
Andrea Maria Piana 2021-04-12 10:26:43 +02:00
parent 310a1ad5f1
commit 5bb849f9c1
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
5 changed files with 115 additions and 64 deletions

View File

@ -0,0 +1,33 @@
(ns status-im.ui.screens.privacy-and-security-settings.messages-from-contacts-only
(:require-macros [status-im.utils.views :as views])
(:require [re-frame.core :as re-frame]
[status-im.utils.fx :as fx]
[status-im.ui.components.react :as react]
[status-im.multiaccounts.update.core :as multiaccounts.update]
[status-im.ui.components.topbar :as topbar]
[status-im.i18n.i18n :as i18n]
[quo.core :as quo]))
(fx/defn handle-messages-from-contacts-only-switched
{:events [::messages-from-contacts-only-switched]}
[cofx value]
(multiaccounts.update/multiaccount-update cofx
:messages-from-contacts-only value {}))
(views/defview messages-from-contacts-only []
(views/letsubs [{:keys [messages-from-contacts-only]} [:multiaccount]]
[react/view {:flex 1}
[topbar/topbar {:title (i18n/label :t/accept-new-chats-from)}]
[react/view {:margin-top 8}
[quo/list-item
{:active (not messages-from-contacts-only)
:accessory :radio
:title (i18n/label :t/anyone)
:on-press #(re-frame/dispatch [::messages-from-contacts-only-switched false])}]
[quo/list-item
{:active messages-from-contacts-only
:accessory :radio
:title (i18n/label :t/contacts)
:subtitle (i18n/label :t/messages-from-contacts-only-subtitle)
:subtitle-max-lines 4
:on-press #(re-frame/dispatch [::messages-from-contacts-only-switched true])}]]]))

View File

@ -14,30 +14,33 @@
[quo/separator {:style {:margin-vertical 8}}]) [quo/separator {:style {:margin-vertical 8}}])
(views/defview privacy-and-security [] (views/defview privacy-and-security []
(views/letsubs [{:keys [mnemonic preview-privacy? webview-allow-permission-requests?]} [:multiaccount] (views/letsubs [{:keys [mnemonic
preview-privacy?
messages-from-contacts-only
webview-allow-permission-requests?]} [:multiaccount]
supported-biometric-auth [:supported-biometric-auth] supported-biometric-auth [:supported-biometric-auth]
auth-method [:auth-method]] auth-method [:auth-method]]
[react/view {:flex 1 :background-color colors/white} [react/view {:flex 1 :background-color colors/white}
[topbar/topbar {:title (i18n/label :t/privacy-and-security)}] [topbar/topbar {:title (i18n/label :t/privacy-and-security)}]
[react/scroll-view {:padding-vertical 8} [react/scroll-view {:padding-vertical 8}
[quo/list-header (i18n/label :t/security)] [quo/list-header (i18n/label :t/security)]
[quo/list-item {:size :small [quo/list-item {:size :small
:title (i18n/label :t/back-up-seed-phrase) :title (i18n/label :t/back-up-seed-phrase)
:accessibility-label :back-up-recovery-phrase-button :accessibility-label :back-up-recovery-phrase-button
:disabled (not mnemonic) :disabled (not mnemonic)
:chevron (boolean mnemonic) :chevron (boolean mnemonic)
:accessory (when mnemonic [components.common/counter {:size 22} 1]) :accessory (when mnemonic [components.common/counter {:size 22} 1])
:on-press #(re-frame/dispatch [:navigate-to :backup-seed])}] :on-press #(re-frame/dispatch [:navigate-to :backup-seed])}]
(when supported-biometric-auth (when supported-biometric-auth
[quo/list-item [quo/list-item
{:size :small {:size :small
:title (str (i18n/label :t/lock-app-with) " " (biometric/get-label supported-biometric-auth)) :title (str (i18n/label :t/lock-app-with) " " (biometric/get-label supported-biometric-auth))
:active (= auth-method "biometric") :active (= auth-method "biometric")
:accessibility-label :biometric-auth-settings-switch :accessibility-label :biometric-auth-settings-switch
:accessory :switch :accessory :switch
:on-press #(re-frame/dispatch [:multiaccounts.ui/biometric-auth-switched :on-press #(re-frame/dispatch [:multiaccounts.ui/biometric-auth-switched
((complement boolean) (= auth-method "biometric"))])}]) ((complement boolean) (= auth-method "biometric"))])}])
[separator] [separator]
;; TODO - uncomment when implemented ;; TODO - uncomment when implemented
;; {:size :small ;; {:size :small
;; :title (i18n/label :t/change-password) ;; :title (i18n/label :t/change-password)
@ -46,42 +49,51 @@
;; :title (i18n/label :t/change-passcode) ;; :title (i18n/label :t/change-passcode)
;; :chevron true} ;; :chevron true}
[quo/list-header (i18n/label :t/privacy)] [quo/list-header (i18n/label :t/privacy)]
[quo/list-item {:size :small [quo/list-item {:size :small
:title (i18n/label :t/set-dapp-access-permissions) :title (i18n/label :t/set-dapp-access-permissions)
:on-press #(re-frame/dispatch [:navigate-to :dapps-permissions]) :on-press #(re-frame/dispatch [:navigate-to :dapps-permissions])
:accessibility-label :dapps-permissions-button :accessibility-label :dapps-permissions-button
:chevron true}] :chevron true}]
[quo/list-item {:size :small [quo/list-item {:size :small
:title (if platform/android? :title (if platform/android?
(i18n/label :t/hide-content-when-switching-apps) (i18n/label :t/hide-content-when-switching-apps)
(i18n/label :t/hide-content-when-switching-apps-ios)) (i18n/label :t/hide-content-when-switching-apps-ios))
:container-margin-bottom 8 :container-margin-bottom 8
:active preview-privacy? :active preview-privacy?
:accessory :switch :accessory :switch
:on-press #(re-frame/dispatch :on-press #(re-frame/dispatch
[:multiaccounts.ui/preview-privacy-mode-switched [:multiaccounts.ui/preview-privacy-mode-switched
((complement boolean) preview-privacy?)])}] ((complement boolean) preview-privacy?)])}]
[quo/list-item {:size :small [quo/list-item {:size :small
:title (i18n/label :t/chat-link-previews) :title (i18n/label :t/chat-link-previews)
:chevron true :chevron true
:on-press #(re-frame/dispatch [:navigate-to :link-previews-settings]) :on-press #(re-frame/dispatch [:navigate-to :link-previews-settings])
:accessibility-label :chat-link-previews}] :accessibility-label :chat-link-previews}]
(when platform/android? [quo/list-item {:size :small
[quo/list-item {:size :small :title (i18n/label :t/accept-new-chats-from)
:title (i18n/label :t/webview-camera-permission-requests) :chevron true
:active webview-allow-permission-requests? :accessory :text
:accessory :switch :accessory-text (i18n/label (if messages-from-contacts-only
:subtitle (i18n/label :t/webview-camera-permission-requests-subtitle) :t/contacts
:subtitle-max-lines 2 :t/anyone))
:on-press #(re-frame/dispatch :on-press #(re-frame/dispatch [:navigate-to :messages-from-contacts-only])
[:multiaccounts.ui/webview-permission-requests-switched :accessibility-label :accept-new-chats-from}]
((complement boolean) webview-allow-permission-requests?)])}]) (when platform/android?
[separator] [quo/list-item {:size :small
[quo/list-item :title (i18n/label :t/webview-camera-permission-requests)
{:size :small :active webview-allow-permission-requests?
:theme :negative :accessory :switch
:title (i18n/label :t/delete-my-profile) :subtitle (i18n/label :t/webview-camera-permission-requests-subtitle)
:on-press #(re-frame/dispatch [:navigate-to :delete-profile]) :subtitle-max-lines 2
:accessibility-label :dapps-permissions-button :on-press #(re-frame/dispatch
:chevron true}]]])) [:multiaccounts.ui/webview-permission-requests-switched
((complement boolean) webview-allow-permission-requests?)])}])
[separator]
[quo/list-item
{:size :small
:theme :negative
:title (i18n/label :t/delete-my-profile)
:on-press #(re-frame/dispatch [:navigate-to :delete-profile])
:accessibility-label :dapps-permissions-button
:chevron true}]]]))

View File

@ -16,6 +16,7 @@
[status-im.ui.screens.dapps-permissions.views :as dapps-permissions] [status-im.ui.screens.dapps-permissions.views :as dapps-permissions]
[status-im.ui.screens.link-previews-settings.views :as link-previews-settings] [status-im.ui.screens.link-previews-settings.views :as link-previews-settings]
[status-im.ui.screens.privacy-and-security-settings.views :as privacy-and-security] [status-im.ui.screens.privacy-and-security-settings.views :as privacy-and-security]
[status-im.ui.screens.privacy-and-security-settings.messages-from-contacts-only :as messages-from-contacts-only]
[status-im.ui.screens.sync-settings.views :as sync-settings] [status-im.ui.screens.sync-settings.views :as sync-settings]
[status-im.ui.screens.advanced-settings.views :as advanced-settings] [status-im.ui.screens.advanced-settings.views :as advanced-settings]
[status-im.ui.screens.help-center.views :as help-center] [status-im.ui.screens.help-center.views :as help-center]
@ -82,6 +83,8 @@
:component link-previews-settings/link-previews-settings} :component link-previews-settings/link-previews-settings}
{:name :privacy-and-security {:name :privacy-and-security
:component privacy-and-security/privacy-and-security} :component privacy-and-security/privacy-and-security}
{:name :messages-from-contacts-only
:component messages-from-contacts-only/messages-from-contacts-only}
{:name :appearance {:name :appearance
:component appearance/appearance} :component appearance/appearance}
{:name :appearance-profile-pic {:name :appearance-profile-pic

View File

@ -2,7 +2,7 @@
"_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead", "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh <tag>' instead",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.75.2", "version": "feature/notification-center-2",
"commit-sha1": "ddc48c7cf45f8176ed23f82478cd1bde1811e8a6", "commit-sha1": "6322d0c1ed9cee5f00eba53ad60daa47fc388944",
"src-sha256": "17nxdspixvj47xli6b2583yll5iky5msiyib8wg6v8m48ssq21ka" "src-sha256": "1ljcds0qfx2n2fm4in5ja12dfbkr0xi5y1h30hkzh1wr104d03gb"
} }

View File

@ -9,6 +9,9 @@
"accept-and-share-address": "Accept and share address", "accept-and-share-address": "Accept and share address",
"account-added": "Account added", "account-added": "Account added",
"account-color": "Account color", "account-color": "Account color",
"anyone": "Anyone",
"messages-from-contacts-only-subtitle": "Only people you added as contacts can start a new chat with you or invite you to a group",
"accept-new-chats-from": "Accept new chats from",
"account-name": "Account name", "account-name": "Account name",
"account-settings": "Account settings", "account-settings": "Account settings",
"accounts": "Accounts", "accounts": "Accounts",