mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-12 18:57:36 +01:00
Add privacy mode that hides the phone number (#588)
This commit is contained in:
parent
17ecee0cab
commit
6989ca9db3
@ -73,9 +73,9 @@ public class GBDeviceService implements DeviceService {
|
||||
}
|
||||
|
||||
protected void invokeService(Intent intent) {
|
||||
if(LanguageUtils.transliterate()){
|
||||
for (String extra: transliterationExtras) {
|
||||
if (intent.hasExtra(extra)){
|
||||
if (LanguageUtils.transliterate()) {
|
||||
for (String extra : transliterationExtras) {
|
||||
if (intent.hasExtra(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));
|
||||
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)) {
|
||||
} else if (context.getString(R.string.p_call_privacy_mode_complete).equals(currentPrivacyMode)) {
|
||||
callSpec.number = 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));
|
||||
}
|
||||
|
||||
@ -372,6 +375,7 @@ public class GBDeviceService implements DeviceService {
|
||||
|
||||
/**
|
||||
* Returns contact DisplayName by call number
|
||||
*
|
||||
* @param number contact number
|
||||
* @return contact DisplayName, if found it
|
||||
*/
|
||||
|
@ -669,18 +669,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
|
||||
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
|
||||
|
||||
@ -697,6 +685,20 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
|
||||
msg[0] = HPlusConstants.CMD_ACTION_DISPLAY_TEXT_NAME_CN;
|
||||
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());
|
||||
} catch (IOException e) {
|
||||
GB.toast(getContext(), "Error showing incoming call: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
|
||||
|
@ -158,12 +158,14 @@
|
||||
<string-array name="pref_call_privacy_mode">
|
||||
<item name="off">@string/pref_call_privacy_mode_off</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>
|
||||
</string-array>
|
||||
|
||||
<string-array name="pref_call_privacy_mode_values">
|
||||
<item>@string/p_call_privacy_mode_off</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>
|
||||
</string-array>
|
||||
|
||||
|
@ -99,8 +99,10 @@
|
||||
<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_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_blacklist">Blacklist Apps</string>
|
||||
|
||||
<string name="pref_header_cannned_messages">Canned Messages</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user