rename checkUserGrayPhoto

This commit is contained in:
Chumva 2018-08-23 10:41:14 +03:00
parent 6e5ed25e33
commit ef915383e5
5 changed files with 11 additions and 12 deletions

View file

@ -46,7 +46,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
Color.WHITE,
ALatLon(item.latLon!!.latitude, item.latLon!!.longitude),
null,
generatePhotoParams(if (stale) item.greyScaledPhotoPath else item.photoPath, stale)
generatePhotoParams(if (stale) item.grayscalePhotoPath else item.photoPath, stale)
)
}
}

View file

@ -69,7 +69,7 @@ object TelegramUiHelper {
}
}
if (user != null) {
res.greyScaledPhotoPath = helper.getUserGreyPhotoPath(user)
res.grayscalePhotoPath = helper.getUserGreyPhotoPath(user)
}
}
} else if (type is TdApi.ChatTypeBasicGroup) {
@ -141,7 +141,7 @@ object TelegramUiHelper {
name = TelegramUiHelper.getUserName(user)
latLon = LatLon(content.location.latitude, content.location.longitude)
photoPath = helper.getUserPhotoPath(user)
greyScaledPhotoPath = helper.getUserGreyPhotoPath(user)
grayscalePhotoPath = helper.getUserGreyPhotoPath(user)
placeholderId = R.drawable.img_user_picture
userId = message.senderUserId
lastUpdated = helper.getLastUpdatedTime(message)
@ -158,7 +158,7 @@ object TelegramUiHelper {
internal set
var photoPath: String? = null
internal set
var greyScaledPhotoPath: String? = null
var grayscalePhotoPath: String? = null
internal set
var placeholderId: Int = 0
internal set

View file

@ -313,7 +313,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
val staleLocation = System.currentTimeMillis() / 1000 - item.lastUpdated > settings.staleLocTime
if (staleLocation) {
TelegramUiHelper.setupPhoto(app, holder.icon, item.greyScaledPhotoPath, item.placeholderId, false)
TelegramUiHelper.setupPhoto(app, holder.icon, item.grayscalePhotoPath, item.placeholderId, false)
} else {
TelegramUiHelper.setupPhoto(app, holder.icon, item.photoPath, R.drawable.img_user_picture_active, false)
}

View file

@ -225,7 +225,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
}
override fun onTelegramUserChanged(user: TdApi.User) {
app.uiUtils.checkUserGreyPhoto(user.id, telegramHelper.getUserPhotoPath(user))
app.uiUtils.checkUserGrayPhoto(user.id, telegramHelper.getUserPhotoPath(user))
val message = telegramHelper.getUserMessage(user)
if (message != null) {
app.showLocationHelper.addOrUpdateLocationOnMap(message)

View file

@ -119,11 +119,11 @@ class UiUtils(private val app: TelegramApplication) {
val chat = app.telegramHelper.getChat(chatId)
val chatIconPath = chat?.photo?.small?.local?.path
if (chat != null && chatIconPath != null) {
checkUserGreyPhoto(app.telegramHelper.getUserIdFromChatType(chat.type), chatIconPath)
checkUserGrayPhoto(app.telegramHelper.getUserIdFromChatType(chat.type), chatIconPath)
}
}
fun checkUserGreyPhoto(userId: Int, userOriginalPhotoPath: String?) {
fun checkUserGrayPhoto(userId: Int, userOriginalPhotoPath: String?) {
if (userId != 0 && !app.telegramHelper.hasGrayscaleUserPhoto(userId)) {
ConvertPhotoToGrayscale().executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR,
@ -250,13 +250,12 @@ class UiUtils(private val app: TelegramApplication) {
fun convertToGrayscaleAndSave(coloredImagePath: String, newFilePath: String) {
val currentImage = BitmapFactory.decodeFile(coloredImagePath)
val greyedImage = toGrayscale(currentImage)
saveBitmap(greyedImage, newFilePath)
val grayscaleImage = toGrayscale(currentImage)
saveBitmap(grayscaleImage, newFilePath)
}
private fun toGrayscale(bmpOriginal: Bitmap): Bitmap {
val bmpGrayscale =
Bitmap.createBitmap(bmpOriginal.width, bmpOriginal.height, Bitmap.Config.ARGB_8888)
val bmpGrayscale = Bitmap.createBitmap(bmpOriginal.width, bmpOriginal.height, Bitmap.Config.ARGB_8888)
val c = Canvas(bmpGrayscale)
val paint = Paint()
val cm = ColorMatrix()