Minor fixes + removed setting for legacy push format

This commit is contained in:
Sylvain Berfini 2021-01-20 10:35:50 +01:00
parent a57d7d4578
commit 1831ad9677
6 changed files with 13 additions and 25 deletions

View file

@ -78,7 +78,7 @@ class ChatMessageViewModel(
if (state == ChatMessage.State.FileTransferDone && !message.isOutgoing) { if (state == ChatMessage.State.FileTransferDone && !message.isOutgoing) {
Log.i("[Chat Message] File transfer done") Log.i("[Chat Message] File transfer done")
// No need to refresh content lists on outgoing messages after file transfer is done // No need to refresh content lists on outgoing messages after file transfer is done
// It will even cause the app to crash if updateContentsList is not call right after // It will even cause the app to crash if updateContentsList isn't called right after
updateContentsList() updateContentsList()
if (!message.isEphemeral && corePreferences.makePublicMediaFilesDownloaded) { if (!message.isEphemeral && corePreferences.makePublicMediaFilesDownloaded) {

View file

@ -91,7 +91,8 @@ class ChatRoomViewModel(val chatRoom: ChatRoom) : ViewModel(), ContactViewModelI
get() = chatRoom.hasCapability(ChatRoomCapabilities.Basic.toInt()) get() = chatRoom.hasCapability(ChatRoomCapabilities.Basic.toInt())
val peerSipUri: String val peerSipUri: String
get() = chatRoom.peerAddress.asStringUriOnly() get() = if (oneToOneChatRoom && !basicChatRoom) chatRoom.participants.first().address.asStringUriOnly()
else chatRoom.peerAddress.asStringUriOnly()
val oneParticipantOneDevice: Boolean val oneParticipantOneDevice: Boolean
get() { get() {

View file

@ -46,13 +46,6 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() {
val pushNotifications = MutableLiveData<Boolean>() val pushNotifications = MutableLiveData<Boolean>()
val pushNotificationsAvailable = MutableLiveData<Boolean>() val pushNotificationsAvailable = MutableLiveData<Boolean>()
val legacyPushNotificationFormatListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) {
prefs.useLegacyPushNotificationFormat = newValue
}
}
val legacyPushNotificationFormat = MutableLiveData<Boolean>()
val randomPortsListener = object : SettingListenerStub() { val randomPortsListener = object : SettingListenerStub() {
override fun onBoolValueChanged(newValue: Boolean) { override fun onBoolValueChanged(newValue: Boolean) {
val port = if (newValue) -1 else 5060 val port = if (newValue) -1 else 5060
@ -78,7 +71,6 @@ class NetworkSettingsViewModel : GenericSettingsViewModel() {
allowIpv6.value = core.ipv6Enabled() allowIpv6.value = core.ipv6Enabled()
pushNotifications.value = core.isPushNotificationEnabled pushNotifications.value = core.isPushNotificationEnabled
pushNotificationsAvailable.value = core.isPushNotificationAvailable pushNotificationsAvailable.value = core.isPushNotificationAvailable
legacyPushNotificationFormat.value = prefs.useLegacyPushNotificationFormat
randomPorts.value = getTransportPort() == -1 randomPorts.value = getTransportPort() == -1
sipPort.value = getTransportPort() sipPort.value = getTransportPort()
} }

View file

@ -254,12 +254,6 @@ class CorePreferences constructor(private val context: Context) {
config.setInt("app", "version_check_url_last_timestamp", value) config.setInt("app", "version_check_url_last_timestamp", value)
} }
var useLegacyPushNotificationFormat: Boolean
get() = config.getBool("net", "use_legacy_push_notification_params", false)
set(value) {
config.setBool("net", "use_legacy_push_notification_params", value)
}
var defaultAccountAvatarPath: String? var defaultAccountAvatarPath: String?
get() = config.getString("app", "default_avatar_path", null) get() = config.getString("app", "default_avatar_path", null)
set(value) { set(value) {

View file

@ -167,6 +167,15 @@ class ShortcutsHelper(val context: Context) {
} }
subject = contact?.fullName ?: LinphoneUtils.getDisplayName(chatRoom.peerAddress) subject = contact?.fullName ?: LinphoneUtils.getDisplayName(chatRoom.peerAddress)
icon = contact?.getPerson()?.icon ?: IconCompat.createWithResource(context, R.drawable.avatar) icon = contact?.getPerson()?.icon ?: IconCompat.createWithResource(context, R.drawable.avatar)
} else if (chatRoom.hasCapability(ChatRoomCapabilities.OneToOne.toInt()) && chatRoom.participants.isNotEmpty()) {
val address = chatRoom.participants.first().address
val contact =
coreContext.contactsManager.findContactByAddress(address)
if (contact != null) {
personsList.add(contact.getPerson())
}
subject = contact?.fullName ?: LinphoneUtils.getDisplayName(address)
icon = contact?.getPerson()?.icon ?: IconCompat.createWithResource(context, R.drawable.avatar)
} else { } else {
for (participant in chatRoom.participants) { for (participant in chatRoom.participants) {
val contact = val contact =
@ -198,7 +207,7 @@ class ShortcutsHelper(val context: Context) {
.setPersons(persons) .setPersons(persons)
.setCategories(categories) .setCategories(categories)
.setIntent(intent) .setIntent(intent)
.setLongLived(Version.sdkAboveOrEqual(30)) // TODO Use Android R API code .setLongLived(Version.sdkAboveOrEqual(Version.API30_ANDROID_11))
.build().toShortcutInfo() .build().toShortcutInfo()
} catch (e: Exception) { } catch (e: Exception) {
Log.e("[Shortcuts Helper] ShortcutInfo.Builder exception: $e") Log.e("[Shortcuts Helper] ShortcutInfo.Builder exception: $e")

View file

@ -87,14 +87,6 @@
linphone:checked="@={viewModel.pushNotifications}" linphone:checked="@={viewModel.pushNotifications}"
linphone:enabled="@{viewModel.pushNotificationsAvailable}"/> linphone:enabled="@{viewModel.pushNotificationsAvailable}"/>
<include
layout="@layout/settings_widget_switch"
linphone:title="@{@string/network_settings_legacy_push_notification_format_title}"
linphone:subtitle="@{@string/network_settings_legacy_push_notification_format_summary}"
linphone:listener="@{viewModel.legacyPushNotificationFormatListener}"
linphone:checked="@={viewModel.legacyPushNotificationFormat}"
linphone:enabled="@{viewModel.pushNotificationsAvailable}"/>
<include <include
layout="@layout/settings_widget_switch" layout="@layout/settings_widget_switch"
linphone:title="@{@string/network_settings_random_ports_title}" linphone:title="@{@string/network_settings_random_ports_title}"