From b30421d5c4085b95d2838c4e1ff03de94d45b77d Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 15 Sep 2020 10:34:49 -0300 Subject: [PATCH] [IMPROVEMENT] Add "Allow_Save_Media_to_Gallery" setting (#2459) * [IMPROVEMENT] Add "Allow_Save_Media_to_Gallery" setting * Default true for old servers --- app/constants/settings.js | 3 +++ app/views/AttachmentView.js | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/constants/settings.js b/app/constants/settings.js index be43be3d9..ccb1803e2 100644 --- a/app/constants/settings.js +++ b/app/constants/settings.js @@ -184,5 +184,8 @@ export default { }, Force_Screen_Lock_After: { type: 'valueAsNumber' + }, + Allow_Save_Media_to_Gallery: { + type: 'valueAsBoolean' } }; diff --git a/app/views/AttachmentView.js b/app/views/AttachmentView.js index 6f43823da..770c30c21 100644 --- a/app/views/AttachmentView.js +++ b/app/views/AttachmentView.js @@ -42,7 +42,8 @@ class AttachmentView extends React.Component { user: PropTypes.shape({ id: PropTypes.string, token: PropTypes.string - }) + }), + Allow_Save_Media_to_Gallery: PropTypes.bool } constructor(props) { @@ -68,7 +69,9 @@ class AttachmentView extends React.Component { } setHeader = () => { - const { route, navigation, theme } = this.props; + const { + route, navigation, theme, Allow_Save_Media_to_Gallery + } = this.props; const attachment = route.params?.attachment; let { title } = attachment; try { @@ -79,10 +82,14 @@ class AttachmentView extends React.Component { const options = { title, headerLeft: () => , - headerRight: () => , + headerRight: () => ( + Allow_Save_Media_to_Gallery + ? + : null + ), headerBackground: () => , headerTintColor: themes[theme].previewTintColor, - headerTitleStyle: { color: themes[theme].previewTintColor } + headerTitleStyle: { color: themes[theme].previewTintColor, marginHorizontal: 10 } }; navigation.setOptions(options); } @@ -180,7 +187,8 @@ class AttachmentView extends React.Component { const mapStateToProps = state => ({ baseUrl: state.server.server, - user: getUserSelector(state) + user: getUserSelector(state), + Allow_Save_Media_to_Gallery: state.settings.Allow_Save_Media_to_Gallery ?? true }); export default connect(mapStateToProps)(withTheme(withDimensions(withSafeAreaInsets(AttachmentView))));