Fixed contact's initials display as avatar when containing more than one emoji (or an emoji + another character)

This commit is contained in:
Sylvain Berfini 2023-04-03 11:35:05 +02:00
parent 8a596a3ef7
commit ccecf3a21f
3 changed files with 19 additions and 8 deletions

View file

@ -10,6 +10,12 @@ Group changes to describe their impact on the project, as follows:
Fixed for any bug fixes. Fixed for any bug fixes.
Security to invite users to upgrade in case of vulnerabilities. Security to invite users to upgrade in case of vulnerabilities.
## [5.0.10] - 2023-01-04
### Fixed
- Plain copy of encrypted files (when VFS is enabled) not cleaned
- Avatar display issue if contact's "initials" contains more than 1 emoji or an emoji + a character
## [5.0.9] - 2023-03-30 ## [5.0.9] - 2023-03-30
### Fixed ### Fixed

View file

@ -343,7 +343,7 @@ class CoreContext(
if (corePreferences.vfsEnabled) { if (corePreferences.vfsEnabled) {
val notClearedCount = FileUtils.countFilesInDirectory(corePreferences.vfsCachePath) val notClearedCount = FileUtils.countFilesInDirectory(corePreferences.vfsCachePath)
if (notClearedCount != 0) { if (notClearedCount > 0) {
Log.w("[Context] [VFS] There are [$notClearedCount] plain files not cleared from previous app lifetime, removing them now") Log.w("[Context] [VFS] There are [$notClearedCount] plain files not cleared from previous app lifetime, removing them now")
} }
FileUtils.clearExistingPlainFiles() FileUtils.clearExistingPlainFiles()
@ -868,7 +868,7 @@ class CoreContext(
return return
} }
if (corePreferences.vfsEnabled) { if (corePreferences.vfsEnabled) {
Log.w("[Context] Do not make received file(s) public when VFS is enabled") Log.w("[Context] [VFS] Do not make received file(s) public when VFS is enabled")
return return
} }
if (!corePreferences.makePublicMediaFilesDownloaded) { if (!corePreferences.makePublicMediaFilesDownloaded) {
@ -890,7 +890,7 @@ class CoreContext(
fun addContentToMediaStore(content: Content) { fun addContentToMediaStore(content: Content) {
if (corePreferences.vfsEnabled) { if (corePreferences.vfsEnabled) {
Log.w("[Context] Do not make received file(s) public when VFS is enabled") Log.w("[Context] [VFS] Do not make received file(s) public when VFS is enabled")
return return
} }
if (!corePreferences.makePublicMediaFilesDownloaded) { if (!corePreferences.makePublicMediaFilesDownloaded) {
@ -1082,10 +1082,10 @@ class CoreContext(
fun activateVFS() { fun activateVFS() {
try { try {
Log.i("[Context] Activating VFS") Log.i("[Context] [VFS] Activating VFS")
val preferences = corePreferences.encryptedSharedPreferences val preferences = corePreferences.encryptedSharedPreferences
if (preferences == null) { if (preferences == null) {
Log.e("[Context] Can't get encrypted SharedPreferences, can't init VFS") Log.e("[Context] [VFS] Can't get encrypted SharedPreferences, can't init VFS")
return return
} }
@ -1105,9 +1105,9 @@ class CoreContext(
32 32
) )
Log.i("[Context] VFS activated") Log.i("[Context] [VFS] VFS activated")
} catch (e: Exception) { } catch (e: Exception) {
Log.f("[Context] Unable to activate VFS encryption: $e") Log.f("[Context] [VFS] Unable to activate VFS encryption: $e")
} }
} }
} }

View file

@ -79,7 +79,12 @@ class AppUtils {
if (split[i].isNotEmpty()) { if (split[i].isNotEmpty()) {
try { try {
if (emoji?.hasEmojiGlyph(split[i]) == true) { if (emoji?.hasEmojiGlyph(split[i]) == true) {
initials += emoji.process(split[i]) val glyph = emoji.process(split[i])
if (characters > 0) { // Limit initial to 1 emoji only
initials = ""
}
initials += glyph
break // Limit initial to 1 emoji only
} else { } else {
initials += split[i][0] initials += split[i][0]
} }