From 4033830b1598ed26e53e1cd230bbc73acbedf54a Mon Sep 17 00:00:00 2001 From: jubb Date: Wed, 24 Feb 2021 15:28:48 +1100 Subject: [PATCH] feat: add forcing config message sending when updating profile picture or name --- .../loki/activities/SettingsActivity.kt | 22 ++++++++++--- app/src/main/res/layout/activity_settings.xml | 32 +++++++++++-------- 2 files changed, 35 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt index 59864f32b7..7abc4ecb57 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/loki/activities/SettingsActivity.kt @@ -17,12 +17,15 @@ import android.view.MenuItem import android.view.View import android.view.inputmethod.InputMethodManager import android.widget.Toast +import androidx.core.view.isVisible import kotlinx.android.synthetic.main.activity_settings.* import network.loki.messenger.BuildConfig import network.loki.messenger.R import nl.komponents.kovenant.Promise import nl.komponents.kovenant.all import nl.komponents.kovenant.deferred +import nl.komponents.kovenant.functional.bind +import nl.komponents.kovenant.task import nl.komponents.kovenant.ui.alwaysUi import org.thoughtcrime.securesms.ApplicationContext import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity @@ -34,8 +37,6 @@ import org.thoughtcrime.securesms.loki.dialogs.ChangeUiModeDialog import org.thoughtcrime.securesms.loki.dialogs.ClearAllDataDialog import org.thoughtcrime.securesms.loki.dialogs.SeedDialog import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities -import org.thoughtcrime.securesms.loki.utilities.fadeIn -import org.thoughtcrime.securesms.loki.utilities.fadeOut import org.thoughtcrime.securesms.loki.utilities.push import org.thoughtcrime.securesms.mms.GlideApp import org.thoughtcrime.securesms.mms.GlideRequests @@ -48,6 +49,7 @@ import org.session.libsession.utilities.TextSecurePreferences import org.session.libsignal.service.api.crypto.ProfileCipher import org.session.libsignal.service.api.util.StreamDetails import org.session.libsignal.service.loki.api.fileserver.FileServerAPI +import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol import java.io.ByteArrayInputStream import java.io.File import java.security.SecureRandom @@ -177,7 +179,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } private fun updateProfile(isUpdatingProfilePicture: Boolean) { - loader.fadeIn() + loader.isVisible = true val promises = mutableListOf>() val displayName = displayNameToBeUploaded if (displayName != null) { @@ -204,7 +206,17 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { } promises.add(deferred.promise) } - all(promises).alwaysUi { + + all(promises).bind { + // updating the profile name or picture + if (profilePicture != null || displayName != null) { + task { + MultiDeviceProtocol.forceSyncConfigurationNowIfNeeded(this@SettingsActivity) + } + } else { + Promise.of(Unit) + } + }.alwaysUi { if (displayName != null) { btnGroupNameDisplay.text = displayName } @@ -217,7 +229,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() { profilePictureView.update() } profilePictureToBeUploaded = null - loader.fadeOut() + loader.isVisible = false } } // endregion diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 36c74258d5..3f985ae909 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -250,22 +250,26 @@ - + android:layout_height="match_parent"> + - + - + + \ No newline at end of file