From 5bb849f9c1a9b2a40471ca85a72b28c82a479429 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 12 Apr 2021 10:26:43 +0200 Subject: [PATCH] Add messages from contacts only --- .../messages_from_contacts_only.cljs | 33 +++++ .../privacy_and_security_settings/views.cljs | 134 ++++++++++-------- .../ui/screens/routing/profile_stack.cljs | 3 + status-go-version.json | 6 +- translations/en.json | 3 + 5 files changed, 115 insertions(+), 64 deletions(-) create mode 100644 src/status_im/ui/screens/privacy_and_security_settings/messages_from_contacts_only.cljs diff --git a/src/status_im/ui/screens/privacy_and_security_settings/messages_from_contacts_only.cljs b/src/status_im/ui/screens/privacy_and_security_settings/messages_from_contacts_only.cljs new file mode 100644 index 0000000000..7f8fb17e72 --- /dev/null +++ b/src/status_im/ui/screens/privacy_and_security_settings/messages_from_contacts_only.cljs @@ -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])}]]])) 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 e4ca2ab8d4..e96e95455d 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 @@ -14,30 +14,33 @@ [quo/separator {:style {:margin-vertical 8}}]) (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] auth-method [:auth-method]] - [react/view {:flex 1 :background-color colors/white} - [topbar/topbar {:title (i18n/label :t/privacy-and-security)}] - [react/scroll-view {:padding-vertical 8} - [quo/list-header (i18n/label :t/security)] - [quo/list-item {:size :small - :title (i18n/label :t/back-up-seed-phrase) - :accessibility-label :back-up-recovery-phrase-button - :disabled (not mnemonic) - :chevron (boolean mnemonic) - :accessory (when mnemonic [components.common/counter {:size 22} 1]) - :on-press #(re-frame/dispatch [:navigate-to :backup-seed])}] - (when supported-biometric-auth - [quo/list-item - {:size :small - :title (str (i18n/label :t/lock-app-with) " " (biometric/get-label supported-biometric-auth)) - :active (= auth-method "biometric") - :accessibility-label :biometric-auth-settings-switch - :accessory :switch - :on-press #(re-frame/dispatch [:multiaccounts.ui/biometric-auth-switched - ((complement boolean) (= auth-method "biometric"))])}]) - [separator] + [react/view {:flex 1 :background-color colors/white} + [topbar/topbar {:title (i18n/label :t/privacy-and-security)}] + [react/scroll-view {:padding-vertical 8} + [quo/list-header (i18n/label :t/security)] + [quo/list-item {:size :small + :title (i18n/label :t/back-up-seed-phrase) + :accessibility-label :back-up-recovery-phrase-button + :disabled (not mnemonic) + :chevron (boolean mnemonic) + :accessory (when mnemonic [components.common/counter {:size 22} 1]) + :on-press #(re-frame/dispatch [:navigate-to :backup-seed])}] + (when supported-biometric-auth + [quo/list-item + {:size :small + :title (str (i18n/label :t/lock-app-with) " " (biometric/get-label supported-biometric-auth)) + :active (= auth-method "biometric") + :accessibility-label :biometric-auth-settings-switch + :accessory :switch + :on-press #(re-frame/dispatch [:multiaccounts.ui/biometric-auth-switched + ((complement boolean) (= auth-method "biometric"))])}]) + [separator] ;; TODO - uncomment when implemented ;; {:size :small ;; :title (i18n/label :t/change-password) @@ -46,42 +49,51 @@ ;; :title (i18n/label :t/change-passcode) ;; :chevron true} - [quo/list-header (i18n/label :t/privacy)] - [quo/list-item {:size :small - :title (i18n/label :t/set-dapp-access-permissions) - :on-press #(re-frame/dispatch [:navigate-to :dapps-permissions]) - :accessibility-label :dapps-permissions-button - :chevron true}] - [quo/list-item {:size :small - :title (if platform/android? - (i18n/label :t/hide-content-when-switching-apps) - (i18n/label :t/hide-content-when-switching-apps-ios)) - :container-margin-bottom 8 - :active preview-privacy? - :accessory :switch - :on-press #(re-frame/dispatch - [:multiaccounts.ui/preview-privacy-mode-switched - ((complement boolean) preview-privacy?)])}] - [quo/list-item {:size :small - :title (i18n/label :t/chat-link-previews) - :chevron true - :on-press #(re-frame/dispatch [:navigate-to :link-previews-settings]) - :accessibility-label :chat-link-previews}] - (when platform/android? - [quo/list-item {:size :small - :title (i18n/label :t/webview-camera-permission-requests) - :active webview-allow-permission-requests? - :accessory :switch - :subtitle (i18n/label :t/webview-camera-permission-requests-subtitle) - :subtitle-max-lines 2 - :on-press #(re-frame/dispatch - [: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}]]])) + [quo/list-header (i18n/label :t/privacy)] + [quo/list-item {:size :small + :title (i18n/label :t/set-dapp-access-permissions) + :on-press #(re-frame/dispatch [:navigate-to :dapps-permissions]) + :accessibility-label :dapps-permissions-button + :chevron true}] + [quo/list-item {:size :small + :title (if platform/android? + (i18n/label :t/hide-content-when-switching-apps) + (i18n/label :t/hide-content-when-switching-apps-ios)) + :container-margin-bottom 8 + :active preview-privacy? + :accessory :switch + :on-press #(re-frame/dispatch + [:multiaccounts.ui/preview-privacy-mode-switched + ((complement boolean) preview-privacy?)])}] + [quo/list-item {:size :small + :title (i18n/label :t/chat-link-previews) + :chevron true + :on-press #(re-frame/dispatch [:navigate-to :link-previews-settings]) + :accessibility-label :chat-link-previews}] + [quo/list-item {:size :small + :title (i18n/label :t/accept-new-chats-from) + :chevron true + :accessory :text + :accessory-text (i18n/label (if messages-from-contacts-only + :t/contacts + :t/anyone)) + :on-press #(re-frame/dispatch [:navigate-to :messages-from-contacts-only]) + :accessibility-label :accept-new-chats-from}] + (when platform/android? + [quo/list-item {:size :small + :title (i18n/label :t/webview-camera-permission-requests) + :active webview-allow-permission-requests? + :accessory :switch + :subtitle (i18n/label :t/webview-camera-permission-requests-subtitle) + :subtitle-max-lines 2 + :on-press #(re-frame/dispatch + [: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}]]])) diff --git a/src/status_im/ui/screens/routing/profile_stack.cljs b/src/status_im/ui/screens/routing/profile_stack.cljs index 899e983533..b041e2db1e 100644 --- a/src/status_im/ui/screens/routing/profile_stack.cljs +++ b/src/status_im/ui/screens/routing/profile_stack.cljs @@ -16,6 +16,7 @@ [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.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.advanced-settings.views :as advanced-settings] [status-im.ui.screens.help-center.views :as help-center] @@ -82,6 +83,8 @@ :component link-previews-settings/link-previews-settings} {:name :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 :component appearance/appearance} {:name :appearance-profile-pic diff --git a/status-go-version.json b/status-go-version.json index 23c2d74342..b41d3ac616 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.75.2", - "commit-sha1": "ddc48c7cf45f8176ed23f82478cd1bde1811e8a6", - "src-sha256": "17nxdspixvj47xli6b2583yll5iky5msiyib8wg6v8m48ssq21ka" + "version": "feature/notification-center-2", + "commit-sha1": "6322d0c1ed9cee5f00eba53ad60daa47fc388944", + "src-sha256": "1ljcds0qfx2n2fm4in5ja12dfbkr0xi5y1h30hkzh1wr104d03gb" } diff --git a/translations/en.json b/translations/en.json index c9a7f8eac6..aea37929df 100644 --- a/translations/en.json +++ b/translations/en.json @@ -9,6 +9,9 @@ "accept-and-share-address": "Accept and share address", "account-added": "Account added", "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-settings": "Account settings", "accounts": "Accounts",