rename checkUserGrayPhoto
This commit is contained in:
parent
6e5ed25e33
commit
ef915383e5
5 changed files with 11 additions and 12 deletions
|
@ -46,7 +46,7 @@ class ShowLocationHelper(private val app: TelegramApplication) {
|
||||||
Color.WHITE,
|
Color.WHITE,
|
||||||
ALatLon(item.latLon!!.latitude, item.latLon!!.longitude),
|
ALatLon(item.latLon!!.latitude, item.latLon!!.longitude),
|
||||||
null,
|
null,
|
||||||
generatePhotoParams(if (stale) item.greyScaledPhotoPath else item.photoPath, stale)
|
generatePhotoParams(if (stale) item.grayscalePhotoPath else item.photoPath, stale)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ object TelegramUiHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
res.greyScaledPhotoPath = helper.getUserGreyPhotoPath(user)
|
res.grayscalePhotoPath = helper.getUserGreyPhotoPath(user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type is TdApi.ChatTypeBasicGroup) {
|
} else if (type is TdApi.ChatTypeBasicGroup) {
|
||||||
|
@ -141,7 +141,7 @@ object TelegramUiHelper {
|
||||||
name = TelegramUiHelper.getUserName(user)
|
name = TelegramUiHelper.getUserName(user)
|
||||||
latLon = LatLon(content.location.latitude, content.location.longitude)
|
latLon = LatLon(content.location.latitude, content.location.longitude)
|
||||||
photoPath = helper.getUserPhotoPath(user)
|
photoPath = helper.getUserPhotoPath(user)
|
||||||
greyScaledPhotoPath = helper.getUserGreyPhotoPath(user)
|
grayscalePhotoPath = helper.getUserGreyPhotoPath(user)
|
||||||
placeholderId = R.drawable.img_user_picture
|
placeholderId = R.drawable.img_user_picture
|
||||||
userId = message.senderUserId
|
userId = message.senderUserId
|
||||||
lastUpdated = helper.getLastUpdatedTime(message)
|
lastUpdated = helper.getLastUpdatedTime(message)
|
||||||
|
@ -158,7 +158,7 @@ object TelegramUiHelper {
|
||||||
internal set
|
internal set
|
||||||
var photoPath: String? = null
|
var photoPath: String? = null
|
||||||
internal set
|
internal set
|
||||||
var greyScaledPhotoPath: String? = null
|
var grayscalePhotoPath: String? = null
|
||||||
internal set
|
internal set
|
||||||
var placeholderId: Int = 0
|
var placeholderId: Int = 0
|
||||||
internal set
|
internal set
|
||||||
|
|
|
@ -313,7 +313,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
|
||||||
|
|
||||||
val staleLocation = System.currentTimeMillis() / 1000 - item.lastUpdated > settings.staleLocTime
|
val staleLocation = System.currentTimeMillis() / 1000 - item.lastUpdated > settings.staleLocTime
|
||||||
if (staleLocation) {
|
if (staleLocation) {
|
||||||
TelegramUiHelper.setupPhoto(app, holder.icon, item.greyScaledPhotoPath, item.placeholderId, false)
|
TelegramUiHelper.setupPhoto(app, holder.icon, item.grayscalePhotoPath, item.placeholderId, false)
|
||||||
} else {
|
} else {
|
||||||
TelegramUiHelper.setupPhoto(app, holder.icon, item.photoPath, R.drawable.img_user_picture_active, false)
|
TelegramUiHelper.setupPhoto(app, holder.icon, item.photoPath, R.drawable.img_user_picture_active, false)
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onTelegramUserChanged(user: TdApi.User) {
|
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)
|
val message = telegramHelper.getUserMessage(user)
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
app.showLocationHelper.addOrUpdateLocationOnMap(message)
|
app.showLocationHelper.addOrUpdateLocationOnMap(message)
|
||||||
|
|
|
@ -119,11 +119,11 @@ class UiUtils(private val app: TelegramApplication) {
|
||||||
val chat = app.telegramHelper.getChat(chatId)
|
val chat = app.telegramHelper.getChat(chatId)
|
||||||
val chatIconPath = chat?.photo?.small?.local?.path
|
val chatIconPath = chat?.photo?.small?.local?.path
|
||||||
if (chat != null && chatIconPath != null) {
|
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)) {
|
if (userId != 0 && !app.telegramHelper.hasGrayscaleUserPhoto(userId)) {
|
||||||
ConvertPhotoToGrayscale().executeOnExecutor(
|
ConvertPhotoToGrayscale().executeOnExecutor(
|
||||||
AsyncTask.THREAD_POOL_EXECUTOR,
|
AsyncTask.THREAD_POOL_EXECUTOR,
|
||||||
|
@ -250,13 +250,12 @@ class UiUtils(private val app: TelegramApplication) {
|
||||||
|
|
||||||
fun convertToGrayscaleAndSave(coloredImagePath: String, newFilePath: String) {
|
fun convertToGrayscaleAndSave(coloredImagePath: String, newFilePath: String) {
|
||||||
val currentImage = BitmapFactory.decodeFile(coloredImagePath)
|
val currentImage = BitmapFactory.decodeFile(coloredImagePath)
|
||||||
val greyedImage = toGrayscale(currentImage)
|
val grayscaleImage = toGrayscale(currentImage)
|
||||||
saveBitmap(greyedImage, newFilePath)
|
saveBitmap(grayscaleImage, newFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toGrayscale(bmpOriginal: Bitmap): Bitmap {
|
private fun toGrayscale(bmpOriginal: Bitmap): Bitmap {
|
||||||
val bmpGrayscale =
|
val bmpGrayscale = Bitmap.createBitmap(bmpOriginal.width, bmpOriginal.height, Bitmap.Config.ARGB_8888)
|
||||||
Bitmap.createBitmap(bmpOriginal.width, bmpOriginal.height, Bitmap.Config.ARGB_8888)
|
|
||||||
val c = Canvas(bmpGrayscale)
|
val c = Canvas(bmpGrayscale)
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
val cm = ColorMatrix()
|
val cm = ColorMatrix()
|
||||||
|
|
Loading…
Reference in a new issue