1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2025-01-26 17:47:34 +01:00

Add privacy mode that hides the phone number (#588)

This commit is contained in:
Alberto 2017-03-14 21:37:16 +01:00 committed by cpfeiffer
parent 17ecee0cab
commit 6989ca9db3
4 changed files with 29 additions and 19 deletions

View File

@ -73,9 +73,9 @@ public class GBDeviceService implements DeviceService {
} }
protected void invokeService(Intent intent) { protected void invokeService(Intent intent) {
if(LanguageUtils.transliterate()){ if (LanguageUtils.transliterate()) {
for (String extra: transliterationExtras) { for (String extra : transliterationExtras) {
if (intent.hasExtra(extra)){ if (intent.hasExtra(extra)) {
intent.putExtra(extra, LanguageUtils.transliterate(intent.getStringExtra(extra))); intent.putExtra(extra, LanguageUtils.transliterate(intent.getStringExtra(extra)));
} }
} }
@ -172,12 +172,15 @@ public class GBDeviceService implements DeviceService {
String currentPrivacyMode = GBApplication.getPrefs().getString("pref_call_privacy_mode", GBApplication.getContext().getString(R.string.p_call_privacy_mode_off)); 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)) { if (context.getString(R.string.p_call_privacy_mode_name).equals(currentPrivacyMode)) {
callSpec.name = callSpec.number; callSpec.name = callSpec.number;
} } else if (context.getString(R.string.p_call_privacy_mode_complete).equals(currentPrivacyMode)) {
else if (context.getString(R.string.p_call_privacy_mode_complete).equals(currentPrivacyMode)) {
callSpec.number = null; callSpec.number = null;
callSpec.name = null; callSpec.name = null;
} else if (context.getString(R.string.pref_call_privacy_mode_number).equals(currentPrivacyMode)) {
callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number));
if (!callSpec.name.equals(callSpec.number)) {
callSpec.number = null;
} }
else { } else {
callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number)); callSpec.name = coalesce(callSpec.name, getContactDisplayNameByNumber(callSpec.number));
} }
@ -372,6 +375,7 @@ public class GBDeviceService implements DeviceService {
/** /**
* Returns contact DisplayName by call number * Returns contact DisplayName by call number
*
* @param number contact number * @param number contact number
* @return contact DisplayName, if found it * @return contact DisplayName, if found it
*/ */

View File

@ -669,18 +669,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
byte[] msg = new byte[13]; byte[] msg = new byte[13];
//Show call number
for (int i = 0; i < msg.length; i++)
msg[i] = ' ';
for (int i = 0; i < number.length() && i < (msg.length - 1); i++)
msg[i + 1] = (byte) number.charAt(i);
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
builder.write(ctrlCharacteristic, msg);
builder.wait(200);
msg = msg.clone();
//Show call name //Show call name
@ -697,6 +685,20 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN; msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN;
builder.write(ctrlCharacteristic, msg); builder.write(ctrlCharacteristic, msg);
builder.wait(200);
msg = msg.clone();
//Show call number
for (int i = 0; i < msg.length; i++)
msg[i] = ' ';
for (int i = 0; i < number.length() && i < (msg.length - 1); i++)
msg[i + 1] = (byte) number.charAt(i);
msg[0] = HPlusConstants.CMD_SET_INCOMING_CALL_NUMBER;
builder.write(ctrlCharacteristic, msg);
builder.queue(getQueue()); builder.queue(getQueue());
} catch (IOException e) { } catch (IOException e) {
GB.toast(getContext(), "Error showing incoming call: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR); GB.toast(getContext(), "Error showing incoming call: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);

View File

@ -158,12 +158,14 @@
<string-array name="pref_call_privacy_mode"> <string-array name="pref_call_privacy_mode">
<item name="off">@string/pref_call_privacy_mode_off</item> <item name="off">@string/pref_call_privacy_mode_off</item>
<item name="name">@string/pref_call_privacy_mode_name</item> <item name="name">@string/pref_call_privacy_mode_name</item>
<item name="number">@string/pref_call_privacy_mode_number</item>
<item name="complete">@string/pref_call_privacy_mode_complete</item> <item name="complete">@string/pref_call_privacy_mode_complete</item>
</string-array> </string-array>
<string-array name="pref_call_privacy_mode_values"> <string-array name="pref_call_privacy_mode_values">
<item>@string/p_call_privacy_mode_off</item> <item>@string/p_call_privacy_mode_off</item>
<item>@string/p_call_privacy_mode_name</item> <item>@string/p_call_privacy_mode_name</item>
<item>@string/pref_call_privacy_mode_number</item>
<item>@string/p_call_privacy_mode_complete</item> <item>@string/p_call_privacy_mode_complete</item>
</string-array> </string-array>

View File

@ -99,8 +99,10 @@
<string name="pref_title_call_privacy_mode">Call Privacy Mode</string> <string name="pref_title_call_privacy_mode">Call Privacy Mode</string>
<string name="pref_call_privacy_mode_off">Display name and number</string> <string name="pref_call_privacy_mode_off">Display name and number</string>
<string name="pref_call_privacy_mode_name">Hide name but display number</string> <string name="pref_call_privacy_mode_name">Hide name but display number</string>
<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_call_privacy_mode_complete">Hide name and number</string>
<string name="pref_blacklist">Blacklist Apps</string> <string name="pref_blacklist">Blacklist Apps</string>
<string name="pref_header_cannned_messages">Canned Messages</string> <string name="pref_header_cannned_messages">Canned Messages</string>