From e2b3394900877e1559020e1036c42d6bc0b69de8 Mon Sep 17 00:00:00 2001 From: Andreas Shimokawa Date: Tue, 7 Feb 2017 10:15:23 +0100 Subject: [PATCH] made caller privacy pebble setting generic --- .../gadgetbridge/impl/GBDeviceService.java | 19 ++++- .../service/devices/pebble/PebbleSupport.java | 8 -- app/src/main/res/values/arrays.xml | 12 +++ app/src/main/res/values/strings.xml | 12 ++- app/src/main/res/values/values.xml | 3 + app/src/main/res/xml/preferences.xml | 85 +++++++++++-------- 6 files changed, 89 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java index c8f83926..05bec9de 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/impl/GBDeviceService.java @@ -11,6 +11,8 @@ import android.support.annotation.Nullable; import java.util.ArrayList; import java.util.UUID; +import nodomain.freeyourgadget.gadgetbridge.GBApplication; +import nodomain.freeyourgadget.gadgetbridge.R; import nodomain.freeyourgadget.gadgetbridge.model.Alarm; import nodomain.freeyourgadget.gadgetbridge.model.CalendarEventSpec; import nodomain.freeyourgadget.gadgetbridge.model.CallSpec; @@ -85,7 +87,7 @@ public class GBDeviceService implements DeviceService { connect(device, false); } - @Override + @Override public void connect(@Nullable GBDevice device, boolean performPair) { Intent intent = createIntent().setAction(ACTION_CONNECT) .putExtra(GBDevice.EXTRA_DEVICE, device) @@ -149,9 +151,22 @@ public class GBDeviceService implements DeviceService { @Override public void onSetCallState(CallSpec callSpec) { + Context context = GBApplication.getContext(); + String currentPrivacyMode = GBApplication.getPrefs().getString("pref_call_privacy_mode", GBApplication.getContext().getString(R.string.p_call_privacy_mode_off)); + if (context.getString(R.string.p_call_privacy_mode_name).equals(currentPrivacyMode)) { + callSpec.name = callSpec.number; + } + else if (context.getString(R.string.p_call_privacy_mode_complete).equals(currentPrivacyMode)) { + callSpec.number = null; + callSpec.name = null; + } + else { + callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number)); + } + Intent intent = createIntent().setAction(ACTION_CALLSTATE) .putExtra(EXTRA_CALL_PHONENUMBER, callSpec.number) - .putExtra(EXTRA_CALL_DISPLAYNAME, coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number))) + .putExtra(EXTRA_CALL_DISPLAYNAME, callSpec.name) .putExtra(EXTRA_CALL_COMMAND, callSpec.command); invokeService(intent); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleSupport.java index e4f59e85..d4afb684 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleSupport.java @@ -131,14 +131,6 @@ public class PebbleSupport extends AbstractSerialDeviceSupport { @Override public void onSetCallState(CallSpec callSpec) { - String currentPrivacyMode = GBApplication.getPrefs().getString("pebble_pref_privacy_mode", getContext().getString(R.string.p_pebble_privacy_mode_off)); - if (getContext().getString(R.string.p_pebble_privacy_mode_complete).equals(currentPrivacyMode)) { - callSpec.name = null; - callSpec.number = null; - } else if (getContext().getString(R.string.p_pebble_privacy_mode_content).equals(currentPrivacyMode)) { - callSpec.name = null; - } - if (reconnect()) { if ((callSpec.command != CallSpec.CALL_OUTGOING) || GBApplication.getPrefs().getBoolean("pebble_enable_outgoing_call", true)) { super.onSetCallState(callSpec); diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index da77e001..88685f63 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -155,4 +155,16 @@ @string/p_timeformat_am_pm + + @string/pref_call_privacy_mode_off + @string/pref_call_privacy_mode_name + @string/pref_call_privacy_mode_complete + + + + @string/p_call_privacy_mode_off + @string/p_call_privacy_mode_name + @string/p_call_privacy_mode_complete + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fbfd13a9..d3661cbd 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -88,6 +88,12 @@ when screen is off never + Privacy + Call Privacy Mode + Display name and number + Hide name but display number + Hide name and number + Blacklist Apps Canned Messages @@ -120,9 +126,9 @@ Notifications are automatically removed from the Pebble when dismissed from the Android device Privacy mode - Normal notifications and incoming calls display. - Shift the notification text off-screen. Hide the caller\'s name on incoming calls. - Show only the notification icon. Hide the caller\'s name and number on incoming calls. + Normal notifications + Shift the notification text off-screen + Show only the notification icon Location Acquire Location diff --git a/app/src/main/res/values/values.xml b/app/src/main/res/values/values.xml index ef1cd4a3..27745d3e 100644 --- a/app/src/main/res/values/values.xml +++ b/app/src/main/res/values/values.xml @@ -22,4 +22,7 @@ content complete + off + name + complete diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 044d5faa..d558fa4b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -36,6 +36,44 @@ android:summaryOff="@string/pref_summary_minimize_priority_off" android:summaryOn="@string/pref_summary_minimize_priority_on" android:title="@string/pref_title_minimize_priority" /> + + + + + + + + + + + + + + - - - - - - - - - - - - - + + +