Message privacy: Add mode Hide only body

This commit is contained in:
Davis Mosenkovs 2023-10-02 20:03:04 +03:00
parent 5f05a0d88f
commit 26e6d7469f
4 changed files with 11 additions and 6 deletions

View File

@ -162,9 +162,10 @@ public class GBDeviceService implements DeviceService {
@Override
public void onNotification(NotificationSpec notificationSpec) {
boolean hideMessageDetails = GBApplication.getPrefs().getString("pref_message_privacy_mode",
GBApplication.getContext().getString(R.string.p_message_privacy_mode_off))
.equals(GBApplication.getContext().getString(R.string.p_message_privacy_mode_complete));
String messagePrivacyMode = GBApplication.getPrefs().getString("pref_message_privacy_mode",
GBApplication.getContext().getString(R.string.p_message_privacy_mode_off));
boolean hideMessageDetails = messagePrivacyMode.equals(GBApplication.getContext().getString(R.string.p_message_privacy_mode_complete));
boolean hideMessageBodyOnly = messagePrivacyMode.equals(GBApplication.getContext().getString(R.string.p_message_privacy_mode_bodyonly));
Intent intent = createIntent().setAction(ACTION_NOTIFICATION)
.putExtra(EXTRA_NOTIFICATION_FLAGS, notificationSpec.flags)
@ -172,7 +173,7 @@ public class GBDeviceService implements DeviceService {
.putExtra(EXTRA_NOTIFICATION_SENDER, hideMessageDetails ? null : coalesce(notificationSpec.sender, getContactDisplayNameByNumber(notificationSpec.phoneNumber)))
.putExtra(EXTRA_NOTIFICATION_SUBJECT, hideMessageDetails ? null : notificationSpec.subject)
.putExtra(EXTRA_NOTIFICATION_TITLE, hideMessageDetails ? null : notificationSpec.title)
.putExtra(EXTRA_NOTIFICATION_BODY, hideMessageDetails ? null : notificationSpec.body)
.putExtra(EXTRA_NOTIFICATION_BODY, hideMessageDetails || hideMessageBodyOnly ? null : notificationSpec.body)
.putExtra(EXTRA_NOTIFICATION_ID, notificationSpec.getId())
.putExtra(EXTRA_NOTIFICATION_TYPE, notificationSpec.type)
.putExtra(EXTRA_NOTIFICATION_ACTIONS, notificationSpec.attachedActions)

View File

@ -2062,11 +2062,13 @@
<string-array name="pref_message_privacy_mode">
<item name="off">@string/pref_message_privacy_mode_off</item>
<item name="complete">@string/pref_message_privacy_mode_complete</item>
<item name="bodyonly">@string/pref_message_privacy_mode_bodyonly</item>
</string-array>
<string-array name="pref_message_privacy_mode_values">
<item>@string/p_message_privacy_mode_off</item>
<item>@string/p_message_privacy_mode_complete</item>
<item>@string/p_message_privacy_mode_bodyonly</item>
</string-array>

View File

@ -293,8 +293,9 @@
<string name="pref_call_privacy_mode_number">Hide number but display name</string>
<string name="pref_call_privacy_mode_complete">Hide name and number</string>
<string name="pref_title_message_privacy_mode">Message privacy mode</string>
<string name="pref_message_privacy_mode_off">Display content</string>
<string name="pref_message_privacy_mode_complete">Hide content</string>
<string name="pref_message_privacy_mode_off">Display all content</string>
<string name="pref_message_privacy_mode_complete">Hide all content</string>
<string name="pref_message_privacy_mode_bodyonly">Hide only body</string>
<string name="pref_title_weather">Weather</string>
<string name="pref_title_weather_location">Weather location (for LineageOS weather provider)</string>
<string name="pref_title_weather_summary">Used for the LineageOS weather provider, other Android versions need to use an app like \"Weather notification\". Find more information in the Gadgetbridge wiki.</string>

View File

@ -108,6 +108,7 @@
<item name="p_message_privacy_mode_off" type="string">off</item>
<item name="p_message_privacy_mode_complete" type="string">complete</item>
<item name="p_message_privacy_mode_bodyonly" type="string">bodyonly</item>
<item name="pref_button_action_disabled_value" translatable="false" type="string">UNKNOWN</item>
<item name="pref_media_play_value" translatable="false" type="string">PLAY</item>