Better styling

This commit is contained in:
ThomasSession 2024-08-09 11:08:04 +10:00
parent 4bb583e7d9
commit 6fff1e1832
2 changed files with 10 additions and 3 deletions

View File

@ -39,17 +39,20 @@ object AvatarSelection {
launcher: ActivityResultLauncher<CropImageContractOptions>,
inputFile: Uri?,
outputFile: Uri?,
@StringRes title: Int
@StringRes title: Int,
bgColor: Int
) {
launcher.launch(
options(inputFile) {
setGuidelines(CropImageView.Guidelines.ON)
setAspectRatio(1, 1)
setCropShape(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) CropImageView.CropShape.RECTANGLE else CropImageView.CropShape.OVAL)
setCropShape(CropImageView.CropShape.OVAL)
setOutputUri(outputFile)
setAllowRotation(true)
setAllowFlipping(true)
setBackgroundColor(ContextCompat.getColor(activity, R.color.avatar_background))
setToolbarColor(bgColor)
setActivityBackgroundColor(bgColor)
setActivityTitle(activity.getString(title))
}
)

View File

@ -61,6 +61,7 @@ import org.session.libsession.utilities.ProfileKeyUtil
import org.session.libsession.utilities.ProfilePictureUtilities
import org.session.libsession.utilities.SSKEnvironment.ProfileManagerProtocol
import org.session.libsession.utilities.TextSecurePreferences
import org.session.libsession.utilities.getColorFromAttr
import org.session.libsession.utilities.recipients.Recipient
import org.session.libsession.utilities.truncateIdForDisplay
import org.session.libsignal.utilities.Log
@ -111,6 +112,8 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
private val hexEncodedPublicKey: String get() = TextSecurePreferences.getLocalNumber(this)!!
private val bgColor by lazy { getColorFromAttr(android.R.attr.colorPrimary) }
private val onAvatarCropped = registerForActivityResult(CropImageContract()) { result ->
when {
result.isSuccessful -> {
@ -226,7 +229,8 @@ class SettingsActivity : PassphraseRequiredActionBarActivity() {
launcher = onAvatarCropped,
inputFile = inputFile,
outputFile = outputFile,
title = R.string.CropImageActivity_profile_avatar
title = R.string.CropImageActivity_profile_avatar,
bgColor = bgColor
)
}
}