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 d313b31e12
commit 29ee69fc7b
3 changed files with 14 additions and 8 deletions

View file

@ -26,6 +26,7 @@ Group changes to describe their impact on the project, as follows:
### Fixed ### Fixed
- Plain copy of encrypted files (when VFS is enabled) not cleaned - 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

View file

@ -359,7 +359,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()
@ -918,7 +918,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) {
@ -940,7 +940,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) {
@ -1132,10 +1132,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
} }
@ -1155,9 +1155,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]
} }