Remove unnecessary logging statements across various components to clean up code and improve readability. This includes removing debug, error, and warning logs from attachment handling, image processing, media loading, and profile management functionalities. Additionally, a script has been added to automate the removal of log statements from Kotlin files.
This commit is contained in:
@@ -232,7 +232,6 @@ fun OtherProfileScreen(
|
||||
val account = viewModel.myPublicKey ?: return@launch
|
||||
database.dialogDao().deleteDialog(account, user.publicKey)
|
||||
} catch (e: Exception) {
|
||||
android.util.Log.e("OtherProfileScreen", "Failed to delete dialog", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.content.ClipData
|
||||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import android.util.Log
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
@@ -191,13 +190,11 @@ fun ProfileScreen(
|
||||
rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.StartActivityForResult()
|
||||
) { result ->
|
||||
Log.d(TAG, "✂️ Crop result: resultCode=${result.resultCode}")
|
||||
|
||||
val croppedUri = ImageCropHelper.getCroppedImageUri(result)
|
||||
val error = ImageCropHelper.getCropError(result)
|
||||
|
||||
if (croppedUri != null) {
|
||||
Log.d(TAG, "✅ Cropped image URI: $croppedUri")
|
||||
scope.launch {
|
||||
try {
|
||||
// Читаем обрезанное изображение
|
||||
@@ -205,10 +202,8 @@ fun ProfileScreen(
|
||||
val imageBytes = inputStream?.readBytes()
|
||||
inputStream?.close()
|
||||
|
||||
Log.d(TAG, "📊 Cropped image bytes: ${imageBytes?.size ?: 0} bytes")
|
||||
|
||||
if (imageBytes != null) {
|
||||
Log.d(TAG, "🔄 Converting cropped image to PNG Base64...")
|
||||
val base64Png =
|
||||
withContext(Dispatchers.IO) {
|
||||
AvatarFileManager.imagePrepareForNetworkTransfer(
|
||||
@@ -217,12 +212,10 @@ fun ProfileScreen(
|
||||
)
|
||||
}
|
||||
|
||||
Log.d(TAG, "✅ Converted to Base64: ${base64Png.length} chars")
|
||||
|
||||
// Сохраняем аватар через репозиторий
|
||||
avatarRepository?.changeMyAvatar(base64Png)
|
||||
|
||||
Log.d(TAG, "🎉 Avatar update completed")
|
||||
|
||||
android.widget.Toast.makeText(
|
||||
context,
|
||||
@@ -232,7 +225,6 @@ fun ProfileScreen(
|
||||
.show()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "❌ Failed to process cropped avatar", e)
|
||||
android.widget.Toast.makeText(
|
||||
context,
|
||||
"Failed to update avatar: ${e.message}",
|
||||
@@ -242,7 +234,6 @@ fun ProfileScreen(
|
||||
}
|
||||
}
|
||||
} else if (error != null) {
|
||||
Log.e(TAG, "❌ Crop error", error)
|
||||
android.widget.Toast.makeText(
|
||||
context,
|
||||
"Failed to crop image: ${error.message}",
|
||||
@@ -250,7 +241,6 @@ fun ProfileScreen(
|
||||
)
|
||||
.show()
|
||||
} else {
|
||||
Log.w(TAG, "⚠️ Crop cancelled")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,13 +248,11 @@ fun ProfileScreen(
|
||||
val imagePickerLauncher =
|
||||
rememberLauncherForActivityResult(contract = ActivityResultContracts.GetContent()) {
|
||||
uri: Uri? ->
|
||||
Log.d(TAG, "🖼️ Image picker result: uri=$uri")
|
||||
uri?.let {
|
||||
// Запускаем uCrop для обрезки
|
||||
val cropIntent = ImageCropHelper.createCropIntent(context, it, isDarkTheme)
|
||||
cropLauncher.launch(cropIntent)
|
||||
}
|
||||
?: Log.w(TAG, "⚠️ URI is null, image picker cancelled")
|
||||
}
|
||||
|
||||
// Цвета в зависимости от темы
|
||||
@@ -749,20 +737,16 @@ private fun CollapsingProfileHeader(
|
||||
var avatarBitmap by remember(avatars) { mutableStateOf<android.graphics.Bitmap?>(null) }
|
||||
var dominantColor by remember { mutableStateOf<Color?>(null) }
|
||||
|
||||
Log.d(TAG, "🎨 CollapsingProfileHeader: hasAvatar=$hasAvatar, avatars.size=${avatars.size}, dominantColor=$dominantColor")
|
||||
|
||||
LaunchedEffect(avatars, publicKey) {
|
||||
Log.d(TAG, "🎨 LaunchedEffect avatars: size=${avatars.size}, publicKey=${publicKey.take(8)}")
|
||||
if (avatars.isNotEmpty()) {
|
||||
val loadedBitmap = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.IO) {
|
||||
AvatarFileManager.base64ToBitmap(avatars.first().base64Data)
|
||||
}
|
||||
avatarBitmap = loadedBitmap
|
||||
Log.d(TAG, "🎨 Bitmap loaded: ${loadedBitmap?.width}x${loadedBitmap?.height}")
|
||||
// Извлекаем доминантный цвет из нижней части аватарки (где будет текст)
|
||||
loadedBitmap?.let { bitmap ->
|
||||
try {
|
||||
Log.d(TAG, "🎨 Extracting color from bitmap ${bitmap.width}x${bitmap.height}")
|
||||
// Берем нижнюю треть изображения для более точного определения
|
||||
val bottomThird =
|
||||
android.graphics.Bitmap.createBitmap(
|
||||
@@ -772,20 +756,15 @@ private fun CollapsingProfileHeader(
|
||||
bitmap.width,
|
||||
(bitmap.height / 3).coerceAtLeast(1)
|
||||
)
|
||||
Log.d(TAG, "🎨 Bottom third: ${bottomThird.width}x${bottomThird.height}")
|
||||
val palette = AndroidPalette.from(bottomThird).generate()
|
||||
Log.d(TAG, "🎨 Palette generated, dominantSwatch=${palette.dominantSwatch}, mutedSwatch=${palette.mutedSwatch}")
|
||||
// Используем доминантный цвет или muted swatch
|
||||
val swatch = palette.dominantSwatch ?: palette.mutedSwatch
|
||||
if (swatch != null) {
|
||||
val extractedColor = Color(swatch.rgb)
|
||||
Log.d(TAG, "🎨 Extracted dominant color: R=${extractedColor.red}, G=${extractedColor.green}, B=${extractedColor.blue}, isLight=${isColorLight(extractedColor)}")
|
||||
dominantColor = extractedColor
|
||||
} else {
|
||||
Log.w(TAG, "🎨 No swatch found in palette!")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Failed to extract dominant color: ${e.message}", e)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -799,7 +778,6 @@ private fun CollapsingProfileHeader(
|
||||
derivedStateOf {
|
||||
if (hasAvatar && dominantColor != null) {
|
||||
val isLight = isColorLight(dominantColor!!)
|
||||
Log.d(TAG, "🎨 Text color: hasAvatar=$hasAvatar, dominantColor=$dominantColor, isLight=$isLight")
|
||||
if (isLight) Color.Black else Color.White
|
||||
} else {
|
||||
if (isColorLight(avatarColors.backgroundColor)) Color.Black else Color.White
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.rosetta.messenger.ui.settings
|
||||
|
||||
import android.app.Application
|
||||
import android.util.Log
|
||||
import androidx.lifecycle.AndroidViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.rosetta.messenger.data.AccountManager
|
||||
@@ -52,7 +51,6 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
|
||||
val timestamp = java.text.SimpleDateFormat("HH:mm:ss.SSS", java.util.Locale.getDefault()).format(java.util.Date())
|
||||
val logMessage = "[$timestamp] $message"
|
||||
_state.value = _state.value.copy(logs = _state.value.logs + logMessage)
|
||||
Log.d("ProfileViewModel", logMessage)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,15 +97,10 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
|
||||
addLog(" - privateKey: ${privateKeyHash.take(16)}... (length: ${privateKeyHash.length})")
|
||||
|
||||
// CRITICAL: Log full packet data for debugging
|
||||
Log.d("ProfileViewModel", "📤 SENDING PacketUserInfo:")
|
||||
Log.d("ProfileViewModel", " username='$username' (${username.length} chars)")
|
||||
Log.d("ProfileViewModel", " title='$actualTitle' (${actualTitle.length} chars)")
|
||||
Log.d("ProfileViewModel", " privateKey='${privateKeyHash.take(32)}...' (${privateKeyHash.length} chars)")
|
||||
|
||||
addLog("Sending packet to server...")
|
||||
ProtocolManager.send(packet)
|
||||
addLog("Packet sent successfully")
|
||||
Log.d("ProfileViewModel", "✅ Packet sent to ProtocolManager")
|
||||
addLog("Waiting for PacketResult (0x02) from server...")
|
||||
|
||||
// Set timeout for server response
|
||||
@@ -135,7 +128,6 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
|
||||
// Wait for response (handled in handlePacketResult)
|
||||
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProfileViewModel", "Error saving profile", e)
|
||||
addLog("❌ ERROR: ${e.message}")
|
||||
_state.value = _state.value.copy(
|
||||
isSaving = false,
|
||||
@@ -191,9 +183,7 @@ class ProfileViewModel(application: Application) : AndroidViewModel(application)
|
||||
try {
|
||||
accountManager.updateAccountName(publicKey, name)
|
||||
accountManager.updateAccountUsername(publicKey, username)
|
||||
Log.d("ProfileViewModel", "Local profile updated: name=$name, username=$username")
|
||||
} catch (e: Exception) {
|
||||
Log.e("ProfileViewModel", "Error updating local profile", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user