mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 08:47:46 +00:00
feat: add forcing config message sending when updating profile picture or name
This commit is contained in:
parent
e4366244fe
commit
4033830b15
@ -17,12 +17,15 @@ import android.view.MenuItem
|
|||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import kotlinx.android.synthetic.main.activity_settings.*
|
import kotlinx.android.synthetic.main.activity_settings.*
|
||||||
import network.loki.messenger.BuildConfig
|
import network.loki.messenger.BuildConfig
|
||||||
import network.loki.messenger.R
|
import network.loki.messenger.R
|
||||||
import nl.komponents.kovenant.Promise
|
import nl.komponents.kovenant.Promise
|
||||||
import nl.komponents.kovenant.all
|
import nl.komponents.kovenant.all
|
||||||
import nl.komponents.kovenant.deferred
|
import nl.komponents.kovenant.deferred
|
||||||
|
import nl.komponents.kovenant.functional.bind
|
||||||
|
import nl.komponents.kovenant.task
|
||||||
import nl.komponents.kovenant.ui.alwaysUi
|
import nl.komponents.kovenant.ui.alwaysUi
|
||||||
import org.thoughtcrime.securesms.ApplicationContext
|
import org.thoughtcrime.securesms.ApplicationContext
|
||||||
import org.thoughtcrime.securesms.PassphraseRequiredActionBarActivity
|
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.ClearAllDataDialog
|
||||||
import org.thoughtcrime.securesms.loki.dialogs.SeedDialog
|
import org.thoughtcrime.securesms.loki.dialogs.SeedDialog
|
||||||
import org.thoughtcrime.securesms.loki.utilities.UiModeUtilities
|
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.loki.utilities.push
|
||||||
import org.thoughtcrime.securesms.mms.GlideApp
|
import org.thoughtcrime.securesms.mms.GlideApp
|
||||||
import org.thoughtcrime.securesms.mms.GlideRequests
|
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.crypto.ProfileCipher
|
||||||
import org.session.libsignal.service.api.util.StreamDetails
|
import org.session.libsignal.service.api.util.StreamDetails
|
||||||
import org.session.libsignal.service.loki.api.fileserver.FileServerAPI
|
import org.session.libsignal.service.loki.api.fileserver.FileServerAPI
|
||||||
|
import org.thoughtcrime.securesms.loki.protocol.MultiDeviceProtocol
|
||||||
import java.io.ByteArrayInputStream
|
import java.io.ByteArrayInputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.SecureRandom
|
import java.security.SecureRandom
|
||||||
@ -177,7 +179,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateProfile(isUpdatingProfilePicture: Boolean) {
|
private fun updateProfile(isUpdatingProfilePicture: Boolean) {
|
||||||
loader.fadeIn()
|
loader.isVisible = true
|
||||||
val promises = mutableListOf<Promise<*, Exception>>()
|
val promises = mutableListOf<Promise<*, Exception>>()
|
||||||
val displayName = displayNameToBeUploaded
|
val displayName = displayNameToBeUploaded
|
||||||
if (displayName != null) {
|
if (displayName != null) {
|
||||||
@ -204,7 +206,17 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
}
|
}
|
||||||
promises.add(deferred.promise)
|
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) {
|
if (displayName != null) {
|
||||||
btnGroupNameDisplay.text = displayName
|
btnGroupNameDisplay.text = displayName
|
||||||
}
|
}
|
||||||
@ -217,7 +229,7 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
|
|||||||
profilePictureView.update()
|
profilePictureView.update()
|
||||||
}
|
}
|
||||||
profilePictureToBeUploaded = null
|
profilePictureToBeUploaded = null
|
||||||
loader.fadeOut()
|
loader.isVisible = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// endregion
|
// endregion
|
||||||
|
@ -250,22 +250,26 @@
|
|||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|
||||||
<RelativeLayout
|
<FrameLayout
|
||||||
android:id="@+id/loader"
|
android:animateLayoutChanges="true"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent">
|
||||||
android:background="#A4000000"
|
<RelativeLayout
|
||||||
android:visibility="gone"
|
android:id="@+id/loader"
|
||||||
android:alpha="0">
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="#A4000000"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<com.github.ybq.android.spinkit.SpinKitView
|
<com.github.ybq.android.spinkit.SpinKitView
|
||||||
style="@style/SpinKitView.Large.ThreeBounce"
|
style="@style/SpinKitView.Large.ThreeBounce"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
android:layout_centerInParent="true"
|
android:layout_centerInParent="true"
|
||||||
app:SpinKit_Color="@android:color/white" />
|
app:SpinKit_Color="@android:color/white" />
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
x
Reference in New Issue
Block a user