Update to 6.2.0 (1985)

This commit is contained in:
DrKLO 2020-06-05 05:40:01 +03:00
parent dceccae0b7
commit e2f7baf2bd
26 changed files with 430 additions and 239 deletions

View file

@ -276,7 +276,7 @@ android {
}
}
defaultConfig.versionCode = 1984
defaultConfig.versionCode = 1985
def tgVoipDexFileName = "libtgvoip.dex"
def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"]

View file

@ -141,14 +141,12 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
if (additionsPending) {
final ArrayList<RecyclerView.ViewHolder> additions = new ArrayList<>();
additions.addAll(mPendingAdditions);
mAdditionsList.add(additions);
mPendingAdditions.clear();
for (RecyclerView.ViewHolder holder : additions) {
animateAddImpl(holder);
}
additions.clear();
mAdditionsList.remove(additions);
}
}
@ -181,26 +179,22 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
if (movesPending) {
final ArrayList<MoveInfo> moves = new ArrayList<>();
moves.addAll(mPendingMoves);
mMovesList.add(moves);
mPendingMoves.clear();
for (MoveInfo moveInfo : moves) {
animateMoveImpl(moveInfo.holder, moveInfo);
}
moves.clear();
mMovesList.remove(moves);
}
if (additionsPending) {
final ArrayList<RecyclerView.ViewHolder> additions = new ArrayList<>();
additions.addAll(mPendingAdditions);
mAdditionsList.add(additions);
mPendingAdditions.clear();
for (RecyclerView.ViewHolder holder : additions) {
animateAddImpl(holder, addedItemsHeight);
}
additions.clear();
mAdditionsList.remove(additions);
}
}

View file

@ -25,6 +25,9 @@ import android.view.ViewGroup;
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildVars;
import java.util.Arrays;
/**
@ -35,7 +38,7 @@ import java.util.Arrays;
*/
public class GridLayoutManager extends LinearLayoutManager {
private static final boolean DEBUG = false;
private static final boolean DEBUG = BuildVars.DEBUG_VERSION;
private static final String TAG = "GridLayoutManager";
public static final int DEFAULT_SPAN_COUNT = -1;
/**

View file

@ -61,6 +61,7 @@ import android.widget.OverScroller;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.BuildConfig;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import androidx.annotation.CallSuper;
import androidx.annotation.IntDef;
@ -4473,8 +4474,8 @@ public class RecyclerView extends ViewGroup implements ScrollingView,
for (int i = 0; i < childCount; i++) {
final ViewHolder holder = getChildViewHolderInt(mChildHelper.getUnfilteredChildAt(i));
if (DEBUG && holder.mPosition == -1 && !holder.isRemoved()) {
throw new IllegalStateException("view holder cannot have position -1 unless it"
+ " is removed" + exceptionLabel());
FileLog.e(new IllegalStateException("view holder cannot have position -1 unless it"
+ " is removed" + exceptionLabel()));
}
if (!holder.shouldIgnore()) {
holder.saveOldPosition();

View file

@ -15,7 +15,7 @@
*/
package androidx.recyclerview.widget;
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import static androidx.recyclerview.widget.ViewInfoStore.InfoRecord.FLAG_APPEAR;
import static androidx.recyclerview.widget.ViewInfoStore.InfoRecord.FLAG_APPEAR_AND_DISAPPEAR;
@ -38,8 +38,6 @@ class ViewInfoStore {
private static final boolean DEBUG = false;
private boolean processing;
/**
* View data records for pre-layout
*/
@ -117,12 +115,6 @@ class ViewInfoStore {
}
// if not pre-post flag is left, clear.
if ((record.flags & (FLAG_PRE | FLAG_POST)) == 0) {
if (processing) {
if (BuildVars.DEBUG_VERSION) {
throw new RuntimeException("popFromLayoutStep while processing");
}
return null;
}
mLayoutHolderMap.removeAt(index);
InfoRecord.recycle(record);
}
@ -224,10 +216,17 @@ class ViewInfoStore {
}
void process(ProcessCallback callback) {
processing = true;
for (int index = mLayoutHolderMap.size() - 1; index >= 0; index--) {
final RecyclerView.ViewHolder viewHolder = mLayoutHolderMap.keyAt(index);
final InfoRecord record = mLayoutHolderMap.removeAt(index);
InfoRecord record = null;
try {
record = mLayoutHolderMap.removeAt(index);
} catch (Exception e) {
FileLog.e(e);
}
if (record == null) {
continue;
}
if ((record.flags & FLAG_APPEAR_AND_DISAPPEAR) == FLAG_APPEAR_AND_DISAPPEAR) {
// Appeared then disappeared. Not useful for animations.
callback.unused(viewHolder);
@ -259,7 +258,6 @@ class ViewInfoStore {
}
InfoRecord.recycle(record);
}
processing = false;
}
/**
@ -275,12 +273,6 @@ class ViewInfoStore {
}
final InfoRecord info = mLayoutHolderMap.get(holder);
if (info != null) {
if (processing) {
if (BuildVars.DEBUG_VERSION) {
throw new RuntimeException("removeViewHolder while processing");
}
return;
}
mLayoutHolderMap.remove(holder);
InfoRecord.recycle(info);
}

View file

@ -315,7 +315,7 @@ public class ApplicationLoader extends Application {
public static boolean isConnectedOrConnectingToWiFi() {
try {
ensureCurrentNetworkGet(false);
if (currentNetworkInfo != null && currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) {
if (currentNetworkInfo != null && (currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || currentNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET)) {
NetworkInfo.State state = currentNetworkInfo.getState();
if (state == NetworkInfo.State.CONNECTED || state == NetworkInfo.State.CONNECTING || state == NetworkInfo.State.SUSPENDED) {
return true;
@ -330,7 +330,7 @@ public class ApplicationLoader extends Application {
public static boolean isConnectedToWiFi() {
try {
ensureCurrentNetworkGet(false);
if (currentNetworkInfo != null && currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI && currentNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
if (currentNetworkInfo != null && (currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || currentNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) && currentNetworkInfo.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
} catch (Exception e) {
@ -360,19 +360,18 @@ public class ApplicationLoader extends Application {
public static int getAutodownloadNetworkType() {
try {
ConnectivityManager connectivityManager = (ConnectivityManager) ApplicationLoader.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (netInfo != null) {
if (netInfo.getState() == NetworkInfo.State.CONNECTED) {
ensureCurrentNetworkGet(false);
if (currentNetworkInfo == null) {
return StatsController.TYPE_MOBILE;
}
if (currentNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI || currentNetworkInfo.getType() == ConnectivityManager.TYPE_ETHERNET) {
if (connectivityManager.isActiveNetworkMetered()) {
return StatsController.TYPE_MOBILE;
} else {
return StatsController.TYPE_WIFI;
}
}
}
netInfo = connectivityManager.getActiveNetworkInfo();
if (netInfo != null && netInfo.isRoaming()) {
if (currentNetworkInfo.isRoaming()) {
return StatsController.TYPE_ROAMING;
}
} catch (Exception e) {

View file

@ -19,7 +19,7 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean TON_WALLET_STANDALONE = false;
public static int BUILD_VERSION = 1984;
public static int BUILD_VERSION = 1985;
public static String BUILD_VERSION_STRING = "6.2.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -4802,7 +4802,12 @@ public class MessageObject {
if (messageOwner.media instanceof TLRPC.TL_messageMediaPhoto) {
return messageOwner.media.photo != null && messageOwner.media.photo.has_stickers;
} else if (messageOwner.media instanceof TLRPC.TL_messageMediaDocument) {
TLRPC.Document document = messageOwner.media.document;
return isDocumentHasAttachedStickers(messageOwner.media.document);
}
return false;
}
public static boolean isDocumentHasAttachedStickers(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
@ -4811,7 +4816,6 @@ public class MessageObject {
}
}
}
}
return false;
}

View file

@ -272,6 +272,7 @@ public class MessagesController extends BaseController implements NotificationCe
public int webFileDatacenterId;
public String suggestedLangCode;
public boolean qrLoginCamera;
public boolean saveGifsWithStickers;
private String installReferer;
public ArrayList<String> gifSearchEmojies = new ArrayList<>();
public HashSet<String> diceEmojies;
@ -621,6 +622,7 @@ public class MessagesController extends BaseController implements NotificationCe
suggestedLangCode = mainPreferences.getString("suggestedLangCode", "en");
animatedEmojisZoom = mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
qrLoginCamera = mainPreferences.getBoolean("qrLoginCamera", false);
saveGifsWithStickers = mainPreferences.getBoolean("saveGifsWithStickers", false);
filtersEnabled = mainPreferences.getBoolean("filtersEnabled", false);
showFiltersTooltip = mainPreferences.getBoolean("showFiltersTooltip", false);
@ -1213,6 +1215,17 @@ public class MessagesController extends BaseController implements NotificationCe
}
break;
}
case "save_gifs_with_stickers": {
if (value.value instanceof TLRPC.TL_jsonBool) {
TLRPC.TL_jsonBool bool = (TLRPC.TL_jsonBool) value.value;
if (bool.value != saveGifsWithStickers) {
saveGifsWithStickers = bool.value;
editor.putBoolean("saveGifsWithStickers", saveGifsWithStickers);
changed = true;
}
}
break;
}
case "emojies_send_dice": {
HashSet<String> newEmojies = new HashSet<>();
if (value.value instanceof TLRPC.TL_jsonArray) {
@ -12070,7 +12083,15 @@ public class MessagesController extends BaseController implements NotificationCe
}
if (message.isOut() && !message.isSending() && !message.isForwarded()) {
if (message.isNewGif()) {
boolean save;
if (MessageObject.isDocumentHasAttachedStickers(message.messageOwner.media.document)) {
save = getMessagesController().saveGifsWithStickers;
} else {
save = true;
}
if (save) {
getMediaDataController().addRecentGif(message.messageOwner.media.document, message.messageOwner.date);
}
} else if (!message.isAnimatedEmoji() && (message.isSticker() || message.isAnimatedSticker())) {
getMediaDataController().addRecentSticker(MediaDataController.TYPE_IMAGE, message, message.messageOwner.media.document, message.messageOwner.date, false);
}

View file

@ -1764,6 +1764,7 @@ public class MessagesStorage extends BaseController {
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
SparseArray<Boolean> archivedDialogs = new SparseArray<>();
if (!usersToLoad.isEmpty()) {
getUsersInternal(TextUtils.join(",", usersToLoad), users);
for (int a = 0, N = users.size(); a < N; a++) {
@ -1774,6 +1775,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(user.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(user.id, true);
}
if (user.bot) {
bots[idx1][idx2]++;
} else if (user.self || user.contact) {
@ -1807,6 +1811,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(user.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(user.id, true);
}
if (user.self || user.contact) {
contacts[idx1][idx2]++;
} else {
@ -1832,6 +1839,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(-chat.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(-chat.id, true);
}
if (ChatObject.isChannel(chat) && !chat.megagroup) {
channels[idx1][idx2]++;
} else {
@ -1945,62 +1955,51 @@ public class MessagesStorage extends BaseController {
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
int did = filter.alwaysShow.get(b);
if (did > 0) {
TLRPC.User user = usersDict.get(did);
for (int i = 0; i < 2; i++) {
SparseArray<TLRPC.User> dict = i == 0 ? usersDict : encUsersDict;
TLRPC.User user = dict.get(did);
if (user != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount++;
int count;
if (i == 0) {
count = 1;
} else {
count = encryptedChatsByUsersCount.get(did, 0);
if (count == 0) {
continue;
}
}
int flag;
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
unreadCount++;
}
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
unreadCount++;
}
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount++;
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
}
}
}
}
user = encUsersDict.get(did);
if (user != null) {
int count = encryptedChatsByUsersCount.get(did, 0);
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
if ((flags & flag) == 0) {
unreadCount += count;
} else {
if (user.bot) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_BOTS) == 0) {
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount += count;
}
} else if (user.self || user.contact) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CONTACTS) == 0) {
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) != 0 && archivedDialogs.indexOfKey(user.id) >= 0) {
unreadCount += count;
}
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS) == 0) {
unreadCount += count;
}
}
}
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0) {
unreadCount++;
} else {
int flag;
if (ChatObject.isChannel(chat) && !chat.megagroup) {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_CHANNELS) == 0) {
unreadCount++;
}
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else {
if ((flags & MessagesController.DIALOG_FILTER_FLAG_GROUPS) == 0) {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
}
if ((flags & flag) == 0) {
unreadCount++;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0) {
unreadCount++;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) != 0 && archivedDialogs.indexOfKey(-chat.id) >= 0) {
unreadCount++;
}
}
}
}
}
@ -2008,21 +2007,53 @@ public class MessagesStorage extends BaseController {
for (int b = 0, N2 = filter.neverShow.size(); b < N2; b++) {
int did = filter.neverShow.get(b);
if (did > 0) {
TLRPC.User user = usersDict.get(did);
for (int i = 0; i < 2; i++) {
SparseArray<TLRPC.User> dict = i == 0 ? usersDict : encUsersDict;
TLRPC.User user = dict.get(did);
if (user != null) {
unreadCount--;
int count;
if (i == 0) {
count = 1;
} else {
count = encryptedChatsByUsersCount.get(did, 0);
if (count == 0) {
continue;
}
}
int flag;
if (user.bot) {
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
} else if (user.self || user.contact) {
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
}
if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(user.id) < 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(user.id) < 0)) {
unreadCount -= count;
}
}
}
user = encUsersDict.get(did);
if (user != null) {
unreadCount -= encryptedChatsByUsersCount.get(did, 0);
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
int flag;
if (ChatObject.isChannel(chat) && !chat.megagroup) {
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
}
if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) {
unreadCount--;
}
}
}
}
}
filter.pendingUnreadCount = unreadCount;
/*if (BuildVars.DEBUG_VERSION) {
FileLog.d("filter " + filter.name + " flags = " + filter.flags + " unread count = " + filter.pendingUnreadCount);
@ -3726,6 +3757,7 @@ public class MessagesStorage extends BaseController {
SparseArray<TLRPC.User> encUsersDict = new SparseArray<>();
SparseArray<Integer> encryptedChatsByUsersCount = new SparseArray<>();
SparseArray<Boolean> mutedDialogs = new SparseArray<>();
SparseArray<Boolean> archivedDialogs = new SparseArray<>();
if (!usersToLoad.isEmpty()) {
getUsersInternal(TextUtils.join(",", usersToLoad), users);
for (int a = 0, N = users.size(); a < N; a++) {
@ -3736,6 +3768,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(user.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(user.id, true);
}
if (user.bot) {
bots[idx1][idx2]++;
} else if (user.self || user.contact) {
@ -3769,6 +3804,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(user.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(user.id, true);
}
if (user.self || user.contact) {
contacts[idx1][idx2]++;
} else {
@ -3794,6 +3832,9 @@ public class MessagesStorage extends BaseController {
if (muted) {
mutedDialogs.put(-chat.id, true);
}
if (idx1 == 1) {
archivedDialogs.put(-chat.id, true);
}
if (muted && dialogsToUpdateMentions != null && dialogsToUpdateMentions.indexOfKey(-chat.id) >= 0) {
if (ChatObject.isChannel(chat) && !chat.megagroup) {
mentionChannels[idx1]++;
@ -3993,28 +4034,113 @@ public class MessagesStorage extends BaseController {
}
}
}
for (int b = 0, N2 = filter.alwaysShow.size(); b < N2; b++) {
int did = filter.alwaysShow.get(b);
if (did > 0) {
for (int i = 0; i < 2; i++) {
SparseArray<TLRPC.User> dict = i == 0 ? usersDict : encUsersDict;
TLRPC.User user = dict.get(did);
if (user != null) {
int count;
if (i == 0) {
count = 1;
} else {
count = encryptedChatsByUsersCount.get(did, 0);
if (count == 0) {
continue;
}
}
int flag;
if (user.bot) {
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
} else if (user.self || user.contact) {
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
}
if ((flags & flag) == 0) {
unreadCount -= count;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(user.id) >= 0) {
unreadCount -= count;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) != 0 && archivedDialogs.indexOfKey(user.id) >= 0) {
unreadCount -= count;
}
}
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
int flag;
if (ChatObject.isChannel(chat) && !chat.megagroup) {
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
}
if ((flags & flag) == 0) {
unreadCount--;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) != 0 && mutedDialogs.indexOfKey(-chat.id) >= 0 && dialogsWithMentions.indexOfKey(-chat.id) < 0) {
unreadCount--;
} else if ((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) != 0 && archivedDialogs.indexOfKey(-chat.id) >= 0) {
unreadCount--;
}
}
}
}
for (int b = 0, N2 = filter.neverShow.size(); b < N2; b++) {
int did = filter.neverShow.get(b);
if (dialogsToUpdateMentions != null && dialogsToUpdateMentions.indexOfKey(did) >= 0 && mutedDialogs.indexOfKey(did) < 0) {
continue;
}
if (did > 0) {
TLRPC.User user = usersDict.get(did);
for (int i = 0; i < 2; i++) {
SparseArray<TLRPC.User> dict = i == 0 ? usersDict : encUsersDict;
TLRPC.User user = dict.get(did);
if (user != null) {
unreadCount++;
int count;
if (i == 0) {
count = 1;
} else {
count = encryptedChatsByUsersCount.get(did, 0);
if (count == 0) {
continue;
}
}
int flag;
if (user.bot) {
flag = MessagesController.DIALOG_FILTER_FLAG_BOTS;
} else if (user.self || user.contact) {
flag = MessagesController.DIALOG_FILTER_FLAG_CONTACTS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_NON_CONTACTS;
}
if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(user.id) < 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(user.id) < 0)) {
unreadCount += count;
}
}
}
user = encUsersDict.get(did);
if (user != null) {
unreadCount += encryptedChatsByUsersCount.get(did, 0);
}
} else {
TLRPC.Chat chat = chatsDict.get(-did);
if (chat != null) {
int flag;
if (ChatObject.isChannel(chat) && !chat.megagroup) {
flag = MessagesController.DIALOG_FILTER_FLAG_CHANNELS;
} else {
flag = MessagesController.DIALOG_FILTER_FLAG_GROUPS;
}
if ((flags & flag) != 0) {
if (((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_ARCHIVED) == 0 || archivedDialogs.indexOfKey(-chat.id) < 0 || dialogsWithMentions.indexOfKey(-chat.id) >= 0) &&
((flags & MessagesController.DIALOG_FILTER_FLAG_EXCLUDE_MUTED) == 0 || mutedDialogs.indexOfKey(-chat.id) < 0)) {
unreadCount++;
}
}
}
}
}
}
if (unreadCount < 0) {
unreadCount = 0;
}

View file

@ -4766,7 +4766,15 @@ public class SendMessagesHelper extends BaseController implements NotificationCe
if ((sentMessage.flags & TLRPC.MESSAGE_FLAG_FWD) == 0 && MessageObject.isOut(sentMessage)) {
if (MessageObject.isNewGifDocument(sentMessage.media.document)) {
boolean save;
if (MessageObject.isDocumentHasAttachedStickers(sentMessage.media.document)) {
save = getMessagesController().saveGifsWithStickers;
} else {
save = true;
}
if (save) {
getMediaDataController().addRecentGif(sentMessage.media.document, sentMessage.date);
}
} else if (MessageObject.isStickerDocument(sentMessage.media.document) || MessageObject.isAnimatedStickerDocument(sentMessage.media.document, true)) {
getMediaDataController().addRecentSticker(MediaDataController.TYPE_IMAGE, sentMessage, sentMessage.media.document, sentMessage.date, false);
}

View file

@ -676,7 +676,7 @@ public class CameraController implements MediaRecorder.OnInfoListener {
final File cacheFile = new File(FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName);
try {
FileOutputStream stream = new FileOutputStream(cacheFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 80, stream);
bitmap.compress(Bitmap.CompressFormat.JPEG, 87, stream);
} catch (Throwable e) {
FileLog.e(e);
}

View file

@ -393,8 +393,9 @@ public class SimpleTextView extends View implements Drawable.Callback {
int textOffsetX = 0;
boolean fade = scrollNonFitText && (textDoesNotFit || scrollingOffset != 0);
int restore = Integer.MIN_VALUE;
if (fade) {
canvas.saveLayerAlpha(0, 0, getMeasuredWidth(), getMeasuredHeight(), 255, Canvas.ALL_SAVE_FLAG);
restore = canvas.saveLayerAlpha(0, 0, getMeasuredWidth(), getMeasuredHeight(), 255, Canvas.ALL_SAVE_FLAG);
}
totalWidth = textWidth;
@ -487,6 +488,9 @@ public class SimpleTextView extends View implements Drawable.Callback {
}
updateScrollAnimation();
}
if (fade) {
canvas.restoreToCount(restore);
}
}
private void updateScrollAnimation() {

View file

@ -6339,11 +6339,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
textX += diff;
}
}
if (transitionParams.animateChangeProgress != 1f && transitionParams.animateMessageText) {
drawMessageText(canvas, transitionParams.animateOutTextBlocks, false, (1f - transitionParams.animateChangeProgress));
if (transitionParams.animateChangeProgress != 1.0f && transitionParams.animateMessageText) {
drawMessageText(canvas, transitionParams.animateOutTextBlocks, false, (1.0f - transitionParams.animateChangeProgress));
drawMessageText(canvas, currentMessageObject.textLayoutBlocks, true, transitionParams.animateChangeProgress);
} else {
drawMessageText(canvas, currentMessageObject.textLayoutBlocks, true, 1f);
drawMessageText(canvas, currentMessageObject.textLayoutBlocks, true, 1.0f);
}
@ -7063,7 +7063,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
private void drawMessageText(Canvas canvas, ArrayList<MessageObject.TextLayoutBlock> textLayoutBlocks, boolean origin, float alpha) {
if (textLayoutBlocks != null && !textLayoutBlocks.isEmpty()) {
if (textLayoutBlocks == null || textLayoutBlocks.isEmpty()) {
return;
}
int oldAlpha = 0;
int firstVisibleBlockNum;
int lastVisibleBlockNum;
@ -7080,7 +7082,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
if (firstVisibleBlockNum >= 0) {
if (alpha != 1f) {
int restore = Integer.MIN_VALUE;
if (alpha != 1.0f) {
if (currentBackgroundDrawable != null) {
int top = currentBackgroundDrawable.getBounds().top;
int bottom = currentBackgroundDrawable.getBounds().bottom;
@ -7098,7 +7101,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
} else {
rect.set(0, 0, getMeasuredWidth(), getMeasuredHeight());
}
canvas.saveLayerAlpha(rect, (int) (alpha * 255), Canvas.ALL_SAVE_FLAG);
restore = canvas.saveLayerAlpha(rect, (int) (alpha * 255), Canvas.ALL_SAVE_FLAG);
}
for (int a = firstVisibleBlockNum; a <= lastVisibleBlockNum; a++) {
if (a >= textLayoutBlocks.size()) {
@ -7129,9 +7132,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
canvas.restore();
}
if (alpha != 1f) {
canvas.restore();
}
if (restore != Integer.MIN_VALUE) {
canvas.restoreToCount(restore);
}
}
}
@ -9132,7 +9134,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (alphaInternal != 1f) {
int restore = Integer.MIN_VALUE;
if (alphaInternal != 1.0f) {
int top = 0;
int left = 0;
int bottom = getMeasuredHeight();
@ -9159,7 +9162,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
bottom = (int) (parentHeight - getY());
}
rect.set(left, top, right, bottom);
canvas.saveLayerAlpha(rect, (int) (255 * alphaInternal), Canvas.ALL_SAVE_FLAG);
restore = canvas.saveLayerAlpha(rect, (int) (255 * alphaInternal), Canvas.ALL_SAVE_FLAG);
}
if (transitionParams.animateBackgroundBoundsInner && currentBackgroundDrawable != null) {
Rect r = currentBackgroundDrawable.getBounds();
@ -9274,8 +9277,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
parent.invalidate();
}
}
if (alphaInternal != 1f) {
canvas.restore();
if (restore != Integer.MIN_VALUE) {
canvas.restoreToCount(restore);
}
updateSelectionTextPosition();
}
@ -9418,9 +9421,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return;
}
int restore = Integer.MIN_VALUE;
if (alpha != 1f) {
rect.set(0, 0, getMaxNameWidth(), getMeasuredHeight());
canvas.saveLayerAlpha(rect, (int) (255 * alpha), Canvas.ALL_SAVE_FLAG);
restore = canvas.saveLayerAlpha(rect, (int) (255 * alpha), Canvas.ALL_SAVE_FLAG);
}
if (drawNameLayout && nameLayout != null) {
@ -9615,8 +9619,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (alpha != 1f) {
canvas.restore();
if (restore != Integer.MIN_VALUE) {
canvas.restoreToCount(restore);
}
}
@ -9751,14 +9755,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (renderingAlpha != 1f) {
int restore = Integer.MIN_VALUE;
if (renderingAlpha != 1.0f) {
rect.set(captionX, captionY, captionX + captionLayout.getWidth(), captionY + captionLayout.getHeight());
canvas.saveLayerAlpha(rect, (int) (255 * renderingAlpha), Canvas.ALL_SAVE_FLAG);
restore = canvas.saveLayerAlpha(rect, (int) (255 * renderingAlpha), Canvas.ALL_SAVE_FLAG);
}
canvas.translate(captionX, captionY);
if (pressedLink != null) {
for (int b = 0; b < urlPath.size(); b++) {
canvas.drawPath(urlPath.get(b), Theme.chat_urlPaint);
@ -9779,8 +9783,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
FileLog.e(e);
}
}
if (renderingAlpha != 1f) {
canvas.restore();
if (restore != Integer.MIN_VALUE) {
canvas.restoreToCount(restore);
}
canvas.restore();
}

View file

@ -3689,6 +3689,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
return false;
}
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
super.onLayoutChildren(recycler, state);
} catch (Exception e) {
FileLog.e(e);
AndroidUtilities.runOnUIThread(() -> chatAdapter.notifyDataSetChanged());
}
}
};
chatLayoutManager.setSpanSizeLookup(new GridLayoutManagerFixed.SpanSizeLookup() {
@Override

View file

@ -788,7 +788,7 @@ public class CropView extends FrameLayout implements CropAreaView.AreaViewListen
matrix.postTranslate(canvasBitmap.getWidth() / 2, canvasBitmap.getHeight() / 2);
canvas.drawBitmap(b, matrix, new Paint(FILTER_BITMAP_FLAG));
FileOutputStream stream = new FileOutputStream(new File(path));
canvasBitmap.compress(format, 83, stream);
canvasBitmap.compress(format, 87, stream);
stream.close();
if (entities != null && !entities.isEmpty()) {

View file

@ -4629,7 +4629,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
@MainThread
private void processResponse(final String query, final String offset, boolean searchUser, boolean isEmoji, boolean cache, String key, TLObject response) {
if (!query.equals(lastSearchImageString)) {
if (query == null || !query.equals(lastSearchImageString)) {
return;
}
reqId = 0;

View file

@ -298,7 +298,7 @@ public class FilterGLThread extends DispatchQueue {
videoHeight /= 2;
}
}
if (!renderDataSet && videoWidth != 0 && videoHeight != 0) {
if (!renderDataSet && videoWidth > 0 && videoHeight > 0) {
filterShaders.setRenderData(currentBitmap, orientation, videoTexture[0], videoWidth, videoHeight);
renderDataSet = true;
renderBufferWidth = filterShaders.getRenderBufferWidth();
@ -382,8 +382,10 @@ public class FilterGLThread extends DispatchQueue {
}
public void setSurfaceTextureSize(int width, int height) {
postRunnable(() -> {
surfaceWidth = width;
surfaceHeight = height;
});
}
@Override

View file

@ -907,7 +907,7 @@ public class FilterShaders {
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, hsvBuffer);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, renderBufferWidth, renderBufferHeight, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
}
public static int loadShader(int type, String shaderCode) {

View file

@ -389,10 +389,10 @@ public class Painting {
int texture = buffers[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, texture);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, GL10.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_LINEAR);
GLES20.glTexParameteri(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_NEAREST);
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, null);
GLES20.glFramebufferTexture2D(GLES20.GL_FRAMEBUFFER, GLES20.GL_COLOR_ATTACHMENT0, GLES20.GL_TEXTURE_2D, texture, 0);
@ -415,24 +415,15 @@ public class Painting {
GLES20.glUniformMatrix4fv(shader.getUniform("mvpMatrix"), 1, false, FloatBuffer.wrap(finalProjection));
if (undo) {
GLES20.glUniform1i(shader.getUniform("texture"), 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTexture());
} else {
GLES20.glUniform1i(shader.getUniform("texture"), 0);
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, bitmapTexture.texture());
GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTexture());
}
GLES20.glClearColor(0, 0, 0, 0);
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ZERO);
GLES20.glVertexAttribPointer(0, 2, GLES20.GL_FLOAT, false, 8, vertexBuffer);
GLES20.glEnableVertexAttribArray(0);

View file

@ -18,7 +18,7 @@ public class ShaderSet {
private static final String PAINT_BRUSH_FSH = "precision highp float; varying vec2 varTexcoord; varying float varIntensity; uniform sampler2D texture; void main (void) { gl_FragColor = vec4(0, 0, 0, varIntensity * texture2D(texture, varTexcoord.st, 0.0).r); }";
private static final String PAINT_BRUSHLIGHT_FSH = "precision highp float; varying vec2 varTexcoord; varying float varIntensity; uniform sampler2D texture; void main (void) { vec4 f = texture2D(texture, varTexcoord.st, 0.0); gl_FragColor = vec4(f.r * varIntensity, f.g, f.b, 0.0); }";
private static final String PAINT_BLIT_VSH = "precision highp float; uniform mat4 mvpMatrix; attribute vec4 inPosition; attribute vec2 inTexcoord; varying vec2 varTexcoord; void main (void) { gl_Position = mvpMatrix * inPosition; varTexcoord = inTexcoord; }";
private static final String PAINT_BLIT_FSH = "precision highp float; varying vec2 varTexcoord; uniform sampler2D texture; void main (void) { vec4 tex = texture2D(texture, varTexcoord.st, 0.0); gl_FragColor = texture2D(texture, varTexcoord.st, 0.0); gl_FragColor.rgb *= gl_FragColor.a; }";
private static final String PAINT_BLIT_FSH = "precision highp float; varying vec2 varTexcoord; uniform sampler2D texture; void main (void) { gl_FragColor = texture2D(texture, varTexcoord.st, 0.0); gl_FragColor.rgb *= gl_FragColor.a; }";
private static final String PAINT_BLITWITHMASKLIGHT_FSH = "precision highp float; varying vec2 varTexcoord; uniform sampler2D texture; uniform sampler2D mask; uniform vec4 color; void main (void) { vec4 dst = texture2D(texture, varTexcoord.st, 0.0); vec3 maskColor = texture2D(mask, varTexcoord.st, 0.0).rgb; float srcAlpha = clamp(0.78 * maskColor.r + maskColor.b + maskColor.g, 0.0, 1.0); vec3 borderColor = mix(color.rgb, vec3(1.0, 1.0, 1.0), 0.86); vec3 finalColor = mix(color.rgb, borderColor, maskColor.g); finalColor = mix(finalColor.rgb, vec3(1.0, 1.0, 1.0), maskColor.b); float outAlpha = srcAlpha + dst.a * (1.0 - srcAlpha); gl_FragColor.rgb = (finalColor * srcAlpha + dst.rgb * dst.a * (1.0 - srcAlpha)) / outAlpha; gl_FragColor.a = outAlpha; gl_FragColor.rgb *= gl_FragColor.a; }";
private static final String PAINT_BLITWITHMASK_FSH = "precision highp float; varying vec2 varTexcoord; uniform sampler2D texture; uniform sampler2D mask; uniform vec4 color; void main (void) { vec4 dst = texture2D(texture, varTexcoord.st, 0.0); float srcAlpha = color.a * texture2D(mask, varTexcoord.st, 0.0).a; float outAlpha = srcAlpha + dst.a * (1.0 - srcAlpha); gl_FragColor.rgb = (color.rgb * srcAlpha + dst.rgb * dst.a * (1.0 - srcAlpha)) / outAlpha; gl_FragColor.a = outAlpha; gl_FragColor.rgb *= gl_FragColor.a; }";
private static final String PAINT_COMPOSITEWITHMASK_FSH = "precision highp float; varying vec2 varTexcoord; uniform sampler2D texture; uniform sampler2D mask; uniform vec4 color; void main(void) { vec4 dst = texture2D(texture, varTexcoord.st, 0.0); float srcAlpha = color.a * texture2D(mask, varTexcoord.st, 0.0).a; float outAlpha = srcAlpha + dst.a * (1.0 - srcAlpha); gl_FragColor.rgb = (color.rgb * srcAlpha + dst.rgb * dst.a * (1.0 - srcAlpha)) / outAlpha; gl_FragColor.a = outAlpha; }";

View file

@ -2,11 +2,11 @@ package org.telegram.ui.Components.Paint;
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import org.telegram.ui.Components.Size;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
public class Texture {
@ -52,10 +52,19 @@ public class Texture {
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
for (int i = 0; i < pixels.length; i += 1) {
int argb = pixels[i];
pixels[i] = argb & 0xff00ff00 | ((argb & 0xff) << 16) | ((argb >> 16) & 0xff);
}
GLES20.glTexImage2D(GLES20.GL_TEXTURE_2D, 0, GLES20.GL_RGBA, width, height, 0, GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, IntBuffer.wrap(pixels));
int px = bitmap.getPixel(0, 0);
ByteBuffer buffer = ByteBuffer.allocateDirect(4); //fix for android 9.0
@ -77,7 +86,7 @@ public class Texture {
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T, GLES20.GL_CLAMP_TO_EDGE);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_LINEAR);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER, GLES20.GL_NEAREST);
GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER, GLES20.GL_LINEAR);
int width = (int) size.width;

View file

@ -1135,7 +1135,7 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
}, entityView, Gravity.CENTER, x, y);
}
private FrameLayout buttonForBrush(final int brush, int resource, boolean selected) {
private FrameLayout buttonForBrush(final int brush, int resource, boolean applyColor, boolean selected) {
FrameLayout button = new FrameLayout(getContext());
button.setBackgroundDrawable(Theme.getSelectorDrawable(false));
button.setOnClickListener(v -> {
@ -1148,6 +1148,9 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
ImageView preview = new ImageView(getContext());
preview.setImageResource(resource);
if (applyColor) {
preview.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), PorterDuff.Mode.SRC_IN));
}
button.addView(preview, LayoutHelper.createFrame(165, 44, Gravity.LEFT | Gravity.CENTER_VERTICAL, 46, 0, 8, 0));
if (selected) {
@ -1163,7 +1166,7 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
private void showBrushSettings() {
showPopup(() -> {
View radial = buttonForBrush(0, R.drawable.paint_radial_preview, currentBrush == 0);
View radial = buttonForBrush(0, R.drawable.paint_radial_preview, true, currentBrush == 0);
popupLayout.addView(radial);
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) radial.getLayoutParams();
@ -1171,7 +1174,7 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
layoutParams.height = AndroidUtilities.dp(52);
radial.setLayoutParams(layoutParams);
View elliptical = buttonForBrush(1, R.drawable.paint_elliptical_preview, currentBrush == 1);
View elliptical = buttonForBrush(1, R.drawable.paint_elliptical_preview, true, currentBrush == 1);
popupLayout.addView(elliptical);
layoutParams = (LinearLayout.LayoutParams) elliptical.getLayoutParams();
@ -1179,7 +1182,7 @@ public class PhotoPaintView extends FrameLayout implements EntityView.EntityView
layoutParams.height = AndroidUtilities.dp(52);
elliptical.setLayoutParams(layoutParams);
View neon = buttonForBrush(2, R.drawable.paint_neon_preview, currentBrush == 2);
View neon = buttonForBrush(2, R.drawable.paint_neon_preview, false, currentBrush == 2);
popupLayout.addView(neon);
layoutParams = (LinearLayout.LayoutParams) neon.getLayoutParams();

View file

@ -241,10 +241,6 @@ public class RecyclerAnimationScrollHelper {
if (recyclerView.mChildHelper.getHiddenChildCount() != 0) {
throw new RuntimeException("hidden child count must be 0");
}
if (recyclerView.getCachedChildCount() != 0) {
throw new RuntimeException("cached child count must be 0");
}
}
int n = recyclerView.getChildCount();

View file

@ -2778,7 +2778,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_POINTER_UP:
AndroidUtilities.runOnUIThread(hideActionBarRunnable, 3000);
scheduleActionBarHide();
break;
}
}
@ -3364,7 +3364,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
@Override
public void onHideSubMenu() {
if (videoPlayerControlVisible && isPlaying) {
AndroidUtilities.runOnUIThread(hideActionBarRunnable, 3000);
scheduleActionBarHide();
}
}
});
@ -5117,6 +5117,27 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
return injectingVideoPlayer != null;
}
private void scheduleActionBarHide() {
scheduleActionBarHide(3000);
}
private void scheduleActionBarHide(int delay) {
if (!isAccessibilityEnabled()) {
AndroidUtilities.cancelRunOnUIThread(hideActionBarRunnable);
AndroidUtilities.runOnUIThread(hideActionBarRunnable, delay);
}
}
private boolean isAccessibilityEnabled() {
try {
AccessibilityManager am = (AccessibilityManager) actvityContext.getSystemService(Context.ACCESSIBILITY_SERVICE);
return am.isEnabled();
} catch (Exception e) {
FileLog.e(e);
}
return false;
}
private void updatePlayerState(boolean playWhenReady, int playbackState) {
if (videoPlayer == null) {
return;
@ -5131,7 +5152,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (buffering) {
AndroidUtilities.cancelRunOnUIThread(hideActionBarRunnable);
} else {
AndroidUtilities.runOnUIThread(hideActionBarRunnable, 3000);
scheduleActionBarHide();
}
toggleMiniProgress(buffering, true);
}
@ -5503,7 +5524,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
setVideoPlayerControlVisible(!isCurrentVideo, true);
if (!isCurrentVideo) {
AndroidUtilities.runOnUIThread(hideActionBarRunnable, playerAutoStarted ? 3000 : 1000);
scheduleActionBarHide(playerAutoStarted ? 3000 : 1000);
}
inPreview = preview;
@ -5802,7 +5823,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
stickers = photoPaintView.getMasks();
}
if (bitmap != null) {
TLRPC.PhotoSize size = ImageLoader.scaleAndSaveImage(bitmap, currentEditMode == 3 ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false, 101, 101);
TLRPC.PhotoSize size = ImageLoader.scaleAndSaveImage(bitmap, currentEditMode == 3 ? Bitmap.CompressFormat.PNG : Bitmap.CompressFormat.JPEG, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 87, false, 101, 101);
if (size != null) {
if (entry.thumbPath != null) {
new File(entry.thumbPath).delete();
@ -5837,7 +5858,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
Canvas b = new Canvas(canvasBitmap);
b.drawBitmap(bitmap, null, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), bitmapPaint);
b.drawBitmap(paintBitmap, null, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), bitmapPaint);
size = ImageLoader.scaleAndSaveImage(canvasBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false, 101, 101);
size = ImageLoader.scaleAndSaveImage(canvasBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 87, false, 101, 101);
entry.imagePath = FileLoader.getPathToAttach(size, true).toString();
canvasBitmap.recycle();
paintingOverlay.setEntities(currentMediaEntities, isCurrentVideo, true);
@ -5872,7 +5893,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
Canvas b = new Canvas(canvasBitmap);
b.drawBitmap(bitmap, null, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), bitmapPaint);
b.drawBitmap(paintBitmap, null, new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()), bitmapPaint);
size = ImageLoader.scaleAndSaveImage(canvasBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false, 101, 101);
size = ImageLoader.scaleAndSaveImage(canvasBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 87, false, 101, 101);
if (entry.imagePath != null) {
new File(entry.imagePath).delete();
}
@ -5915,11 +5936,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
new File(entry.fullPaintPath).delete();
}
}
entry.stickers = stickers;
entry.paintPath = currentPaintPath = FileLoader.getPathToAttach(size, true).toString();
paintingOverlay.setEntities(entry.mediaEntities = currentMediaEntities = entities == null || entities.isEmpty() ? null : entities, isCurrentVideo, true);
entry.averageDuration = currentAverageDuration = photoPaintView.getLcm();
if (entry.mediaEntities != null && paintThumbBitmap[0] != null) {
size = ImageLoader.scaleAndSaveImage(paintThumbBitmap[0], Bitmap.CompressFormat.PNG, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false, 101, 101);
size = ImageLoader.scaleAndSaveImage(paintThumbBitmap[0], Bitmap.CompressFormat.PNG, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 87, false, 101, 101);
entry.fullPaintPath = FileLoader.getPathToAttach(size, true).toString();
} else {
entry.fullPaintPath = entry.paintPath;
@ -5942,7 +5964,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (originalBitmap != null) {
Canvas b = new Canvas(originalBitmap);
b.drawBitmap(paintThumbBitmap[0] != null ? paintThumbBitmap[0] : bitmap, null, new Rect(0, 0, originalBitmap.getWidth(), originalBitmap.getHeight()), bitmapPaint);
size = ImageLoader.scaleAndSaveImage(originalBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 80, false, 101, 101);
size = ImageLoader.scaleAndSaveImage(originalBitmap, AndroidUtilities.getPhotoSize(), AndroidUtilities.getPhotoSize(), 87, false, 101, 101);
if (entry.imagePath != null) {
new File(entry.imagePath).delete();
}
@ -5986,7 +6008,6 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
SharedConfig.saveConfig();
entry.stickers = stickers;
if (savedFilterState != null) {
entry.savedFilterState = currentSavedFilterState = savedFilterState;
}
@ -6750,7 +6771,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
updateContainerFlags(show);
if (videoPlayerControlVisible && isPlaying && show) {
AndroidUtilities.runOnUIThread(hideActionBarRunnable, 3000);
scheduleActionBarHide();
} else {
AndroidUtilities.cancelRunOnUIThread(hideActionBarRunnable);
}
@ -6889,7 +6910,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
if (Math.abs(videoPlayerSeekbar.getProgress() - 1.0f) < 0.01f || videoPlayer.getCurrentPosition() == videoPlayer.getDuration()) {
videoPlayer.seekTo(0);
}
AndroidUtilities.runOnUIThread(hideActionBarRunnable, 1000);
scheduleActionBarHide();
}
videoPlayer.play();
}

View file

@ -1630,6 +1630,9 @@ public class ThemePreviewActivity extends BaseFragment implements DownloadContro
saveButtonsContainer.addView(doneButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.RIGHT));
doneButton.setOnClickListener(v -> {
Theme.ThemeInfo previousTheme = Theme.getPreviousTheme();
if (previousTheme == null) {
return;
}
Theme.ThemeAccent previousAccent;
if (previousTheme != null && previousTheme.prevAccentId >= 0) {
previousAccent = previousTheme.themeAccentsMap.get(previousTheme.prevAccentId);