Added setting for each proxy config to know whether or not to enable push notification

This commit is contained in:
Sylvain Berfini 2018-04-13 17:38:00 +02:00
parent c9b68fd05b
commit 9d45aee452
19 changed files with 57 additions and 7 deletions

View file

@ -66,6 +66,7 @@
<application
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:largeHeap="true">
<activity

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View file

@ -81,6 +81,7 @@
<string name="pref_escape_plus_key">pref_escape_plus_key</string>
<string name="pref_friendlist_subscribe_key">pref_friendlist_subscribe_key</string>
<string name="pref_link_account_key">pref_link_account_key</string>
<string name="pref_proxy_push_notif_key">pref_proxy_push_notif_key</string>
<string name="pref_echo_cancellation_key">pref_echo_cancellation_key</string>
<string name="pref_autostart_key">pref_autostart_key</string>
<string name="pref_enable_outbound_proxy_key">Outbound proxy</string>

View file

@ -331,6 +331,7 @@
<string name="pref_change_password">Change password</string>
<string name="pref_default_account">Use as default</string>
<string name="pref_password_changed">Password changed</string>
<string name="pref_proxy_push_notif">Allow push notification</string>
<!-- Settings -->
<string name="pref_sipaccounts">SIP Accounts</string>

View file

@ -103,6 +103,11 @@
android:key="@string/pref_link_account_key"
android:persistent="false"/>
<CheckBoxPreference
android:title="@string/pref_proxy_push_notif"
android:key="@string/pref_proxy_push_notif_key"
android:persistent="false"/>
</PreferenceCategory>
<PreferenceCategory

View file

@ -395,6 +395,7 @@ public class LinphonePreferences {
int port = 0;
if (transport.equals(getString(R.string.pref_transport_udp_key))) {
proxyAddr.setTransport(TransportType.Udp);
} else if (transport.equals(getString(R.string.pref_transport_tcp_key))) {
proxyAddr.setTransport(TransportType.Tcp);
} else if (transport.equals(getString(R.string.pref_transport_tls_key))) {
@ -724,6 +725,20 @@ public class LinphonePreferences {
prxCfg.done();
}
public void enablePushNotifForProxy(int n, boolean enable) {
ProxyConfig prxCfg = getProxyConfig(n);
prxCfg.edit();
prxCfg.setPushNotificationAllowed(enable);
prxCfg.done();
setPushNotificationEnabled(isPushNotificationEnabled());
}
public boolean isPushNotifEnabledForProxy(int n) {
ProxyConfig prxCfg = getProxyConfig(n);
return prxCfg.isPushNotificationAllowed();
}
public boolean isFriendlistsubscriptionEnabled() {
return getConfig().getBool("app", "friendlist_subscription_enabled", false);
}
@ -1142,6 +1157,13 @@ public class LinphonePreferences {
String appId = getString(R.string.push_sender_id);
if (regId != null && lc.getProxyConfigList().length > 0) {
for (ProxyConfig lpc : lc.getProxyConfigList()) {
if (!lpc.isPushNotificationAllowed()) {
lpc.edit();
lpc.setContactUriParameters(null);
lpc.done();
if (lpc.getIdentityAddress() != null)
Log.d("Push notif infos removed from proxy config " + lpc.getIdentityAddress().asStringUriOnly());
} else {
String contactInfos = "app-id=" + appId + ";pn-type=" + getString(R.string.push_type) + ";pn-tok=" + regId + ";pn-silent=1";
String prevContactParams = lpc.getContactParameters();
if (prevContactParams == null || prevContactParams.compareTo(contactInfos) != 0) {
@ -1152,6 +1174,7 @@ public class LinphonePreferences {
Log.d("Push notif infos added to proxy config " + lpc.getIdentityAddress().asStringUriOnly());
}
}
}
lc.refreshRegisters();
}
} else {

View file

@ -260,6 +260,18 @@ public class AccountPreferencesFragment extends PreferencesListFragment implemen
return true;
}
};
OnPreferenceChangeListener pushNotificationListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
boolean value = (Boolean) newValue;
if (isNewAccount) {
//TODO
} else {
mPrefs.enablePushNotifForProxy(n, value);
}
return true;
}
};
OnPreferenceChangeListener disableChangedListener = new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
@ -443,6 +455,12 @@ public class AccountPreferencesFragment extends PreferencesListFragment implemen
Preference linkAccount = advanced.getPreference(10);
linkAccount.setOnPreferenceClickListener(linkAccountListener);
CheckBoxPreference pushNotif = (CheckBoxPreference) advanced.getPreference(11);
pushNotif.setOnPreferenceChangeListener(pushNotificationListener);
if(!isNewAccount){
pushNotif.setChecked(mPrefs.isPushNotifEnabledForProxy(n));
}
PreferenceCategory manage = (PreferenceCategory) getPreferenceScreen().findPreference(getString(R.string.pref_manage_key));
final CheckBoxPreference disable = (CheckBoxPreference) manage.getPreference(0);
disable.setEnabled(true);

1
submodules/externals/zxing-cpp vendored Submodule

@ -0,0 +1 @@
Subproject commit 9d5bfe077dc53968ea1a4b386be7a2af14121aa0

@ -1 +1 @@
Subproject commit 701685a9fca6b420861d1917cbadffae6daee71e
Subproject commit 7705ada69553c274040ce7b3164ea8c1584f7edb

@ -1 +1 @@
Subproject commit 65946f227bd94548264e99ea13c662b0b899c18d
Subproject commit 0be2e0ed887ea9db50666d98f0059c92a3f38ad8