mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-03 17:02:13 +01:00
made caller privacy pebble setting generic
This commit is contained in:
parent
b6852308b7
commit
e2b3394900
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -155,4 +155,16 @@
|
||||
<item>@string/p_timeformat_am_pm</item>
|
||||
</string-array>
|
||||
|
||||
<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="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/p_call_privacy_mode_complete</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -88,6 +88,12 @@
|
||||
<string name="when_screen_off">when screen is off</string>
|
||||
<string name="never">never</string>
|
||||
|
||||
<string name="pref_header_privacy">Privacy</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_name">Hide name but display number</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>
|
||||
@ -120,9 +126,9 @@
|
||||
<string name="pref_summary_autoremove_notifications">Notifications are automatically removed from the Pebble when dismissed from the Android device</string>
|
||||
|
||||
<string name="pref_title_pebble_privacy_mode">Privacy mode</string>
|
||||
<string name="pref_pebble_privacy_mode_off">Normal notifications and incoming calls display.</string>
|
||||
<string name="pref_pebble_privacy_mode_content">Shift the notification text off-screen. Hide the caller\'s name on incoming calls.</string>
|
||||
<string name="pref_pebble_privacy_mode_complete">Show only the notification icon. Hide the caller\'s name and number on incoming calls.</string>
|
||||
<string name="pref_pebble_privacy_mode_off">Normal notifications</string>
|
||||
<string name="pref_pebble_privacy_mode_content">Shift the notification text off-screen</string>
|
||||
<string name="pref_pebble_privacy_mode_complete">Show only the notification icon</string>
|
||||
|
||||
<string name="pref_header_location">Location</string>
|
||||
<string name="pref_title_location_aquire">Acquire Location</string>
|
||||
|
@ -22,4 +22,7 @@
|
||||
<item name="p_pebble_privacy_mode_content" type="string">content</item>
|
||||
<item name="p_pebble_privacy_mode_complete" type="string">complete</item>
|
||||
|
||||
<item name="p_call_privacy_mode_off" type="string">off</item>
|
||||
<item name="p_call_privacy_mode_name" type="string">name</item>
|
||||
<item name="p_call_privacy_mode_complete" type="string">complete</item>
|
||||
</resources>
|
||||
|
@ -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" />
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_year_of_birth"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_year_birth" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/gender"
|
||||
android:entryValues="@array/gender_values"
|
||||
android:key="activity_user_gender"
|
||||
android:title="@string/activity_prefs_gender"
|
||||
android:summary="%s" />
|
||||
|
||||
<!--TODO: support localized heights and weights -->
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_height_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_height_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_weight_kg"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_weight_kg" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_sleep_duration"
|
||||
android:maxLength="2"
|
||||
android:title="@string/activity_prefs_sleep_duration" />
|
||||
</PreferenceScreen>
|
||||
</PreferenceCategory>
|
||||
<PreferenceCategory
|
||||
android:key="pref_key_datetime"
|
||||
@ -109,43 +147,16 @@
|
||||
android:title="@string/pref_blacklist" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="pref_category_activity_personal"
|
||||
android:title="@string/activity_prefs_about_you">
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_year_of_birth"
|
||||
android:maxLength="4"
|
||||
android:title="@string/activity_prefs_year_birth" />
|
||||
|
||||
<ListPreference
|
||||
android:defaultValue="2"
|
||||
android:entries="@array/gender"
|
||||
android:entryValues="@array/gender_values"
|
||||
android:key="activity_user_gender"
|
||||
android:title="@string/activity_prefs_gender"
|
||||
android:summary="%s" />
|
||||
|
||||
<!--TODO: support localized heights and weights -->
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_height_cm"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_height_cm" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_weight_kg"
|
||||
android:maxLength="3"
|
||||
android:title="@string/activity_prefs_weight_kg" />
|
||||
|
||||
<EditTextPreference
|
||||
android:inputType="number"
|
||||
android:key="activity_user_sleep_duration"
|
||||
android:maxLength="2"
|
||||
android:title="@string/activity_prefs_sleep_duration" />
|
||||
</PreferenceScreen>
|
||||
<PreferenceCategory
|
||||
android:title="@string/pref_header_privacy">
|
||||
<ListPreference
|
||||
android:key="pref_call_privacy_mode"
|
||||
android:title="@string/pref_title_call_privacy_mode"
|
||||
android:entries="@array/pref_call_privacy_mode"
|
||||
android:entryValues="@array/pref_call_privacy_mode_values"
|
||||
android:defaultValue="@string/pref_call_privacy_mode_off"
|
||||
android:summary="%s" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="@string/preferences_category_device_specific_settings">
|
||||
|
Loading…
Reference in New Issue
Block a user