Added a setting to change the device name that appears in Contact header and used when using the same account on multiple devices in secured group chat

This commit is contained in:
Sylvain Berfini 2019-04-15 10:59:07 +02:00
parent bfc56486ef
commit 15af0c4673
5 changed files with 35 additions and 3 deletions

View file

@ -72,7 +72,6 @@ import org.linphone.assistant.AssistantActivity;
import org.linphone.call.CallActivity; import org.linphone.call.CallActivity;
import org.linphone.call.CallIncomingActivity; import org.linphone.call.CallIncomingActivity;
import org.linphone.call.CallManager; import org.linphone.call.CallManager;
import org.linphone.compatibility.Compatibility;
import org.linphone.contacts.ContactsManager; import org.linphone.contacts.ContactsManager;
import org.linphone.contacts.LinphoneContact; import org.linphone.contacts.LinphoneContact;
import org.linphone.core.AccountCreator; import org.linphone.core.AccountCreator;
@ -728,10 +727,11 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
mCore.setZrtpSecretsFile(mBasePath + "/zrtp_secrets"); mCore.setZrtpSecretsFile(mBasePath + "/zrtp_secrets");
String deviceName = Compatibility.getDeviceName(mServiceContext); String deviceName = mPrefs.getDeviceName(mServiceContext);
String appName = mServiceContext.getResources().getString(R.string.user_agent); String appName = mServiceContext.getResources().getString(R.string.user_agent);
String androidVersion = BuildConfig.VERSION_NAME; String androidVersion = BuildConfig.VERSION_NAME;
String userAgent = appName + "/" + androidVersion + " (" + deviceName + ") LinphoneSDK"; String userAgent = appName + "/" + androidVersion + " (" + deviceName + ") LinphoneSDK";
mCore.setUserAgent( mCore.setUserAgent(
userAgent, userAgent,
getString(R.string.linphone_sdk_version) getString(R.string.linphone_sdk_version)

View file

@ -50,7 +50,7 @@ public class AdvancedSettingsFragment extends Fragment {
mBackgroundMode, mBackgroundMode,
mStartAtBoot, mStartAtBoot,
mDarkMode; mDarkMode;
private TextSetting mRemoteProvisioningUrl, mDisplayName, mUsername; private TextSetting mRemoteProvisioningUrl, mDisplayName, mUsername, mDeviceName;
private BasicSetting mAndroidAppSettings; private BasicSetting mAndroidAppSettings;
@Nullable @Nullable
@ -104,6 +104,8 @@ public class AdvancedSettingsFragment extends Fragment {
mUsername = mRootView.findViewById(R.id.pref_user_name); mUsername = mRootView.findViewById(R.id.pref_user_name);
mAndroidAppSettings = mRootView.findViewById(R.id.pref_android_app_settings); mAndroidAppSettings = mRootView.findViewById(R.id.pref_android_app_settings);
mDeviceName = mRootView.findViewById(R.id.pref_device_name);
} }
protected void setListeners() { protected void setListeners() {
@ -199,6 +201,14 @@ public class AdvancedSettingsFragment extends Fragment {
startActivityForResult(i, LinphoneActivity.ANDROID_APP_SETTINGS_ACTIVITY); startActivityForResult(i, LinphoneActivity.ANDROID_APP_SETTINGS_ACTIVITY);
} }
}); });
mDeviceName.setListener(
new SettingListenerBase() {
@Override
public void onTextValueChanged(String newValue) {
mPrefs.setDeviceName(newValue);
}
});
} }
protected void updateValues() { protected void updateValues() {
@ -220,6 +230,8 @@ public class AdvancedSettingsFragment extends Fragment {
mUsername.setValue(mPrefs.getDefaultUsername()); mUsername.setValue(mPrefs.getDefaultUsername());
mDeviceName.setValue(mPrefs.getDeviceName(LinphoneActivity.instance()));
setListeners(); setListeners();
} }
} }

View file

@ -32,6 +32,7 @@ import java.util.ArrayList;
import org.linphone.LinphoneActivity; import org.linphone.LinphoneActivity;
import org.linphone.LinphoneManager; import org.linphone.LinphoneManager;
import org.linphone.R; import org.linphone.R;
import org.linphone.compatibility.Compatibility;
import org.linphone.core.Address; import org.linphone.core.Address;
import org.linphone.core.AuthInfo; import org.linphone.core.AuthInfo;
import org.linphone.core.Config; import org.linphone.core.Config;
@ -1066,4 +1067,13 @@ public class LinphonePreferences {
LinphoneActivity.instance().recreate(); LinphoneActivity.instance().recreate();
} }
} }
public String getDeviceName(Context context) {
String defaultValue = Compatibility.getDeviceName(context);
return getConfig().getString("app", "device_name", defaultValue);
}
public void setDeviceName(String name) {
getConfig().setString("app", "device_name", name);
}
} }

View file

@ -49,6 +49,14 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
linphone:title="@string/pref_dark_mode" /> linphone:title="@string/pref_dark_mode" />
<org.linphone.settings.widget.TextSetting
android:id="@+id/pref_device_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
linphone:subtitle="@string/pref_display_name_subtitle"
linphone:hint="@string/pref_device_name"
linphone:title="@string/pref_device_name" />
<org.linphone.settings.widget.TextSetting <org.linphone.settings.widget.TextSetting
android:id="@+id/pref_remote_provisioning" android:id="@+id/pref_remote_provisioning"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -488,6 +488,8 @@
<string name="pref_service_notification">Enable service notification</string> <string name="pref_service_notification">Enable service notification</string>
<string name="pref_autostart">Start at boot time</string> <string name="pref_autostart">Start at boot time</string>
<string name="pref_incoming_call_timeout_title">Incoming call hangup (in seconds)</string> <string name="pref_incoming_call_timeout_title">Incoming call hangup (in seconds)</string>
<string name="pref_device_name">Device name</string>
<string name="pref_display_name_subtitle">Changes will be applied at next start up</string>
<string name="pref_remote_provisioning_title">Remote provisioning</string> <string name="pref_remote_provisioning_title">Remote provisioning</string>
<string name="pref_android_app_settings_title">Android app settings</string> <string name="pref_android_app_settings_title">Android app settings</string>
<string name="pref_android_app_notif_settings_title">Android notification settings</string> <string name="pref_android_app_notif_settings_title">Android notification settings</string>