diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index c6cfa51e7..bc1391f81 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -22,7 +22,7 @@ dependencies { implementation 'androidx.exifinterface:exifinterface:1.3.3' implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' implementation 'androidx.multidex:multidex:2.0.1' - implementation "androidx.sharetarget:sharetarget:1.1.0" + implementation "androidx.sharetarget:sharetarget:1.2.0" compileOnly 'org.checkerframework:checker-qual:2.5.2' compileOnly 'org.checkerframework:checker-compat-qual:2.5.0' @@ -79,8 +79,8 @@ android { defaultConfig.versionCode = Integer.parseInt(APP_VERSION_CODE) defaultConfig { - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion 19 + targetSdkVersion 31 versionName "8.9.0" vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/config/debug/AndroidManifest.xml b/TMessagesProj/config/debug/AndroidManifest.xml index 296eba444..92a95c778 100644 --- a/TMessagesProj/config/debug/AndroidManifest.xml +++ b/TMessagesProj/config/debug/AndroidManifest.xml @@ -13,6 +13,7 @@ + @@ -31,7 +32,7 @@ + android:name="org.telegram.messenger.GcmPushListenerService" android:exported="true"> @@ -45,7 +46,8 @@ + android:enabled="false" + android:exported="false"> diff --git a/TMessagesProj/config/debug/AndroidManifest_SDK23.xml b/TMessagesProj/config/debug/AndroidManifest_SDK23.xml index 81dda4002..8ec744152 100644 --- a/TMessagesProj/config/debug/AndroidManifest_SDK23.xml +++ b/TMessagesProj/config/debug/AndroidManifest_SDK23.xml @@ -34,7 +34,7 @@ + android:name="org.telegram.messenger.GcmPushListenerService" android:exported="true"> @@ -48,7 +48,8 @@ + android:enabled="false" + android:exported="false"> diff --git a/TMessagesProj/config/release/AndroidManifest.xml b/TMessagesProj/config/release/AndroidManifest.xml index 188507760..7f7ef4852 100644 --- a/TMessagesProj/config/release/AndroidManifest.xml +++ b/TMessagesProj/config/release/AndroidManifest.xml @@ -13,6 +13,7 @@ + @@ -31,7 +32,7 @@ + android:name="org.telegram.messenger.GcmPushListenerService" android:exported="true"> @@ -45,7 +46,8 @@ + android:enabled="false" + android:exported="false"> diff --git a/TMessagesProj/config/release/AndroidManifest_SDK23.xml b/TMessagesProj/config/release/AndroidManifest_SDK23.xml index dfcdb1322..1acb98b05 100644 --- a/TMessagesProj/config/release/AndroidManifest_SDK23.xml +++ b/TMessagesProj/config/release/AndroidManifest_SDK23.xml @@ -34,7 +34,8 @@ + android:name="org.telegram.messenger.GcmPushListenerService" + android:exported="true"> @@ -48,7 +49,8 @@ + android:enabled="false" + android:exported="false"> diff --git a/TMessagesProj/config/release/AndroidManifest_standalone.xml b/TMessagesProj/config/release/AndroidManifest_standalone.xml index 8849bb3d9..9fb714487 100644 --- a/TMessagesProj/config/release/AndroidManifest_standalone.xml +++ b/TMessagesProj/config/release/AndroidManifest_standalone.xml @@ -114,7 +114,7 @@ + android:name="org.telegram.messenger.GcmPushListenerService" android:exported="true"> @@ -128,7 +128,8 @@ + android:enabled="false" + android:exported="false"> diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml index 4b7995072..cf4d88066 100644 --- a/TMessagesProj/src/main/AndroidManifest.xml +++ b/TMessagesProj/src/main/AndroidManifest.xml @@ -184,7 +184,8 @@ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:hardwareAccelerated="@bool/useHardwareAcceleration" android:launchMode="singleTask" - android:windowSoftInputMode="adjustResize"> + android:windowSoftInputMode="adjustResize" + android:exported="true"> @@ -251,7 +252,8 @@ + android:permission="android.permission.CALL_PHONE" + android:exported="true"> @@ -274,7 +276,8 @@ android:windowSoftInputMode="adjustPan" android:excludeFromRecents="true" android:stateNotNeeded="true" - android:theme="@style/Theme.TMessages.Transparent"> + android:theme="@style/Theme.TMessages.Transparent" + android:exported="true"> @@ -286,7 +289,8 @@ android:name="org.telegram.ui.ExternalActionActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:hardwareAccelerated="@bool/useHardwareAcceleration" - android:windowSoftInputMode="adjustPan"> + android:windowSoftInputMode="adjustPan" + android:exported="true"> @@ -296,7 +300,8 @@ android:name="org.telegram.ui.ChatsWidgetConfigActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:hardwareAccelerated="@bool/useHardwareAcceleration" - android:windowSoftInputMode="adjustPan"> + android:windowSoftInputMode="adjustPan" + android:exported="true"> @@ -305,7 +310,8 @@ android:name="org.telegram.ui.ContactsWidgetConfigActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode" android:hardwareAccelerated="@bool/useHardwareAcceleration" - android:windowSoftInputMode="adjustPan"> + android:windowSoftInputMode="adjustPan" + android:exported="true"> @@ -377,7 +383,7 @@ - + @@ -404,14 +410,15 @@ - - + + - - + + + android:enabled="true" + android:exported="true"/> @@ -419,13 +426,13 @@ - + - + @@ -442,7 +449,7 @@ - + diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java index fe3c053ab..d449fc068 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ApplicationLoader.java @@ -297,7 +297,7 @@ public class ApplicationLoader extends Application { } else { applicationContext.stopService(new Intent(applicationContext, NotificationsService.class)); - PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), 0); + PendingIntent pintent = PendingIntent.getService(applicationContext, 0, new Intent(applicationContext, NotificationsService.class), PendingIntent.FLAG_MUTABLE); AlarmManager alarm = (AlarmManager)applicationContext.getSystemService(Context.ALARM_SERVICE); alarm.cancel(pintent); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 926d02169..252e404dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -24,8 +24,8 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; - public static int BUILD_VERSION = 2917; - public static String BUILD_VERSION_STRING = "9.1.3"; + public static int BUILD_VERSION = 2927; + public static String BUILD_VERSION_STRING = "9.1.4"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java index a9f50cbc8..592bdbf5e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java @@ -110,7 +110,7 @@ public class ChatsWidgetProvider extends AppWidgetProvider { intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); rv.setPendingIntentTemplate(R.id.list_view, contentIntent); appWidgetManager.updateAppWidget(appWidgetId, rv); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetService.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetService.java index 21aaa4340..06b0d3317 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetService.java @@ -23,6 +23,8 @@ import android.widget.RemoteViewsService; import androidx.collection.LongSparseArray; +import com.google.android.exoplayer2.util.Log; + import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.AvatarDrawable; @@ -350,6 +352,8 @@ class ChatsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactory { fillInIntent.putExtras(extras); rv.setOnClickFillInIntent(R.id.shortcut_widget_item, fillInIntent); + Log.d("kek", "kek " + name); + rv.setViewVisibility(R.id.shortcut_widget_item_divider, position == getCount() ? View.GONE : View.VISIBLE); return rv; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java index 2a6c1eb22..d05ca41a3 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java @@ -111,7 +111,7 @@ public class ContactsWidgetProvider extends AppWidgetProvider { intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); rv.setPendingIntentTemplate(R.id.list_view, contentIntent); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java index 41dd23557..ea0cadb1a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java @@ -20,6 +20,8 @@ import android.widget.RemoteViewsService; import androidx.collection.LongSparseArray; +import com.google.android.exoplayer2.util.Log; + import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.AvatarDrawable; @@ -201,6 +203,8 @@ class ContactsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor } extras.putInt("currentAccount", accountInstance.getCurrentAccount()); + Log.d("kek", "kek " + name); + Intent fillInIntent = new Intent(); fillInIntent.putExtras(extras); rv.setOnClickFillInIntent(a == 0 ? R.id.contacts_widget_item1 : R.id.contacts_widget_item2, fillInIntent); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FeedWidgetProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/FeedWidgetProvider.java index 60c37345a..194a96b4d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FeedWidgetProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FeedWidgetProvider.java @@ -42,14 +42,14 @@ public class FeedWidgetProvider extends AppWidgetProvider { intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); intent2.setData(Uri.parse(intent2.toUri(Intent.URI_INTENT_SCHEME))); RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.feed_widget_layout); - rv.setRemoteAdapter(appWidgetId, R.id.list_view, intent2); + rv.setRemoteAdapter(R.id.list_view, intent2); rv.setEmptyView(R.id.list_view, R.id.empty_view); Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); rv.setPendingIntentTemplate(R.id.list_view, contentIntent); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java index b87283fbf..7cf4f94b8 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileLog.java @@ -15,6 +15,7 @@ import com.google.gson.FieldAttributes; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.telegram.SQLite.SQLiteException; import org.telegram.messenger.time.FastDateFormat; import org.telegram.messenger.video.MediaCodecVideoConvertor; import org.telegram.tgnet.TLObject; @@ -308,6 +309,9 @@ public class FileLog { } if (BuildVars.DEBUG_VERSION && needSent(e) && logToAppCenter) { AndroidUtilities.appCenterLog(e); + } + if (BuildVars.DEBUG_VERSION && e instanceof SQLiteException && e.getMessage() != null && e.getMessage().contains("disk image is malformed")) { + } ensureInitied(); e.printStackTrace(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java index 6639c96ee..e1a65d098 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FilePathDatabase.java @@ -140,7 +140,6 @@ public class FilePathDatabase { CountDownLatch syncLatch = new CountDownLatch(1); String[] res = new String[1]; - long time = System.currentTimeMillis(); dispatchQueue.postRunnable(() -> { if (database != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LocationSharingService.java b/TMessagesProj/src/main/java/org/telegram/messenger/LocationSharingService.java index 72a4120d7..aaf5a60dc 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LocationSharingService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LocationSharingService.java @@ -132,7 +132,7 @@ public class LocationSharingService extends Service implements NotificationCente Intent intent2 = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent2.setAction("org.tmessages.openlocations"); intent2.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, 0); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent2, PendingIntent.FLAG_MUTABLE); builder = new NotificationCompat.Builder(ApplicationLoader.applicationContext); builder.setWhen(System.currentTimeMillis()); @@ -142,7 +142,7 @@ public class LocationSharingService extends Service implements NotificationCente builder.setChannelId(NotificationsController.OTHER_NOTIFICATIONS_CHANNEL); builder.setContentTitle(LocaleController.getString("AppName", R.string.AppName)); Intent stopIntent = new Intent(ApplicationLoader.applicationContext, StopLiveLocationReceiver.class); - builder.addAction(0, LocaleController.getString("StopLiveLocation", R.string.StopLiveLocation), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + builder.addAction(0, LocaleController.getString("StopLiveLocation", R.string.StopLiveLocation), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, stopIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } updateNotification(false); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 2f3fb6c76..c90cf95eb 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -52,7 +52,6 @@ import android.provider.OpenableColumns; import android.telephony.PhoneStateListener; import android.telephony.TelephonyManager; import android.text.TextUtils; -import android.util.Log; import android.util.SparseArray; import android.view.HapticFeedbackConstants; import android.view.TextureView; @@ -5041,7 +5040,11 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, FileLog.e(e); } - retriever.release(); + try { + retriever.release(); + } catch (Throwable throwable) { + FileLog.e(throwable); + } return bitrate; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 3607e5585..1e4f23ab4 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -120,6 +120,7 @@ public class MessagesController extends BaseController implements NotificationCe public LongSparseArray> printingStringsTypes = new LongSparseArray<>(); public LongSparseArray>[] sendingTypings = new LongSparseArray[12]; public ConcurrentHashMap onlinePrivacy = new ConcurrentHashMap<>(20, 1.0f, 2); + private LongSparseIntArray pendingUnreadCounter = new LongSparseIntArray(); private int lastPrintingStringCount; private boolean dialogsInTransaction; @@ -1331,6 +1332,7 @@ public class MessagesController extends BaseController implements NotificationCe sendLoadPeersRequest(req3, requests, pinnedDialogs, pinnedRemoteDialogs, users, chats, filtersToSave, filtersToDelete, filtersOrder, filterDialogRemovals, filterUserRemovals, filtersUnreadCounterReset); } + //no TLRPC.TL_messages_getPeerDialogs req4 = null; for (HashMap.Entry entry : dialogsToLoadMap.entrySet()) { if (req4 == null) { @@ -4128,6 +4130,7 @@ public class MessagesController extends BaseController implements NotificationCe if (did == 0 && (dialogs == null || dialogs.isEmpty())) { return; } + //probably TLRPC.TL_messages_getPeerDialogs req = new TLRPC.TL_messages_getPeerDialogs(); if (dialogs != null) { for (int a = 0; a < dialogs.size(); a++) { @@ -6755,6 +6758,7 @@ public class MessagesController extends BaseController implements NotificationCe chatsDict.put(c.id, c); } + //no TLRPC.TL_messages_getPeerDialogs req1 = new TLRPC.TL_messages_getPeerDialogs(); TLRPC.TL_inputDialogPeer peer = new TLRPC.TL_inputDialogPeer(); if (res.peer.user_id != 0) { @@ -7352,6 +7356,7 @@ public class MessagesController extends BaseController implements NotificationCe getConnectionsManager().bindRequestToGuid(reqId, classGuid); } else { if (loadDialog && (load_type == 3 || load_type == 2) && last_message_id == 0) { + //probably-- TLRPC.TL_messages_getPeerDialogs req = new TLRPC.TL_messages_getPeerDialogs(); TLRPC.InputPeer inputPeer = getInputPeer(dialogId); TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); @@ -8118,6 +8123,7 @@ public class MessagesController extends BaseController implements NotificationCe FileLog.d("load unknown dialog " + dialogId); } + //probably-- TLRPC.TL_messages_getPeerDialogs req = new TLRPC.TL_messages_getPeerDialogs(); TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); inputDialogPeer.peer = peer; @@ -9210,6 +9216,7 @@ public class MessagesController extends BaseController implements NotificationCe if (BuildVars.DEBUG_PRIVATE_VERSION) { FileLog.d("can't update dialog " + dialogId + " with new unread " + dialogsToUpdate.valueAt(a)); } + pendingUnreadCounter.put(dialogId, dialogsToUpdate.valueAt(a)); } if (currentDialog != null) { int prevCount = currentDialog.unread_count; @@ -11262,6 +11269,7 @@ public class MessagesController extends BaseController implements NotificationCe gettingUnknownChannels.put(channel.id, true); + //no TLRPC.TL_messages_getPeerDialogs req = new TLRPC.TL_messages_getPeerDialogs(); TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); inputDialogPeer.peer = inputPeer; @@ -13196,8 +13204,8 @@ public class MessagesController extends BaseController implements NotificationCe for (int c = 0, size3 = updates.size(); c < size3; c++) { TLRPC.Update baseUpdate = updates.get(c); - if (BuildVars.LOGS_ENABLED) { - FileLog.d("process update " + baseUpdate); + if (BuildVars.LOGS_ENABLED && baseUpdate != null) { + FileLog.d("process update " + baseUpdate.getClass().getSimpleName()); } if (baseUpdate instanceof TLRPC.TL_updateNewMessage || baseUpdate instanceof TLRPC.TL_updateNewChannelMessage || baseUpdate instanceof TLRPC.TL_updateNewScheduledMessage) { TLRPC.Message message; @@ -15553,6 +15561,7 @@ public class MessagesController extends BaseController implements NotificationCe } if (needReload) { if (topicId == 0) { + //no TLRPC.TL_messages_getPeerDialogs req = new TLRPC.TL_messages_getPeerDialogs(); TLRPC.TL_inputDialogPeer inputDialogPeer = new TLRPC.TL_inputDialogPeer(); inputDialogPeer.peer = getInputPeer(dialogId); @@ -16009,11 +16018,27 @@ public class MessagesController extends BaseController implements NotificationCe if (BuildVars.LOGS_ENABLED) { FileLog.d("not found dialog with id " + dialogId + " dictCount = " + dialogs_dict.size() + " allCount = " + allDialogs.size()); } + boolean filterDialogsChanged = false; dialog = new TLRPC.TL_dialog(); dialog.id = dialogId; int mid = dialog.top_message = lastMessage.getId(); dialog.last_message_date = lastMessage.messageOwner.date; dialog.flags = ChatObject.isChannel(chat) ? 1 : 0; + if (pendingUnreadCounter.get(dialogId, 0) > 0) { + dialog.unread_count = pendingUnreadCounter.get(dialogId); + pendingUnreadCounter.delete(dialogId); + if (!isDialogMuted(dialogId, 0)) { + unreadUnmutedDialogs++; + } + + for (int b = 0; b < selectedDialogFilter.length; b++) { + if (selectedDialogFilter[b] != null && (selectedDialogFilter[b].flags & DIALOG_FILTER_FLAG_EXCLUDE_READ) != 0) { + filterDialogsChanged = true; + break; + } + } + + } dialogs_dict.put(dialogId, dialog); allDialogs.add(dialog); ArrayList arrayList = new ArrayList(); @@ -16032,6 +16057,10 @@ public class MessagesController extends BaseController implements NotificationCe dialogMessage.put(dialogId, arrayList); changed = true; + if (filterDialogsChanged) { + sortDialogs(null); + getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload); + } TLRPC.Dialog dialogFinal = dialog; getMessagesStorage().getDialogFolderId(dialogId, param -> { if (param != -1) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index b75667f8b..3d0c6eb00 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -2630,6 +2630,38 @@ public class MessagesStorage extends BaseController { } } + cursor2.dispose(); + if (!topMessageIds.isEmpty()) { + cursor2 = database.queryFinalized("SELECT mid, data FROM messages_topics WHERE uid = " + dialogId + " AND mid IN (" + TextUtils.join(",", topMessageIds) + ")"); + try { + while (cursor2.next()) { + int messageId = cursor2.intValue(0); + NativeByteBuffer data = cursor2.byteBufferValue(1); + if (data != null) { + TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); + if (message != null) { + message.readAttachPath(data, UserConfig.getInstance(currentAccount).clientUserId); + } + data.reuse(); + + topMessageIds.remove(messageId); + addUsersAndChatsFromMessage(message, usersToLoad, chatsToLoad, null); + + ArrayList topicsList = topicsByTopMessageId.get(messageId); + if (topicsList != null) { + for (int i = 0; i < topicsList.size(); i++) { + topicsList.get(i).topMessage = message; + } + } + } + } + } catch (Exception e) { + FileLog.e(e); + } + } + + loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false); + ArrayList chats = new ArrayList<>(); ArrayList users = new ArrayList<>(); if (!chatsToLoad.isEmpty()) { @@ -2648,35 +2680,6 @@ public class MessagesStorage extends BaseController { } }); - cursor2.dispose(); - if (!topMessageIds.isEmpty()) { - cursor2 = database.queryFinalized("SELECT mid, data FROM messages_topics WHERE uid = " + dialogId + " AND mid IN (" + TextUtils.join(",", topMessageIds) + ")"); - try { - while (cursor2.next()) { - int messageId = cursor2.intValue(0); - NativeByteBuffer data = cursor2.byteBufferValue(1); - if (data != null) { - TLRPC.Message message = TLRPC.Message.TLdeserialize(data, data.readInt32(false), false); - if (message != null) { - message.readAttachPath(data, UserConfig.getInstance(currentAccount).clientUserId); - } - data.reuse(); - - topMessageIds.remove(messageId); - ArrayList topicsList = topicsByTopMessageId.get(messageId); - if (topicsList != null) { - for (int i = 0; i < topicsList.size(); i++) { - topicsList.get(i).topMessage = message; - } - } - } - } - } catch (Exception e) { - FileLog.e(e); - } - } - - loadReplyMessages(replyMessageOwners, dialogReplyMessagesIds, usersToLoad, chatsToLoad, false); loadGroupedMessagesForTopics(dialogId, topics); } @@ -10190,6 +10193,7 @@ public class MessagesStorage extends BaseController { private int malformedCleanupCount = 0; public void checkMalformed(Exception e) { if (e != null && e.getMessage() != null && e.getMessage().contains("malformed") && malformedCleanupCount < 3) { + FileLog.e("detected database malformed error, cleaning up..."); malformedCleanupCount++; cleanup(false); } @@ -10238,6 +10242,7 @@ public class MessagesStorage extends BaseController { } } catch (Exception e) { FileLog.e(e); + checkMalformed(e); } } cursor.dispose(); @@ -10812,23 +10817,44 @@ public class MessagesStorage extends BaseController { cursor = null; database.executeFast(String.format(Locale.US, "UPDATE messages_topics SET read_state = read_state | 1 WHERE uid = %d AND topic_id = %d AND mid <= %d AND read_state IN(0,2) AND out = 0", -chatId, mid, readMaxId)).stepThis().dispose(); + //mark mentions as read + database.executeFast(String.format(Locale.US, "UPDATE messages_topics SET read_state = read_state | 2 WHERE uid = %d AND topic_id = %d AND mid <= %d AND read_state IN(0,1) AND out = 0", -chatId, mid, readMaxId)).stepThis().dispose(); + int unreadMentionsCount = -1; if (unreadCount < 0) { unreadCount = 0; - cursor = database.queryFinalized(String.format(Locale.US, "SELECT count(mid) FROM messages_topics WHERE uid = %d AND topic_id = %d AND mid > %d AND read_state IN(0,2) AND out = 0", -chatId, mid, readMaxId)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT count(mid) FROM messages_topics WHERE uid = %d AND topic_id = %d AND mid > %d AND read_state IN(0,2) AND out = 0", -chatId, mid, readMaxId)); if (cursor.next()) { unreadCount = cursor.intValue(0); } cursor.dispose(); cursor = null; + if (unreadCount == 0) { + unreadMentionsCount = 0; + } else { + cursor = database.queryFinalized(String.format(Locale.US, "SELECT count(mid) FROM messages_topics WHERE uid = %d AND topic_id = %d AND mid > %d AND read_state < 2 AND out = 0", -chatId, mid, readMaxId)); + if (cursor.next()) { + unreadMentionsCount = cursor.intValue(0); + } + cursor.dispose(); + cursor = null; + } + } else if (unreadCount == 0) { + unreadMentionsCount = 0; } + if (updateTopic) { - database.executeFast(String.format(Locale.ENGLISH, "UPDATE topics SET max_read_id = %d, unread_count = %d WHERE did = %d AND topic_id = %d", readMaxId, unreadCount, -chatId, mid)).stepThis().dispose(); + if (unreadMentionsCount >= 0) { + database.executeFast(String.format(Locale.ENGLISH, "UPDATE topics SET max_read_id = %d, unread_count = %d, unread_mentions = %d WHERE did = %d AND topic_id = %d", readMaxId, unreadCount, unreadMentionsCount, -chatId, mid)).stepThis().dispose(); + } else { + database.executeFast(String.format(Locale.ENGLISH, "UPDATE topics SET max_read_id = %d, unread_count = %d WHERE did = %d AND topic_id = %d", readMaxId, unreadCount, -chatId, mid)).stepThis().dispose(); + } int finalUnreadCount = unreadCount; + int finalUnreadMentionsCount = unreadMentionsCount; AndroidUtilities.runOnUIThread(() -> { - getMessagesController().getTopicsController().updateMaxReadId(chatId, mid, readMaxId, finalUnreadCount); + getMessagesController().getTopicsController().updateMaxReadId(chatId, mid, readMaxId, finalUnreadCount, finalUnreadMentionsCount); }); resetForumBadgeIfNeed(-chatId); @@ -15017,6 +15043,7 @@ public class MessagesStorage extends BaseController { encryptedChats.clear(); FileLog.e(e); getMessagesController().processLoadedDialogs(dialogs, encryptedChats, folderId, 0, 100, 1, true, false, true); + checkMalformed(e); } finally { if (cursor != null) { cursor.dispose(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MusicBrowserService.java b/TMessagesProj/src/main/java/org/telegram/messenger/MusicBrowserService.java index abfd1deaf..3ed7fcd43 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MusicBrowserService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MusicBrowserService.java @@ -97,7 +97,7 @@ public class MusicBrowserService extends MediaBrowserService implements Notifica Context context = getApplicationContext(); Intent intent = new Intent(context, LaunchActivity.class); - PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); mediaSession.setSessionActivity(pi); Bundle extras = new Bundle(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java b/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java index 69eec1f11..058e4ed87 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MusicPlayerService.java @@ -172,7 +172,7 @@ public class MusicPlayerService extends Service implements NotificationCenter.No audioManager.registerMediaButtonEventReceiver(remoteComponentName); Intent mediaButtonIntent = new Intent(Intent.ACTION_MEDIA_BUTTON); mediaButtonIntent.setComponent(remoteComponentName); - PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, 0); + PendingIntent mediaPendingIntent = PendingIntent.getBroadcast(this, 0, mediaButtonIntent, PendingIntent.FLAG_MUTABLE); remoteControlClient = new RemoteControlClient(mediaPendingIntent); audioManager.registerRemoteControlClient(remoteControlClient); } @@ -219,7 +219,7 @@ public class MusicPlayerService extends Service implements NotificationCenter.No Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class); intent.setAction("com.tmessages.openplayer"); intent.addCategory(Intent.CATEGORY_LAUNCHER); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, 0); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE); Notification notification; @@ -246,12 +246,12 @@ public class MusicPlayerService extends Service implements NotificationCenter.No if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { boolean isPlaying = !MediaController.getInstance().isMessagePaused(); - PendingIntent pendingPrev = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PREVIOUS).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent pendingPrev = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PREVIOUS).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); //PendingIntent pendingStop = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_CANCEL_CURRENT); - PendingIntent pendingStop = PendingIntent.getService(getApplicationContext(), 0, new Intent(this, getClass()).setAction(getPackageName() + ".STOP_PLAYER"), PendingIntent.FLAG_CANCEL_CURRENT); - PendingIntent pendingPlaypause = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(isPlaying ? NOTIFY_PAUSE : NOTIFY_PLAY).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_CANCEL_CURRENT); - PendingIntent pendingNext = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_CANCEL_CURRENT); - PendingIntent pendingSeek = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_SEEK).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent pendingStop = PendingIntent.getService(getApplicationContext(), 0, new Intent(this, getClass()).setAction(getPackageName() + ".STOP_PLAYER"), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent pendingPlaypause = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(isPlaying ? NOTIFY_PAUSE : NOTIFY_PLAY).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent pendingNext = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent pendingSeek = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_SEEK).setComponent(new ComponentName(this, MusicPlayerReceiver.class)), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); Notification.Builder bldr = new Notification.Builder(this); bldr.setSmallIcon(R.drawable.player) @@ -480,15 +480,15 @@ public class MusicPlayerService extends Service implements NotificationCenter.No } public void setListeners(RemoteViews view) { - PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PREVIOUS), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_previous, pendingIntent); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_close, pendingIntent); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PAUSE), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_pause, pendingIntent); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_next, pendingIntent); - pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PLAY), PendingIntent.FLAG_UPDATE_CURRENT); + pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PLAY), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_play, pendingIntent); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index dfdd72a49..74abe4ee0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -55,6 +55,8 @@ import androidx.core.content.pm.ShortcutInfoCompat; import androidx.core.content.pm.ShortcutManagerCompat; import androidx.core.graphics.drawable.IconCompat; +import com.google.android.exoplayer2.util.Log; + import org.telegram.messenger.support.LongSparseIntArray; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLRPC; @@ -65,6 +67,7 @@ import org.telegram.ui.PopupNotificationActivity; import java.io.File; import java.util.ArrayList; import java.util.Calendar; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -144,7 +147,7 @@ public class NotificationsController extends BaseController { } audioManager = (AudioManager) ApplicationLoader.applicationContext.getSystemService(Context.AUDIO_SERVICE); } - + private static volatile NotificationsController[] Instance = new NotificationsController[UserConfig.MAX_ACCOUNT_COUNT]; private static final Object[] lockObjects = new Object[UserConfig.MAX_ACCOUNT_COUNT]; static { @@ -470,8 +473,13 @@ public class NotificationsController extends BaseController { smartNotificationsDialogs.remove(dialogId); } if (!newCount.equals(currentCount)) { - total_unread_count -= currentCount; - total_unread_count += newCount; + if (getMessagesController().isForum(dialogId)) { + total_unread_count -= currentCount > 0 ? 1 : 0; + total_unread_count += newCount > 0 ? 1 : 0; + } else { + total_unread_count -= currentCount; + total_unread_count += newCount; + } pushDialogs.put(dialogId, newCount); } if (newCount == 0) { @@ -562,8 +570,13 @@ public class NotificationsController extends BaseController { smartNotificationsDialogs.remove(dialogId); } if (!newCount.equals(currentCount)) { - total_unread_count -= currentCount; - total_unread_count += newCount; + if (getMessagesController().isForum(dialogId)) { + total_unread_count -= currentCount > 0 ? 1 : 0; + total_unread_count += newCount > 0 ? 1 : 0; + } else { + total_unread_count -= currentCount; + total_unread_count += newCount; + } pushDialogs.put(dialogId, newCount); } if (newCount == 0) { @@ -967,10 +980,15 @@ public class NotificationsController extends BaseController { } if (canAddValue) { - if (currentCount != null) { - total_unread_count -= currentCount; + if (getMessagesController().isForum(dialog_id)) { + total_unread_count -= currentCount != null && currentCount > 0 ? 1 : 0; + total_unread_count += newCount > 0 ? 1 : 0; + } else { + if (currentCount != null) { + total_unread_count -= currentCount; + } + total_unread_count += newCount; } - total_unread_count += newCount; pushDialogs.put(dialog_id, newCount); } if (old_unread_count != total_unread_count) { @@ -1051,7 +1069,11 @@ public class NotificationsController extends BaseController { } if (canAddValue || newCount == 0) { if (currentCount != null) { - total_unread_count -= currentCount; + if (getMessagesController().isForum(dialogId)) { + total_unread_count -= currentCount > 0 ? 1 : 0; + } else { + total_unread_count -= currentCount; + } } } if (newCount == 0) { @@ -1083,7 +1105,11 @@ public class NotificationsController extends BaseController { } } } else if (canAddValue) { - total_unread_count += newCount; + if (getMessagesController().isForum(dialogId)) { + total_unread_count += newCount > 0 ? 1 : 0; + } else { + total_unread_count += newCount; + } pushDialogs.put(dialogId, newCount); } } @@ -1209,7 +1235,11 @@ public class NotificationsController extends BaseController { } int count = dialogs.valueAt(a); pushDialogs.put(dialog_id, count); - total_unread_count += count; + if (getMessagesController().isForum(dialog_id)) { + total_unread_count += count > 0 ? 1 : 0; + } else { + total_unread_count += count; + } } if (push != null) { @@ -1270,10 +1300,17 @@ public class NotificationsController extends BaseController { Integer currentCount = pushDialogs.get(dialogId); int newCount = currentCount != null ? currentCount + 1 : 1; - if (currentCount != null) { - total_unread_count -= currentCount; + if (getMessagesController().isForum(dialogId)) { + if (currentCount != null) { + total_unread_count -= currentCount > 0 ? 1 : 0; + } + total_unread_count += newCount > 0 ? 1 : 0; + } else { + if (currentCount != null) { + total_unread_count -= currentCount; + } + total_unread_count += newCount; } - total_unread_count += newCount; pushDialogs.put(dialogId, newCount); } } @@ -1313,8 +1350,8 @@ public class NotificationsController extends BaseController { continue; } } - if (dialog != null && dialog.unread_count != 0) { - count += dialog.unread_count; + if (dialog != null) { + count += MessagesController.getInstance(a).getDialogUnreadCount(dialog); } } } catch (Exception e) { @@ -1334,7 +1371,7 @@ public class NotificationsController extends BaseController { continue; } } - if (dialog.unread_count != 0) { + if (MessagesController.getInstance(a).getDialogUnreadCount(dialog) != 0) { count++; } } @@ -2608,7 +2645,7 @@ public class NotificationsController extends BaseController { try { Intent intent = new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class); intent.putExtra("currentAccount", currentAccount); - PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, intent, 0); + PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE); SharedPreferences preferences = getAccountInstance().getNotificationsSettings(); int minutes = preferences.getInt("repeat_messages", 60); if (minutes > 0 && personalCount > 0) { @@ -2990,7 +3027,7 @@ public class NotificationsController extends BaseController { } NotificationCompat.BubbleMetadata.Builder bubbleBuilder = new NotificationCompat.BubbleMetadata.Builder( - PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT), + PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT), icon); bubbleBuilder.setSuppressNotification(openedDialogId == did); bubbleBuilder.setAutoExpandBubble(false); @@ -3737,7 +3774,7 @@ public class NotificationsController extends BaseController { } } intent.putExtra("currentAccount", currentAccount); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ONE_SHOT); mBuilder.setContentTitle(name) .setSmallIcon(R.drawable.notification) @@ -3761,7 +3798,7 @@ public class NotificationsController extends BaseController { Intent dismissIntent = new Intent(ApplicationLoader.applicationContext, NotificationDismissReceiver.class); dismissIntent.putExtra("messageDate", lastMessageObject.messageOwner.date); dismissIntent.putExtra("currentAccount", currentAccount); - mBuilder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + mBuilder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 1, dismissIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); if (photoPath != null) { BitmapDrawable img = ImageLoader.getInstance().getImageFromMemory(photoPath, null, "50_50"); @@ -3885,7 +3922,7 @@ public class NotificationsController extends BaseController { callbackIntent.putExtra("data", button.data); } callbackIntent.putExtra("mid", lastMessageObject.getId()); - mBuilder.addAction(0, button.text, PendingIntent.getBroadcast(ApplicationLoader.applicationContext, lastButtonId++, callbackIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + mBuilder.addAction(0, button.text, PendingIntent.getBroadcast(ApplicationLoader.applicationContext, lastButtonId++, callbackIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); hasCallback = true; } } @@ -3897,9 +3934,9 @@ public class NotificationsController extends BaseController { Intent replyIntent = new Intent(ApplicationLoader.applicationContext, PopupReplyReceiver.class); replyIntent.putExtra("currentAccount", currentAccount); if (Build.VERSION.SDK_INT <= 19) { - mBuilder.addAction(R.drawable.ic_ab_reply2, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + mBuilder.addAction(R.drawable.ic_ab_reply2, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } else { - mBuilder.addAction(R.drawable.ic_ab_reply, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + mBuilder.addAction(R.drawable.ic_ab_reply, LocaleController.getString("Reply", R.string.Reply), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 2, replyIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } } showExtraNotifications(mBuilder, detailText, dialog_id, topicId, chatName, vibrationPattern, ledColor, sound, configImportance, isDefault, isInApp, notifyDisabled, chatType); @@ -4202,7 +4239,7 @@ public class NotificationsController extends BaseController { replyIntent.putExtra("max_id", maxId); replyIntent.putExtra("topic_id", topicId); replyIntent.putExtra("currentAccount", currentAccount); - PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, replyIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); RemoteInput remoteInputWear = new RemoteInput.Builder(EXTRA_VOICE_REPLY).setLabel(LocaleController.getString("Reply", R.string.Reply)).build(); String replyToString; if (DialogObject.isChatDialog(dialogId)) { @@ -4443,7 +4480,7 @@ public class NotificationsController extends BaseController { intent.putExtra("topicId", topicId); } intent.putExtra("currentAccount", currentAccount); - PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_ONE_SHOT); + PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ONE_SHOT); NotificationCompat.WearableExtender wearableExtender = new NotificationCompat.WearableExtender(); if (wearReplyAction != null) { @@ -4455,7 +4492,7 @@ public class NotificationsController extends BaseController { msgHeardIntent.putExtra("dialog_id", dialogId); msgHeardIntent.putExtra("max_id", maxId); msgHeardIntent.putExtra("currentAccount", currentAccount); - PendingIntent readPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, msgHeardIntent, PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent readPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, msgHeardIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Action readAction = new NotificationCompat.Action.Builder(R.drawable.msg_markread, LocaleController.getString("MarkAsRead", R.string.MarkAsRead), readPendingIntent) .setSemanticAction(NotificationCompat.Action.SEMANTIC_ACTION_MARK_AS_READ) .setShowsUserInterface(false) @@ -4504,7 +4541,7 @@ public class NotificationsController extends BaseController { dismissIntent.putExtra("messageDate", maxDate); dismissIntent.putExtra("dialogId", dialogId); dismissIntent.putExtra("currentAccount", currentAccount); - builder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + builder.setDeleteIntent(PendingIntent.getBroadcast(ApplicationLoader.applicationContext, internalId, dismissIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); if (useSummaryNotification) { builder.setGroup(notificationGroup); @@ -4541,7 +4578,7 @@ public class NotificationsController extends BaseController { callbackIntent.putExtra("data", button.data); } callbackIntent.putExtra("mid", rowsMid); - builder.addAction(0, button.text, PendingIntent.getBroadcast(ApplicationLoader.applicationContext, lastButtonId++, callbackIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + builder.addAction(0, button.text, PendingIntent.getBroadcast(ApplicationLoader.applicationContext, lastButtonId++, callbackIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 28ff12fe6..ca6158704 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -3612,7 +3612,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe newMsg.via_bot_name = ""; } } else { - newMsg.via_bot_id = Utilities.parseInt(params.get("bot")); + newMsg.via_bot_id = Utilities.parseLong(params.get("bot")); } newMsg.flags |= TLRPC.MESSAGE_FLAG_HAS_BOT_ID; } @@ -8037,7 +8037,7 @@ public class SendMessagesHelper extends BaseController implements NotificationCe } finally { try { retriever.release(); - } catch (RuntimeException ex) { + } catch (Throwable ex) { // Ignore failures while cleaning up. } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/TopicsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/TopicsController.java index ae4ac210d..635d80159 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/TopicsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/TopicsController.java @@ -70,6 +70,8 @@ public class TopicsController extends BaseController { if (BuildVars.DEBUG_PRIVATE_VERSION) { FileLog.d("load topics " + chatId + " fromCache=" + fromCache + " loadType=" + loadType); } + topicsIsLoading.put(chatId, 1); + if (fromCache) { getMessagesStorage().loadTopics(-chatId, topics -> { AndroidUtilities.runOnUIThread(() -> { @@ -88,7 +90,6 @@ public class TopicsController extends BaseController { return; } - topicsIsLoading.put(chatId, 1); TLRPC.TL_channels_getForumTopics getForumTopics = new TLRPC.TL_channels_getForumTopics(); getForumTopics.channel = getMessagesController().getInputChannel(chatId); if (loadType == LOAD_TYPE_PRELOAD) { @@ -113,6 +114,7 @@ public class TopicsController extends BaseController { messagesMap.put(topics.messages.get(i).id, topics.messages.get(i)); } AndroidUtilities.runOnUIThread(() -> { + getMessagesStorage().putUsersAndChats(((TLRPC.TL_messages_forumTopics) response).users, ((TLRPC.TL_messages_forumTopics) response).chats, true, false); getMessagesController().putUsers(((TLRPC.TL_messages_forumTopics) response).users, false); getMessagesController().putChats(((TLRPC.TL_messages_forumTopics) response).chats, false); @@ -172,20 +174,19 @@ public class TopicsController extends BaseController { topicsToReload = new ArrayList<>(); } topicsToReload.add(newTopic); - } else { - if (newTopic.topicStartMessage == null) { - newTopic.topicStartMessage = new TLRPC.TL_message(); - newTopic.topicStartMessage.message = ""; - newTopic.topicStartMessage.id = newTopic.id; - newTopic.topicStartMessage.peer_id = getMessagesController().getPeer(-chatId); - newTopic.topicStartMessage.action = new TLRPC.TL_messageActionTopicCreate(); - newTopic.topicStartMessage.action.title = newTopic.title; - } - topics.add(newTopic); - topicsMap.put(newTopic.id, newTopic); - topicsByTopMsgId.put(messageHash(newTopic.top_message, chatId), newTopic); - changed = true; } + if (newTopic.topicStartMessage == null) { + newTopic.topicStartMessage = new TLRPC.TL_message(); + newTopic.topicStartMessage.message = ""; + newTopic.topicStartMessage.id = newTopic.id; + newTopic.topicStartMessage.peer_id = getMessagesController().getPeer(-chatId); + newTopic.topicStartMessage.action = new TLRPC.TL_messageActionTopicCreate(); + newTopic.topicStartMessage.action.title = newTopic.title; + } + topics.add(newTopic); + topicsMap.put(newTopic.id, newTopic); + topicsByTopMsgId.put(messageHash(newTopic.top_message, chatId), newTopic); + changed = true; } } } @@ -202,9 +203,7 @@ public class TopicsController extends BaseController { } } - if (changed) { - sortTopics(chatId); - } + if (topicsToReload != null && loadType != LOAD_TYPE_LOAD_UNKNOWN) { reloadTopics(chatId, topicsToReload); @@ -213,6 +212,10 @@ public class TopicsController extends BaseController { getUserConfig().getPreferences().edit().putBoolean("topics_end_reached_" + chatId, true).apply(); } + if (changed) { + sortTopics(chatId); + } + getNotificationCenter().postNotificationName(NotificationCenter.topicsDidLoaded, chatId, true); if ((loadType == LOAD_TYPE_PRELOAD || (loadType == LOAD_TYPE_PRELOAD && !fromCache)) && fromCache && topicsByChatId.get(chatId).isEmpty()) { @@ -367,11 +370,14 @@ public class TopicsController extends BaseController { })); } - public void updateMaxReadId(long chatId, int topicId, int readMaxId, int unreadCount) { + public void updateMaxReadId(long chatId, int topicId, int readMaxId, int unreadCount, int mentionsUnread) { TLRPC.TL_forumTopic topic = findTopic(chatId, topicId); if (topic != null) { topic.read_inbox_max_id = readMaxId; topic.unread_count = unreadCount; + if (mentionsUnread >= 0) { + topic.unread_mentions_count = mentionsUnread; + } sortTopics(chatId); } } @@ -669,14 +675,6 @@ public class TopicsController extends BaseController { } } - public TLRPC.Message getLastMessage(long id) { - ArrayList topics = topicsByChatId.get(id); - if (!topics.isEmpty()) { - return topics.get(0).topMessage; - } - return null; - } - LongSparseArray offsets = new LongSparseArray<>(); public TopicsLoadOffset getLoadOffset(long chatId) { @@ -867,7 +865,7 @@ public class TopicsController extends BaseController { if (topic != null) { topic.read_outbox_max_id = Math.max(topic.read_outbox_max_id, value); updatedChats.add(-topicKey.dialogId); - if (topic.read_outbox_max_id >= topic.topMessage.id) { + if (topic.topMessage != null && topic.read_outbox_max_id >= topic.topMessage.id) { topic.topMessage.unread = false; } } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java index a7a2ae7a3..cc58fc6ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/browser/Browser.java @@ -178,7 +178,7 @@ public class Browser { if (equals) { return url.equals("telegra.ph") || url.equals("te.legra.ph") || url.equals("graph.org"); } - return url.matches("^(https" + (forceHttps ? "" : "?") + "://)?(te\\.?legra\\.ph|graph\\.org).*"); // telegra.ph, te.legra.ph, graph.org + return url.matches("^(https" + (forceHttps ? "" : "?") + "://)?(te\\.?legra\\.ph|graph\\.org)(/.*|$)"); // telegra.ph, te.legra.ph, graph.org } public static String extractUsername(String link) { @@ -207,9 +207,9 @@ public class Browser { public static boolean urlMustNotHaveConfirmation(String url) { return ( isTelegraphUrl(url, false, true) || - url.matches("^(https://)?t\\.me/iv\\??.*") || // t.me/iv? - url.matches("^(https://)?telegram\\.org/(blog|tour)/?.*") || // telegram.org/blog, telegram.org/tour - url.matches("^(https://)?fragment\\.com/?.*") // fragment.com + url.matches("^(https://)?t\\.me/iv\\??(/.*|$)") || // t.me/iv? + url.matches("^(https://)?telegram\\.org/(blog|tour)(/.*|$)") || // telegram.org/blog, telegram.org/tour + url.matches("^(https://)?fragment\\.com(/.*|$)") // fragment.com ); } @@ -346,14 +346,14 @@ public class Browser { Intent share = new Intent(ApplicationLoader.applicationContext, ShareBroadcastReceiver.class); share.setAction(Intent.ACTION_SEND); - PendingIntent copy = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, CustomTabsCopyReceiver.class), PendingIntent.FLAG_UPDATE_CURRENT); + PendingIntent copy = PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, CustomTabsCopyReceiver.class), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT); CustomTabsIntent.Builder builder = new CustomTabsIntent.Builder(getSession()); builder.addMenuItem(LocaleController.getString("CopyLink", R.string.CopyLink), copy); builder.setToolbarColor(Theme.getColor(Theme.key_actionBarBrowser)); builder.setShowTitle(true); - builder.setActionButton(BitmapFactory.decodeResource(context.getResources(), R.drawable.msg_filled_shareout), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, share, 0), true); + builder.setActionButton(BitmapFactory.decodeResource(context.getResources(), R.drawable.msg_filled_shareout), LocaleController.getString("ShareFile", R.string.ShareFile), PendingIntent.getBroadcast(ApplicationLoader.applicationContext, 0, share, PendingIntent.FLAG_MUTABLE ), true); CustomTabsIntent intent = builder.build(); intent.setUseNewTask(); intent.launchUrl(context, uri); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/utils/BitmapsCache.java b/TMessagesProj/src/main/java/org/telegram/messenger/utils/BitmapsCache.java index 1ae05ed4b..3aafb812e 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/utils/BitmapsCache.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/utils/BitmapsCache.java @@ -9,6 +9,7 @@ import org.telegram.messenger.BuildVars; import org.telegram.messenger.DispatchQueuePoolBackground; import org.telegram.messenger.FileLoader; import org.telegram.messenger.FileLog; +import org.telegram.messenger.SharedConfig; import org.telegram.messenger.Utilities; import org.telegram.ui.Components.RLottieDrawable; @@ -47,12 +48,12 @@ public class BitmapsCache { static volatile boolean cleanupScheduled; byte[] bufferTmp; - private final static int N = Utilities.clamp(Runtime.getRuntime().availableProcessors(), 8, 1); + private final static int N = Utilities.clamp(Runtime.getRuntime().availableProcessors() - 2, 8, 1); private static ThreadPoolExecutor bitmapCompressExecutor; private final Object mutex = new Object(); private int frameIndex; boolean error; - boolean fileExist; + volatile boolean fileExist; int compressQuality; final File file; @@ -89,36 +90,47 @@ public class BitmapsCache { File fileTmo = new File(FileLoader.checkDirectory(FileLoader.MEDIA_DIR_CACHE), "acache"); file = new File(fileTmo, fileName + "_" + w + "_" + h + (noLimit ? "_nolimit" : " ") + ".pcache2"); useSharedBuffers = w < AndroidUtilities.dp(60) && h < AndroidUtilities.dp(60); - fileExist = file.exists(); - if (fileExist) { - RandomAccessFile randomAccessFile = null; - try { - randomAccessFile = new RandomAccessFile(file, "r"); - cacheCreated = randomAccessFile.readBoolean(); - if (cacheCreated && frameOffsets.isEmpty()) { - randomAccessFile.seek(randomAccessFile.readInt()); - int count = randomAccessFile.readInt(); - fillFrames(randomAccessFile, count); - if (count == 0) { - file.delete(); - cacheCreated = false; - fileExist = false; - } - } - } catch (Throwable e) { - e.printStackTrace(); - file.delete(); - fileExist = false; - } finally { + // check cache created in file load queue only for high devices + if (SharedConfig.getDevicePerformanceClass() >= SharedConfig.PERFORMANCE_CLASS_HIGH) { + fileExist = file.exists(); + if (fileExist) { + RandomAccessFile randomAccessFile = null; try { - if (randomAccessFile != null) { - randomAccessFile.close(); + randomAccessFile = new RandomAccessFile(file, "r"); + cacheCreated = randomAccessFile.readBoolean(); + if (cacheCreated && frameOffsets.isEmpty()) { + randomAccessFile.seek(randomAccessFile.readInt()); + int count = randomAccessFile.readInt(); + if (count > 10_000) { + count = 0; + } + fillFrames(randomAccessFile, count); + if (frameOffsets.size() == 0) { + cacheCreated = false; + fileExist = false; + file.delete(); + } else { + cachedFile = randomAccessFile; + } } - } catch (IOException e) { + } catch (Throwable e) { e.printStackTrace(); + file.delete(); + fileExist = false; + } finally { + try { + if (cachedFile != randomAccessFile && randomAccessFile != null) { + randomAccessFile.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } } } + } else { + fileExist = false; + cacheCreated = false; } } @@ -152,25 +164,30 @@ public class BitmapsCache { public void createCache() { try { - long time = System.currentTimeMillis(); if (file.exists()) { RandomAccessFile randomAccessFile = null; try { randomAccessFile = new RandomAccessFile(file, "r"); cacheCreated = randomAccessFile.readBoolean(); - int framesCount = randomAccessFile.readInt(); - if (framesCount == 0) { - cacheCreated = false; - } if (cacheCreated) { frameOffsets.clear(); randomAccessFile.seek(randomAccessFile.readInt()); int count = randomAccessFile.readInt(); - fillFrames(randomAccessFile, count); - randomAccessFile.close(); - fileExist = true; - return; - } else { + if (count > 10_000) { + count = 0; + } + if (count > 0) { + fillFrames(randomAccessFile, count); + randomAccessFile.seek(0); + cachedFile = randomAccessFile; + fileExist = true; + return; + } else { + fileExist = false; + cacheCreated = false; + } + } + if (!cacheCreated) { file.delete(); } } catch (Throwable e) { @@ -180,7 +197,7 @@ public class BitmapsCache { } } finally { - if (randomAccessFile != null) { + if (cachedFile != randomAccessFile && randomAccessFile != null) { try { randomAccessFile.close(); } catch (Throwable e2) { @@ -207,9 +224,6 @@ public class BitmapsCache { finalRandomAccessFile.writeInt(0); int index = 0; - long bitmapFrameTime = 0; - long compressTime = 0; - long writeFileTime = 0; int framePosition = 0; AtomicBoolean closed = new AtomicBoolean(false); @@ -250,11 +264,9 @@ public class BitmapsCache { return; } - long time2 = System.currentTimeMillis(); if (source.getNextFrame(bitmap[index]) != 1) { break; } - bitmapFrameTime += System.currentTimeMillis() - time2; countDownLatch[index] = new CountDownLatch(1); @@ -332,12 +344,10 @@ public class BitmapsCache { randomAccessFile.close(); this.frameOffsets.clear(); -// this.frameOffsets.addAll(frameOffsets); + this.frameOffsets.addAll(frameOffsets); + cachedFile = new RandomAccessFile(file, "r"); + cacheCreated = true; fileExist = true; - -// if (BuildVars.DEBUG_VERSION) { -// FileLog.d("generate cache for time = " + (System.currentTimeMillis() - time) + " drawFrameTime = " + bitmapFrameTime + " comressQuality = " + compressQuality + " fileSize = " + AndroidUtilities.formatFileSize(file.length()) + " " + fileName); -// } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { @@ -348,6 +358,9 @@ public class BitmapsCache { } private void fillFrames(RandomAccessFile randomAccessFile, int count) throws Throwable { + if (count == 0) { + return; + } byte[] bytes = new byte[4 * 2 * count]; randomAccessFile.read(bytes); ByteBuffer byteBuffer = ByteBuffer.wrap(bytes); @@ -385,6 +398,7 @@ public class BitmapsCache { synchronized (mutex) { randomAccessFile = new RandomAccessFile(file, "r"); cacheCreated = randomAccessFile.readBoolean(); + randomAccessFile.seek(randomAccessFile.readInt()); framesCount = randomAccessFile.readInt(); if (framesCount <= 0) { cacheCreated = false; @@ -436,6 +450,9 @@ public class BitmapsCache { } else { randomAccessFile = cachedFile; } + if (frameOffsets.size() == 0) { + return FRAME_RESULT_NO_FRAME; + } index = Utilities.clamp(index, frameOffsets.size() - 1, 0); selectedFrame = frameOffsets.get(index); randomAccessFile.seek(selectedFrame.frameOffset); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java index 9e1415902..92601ebd9 100755 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/VoIPService.java @@ -79,7 +79,6 @@ import android.widget.RemoteViews; import android.widget.Toast; import androidx.annotation.Nullable; -import androidx.core.app.ActivityCompat; import org.json.JSONObject; import org.telegram.messenger.AccountInstance; @@ -1562,7 +1561,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa .putExtra("call_access_hash", privateCall.access_hash) .putExtra("call_video", privateCall.video) .putExtra("account", currentAccount) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP), 0).send(); + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_MUTABLE).send(); } catch (Exception x) { if (BuildVars.LOGS_ENABLED) { FileLog.e("Error starting incall activity", x); @@ -2858,7 +2857,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa } Notification.Builder builder = new Notification.Builder(this) .setContentText(name) - .setContentIntent(PendingIntent.getActivity(this, 50, intent, 0)); + .setContentIntent(PendingIntent.getActivity(this, 50, intent, PendingIntent.FLAG_MUTABLE)); if (groupCall != null) { builder.setContentTitle(ChatObject.isChannelOrGiga(chat) ? LocaleController.getString("VoipLiveStream", R.string.VoipLiveStream) : LocaleController.getString("VoipVoiceChat", R.string.VoipVoiceChat)); builder.setSmallIcon(isMicMute() ? R.drawable.voicechat_muted : R.drawable.voicechat_active); @@ -2870,9 +2869,9 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa Intent endIntent = new Intent(this, VoIPActionsReceiver.class); endIntent.setAction(getPackageName() + ".END_CALL"); if (groupCall != null) { - builder.addAction(R.drawable.ic_call_end_white_24dp, ChatObject.isChannelOrGiga(chat) ? LocaleController.getString("VoipChannelLeaveAlertTitle", R.string.VoipChannelLeaveAlertTitle) : LocaleController.getString("VoipGroupLeaveAlertTitle", R.string.VoipGroupLeaveAlertTitle), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + builder.addAction(R.drawable.ic_call_end_white_24dp, ChatObject.isChannelOrGiga(chat) ? LocaleController.getString("VoipChannelLeaveAlertTitle", R.string.VoipChannelLeaveAlertTitle) : LocaleController.getString("VoipGroupLeaveAlertTitle", R.string.VoipGroupLeaveAlertTitle), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } else { - builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_UPDATE_CURRENT)); + builder.addAction(R.drawable.ic_call_end_white_24dp, LocaleController.getString("VoipEndCall", R.string.VoipEndCall), PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_UPDATE_CURRENT)); } builder.setPriority(Notification.PRIORITY_MAX); } @@ -3313,7 +3312,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa FileLog.d("Starting incall activity for incoming call"); } try { - PendingIntent.getActivity(VoIPService.this, 12345, new Intent(VoIPService.this, LaunchActivity.class).setAction("voip"), 0).send(); + PendingIntent.getActivity(VoIPService.this, 12345, new Intent(VoIPService.this, LaunchActivity.class).setAction("voip"), PendingIntent.FLAG_MUTABLE).send(); } catch (Exception x) { if (BuildVars.LOGS_ENABLED) { FileLog.e("Error starting incall activity", x); @@ -3914,7 +3913,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa .setContentText(name) .setSmallIcon(R.drawable.notification) .setSubText(subText) - .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)); + .setContentIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE)); Uri soundProviderUri = Uri.parse("content://" + ApplicationLoader.getApplicationId() + ".call_sound_provider/start_ringing"); if (Build.VERSION.SDK_INT >= 26) { SharedPreferences nprefs = MessagesController.getGlobalNotificationsSettings(); @@ -3969,7 +3968,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa endTitle = new SpannableString(endTitle); ((SpannableString) endTitle).setSpan(new ForegroundColorSpan(0xFFF44336), 0, endTitle.length(), 0); } - PendingIntent endPendingIntent = PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent endPendingIntent = PendingIntent.getBroadcast(this, 0, endIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_call_end_white_24dp, endTitle, endPendingIntent); Intent answerIntent = new Intent(this, VoIPActionsReceiver.class); answerIntent.setAction(getPackageName() + ".ANSWER_CALL"); @@ -3979,7 +3978,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa answerTitle = new SpannableString(answerTitle); ((SpannableString) answerTitle).setSpan(new ForegroundColorSpan(0xFF00AA00), 0, answerTitle.length(), 0); } - PendingIntent answerPendingIntent = PendingIntent.getBroadcast(this, 0, answerIntent, PendingIntent.FLAG_CANCEL_CURRENT); + PendingIntent answerPendingIntent = PendingIntent.getBroadcast(this, 0, answerIntent, PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_CANCEL_CURRENT); builder.addAction(R.drawable.ic_call, answerTitle, answerPendingIntent); builder.setPriority(Notification.PRIORITY_MAX); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { @@ -3989,7 +3988,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa builder.setColor(0xff2ca5e0); builder.setVibrate(new long[0]); builder.setCategory(Notification.CATEGORY_CALL); - builder.setFullScreenIntent(PendingIntent.getActivity(this, 0, intent, 0), true); + builder.setFullScreenIntent(PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_MUTABLE), true); if (userOrChat instanceof TLRPC.User) { TLRPC.User user = (TLRPC.User) userOrChat; if (!TextUtils.isEmpty(user.phone)) { @@ -4269,7 +4268,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Build.VERSION.SDK_INT < Build.VERSION_CODES.R && (checkSelfPermission(Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED || privateCall.video && checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED)) { try { //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT); - PendingIntent.getActivity(VoIPService.this, 0, new Intent(VoIPService.this, VoIPPermissionActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_ONE_SHOT).send(); + PendingIntent.getActivity(VoIPService.this, 0, new Intent(VoIPService.this, VoIPPermissionActivity.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), PendingIntent.FLAG_MUTABLE | PendingIntent.FLAG_ONE_SHOT).send(); } catch (Exception x) { if (BuildVars.LOGS_ENABLED) { FileLog.e("Error starting permission activity", x); @@ -4279,7 +4278,7 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa } acceptIncomingCall(); try { - PendingIntent.getActivity(VoIPService.this, 0, new Intent(VoIPService.this, getUIActivityClass()).setAction("voip"), 0).send(); + PendingIntent.getActivity(VoIPService.this, 0, new Intent(VoIPService.this, getUIActivityClass()).setAction("voip"), PendingIntent.FLAG_MUTABLE).send(); } catch (Exception x) { if (BuildVars.LOGS_ENABLED) { FileLog.e("Error starting incall activity", x); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index ebdff451a..fc443f7c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -69,6 +69,7 @@ public class ActionBar extends FrameLayout { } } + private INavigationLayout.BackButtonState backButtonState; private ImageView backButtonImageView; private Drawable backButtonDrawable; private SimpleTextView[] titleTextView = new SimpleTextView[2]; @@ -157,6 +158,10 @@ public class ActionBar extends FrameLayout { }); } + public INavigationLayout.BackButtonState getBackButtonState() { + return backButtonState; + } + private void createBackButtonImage() { if (backButtonImageView != null) { return; @@ -247,6 +252,10 @@ public class ActionBar extends FrameLayout { @Override protected boolean drawChild(Canvas canvas, View child, long drawingTime) { + if (parentFragment != null && parentFragment.getParentLayout().isActionBarInCrossfade()) { + return false; + } + boolean clip = shouldClipChild(child); if (clip) { canvas.save(); @@ -309,6 +318,9 @@ public class ActionBar extends FrameLayout { } backButtonImageView.setVisibility(resource == 0 ? GONE : VISIBLE); backButtonImageView.setImageResource(resource); + if (resource == R.drawable.ic_ab_back) { + backButtonState = INavigationLayout.BackButtonState.BACK; + } } private void createSubtitleTextView() { @@ -592,6 +604,45 @@ public class ActionBar extends FrameLayout { return actionMode; } + public void onDrawCrossfadeBackground(Canvas canvas) { + if (blurredBackground && actionBarColor != Color.TRANSPARENT) { + rectTmp.set(0, 0, getMeasuredWidth(), getMeasuredHeight()); + blurScrimPaint.setColor(actionBarColor); + contentView.drawBlurRect(canvas, getY(), rectTmp, blurScrimPaint, true); + } else { + Drawable drawable = getBackground(); + if (drawable != null) { + drawable.setBounds(0, 0, getWidth(), getHeight()); + drawable.draw(canvas); + } + } + } + + public void onDrawCrossfadeContent(Canvas canvas, boolean front, boolean hideBackDrawable, float progress) { + for (int i = 0; i < getChildCount(); i++) { + View ch = getChildAt(i); + if ((!hideBackDrawable || ch != backButtonImageView) && ch.getVisibility() == View.VISIBLE && ch instanceof ActionBarMenu) { + canvas.save(); + canvas.translate(ch.getX(), ch.getY()); + ch.draw(canvas); + canvas.restore(); + } + } + + canvas.save(); + canvas.translate(front ? getWidth() * progress * 0.5f : -getWidth() * 0.4f * (1f - progress), 0); + for (int i = 0; i < getChildCount(); i++) { + View ch = getChildAt(i); + if ((!hideBackDrawable || ch != backButtonImageView) && ch.getVisibility() == View.VISIBLE && !(ch instanceof ActionBarMenu)) { + canvas.save(); + canvas.translate(ch.getX(), ch.getY()); + ch.draw(canvas); + canvas.restore(); + } + } + canvas.restore(); + } + public void showActionMode() { showActionMode(true, null, null, null, null, null, 0); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index 94c88272d..254fb21c5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -87,6 +87,8 @@ public class ActionBarMenuItem extends FrameLayout { } public static class ActionBarMenuItemSearchListener { + public void onPreToggleSearch() {} + public void onSearchExpand() { } @@ -144,6 +146,8 @@ public class ActionBarMenuItem extends FrameLayout { private LinearLayout searchFilterLayout; private ArrayList searchFilterViews = new ArrayList<>(); private TextView searchFieldCaption; + private CharSequence searchFieldHint; + private CharSequence searchFieldText; private ImageView clearButton; private AnimatorSet clearButtonAnimator; private View searchAdditionalButton; @@ -151,6 +155,7 @@ public class ActionBarMenuItem extends FrameLayout { protected TextView textView; private FrameLayout searchContainer; private boolean isSearchField; + private boolean wrapSearchInScrollView; protected ActionBarMenuItemSearchListener listener; private Rect rect; private int[] location; @@ -756,6 +761,7 @@ public class ActionBarMenuItem extends FrameLayout { } public void openSearch(boolean openKeyboard) { + checkCreateSearchField(); if (searchContainer == null || searchContainer.getVisibility() == VISIBLE || parentMenu == null) { return; } @@ -773,6 +779,10 @@ public class ActionBarMenuItem extends FrameLayout { AnimatorSet searchContainerAnimator; public boolean toggleSearch(boolean openKeyboard) { + checkCreateSearchField(); + if (listener != null) { + listener.onPreToggleSearch(); + } if (searchContainer == null || (listener != null && !listener.canToggleSearch())) { return false; } @@ -1090,6 +1100,7 @@ public class ActionBarMenuItem extends FrameLayout { } public void setSearchFieldHint(CharSequence hint) { + searchFieldHint = hint; if (searchFieldCaption == null) { return; } @@ -1098,6 +1109,7 @@ public class ActionBarMenuItem extends FrameLayout { } public void setSearchFieldText(CharSequence text, boolean animated) { + searchFieldText = text; if (searchFieldCaption == null) { return; } @@ -1115,6 +1127,7 @@ public class ActionBarMenuItem extends FrameLayout { } public EditTextBoldCursor getSearchField() { + checkCreateSearchField(); return searchField; } @@ -1135,7 +1148,13 @@ public class ActionBarMenuItem extends FrameLayout { if (parentMenu == null) { return this; } - if (value && searchContainer == null) { + isSearchField = value; + wrapSearchInScrollView = wrapInScrollView; + return this; + } + + private void checkCreateSearchField() { + if (searchContainer == null && isSearchField) { searchContainer = new FrameLayout(getContext()) { private boolean ignoreRequestLayout; @@ -1166,7 +1185,7 @@ public class ActionBarMenuItem extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (!wrapInScrollView) { + if (!wrapSearchInScrollView) { measureChildWithMargins(clearButton, widthMeasureSpec, 0, heightMeasureSpec, 0); if (searchAdditionalButton != null) { measureChildWithMargins(searchAdditionalButton, widthMeasureSpec, 0, heightMeasureSpec, 0); @@ -1233,7 +1252,7 @@ public class ActionBarMenuItem extends FrameLayout { }; searchContainer.setClipChildren(searchItemPaddingStart != 0); wrappedSearchFrameLayout = null; - if (wrapInScrollView) { + if (wrapSearchInScrollView) { wrappedSearchFrameLayout = new FrameLayout(getContext()); HorizontalScrollView horizontalScrollView = new HorizontalScrollView(getContext()) { @@ -1402,16 +1421,24 @@ public class ActionBarMenuItem extends FrameLayout { searchField.setHighlightColor(getThemedColor(Theme.key_chat_inTextSelectionHighlight)); searchField.setHandlesColor(getThemedColor(Theme.key_chat_TextSelectionCursor)); + if (searchFieldHint != null) { + searchField.setHint(searchFieldHint); + setContentDescription(searchFieldHint); + } + if (searchFieldText != null) { + searchField.setText(searchFieldText); + } + searchFilterLayout = new LinearLayout(getContext()); searchFilterLayout.setOrientation(LinearLayout.HORIZONTAL); searchFilterLayout.setVisibility(View.VISIBLE); if (!LocaleController.isRTL) { searchContainer.addView(searchFieldCaption, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 36, Gravity.CENTER_VERTICAL | Gravity.LEFT, 0, 5.5f, 0, 0)); - searchContainer.addView(searchField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL, 6, 0, wrapInScrollView ? 0 : 48, 0)); + searchContainer.addView(searchField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL, 6, 0, wrapSearchInScrollView ? 0 : 48, 0)); searchContainer.addView(searchFilterLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 32, Gravity.CENTER_VERTICAL, 0, 0, 48, 0)); } else { searchContainer.addView(searchFilterLayout, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 32, Gravity.CENTER_VERTICAL, 0, 0, 48, 0)); - searchContainer.addView(searchField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL, 0, 0, wrapInScrollView ? 0 : 48, 0)); + searchContainer.addView(searchField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36, Gravity.CENTER_VERTICAL, 0, 0, wrapSearchInScrollView ? 0 : 48, 0)); searchContainer.addView(searchFieldCaption, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 36, Gravity.CENTER_VERTICAL | Gravity.RIGHT, 0, 5.5f, 48, 0)); } searchFilterLayout.setClipChildren(false); @@ -1474,14 +1501,12 @@ public class ActionBarMenuItem extends FrameLayout { AndroidUtilities.showKeyboard(searchField); }); clearButton.setContentDescription(LocaleController.getString("ClearButton", R.string.ClearButton)); - if (wrapInScrollView) { + if (wrapSearchInScrollView) { wrappedSearchFrameLayout.addView(clearButton, LayoutHelper.createFrame(48, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); } else { searchContainer.addView(clearButton, LayoutHelper.createFrame(48, LayoutHelper.MATCH_PARENT, Gravity.CENTER_VERTICAL | Gravity.RIGHT)); } } - isSearchField = value; - return this; } public OnClickListener getOnClickListener() { @@ -1632,6 +1657,7 @@ public class ActionBarMenuItem extends FrameLayout { } public void clearSearchText() { + searchFieldText = null; if (searchField == null) { return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java index e7799c2de..a46d198bd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/BaseFragment.java @@ -153,6 +153,14 @@ public abstract class BaseFragment { return parentLayout != null && parentLayout.isInPassivePreviewMode(); } + public boolean isActionBarCrossfadeEnabled() { + return actionBar != null; + } + + public INavigationLayout.BackButtonState getBackButtonState() { + return actionBar != null ? actionBar.getBackButtonState() : null; + } + public void setInPreviewMode(boolean value) { inPreviewMode = value; if (actionBar != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/INavigationLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/INavigationLayout.java index 96c71ee9d..ad9fc190e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/INavigationLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/INavigationLayout.java @@ -78,6 +78,10 @@ public interface INavigationLayout { return SharedConfig.useLNavigation ? new LNavigation(context) : new ActionBarLayout(context); } + default boolean isActionBarInCrossfade() { + return false; + } + default boolean hasIntegratedBlurInPreview() { return false; } @@ -376,4 +380,9 @@ public interface INavigationLayout { } } } + + enum BackButtonState { + BACK, + MENU + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java index 3d3e1f7f5..d9af7a13b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/MenuDrawable.java @@ -181,7 +181,7 @@ public class MenuDrawable extends Drawable { startXDiff += (paint.getStrokeWidth() / 2f) * (1f - currentRotation); endYDiff += AndroidUtilities.dp(.5f) * currentRotation; endXDiff -= AndroidUtilities.dp(.5f) * currentRotation + (paint.getStrokeWidth() / 2f) * (1f - currentRotation); - startYDiff -= AndroidUtilities.dp(.25f) * currentRotation; + startYDiff -= AndroidUtilities.dp(.75f) * currentRotation; endYDiff += AndroidUtilities.dp(.25f) * currentRotation; } } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java index 34d99e5bf..346abb90d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/Theme.java @@ -3117,6 +3117,8 @@ public class Theme { public static Drawable chat_commentDrawable; public static Drawable chat_commentStickerDrawable; public static Drawable chat_commentArrowDrawable; + public static Drawable chat_gradientLeftDrawable; + public static Drawable chat_gradientRightDrawable; public static Drawable[] chat_msgInCallDrawable = new Drawable[2]; public static Drawable[] chat_msgInCallSelectedDrawable = new Drawable[2]; public static Drawable[] chat_msgOutCallDrawable = new Drawable[2]; @@ -5043,6 +5045,7 @@ public class Theme { fallbackKeys.put(key_topics_unreadCounter, key_chats_unreadCounter); fallbackKeys.put(key_topics_unreadCounterMuted, key_chats_message); + fallbackKeys.put(key_avatar_background2Saved, key_avatar_backgroundSaved); fallbackKeys.put(key_avatar_background2Red, key_avatar_backgroundRed); fallbackKeys.put(key_avatar_background2Orange, key_avatar_backgroundOrange); fallbackKeys.put(key_avatar_background2Violet, key_avatar_backgroundViolet); @@ -9316,6 +9319,8 @@ public class Theme { chat_commentDrawable = resources.getDrawable(R.drawable.msg_msgbubble); chat_commentStickerDrawable = resources.getDrawable(R.drawable.msg_msgbubble2); chat_commentArrowDrawable = resources.getDrawable(R.drawable.msg_arrowright); + chat_gradientLeftDrawable = resources.getDrawable(R.drawable.gradient_left); + chat_gradientRightDrawable = resources.getDrawable(R.drawable.gradient_right); chat_contextResult_shadowUnderSwitchDrawable = resources.getDrawable(R.drawable.header_shadow).mutate(); @@ -9641,6 +9646,8 @@ public class Theme { setDrawableColorByKey(chat_commentDrawable, key_chat_inInstant); setDrawableColorByKey(chat_commentStickerDrawable, key_chat_serviceIcon); setDrawableColorByKey(chat_commentArrowDrawable, key_chat_inInstant); + setDrawableColorByKey(chat_gradientLeftDrawable, key_chat_stickersHintPanel); + setDrawableColorByKey(chat_gradientRightDrawable, key_chat_stickersHintPanel); for (int a = 0; a < 2; a++) { setDrawableColorByKey(chat_msgInCallDrawable[a], key_chat_inInstant); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 79b92626b..4718d5acf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -8552,9 +8552,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } } timeX -= getExtraTimeX(); -// if (transitionParams != null && !transitionParams.shouldAnimateTimeX) { -// transitionParams.lastTimeX = timeX; -// } if ((currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0) { viewsLayout = new StaticLayout(currentViewsString, Theme.chat_timePaint, viewsTextWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); @@ -9745,13 +9742,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } reactionsLayoutInBubble.y = getBackgroundDrawableBottom() - AndroidUtilities.dp(10) - reactionsLayoutInBubble.height; reactionsLayoutInBubble.y -= (drawCommentButton ? AndroidUtilities.dp(43) : 0); - if (hasNewLineForTime) { + if (hasNewLineForTime && !(drawForwardedName && hasLinkPreview && documentAttachType == DOCUMENT_ATTACH_TYPE_AUDIO)) { reactionsLayoutInBubble.y -= AndroidUtilities.dp(16); } if (captionLayout != null && ((currentMessageObject.type != MessageObject.TYPE_VOICE && !(currentMessageObject.isOut() && drawForwardedName && !drawPhotoImage) && !(currentMessageObject.type == MessageObject.TYPE_FILE && drawPhotoImage)) || (currentPosition != null && currentMessagesGroup != null))) { reactionsLayoutInBubble.y -= AndroidUtilities.dp(14); } - reactionsLayoutInBubble.y = reactionsLayoutInBubble.y + reactionsLayoutInBubble.positionOffsetY; + reactionsLayoutInBubble.y += reactionsLayoutInBubble.positionOffsetY; } if (reactionsLayoutInBubble.isSmall && !reactionsLayoutInBubble.isEmpty) { int timeYOffset; @@ -13912,7 +13909,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } } - if (drawTopic && (animatingAlpha > 0 && replyForwardAlpha > 0) && (currentPosition == null || currentPosition.minY == 0 && currentPosition.minX == 0)) { + if (drawTopic && topicButton != null && (animatingAlpha > 0 && replyForwardAlpha > 0) && (currentPosition == null || currentPosition.minY == 0 && currentPosition.minX == 0)) { float x, y; if (currentMessageObject.shouldDrawWithoutBackground()) { if (currentMessageObject.isOutOwner()) { @@ -14878,7 +14875,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate reactionsLayoutInBubble.draw(canvas, transitionParams.animateChangeProgress, null); } if (ChatObject.isChannel(currentChat) && !currentChat.megagroup || (currentMessageObject.messageOwner.flags & TLRPC.MESSAGE_FLAG_HAS_VIEWS) != 0 || (repliesLayout != null || transitionParams.animateReplies) || (isPinned || transitionParams.animatePinned)) { - additionalX += this.timeWidth - timeLayout.getLineWidth(0); + additionalX += timeWidth - timeLayout.getLineWidth(0); if (reactionsLayoutInBubble.isSmall && !reactionsLayoutInBubble.isEmpty) { additionalX -= reactionsLayoutInBubble.width; } @@ -18171,7 +18168,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate animateTimeWidth = lastTimeWidth; changed = true; } else if (timeDrawablesIsChanged || Math.abs(timeX - lastTimeX) > 1) { - shouldAnimateTimeX = true ; + shouldAnimateTimeX = true; animateTimeWidth = lastTimeWidth; animateFromTimeX = lastTimeX; animateFromTimeXViews = lastTimeXViews; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java index d2a8cf19e..d096e8806 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/DialogCell.java @@ -1047,9 +1047,9 @@ public class DialogCell extends BaseCell { updateMessageThumbs(); messageNameString = getMessageNameString(); messageString = formatTopicsNames(); - String restrictionReason = MessagesController.getRestrictionReason(message.messageOwner.restriction_reason); - buttonString = getMessageStringFormatted(messageFormat, restrictionReason, messageNameString, true); - if (applyName && buttonString.length() >= 0) { + String restrictionReason = message != null ? MessagesController.getRestrictionReason(message.messageOwner.restriction_reason) : null; + buttonString = message != null ? getMessageStringFormatted(messageFormat, restrictionReason, messageNameString, true) : ""; + if (applyName && buttonString.length() >= 0 && messageNameString != null) { SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(buttonString); spannableStringBuilder.setSpan(new ForegroundColorSpanThemable(Theme.key_chats_name, resourcesProvider), 0, Math.min(spannableStringBuilder.length(), messageNameString.length() + 1), 0); buttonString = spannableStringBuilder; @@ -2066,10 +2066,10 @@ public class DialogCell extends BaseCell { } try { CharSequence text = layout.getText(); - if (text instanceof Spannable) { - FixedWidthSpan[] spans = ((Spannable) text).getSpans(0, text.length(), FixedWidthSpan.class); + if (text instanceof Spanned) { + FixedWidthSpan[] spans = ((Spanned) text).getSpans(0, text.length(), FixedWidthSpan.class); if (spans != null && spans.length > 0) { - int spanOffset = ((Spannable) text).getSpanStart(spans[0]); + int spanOffset = ((Spanned) text).getSpanStart(spans[0]); if (spanOffset < 0) { spanOffset = 0; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index e80e0e756..886251a03 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -312,6 +312,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private final static boolean DISABLE_PROGRESS_VIEW = true; private final static int SKELETON_DISAPPEAR_MS = 200; + private static int SKELETON_LIGHT_OVERLAY_ALPHA = 22; + private static float SKELETON_SATURATION = 1.4f; + public final static int DEBUG_SHARE_ALERT_MODE_NORMAL = 0, DEBUG_SHARE_ALERT_MODE_LESS = 1, DEBUG_SHARE_ALERT_MODE_MORE = 2; @@ -682,6 +685,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private int lastSkeletonCount; private int lastSkeletonMessageCount; private Paint skeletonPaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private Paint skeletonServicePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private ColorMatrix skeletonColorMatrix = new ColorMatrix(); private Theme.MessageDrawable.PathDrawParams skeletonBackgroundCacheParams = new Theme.MessageDrawable.PathDrawParams(); private Theme.MessageDrawable skeletonBackgroundDrawable = new Theme.MessageDrawable(Theme.MessageDrawable.TYPE_TEXT, false, false, this::getThemedColor); private long skeletonLastUpdateTime; @@ -692,6 +697,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private int skeletonColor0; private int skeletonColor1; + private Paint skeletonOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG); + private Matrix skeletonOutlineMatrix = new Matrix(); + private LinearGradient skeletonOutlineGradient; + + { + skeletonOutlinePaint.setStyle(Paint.Style.STROKE); + skeletonOutlinePaint.setStrokeWidth(AndroidUtilities.dp(1)); + } + private boolean premiumInvoiceBot; private boolean showScrollToMessageError; private int startLoadFromMessageId; @@ -1037,7 +1051,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public List onGetDebugItems() { List items = new ArrayList<>(); - if (currentChat != null && ChatObject.isChannel(currentChat)) { + if (ChatObject.isChannel(currentChat)) { + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugShareAlert))); String mode; switch (shareAlertDebugMode) { default: @@ -1057,6 +1072,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugShareAlertTopicsSlowMotion), ()-> shareAlertDebugTopicsSlowMotion = !shareAlertDebugTopicsSlowMotion)); } + if (currentUser == null) { + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletons))); + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletonsLightOverlayAlpha), 0, 255, new AnimationProperties.FloatProperty("") { + @Override + public void setValue(Object object, float value) { + SKELETON_LIGHT_OVERLAY_ALPHA = (int) value; + } + + @Override + public Object get(Object object) { + return (float) SKELETON_LIGHT_OVERLAY_ALPHA; + } + })); + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugMessageSkeletonsSaturation), 1f, 10f, new AnimationProperties.FloatProperty("") { + @Override + public void setValue(Object object, float value) { + SKELETON_SATURATION = value; + skeletonColorMatrix.setSaturation(value); + skeletonServicePaint.setColorFilter(new ColorMatrixColorFilter(skeletonColorMatrix)); + } + + @Override + public Object get(Object object) { + return SKELETON_SATURATION; + } + })); + } return items; } @@ -4833,7 +4875,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private boolean isSkeletonVisible() { - if (justCreatedTopic) { + if (justCreatedTopic || currentUser != null || !SharedConfig.animationsEnabled()) { return false; } int childHeight = 0; @@ -4849,10 +4891,26 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not checkDispatchHideSkeletons(fragmentBeginToShow); } - boolean visible = (!endReached[0] || mergeDialogId != 0 && !endReached[1] || messages.isEmpty()) && loading && maxTop > 0 && (messages.isEmpty() ? animateProgressViewTo : childHeight != 0); + boolean visible = (!endReached[0] || mergeDialogId != 0 && !endReached[1] || messages.isEmpty()) && loading && maxTop > chatListViewPaddingTop && (messages.isEmpty() ? animateProgressViewTo : childHeight != 0); if (!visible && startMessageAppearTransitionMs == 0) { checkDispatchHideSkeletons(fragmentBeginToShow); } + if (SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && !fromPullingDownTransition && !fragmentBeginToShow) { + Drawable wallpaper = themeDelegate.getWallpaperDrawable(); + if (fragmentView != null) { + wallpaper = ((SizeNotifierFrameLayout) fragmentView).getBackgroundImage(); + } + if (wallpaper instanceof MotionBackgroundDrawable) { + MotionBackgroundDrawable motion = (MotionBackgroundDrawable) wallpaper; + if (((MotionBackgroundDrawable) wallpaper).isIndeterminateAnimation() != visible) { + motion.setIndeterminateAnimation(visible); + motion.setIndeterminateSpeedScale(visible ? 1.5f : 1f); + motion.updateAnimation(true); + } else if (visible) { + motion.updateAnimation(false); + } + } + } return visible || startMessageAppearTransitionMs != 0 && System.currentTimeMillis() - startMessageAppearTransitionMs <= SKELETON_DISAPPEAR_MS; } @@ -4882,6 +4940,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } Paint servicePaint = getThemedPaint(Theme.key_paint_chatActionBackground); + if (skeletonServicePaint.getColor() != servicePaint.getColor()) { + skeletonServicePaint.setColor(servicePaint.getColor()); + } + if (skeletonServicePaint.getShader() != servicePaint.getShader()) { + skeletonServicePaint.setShader(servicePaint.getShader()); + skeletonColorMatrix.setSaturation(SKELETON_SATURATION); + skeletonServicePaint.setColorFilter(new ColorMatrixColorFilter(skeletonColorMatrix)); + } for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); @@ -4952,10 +5018,22 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (isSkeletonVisible()) { + boolean drawService = SharedConfig.getDevicePerformanceClass() != SharedConfig.PERFORMANCE_CLASS_LOW && Theme.hasGradientService(); + boolean darkOverlay = ColorUtils.calculateLuminance(getThemedColor(Theme.key_windowBackgroundWhite)) <= 0.7f && Theme.hasGradientService(); + boolean blackOverlay = ColorUtils.calculateLuminance(getThemedColor(Theme.key_windowBackgroundWhite)) <= 0.01f && Theme.hasGradientService(); + if (drawService) { + Theme.applyServiceShaderMatrix(getMeasuredWidth(), AndroidUtilities.displaySize.y, 0, getY() - contentPanTranslation); + } + int wasDarkenAlpha = Theme.chat_actionBackgroundGradientDarkenPaint.getAlpha(); + if (blackOverlay) { + Theme.chat_actionBackgroundGradientDarkenPaint.setAlpha((int) (wasDarkenAlpha * 4f)); + } + float topSkeletonAlpha = startMessageAppearTransitionMs != 0 ? 1f - (System.currentTimeMillis() - startMessageAppearTransitionMs) / (float) SKELETON_DISAPPEAR_MS : 1f; int alpha = skeletonPaint.getAlpha(); - int wasServiceAlpha = servicePaint.getAlpha(); - servicePaint.setAlpha((int) (wasServiceAlpha * 0.4f * topSkeletonAlpha)); + int wasServiceAlpha = skeletonServicePaint.getAlpha(); + int wasOutlineAlpha = skeletonOutlinePaint.getAlpha(); + skeletonServicePaint.setAlpha((int) (0xFF * topSkeletonAlpha)); skeletonPaint.setAlpha((int) (topSkeletonAlpha * alpha)); while (lastTop > blurredViewTopOffset) { lastTop -= AndroidUtilities.dp(3f); @@ -4982,21 +5060,33 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not int bottom = skeleton.lastBottom; skeletonBackgroundDrawable.setBounds(noAvatar ? AndroidUtilities.dp(3f) : AndroidUtilities.dp(51), bottom - skeleton.height, skeleton.width, bottom); - Theme.applyServiceShaderMatrix(getMeasuredWidth(), AndroidUtilities.displaySize.y, 0, getY() + skeletonBackgroundDrawable.getBounds().top); - skeletonBackgroundDrawable.drawCached(canvas, skeletonBackgroundCacheParams, servicePaint); + if (drawService) { + skeletonBackgroundDrawable.drawCached(canvas, skeletonBackgroundCacheParams, skeletonServicePaint); + } skeletonBackgroundDrawable.drawCached(canvas, skeletonBackgroundCacheParams, skeletonPaint); + if (darkOverlay) { + skeletonBackgroundDrawable.drawCached(canvas, skeletonBackgroundCacheParams, Theme.chat_actionBackgroundGradientDarkenPaint); + } + skeletonBackgroundDrawable.drawCached(canvas, skeletonBackgroundCacheParams, skeletonOutlinePaint); if (!noAvatar) { - Theme.applyServiceShaderMatrix(getMeasuredWidth(), AndroidUtilities.displaySize.y, 0, getY() + bottom - AndroidUtilities.dp(42)); - canvas.drawCircle(AndroidUtilities.dp(48 - 21), bottom - AndroidUtilities.dp(21), AndroidUtilities.dp(21), servicePaint); + if (drawService) { + canvas.drawCircle(AndroidUtilities.dp(48 - 21), bottom - AndroidUtilities.dp(21), AndroidUtilities.dp(21), skeletonServicePaint); + } canvas.drawCircle(AndroidUtilities.dp(48 - 21), bottom - AndroidUtilities.dp(21), AndroidUtilities.dp(21), skeletonPaint); + if (darkOverlay) { + canvas.drawCircle(AndroidUtilities.dp(48 - 21), bottom - AndroidUtilities.dp(21), AndroidUtilities.dp(21), Theme.chat_actionBackgroundGradientDarkenPaint); + } + canvas.drawCircle(AndroidUtilities.dp(48 - 21), bottom - AndroidUtilities.dp(21), AndroidUtilities.dp(21), skeletonOutlinePaint); } lastTop -= skeleton.height; } - servicePaint.setAlpha(wasServiceAlpha); + skeletonServicePaint.setAlpha(wasServiceAlpha); skeletonPaint.setAlpha(alpha); + skeletonOutlinePaint.setAlpha(wasOutlineAlpha); + Theme.chat_actionBackgroundGradientDarkenPaint.setAlpha(wasDarkenAlpha); invalidated = false; invalidate(); } else if (System.currentTimeMillis() - startMessageAppearTransitionMs > SKELETON_DISAPPEAR_MS) { @@ -5012,13 +5102,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private void updateSkeletonColors() { - int color0 = ColorUtils.setAlphaComponent(getThemedColor(Theme.key_listSelector), 30); - int color1 = ColorUtils.setAlphaComponent(getThemedColor(Theme.key_listSelector), 20); + boolean dark = ColorUtils.calculateLuminance(getThemedColor(Theme.key_windowBackgroundWhite)) <= 0.7f; + int color0 = ColorUtils.blendARGB(getThemedColor(Theme.key_listSelector), Color.argb(dark ? 0x21 : 0x03, 0xFF, 0xFF, 0xFF), dark ? 0.9f : 0.5f); + int color1 = ColorUtils.setAlphaComponent(getThemedColor(Theme.key_listSelector), dark ? 24 : SKELETON_LIGHT_OVERLAY_ALPHA); if (skeletonColor1 != color1 || skeletonColor0 != color0) { skeletonColor0 = color0; skeletonColor1 = color1; skeletonGradient = new LinearGradient(0, 0, skeletonGradientWidth = AndroidUtilities.dp(200), 0, new int[]{color1, color0, color0, color1}, new float[]{0.0f, 0.4f, 0.6f, 1f}, Shader.TileMode.CLAMP); skeletonPaint.setShader(skeletonGradient); + + int outlineColor = Color.argb(dark ? 0x2B : 0x60, 0xFF, 0xFF, 0xFF); + skeletonOutlineGradient = new LinearGradient(0, 0, skeletonGradientWidth, 0, new int[]{Color.TRANSPARENT, outlineColor, outlineColor, Color.TRANSPARENT}, new float[]{0.0f, 0.4f, 0.6f, 1f}, Shader.TileMode.CLAMP); + skeletonOutlinePaint.setShader(skeletonOutlineGradient); } } @@ -5041,6 +5136,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (skeletonGradient != null) { skeletonGradient.setLocalMatrix(skeletonMatrix); } + skeletonOutlineMatrix.setTranslate(skeletonTotalTranslation, 0); + if (skeletonOutlineGradient != null) { + skeletonOutlineGradient.setLocalMatrix(skeletonOutlineMatrix); + } } @Override @@ -8907,6 +9006,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return fragmentView; } + @Override + public INavigationLayout.BackButtonState getBackButtonState() { + return INavigationLayout.BackButtonState.BACK; + } + public void onPageDownClicked() { wasManualScroll = true; textSelectionHelper.cancelTextSelectionRunnable(); @@ -13018,6 +13122,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } private int getHeightForMessage(MessageObject object) { + if (getParentActivity() == null) { + return 0; + } if (dummyMessageCell == null) { dummyMessageCell = new ChatMessageCell(getParentActivity(), true, themeDelegate); } @@ -22176,7 +22283,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not final ArrayList options = new ArrayList<>(); View optionsView = null; - if (!getUserConfig().isPremium() && !getMessagesController().premiumLocked && message.getDocument() != null && message.getDocument().size >= 300 * 1024 * 1024 && FileLoader.getInstance(currentAccount).isLoadingFile(FileLoader.getAttachFileName(message.getDocument()))) { + if (!getUserConfig().isPremium() && !getMessagesController().premiumLocked && message.getDocument() != null && message.getDocument().size >= 150 * 1024 * 1024 && FileLoader.getInstance(currentAccount).isLoadingFile(FileLoader.getAttachFileName(message.getDocument()))) { items.add(LocaleController.getString(R.string.PremiumSpeedPromo)); options.add(OPTION_SPEED_PROMO); icons.add(R.drawable.msg_speed); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatReactionsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatReactionsEditActivity.java index 6c34ec20c..fa7da3b92 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatReactionsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatReactionsEditActivity.java @@ -251,6 +251,9 @@ public class ChatReactionsEditActivity extends BaseFragment implements Notificat } else { chatReactions.remove(react.reaction); if (chatReactions.isEmpty()) { + if (listAdapter != null) { + listAdapter.notifyItemRangeRemoved((isChannel ? 1 : 2), 1 + availableReactions.size()); + } setCheckedEnableReactionCell(SELECT_TYPE_NONE, true); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java index aee67a41e..a48258968 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java @@ -1272,10 +1272,10 @@ public class Bulletin { avatarsImageView = new AvatarsImageView(context, false); avatarsImageView.setStyle(AvatarsDrawable.STYLE_MESSAGE_SEEN); + avatarsImageView.setAvatarsTextSize(AndroidUtilities.dp(18)); addView(avatarsImageView, LayoutHelper.createFrameRelatively(24 + 12 + 12 + 8, 48, Gravity.START | Gravity.CENTER_VERTICAL, 12, 0, 0, 0)); textView = new LinkSpanDrawable.LinksTextView(context); - textView.setSingleLine(); textView.setTypeface(Typeface.SANS_SERIF); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setEllipsize(TextUtils.TruncateAt.END); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java index ea6f2ed3a..edfd45b1d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BulletinFactory.java @@ -9,6 +9,7 @@ import android.text.style.ClickableSpan; import android.util.TypedValue; import android.view.HapticFeedbackConstants; import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.CheckResult; @@ -203,10 +204,17 @@ public final class BulletinFactory { } } layout.avatarsImageView.commitTransition(false); - layout.textView.setSingleLine(true); - layout.textView.setLines(1); + layout.textView.setSingleLine(false); + layout.textView.setMaxLines(2); layout.textView.setText(text); - layout.textView.setTranslationX(-(3 - count) * AndroidUtilities.dp(12)); + if (layout.textView.getLayoutParams() instanceof ViewGroup.MarginLayoutParams) { + int margin = AndroidUtilities.dp(12 + 56 + 2 - (3 - count) * 12); + if (LocaleController.isRTL) { + ((ViewGroup.MarginLayoutParams) layout.textView.getLayoutParams()).rightMargin = margin; + } else { + ((ViewGroup.MarginLayoutParams) layout.textView.getLayoutParams()).leftMargin = margin; + } + } return create(layout, Bulletin.DURATION_LONG); } @@ -216,9 +224,9 @@ public final class BulletinFactory { text = null; } else if (users.size() == 1) { if (ChatObject.isChannelAndNotMegaGroup(chat)) { - text = AndroidUtilities.replaceTags(LocaleController.formatString("HasBeenAddedToChannel", R.string.HasBeenAddedToChannel, "**" + UserObject.getUserName(users.get(0)) + "**")); + text = AndroidUtilities.replaceTags(LocaleController.formatString("HasBeenAddedToChannel", R.string.HasBeenAddedToChannel, "**" + UserObject.getFirstName(users.get(0)) + "**")); } else { - text = AndroidUtilities.replaceTags(LocaleController.formatString("HasBeenAddedToGroup", R.string.HasBeenAddedToGroup, "**" + UserObject.getUserName(users.get(0)) + "**")); + text = AndroidUtilities.replaceTags(LocaleController.formatString("HasBeenAddedToGroup", R.string.HasBeenAddedToGroup, "**" + UserObject.getFirstName(users.get(0)) + "**")); } } else { if (ChatObject.isChannelAndNotMegaGroup(chat)) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java index 19ee6713e..66901f4bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/EmojiPacksAlert.java @@ -930,6 +930,9 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N @Override public void dismiss() { super.dismiss(); + if (customEmojiPacks != null) { + customEmojiPacks.recycle(); + } NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.startAllHeavyOperations, 4); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugController.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugController.java index 0977ea6c4..858a4252d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugController.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugController.java @@ -5,6 +5,7 @@ import android.view.ViewGroup; import android.widget.FrameLayout; import org.telegram.messenger.SharedConfig; +import org.telegram.ui.Components.AnimationProperties; import org.telegram.ui.LaunchActivity; public class FloatingDebugController { @@ -54,16 +55,34 @@ public class FloatingDebugController { public static class DebugItem { final CharSequence title; final DebugItemType type; - final Runnable action; + Runnable action; + float from; + float to; + AnimationProperties.FloatProperty floatProperty; public DebugItem(CharSequence title, Runnable action) { this.type = DebugItemType.SIMPLE; this.title = title; this.action = action; } + + public DebugItem(CharSequence title) { + this.type = DebugItemType.HEADER; + this.title = title; + } + + public DebugItem(CharSequence title, float from, float to, AnimationProperties.FloatProperty callback) { + this.type = DebugItemType.SEEKBAR; + this.title = title; + this.from = from; + this.to = to; + this.floatProperty = callback; + } } public enum DebugItemType { - SIMPLE + SIMPLE, + HEADER, + SEEKBAR } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugView.java index a64401f68..c4b27b6e1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FloatingDebug/FloatingDebugView.java @@ -7,10 +7,13 @@ import android.content.SharedPreferences; import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Color; +import android.graphics.Paint; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.drawable.Drawable; import android.os.Build; +import android.os.Bundle; +import android.text.TextPaint; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.GestureDetector; @@ -21,6 +24,7 @@ import android.view.View; import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.Window; +import android.view.accessibility.AccessibilityNodeInfo; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; @@ -38,6 +42,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.LocaleController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; @@ -45,13 +50,17 @@ import org.telegram.messenger.SharedConfig; import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.INavigationLayout; import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.Cells.HeaderCell; +import org.telegram.ui.Components.AnimationProperties; import org.telegram.ui.Components.CombinedDrawable; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RecyclerListView; +import org.telegram.ui.Components.SeekBarView; import org.telegram.ui.LaunchActivity; import java.util.ArrayList; import java.util.List; +import java.util.Locale; public class FloatingDebugView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { private FrameLayout floatingButtonContainer; @@ -225,10 +234,16 @@ public class FloatingDebugView extends FrameLayout implements NotificationCenter switch (FloatingDebugController.DebugItemType.values()[viewType]) { default: case SIMPLE: - v = new AlertDialog.AlertDialogCell(context, null); - v.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - break; + v = new AlertDialog.AlertDialogCell(context, null); + break; + case HEADER: + v = new HeaderCell(context); + break; + case SEEKBAR: + v = new SeekBarCell(context); + break; } + v.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); return new RecyclerListView.Holder(v); } @@ -236,11 +251,28 @@ public class FloatingDebugView extends FrameLayout implements NotificationCenter public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { FloatingDebugController.DebugItem item = debugItems.get(position); switch (item.type) { - case SIMPLE: + case SIMPLE: { AlertDialog.AlertDialogCell cell = (AlertDialog.AlertDialogCell) holder.itemView; cell.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); cell.setTextAndIcon(item.title, 0); break; + } + case HEADER: { + HeaderCell cell = (HeaderCell) holder.itemView; + cell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader)); + cell.setText(item.title); + break; + } + case SEEKBAR: { + SeekBarCell cell = (SeekBarCell) holder.itemView; + cell.title = item.title.toString(); + cell.value = (float) item.floatProperty.get(null); + cell.min = item.from; + cell.max = item.to; + cell.callback = item.floatProperty; + cell.invalidate(); + break; + } } } @@ -450,6 +482,7 @@ public class FloatingDebugView extends FrameLayout implements NotificationCenter private List getBuiltInDebugItems() { List items = new ArrayList<>(); + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugGeneral))); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { items.add(new FloatingDebugController.DebugItem(LocaleController.getString(SharedConfig.debugWebView ? R.string.DebugMenuDisableWebViewDebug : R.string.DebugMenuEnableWebViewDebug), ()->{ SharedConfig.toggleDebugWebView(); @@ -463,6 +496,37 @@ public class FloatingDebugView extends FrameLayout implements NotificationCenter ((Activity) getContext()).recreate(); } })); + items.add(new FloatingDebugController.DebugItem(Theme.isCurrentThemeDark() ? "Switch to day theme" : "Switch to dark theme", () -> { + boolean toDark; + + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("themeconfig", Activity.MODE_PRIVATE); + String dayThemeName = preferences.getString("lastDayTheme", "Blue"); + if (Theme.getTheme(dayThemeName) == null || Theme.getTheme(dayThemeName).isDark()) { + dayThemeName = "Blue"; + } + String nightThemeName = preferences.getString("lastDarkTheme", "Dark Blue"); + if (Theme.getTheme(nightThemeName) == null || !Theme.getTheme(nightThemeName).isDark()) { + nightThemeName = "Dark Blue"; + } + Theme.ThemeInfo themeInfo = Theme.getActiveTheme(); + if (dayThemeName.equals(nightThemeName)) { + if (themeInfo.isDark() || dayThemeName.equals("Dark Blue") || dayThemeName.equals("Night")) { + dayThemeName = "Blue"; + } else { + nightThemeName = "Dark Blue"; + } + } + + if (!Theme.isCurrentThemeDark()) { + themeInfo = Theme.getTheme(nightThemeName); + } else { + themeInfo = Theme.getTheme(dayThemeName); + } + Theme.ThemeInfo finalThemeInfo = themeInfo; + AndroidUtilities.runOnUIThread(() -> { + NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.needSetDayNightTheme, finalThemeInfo, true, null, -1); + }, 200); + })); return items; } @@ -511,4 +575,87 @@ public class FloatingDebugView extends FrameLayout implements NotificationCenter public void dismiss(Runnable callback) { callback.run(); } + + @SuppressWarnings("unchecked") + private class SeekBarCell extends FrameLayout { + + private SeekBarView seekBar; + private float min; + private float max; + private float value; + private AnimationProperties.FloatProperty callback; + private String title; + + private TextPaint textPaint; + private int lastWidth; + + public SeekBarCell(Context context) { + super(context); + + setWillNotDraw(false); + + textPaint = new TextPaint(Paint.ANTI_ALIAS_FLAG); + textPaint.setTextSize(AndroidUtilities.dp(16)); + + seekBar = new SeekBarView(context); + seekBar.setReportChanges(true); + seekBar.setDelegate(new SeekBarView.SeekBarViewDelegate() { + @Override + public void onSeekBarDrag(boolean stop, float progress) { + value = min + (max - min) * progress; + if (stop) { + callback.set(null, value); + } + invalidate(); + } + + @Override + public void onSeekBarPressed(boolean pressed) {} + + @Override + public CharSequence getContentDescription() { + return String.valueOf(Math.round(min + (max - min) * seekBar.getProgress())); + } + }); + seekBar.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); + addView(seekBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 38, Gravity.LEFT | Gravity.BOTTOM, 5, 5 + 24, 47, 0)); + } + + @Override + protected void onDraw(Canvas canvas) { + textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); + canvas.drawText(title, AndroidUtilities.dp(24), AndroidUtilities.dp(24), textPaint); + + textPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText)); + String str = String.format(Locale.ROOT, "%.2f", value); + canvas.drawText(str, getMeasuredWidth() - AndroidUtilities.dp(8) - textPaint.measureText(str), AndroidUtilities.dp(28 - 5) + seekBar.getY(), textPaint); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + int width = MeasureSpec.getSize(widthMeasureSpec); + if (lastWidth != width) { + seekBar.setProgress(((float) callback.get(null) - min) / (float) (max - min)); + lastWidth = width; + } + } + + @Override + public void invalidate() { + super.invalidate(); + seekBar.invalidate(); + } + + @Override + public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { + super.onInitializeAccessibilityNodeInfo(info); + seekBar.getSeekBarAccessibilityDelegate().onInitializeAccessibilityNodeInfoInternal(this, info); + } + + @Override + public boolean performAccessibilityAction(int action, Bundle arguments) { + return super.performAccessibilityAction(action, arguments) || seekBar.getSeekBarAccessibilityDelegate().performAccessibilityActionInternal(this, action, arguments); + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/MotionBackgroundDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/MotionBackgroundDrawable.java index 240d45d7e..a2b17eca4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/MotionBackgroundDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/MotionBackgroundDrawable.java @@ -110,6 +110,7 @@ public class MotionBackgroundDrawable extends Drawable { private ColorFilter legacyBitmapColorFilter; private int legacyBitmapColor; + private float indeterminateSpeedScale = 1f; private boolean isIndeterminateAnimation; private Paint overrideBitmapPaint; @@ -861,7 +862,7 @@ public class MotionBackgroundDrawable extends Drawable { float progress; boolean isNeedGenerateGradient = postInvalidateParent || rotatingPreview; if (isIndeterminateAnimation) { - posAnimationProgress += dt / 12000f; + posAnimationProgress += (dt / 12000f) * indeterminateSpeedScale; if (posAnimationProgress >= 1.0f) { posAnimationProgress = 0.0f; } @@ -1007,6 +1008,18 @@ public class MotionBackgroundDrawable extends Drawable { return colors[0] == colors[1] && colors[0] == colors[2] && colors[0] == colors[3]; } + public float getIndeterminateSpeedScale() { + return indeterminateSpeedScale; + } + + public void setIndeterminateSpeedScale(float indeterminateSpeedScale) { + this.indeterminateSpeedScale = indeterminateSpeedScale; + } + + public boolean isIndeterminateAnimation() { + return isIndeterminateAnimation; + } + public void setIndeterminateAnimation(boolean isIndeterminateAnimation) { this.isIndeterminateAnimation = isIndeterminateAnimation; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/VideoScreenPreview.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/VideoScreenPreview.java index b550ba52c..f59fac62f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/VideoScreenPreview.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Premium/VideoScreenPreview.java @@ -69,8 +69,8 @@ public class VideoScreenPreview extends FrameLayout implements PagerHeaderView, MediaMetadataRetriever retriever = new MediaMetadataRetriever(); retriever.setDataSource(ApplicationLoader.applicationContext, Uri.fromFile(file)); - int width = Integer.valueOf(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)); - int height = Integer.valueOf(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)); + int width = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)); + int height = Integer.parseInt(retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)); retriever.release(); aspectRatio = width / (float) height; } else { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java index 45b19d93b..03d88bc70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RLottieDrawable.java @@ -48,10 +48,15 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma public boolean skipFrameUpdate; public static native long create(String src, String json, int w, int h, int[] params, boolean precache, int[] colorReplacement, boolean limitFps, int fitzModifier); + protected static native long createWithJson(String json, String name, int[] params, int[] colorReplacement); + public static native void destroy(long ptr); + private static native void setLayerColor(long ptr, String layer, int color); + private static native void replaceColors(long ptr, int[] colorReplacement); + public static native int getFrame(long ptr, int frame, Bitmap bitmap, int w, int h, int stride, boolean clear); protected final int width; @@ -177,9 +182,13 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma } BitmapsCache.incrementTaskCounter(); lottieCacheGenerateQueue.postRunnable(cacheGenerateTask = () -> { - BitmapsCache bitmapsCacheFinal = bitmapsCache; - if (bitmapsCacheFinal != null) { - bitmapsCacheFinal.createCache(); + try { + BitmapsCache bitmapsCacheFinal = bitmapsCache; + if (bitmapsCacheFinal != null) { + bitmapsCacheFinal.createCache(); + } + } catch (Throwable throwable) { + } uiHandler.post(uiRunnableCacheFinished); }); @@ -267,6 +276,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma private boolean genCacheSend; protected Runnable loadFrameRunnable = new Runnable() { private long lastUpdate = 0; + @Override public void run() { if (isRecycled) { @@ -717,7 +727,6 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma return; } parentViews.add(parent); - checkCacheCancel(); } public void removeParentView(ImageReceiver parent) { @@ -729,6 +738,7 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma } private Runnable cancelCache; + public void checkCacheCancel() { if (bitmapsCache == null || lottieCacheGenerateQueue == null || cacheGenerateTask == null) { return; @@ -739,17 +749,14 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma } else { mustCancel = mustCancel && masterParent == null; } - if (mustCancel && cancelCache == null) { - AndroidUtilities.runOnUIThread(cancelCache = () -> { + if (mustCancel) { + if (cacheGenerateTask != null) { lottieCacheGenerateQueue.cancelRunnable(cacheGenerateTask); - if (bitmapsCache != null) { - bitmapsCache.cancelCreate(); - } BitmapsCache.decrementTaskCounter(); - }, 600); - } else if (!mustCancel && cancelCache != null) { - AndroidUtilities.cancelRunOnUIThread(cancelCache); - cancelCache = null; + cacheGenerateTask = null; + } + generatingCache = false; + genCacheSend = false; } } @@ -1315,33 +1322,30 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma AndroidUtilities.runOnUIThread(onReady); return; } - loadFrameRunnableQueue.execute(() -> { - if (bitmapsCache.cacheExist()) { - AndroidUtilities.runOnUIThread(onReady); - } else { - AndroidUtilities.runOnUIThread(() -> { - generatingCache = true; - if (lottieCacheGenerateQueue == null) { - createCacheGenQueue(); + + generatingCache = true; + if (lottieCacheGenerateQueue == null) { + createCacheGenQueue(); + } + if (cacheGenerateTask == null) { + BitmapsCache.incrementTaskCounter(); + lottieCacheGenerateQueue.postRunnable(cacheGenerateTask = () -> { + try { + BitmapsCache bitmapsCacheFinal = bitmapsCache; + if (bitmapsCacheFinal != null) { + bitmapsCacheFinal.createCache(); } - if (cacheGenerateTask == null) { - BitmapsCache.incrementTaskCounter(); - lottieCacheGenerateQueue.postRunnable(cacheGenerateTask = () -> { - BitmapsCache bitmapsCacheFinal = bitmapsCache; - if (bitmapsCacheFinal != null) { - bitmapsCacheFinal.createCache(); - } - AndroidUtilities.runOnUIThread(() -> { - onReady.run(); - if (cacheGenerateTask != null) { - cacheGenerateTask = null; - BitmapsCache.decrementTaskCounter(); - } - }); - }); + } catch (Throwable e) { + FileLog.e(e); + } + AndroidUtilities.runOnUIThread(() -> { + onReady.run(); + if (cacheGenerateTask != null) { + cacheGenerateTask = null; + BitmapsCache.decrementTaskCounter(); } }); - } - }); + }); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java index 41b762e57..05e170187 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactedUsersListView.java @@ -386,9 +386,10 @@ public class ReactedUsersListView extends FrameLayout { titleView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem)); titleView.setEllipsizeByGradient(true); titleView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO); - titleView.setWidthWrapContent(true); titleView.setPadding(0, AndroidUtilities.dp(12), 0, AndroidUtilities.dp(12)); - addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL, 58, 0, 36 + 6, 0)); + titleView.setRightPadding(AndroidUtilities.dp(30)); + titleView.setTranslationX(LocaleController.isRTL ? AndroidUtilities.dp(30) : 0); + addView(titleView, LayoutHelper.createFrameRelatively(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.FILL_HORIZONTAL | Gravity.CENTER_VERTICAL, 58, 0, 12, 0)); reactView = new BackupImageView(context); addView(reactView, LayoutHelper.createFrameRelatively(24, 24, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 12, 0)); @@ -411,6 +412,7 @@ public class ReactedUsersListView extends FrameLayout { } avatarView.setImage(ImageLocation.getForUser(u, ImageLocation.TYPE_SMALL), "50_50", thumb, u); + boolean hasReactImage = false; if (reaction.reaction != null) { ReactionsLayoutInBubble.VisibleReaction visibleReaction = ReactionsLayoutInBubble.VisibleReaction.fromTLReaction(reaction.reaction); if (visibleReaction.emojicon != null) { @@ -418,17 +420,21 @@ public class ReactedUsersListView extends FrameLayout { if (r != null) { SvgHelper.SvgDrawable svgThumb = DocumentObject.getSvgThumb(r.static_icon.thumbs, Theme.key_windowBackgroundGray, 1.0f); reactView.setImage(ImageLocation.getForDocument(r.center_icon), "40_40_lastframe", "webp", svgThumb, r); + hasReactImage = true; } else { reactView.setImageDrawable(null); } } else { reactView.setAnimatedEmojiDrawable(new AnimatedEmojiDrawable(AnimatedEmojiDrawable.CACHE_TYPE_MESSAGES, currentAccount, visibleReaction.documentId)); + hasReactImage = true; } setContentDescription(LocaleController.formatString("AccDescrReactedWith", R.string.AccDescrReactedWith, UserObject.getUserName(u), reaction.reaction)); } else { reactView.setImageDrawable(null); setContentDescription(LocaleController.formatString("AccDescrPersonHasSeen", R.string.AccDescrPersonHasSeen, UserObject.getUserName(u))); } + titleView.setRightPadding(AndroidUtilities.dp(hasReactImage ? 30 : 0)); + titleView.setTranslationX(hasReactImage && LocaleController.isRTL ? AndroidUtilities.dp(30) : 0); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java index 67bc8fc5c..4d476beba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java @@ -66,6 +66,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Objects; +@SuppressWarnings("JavaReflectionMemberAccess") public class RecyclerListView extends RecyclerView { public final static int SECTIONS_TYPE_SIMPLE = 0, SECTIONS_TYPE_STICKY_HEADERS = 1, @@ -181,6 +182,18 @@ public class RecyclerListView extends RecyclerView { private boolean accessibilityEnabled = true; + private final static Method initializeScrollbars; + + static { + Method notSoFinalInitializeScrollbars; + try { + notSoFinalInitializeScrollbars = android.view.View.class.getDeclaredMethod("initializeScrollbars", TypedArray.class); + } catch (Exception ignored) { + notSoFinalInitializeScrollbars = null; + } + initializeScrollbars = notSoFinalInitializeScrollbars; + } + private AccessibilityDelegate accessibilityDelegate = new AccessibilityDelegate() { @Override public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) { @@ -1367,10 +1380,9 @@ public class RecyclerListView extends RecyclerView { gotAttributes = true; } TypedArray a = context.getTheme().obtainStyledAttributes(attributes); - @SuppressLint("DiscouragedPrivateApi") - Method initializeScrollbars = android.view.View.class.getDeclaredMethod("initializeScrollbars", TypedArray.class); - initializeScrollbars.invoke(this, a); - a.recycle(); + if (initializeScrollbars != null) { + initializeScrollbars.invoke(this, a); + } } catch (Throwable e) { FileLog.e(e); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SearchViewPager.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SearchViewPager.java index a9ffbb63a..edcdce3b5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SearchViewPager.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SearchViewPager.java @@ -434,7 +434,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie return false; } for (MessageObject obj : selectedFiles.values()) { - if (obj.getDocument() != null && obj.getDocument().size >= 300 * 1024 * 1024) { + if (obj.getDocument() != null && obj.getDocument().size >= 150 * 1024 * 1024) { return true; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java index 71b64a1f4..ab9ddeeee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java @@ -839,12 +839,23 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter for (int i = 0 ; i < sharedMediaData.length; i++) { allMessages.addAll(sharedMediaData[i].messages); } - Utilities.globalQueue.postRunnable(new Runnable() { - @Override - public void run() { - FileLoader.getInstance(account).checkMediaExistance(allMessages); - } - }); + String fileName = (String) args[0]; + if (fileName != null) { + Utilities.globalQueue.postRunnable(new Runnable() { + @Override + public void run() { + for (int i = 0; i < allMessages.size(); i++) { + if (!fileName.equals(allMessages.get(i).getFileName())) { + allMessages.remove(i); + i--; + } + } + if (allMessages.size() > 0) { + FileLoader.getInstance(account).checkMediaExistance(allMessages); + } + } + }); + } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SuggestEmojiView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SuggestEmojiView.java index 7ef65eb77..2b9f7ebce 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SuggestEmojiView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SuggestEmojiView.java @@ -32,7 +32,6 @@ import org.telegram.messenger.Emoji; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessageObject; import org.telegram.messenger.NotificationCenter; -import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; import org.telegram.tgnet.TLRPC; import org.telegram.ui.ActionBar.Theme; @@ -133,12 +132,6 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter. } }); - this.leftGradient = getResources().getDrawable(R.drawable.gradient_right).mutate(); - this.leftGradient.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); - - this.rightGradient = getResources().getDrawable(R.drawable.gradient_left).mutate(); - this.rightGradient.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); - MediaDataController.getInstance(currentAccount).checkStickers(MediaDataController.TYPE_EMOJIPACKS); } @@ -154,8 +147,8 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter. if (backgroundPaint != null) { backgroundPaint.setColor(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider)); } - this.leftGradient.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); - this.rightGradient.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); + Theme.chat_gradientLeftDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); + Theme.chat_gradientRightDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chat_stickersHintPanel, resourcesProvider), PorterDuff.Mode.MULTIPLY)); } public void forceClose() { @@ -423,7 +416,6 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter. private AnimatedFloat showFloat2 = new AnimatedFloat(containerView, 150, 600, CubicBezierInterpolator.EASE_OUT_QUINT); private OvershootInterpolator overshootInterpolator = new OvershootInterpolator(.4f); - private Drawable leftGradient, rightGradient; private AnimatedFloat leftGradientAlpha = new AnimatedFloat(containerView, 300, CubicBezierInterpolator.EASE_OUT_QUINT); private AnimatedFloat rightGradientAlpha = new AnimatedFloat(containerView, 300, CubicBezierInterpolator.EASE_OUT_QUINT); @@ -549,16 +541,16 @@ public class SuggestEmojiView extends FrameLayout implements NotificationCenter. float leftAlpha = leftGradientAlpha.set(listView.canScrollHorizontally(-1) ? 1f : 0f); if (leftAlpha > 0) { - leftGradient.setBounds((int) left, (int) top, (int) left + AndroidUtilities.dp(32), (int) bottom); - leftGradient.setAlpha((int) (255 * leftAlpha)); - leftGradient.draw(canvas); + Theme.chat_gradientLeftDrawable.setBounds((int) left, (int) top, (int) left + AndroidUtilities.dp(32), (int) bottom); + Theme.chat_gradientLeftDrawable.setAlpha((int) (255 * leftAlpha)); + Theme.chat_gradientLeftDrawable.draw(canvas); } float rightAlpha = rightGradientAlpha.set(listView.canScrollHorizontally(1) ? 1f : 0f); if (rightAlpha > 0) { - rightGradient.setBounds((int) right - AndroidUtilities.dp(32), (int) top, (int) right, (int) bottom); - rightGradient.setAlpha((int) (255 * rightAlpha)); - rightGradient.draw(canvas); + Theme.chat_gradientRightDrawable.setBounds((int) right - AndroidUtilities.dp(32), (int) top, (int) right, (int) bottom); + Theme.chat_gradientRightDrawable.setAlpha((int) (255 * rightAlpha)); + Theme.chat_gradientRightDrawable.draw(canvas); } canvas.restore(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UnreadCounterTextView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UnreadCounterTextView.java index 40e23811c..b249327b2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UnreadCounterTextView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UnreadCounterTextView.java @@ -46,6 +46,8 @@ public class UnreadCounterTextView extends View { int counterColor; CharSequence lastText; + String textColorKey = Theme.key_chat_fieldOverlayText; + public UnreadCounterTextView(Context context) { super(context); textPaint.setTextSize(AndroidUtilities.dp(13)); @@ -202,7 +204,7 @@ public class UnreadCounterTextView extends View { @Override protected void onDraw(Canvas canvas) { Layout layout = textLayout; - int color = Theme.getColor(isEnabled() ? Theme.key_chat_fieldOverlayText : Theme.key_windowBackgroundWhiteGrayText, getResourceProvider()); + int color = Theme.getColor(isEnabled() ? textColorKey : Theme.key_windowBackgroundWhiteGrayText, getResourceProvider()); if (textColor != color) { layoutPaint.setColor(textColor = color); } @@ -218,8 +220,8 @@ public class UnreadCounterTextView extends View { if (getParent() != null) { int contentWidth = getMeasuredWidth(); int x = (getMeasuredWidth() - contentWidth) / 2; - if (rippleColor != Theme.getColor(Theme.key_chat_fieldOverlayText, getResourceProvider()) || selectableBackground == null) { - selectableBackground = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(60), 0, ColorUtils.setAlphaComponent(rippleColor = Theme.getColor(Theme.key_chat_fieldOverlayText, getResourceProvider()), 26)); + if (rippleColor != Theme.getColor(textColorKey, getResourceProvider()) || selectableBackground == null) { + selectableBackground = Theme.createSimpleSelectorCircleDrawable(AndroidUtilities.dp(60), 0, ColorUtils.setAlphaComponent(rippleColor = Theme.getColor(textColorKey, getResourceProvider()), 26)); selectableBackground.setCallback(this); } int start = (getLeft() + x) <= 0 ? x - AndroidUtilities.dp(20) : x; @@ -298,4 +300,9 @@ public class UnreadCounterTextView extends View { } } } + + public void setTextColorKey(String textColorKey) { + this.textColorKey = textColorKey; + invalidate(); + } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 1b9d41053..132bfbcc8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -2208,6 +2208,32 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. updateProxyButton(false, false); } searchItem = menu.addItem(0, R.drawable.ic_ab_search).setIsSearchField(true, true).setActionBarMenuItemSearchListener(new ActionBarMenuItem.ActionBarMenuItemSearchListener() { + boolean isSpeedItemCreated = false; + + @Override + public void onPreToggleSearch() { + if (!isSpeedItemCreated) { + isSpeedItemCreated = true; + FrameLayout searchContainer = (FrameLayout) searchItem.getSearchClearButton().getParent(); + speedItem = new ActionBarMenuItem(context, menu, Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); + speedItem.setIcon(R.drawable.avd_speed); + speedItem.getIconView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), PorterDuff.Mode.SRC_IN)); + speedItem.setTranslationX(AndroidUtilities.dp(32)); + speedItem.setAlpha(0f); + speedItem.setOnClickListener(v -> showDialog(new PremiumFeatureBottomSheet(DialogsActivity.this, PremiumPreviewFragment.PREMIUM_FEATURE_DOWNLOAD_SPEED, true))); + speedItem.setClickable(false); + speedItem.setFixBackground(true); + FrameLayout.LayoutParams speedParams = new FrameLayout.LayoutParams(AndroidUtilities.dp(42), ViewGroup.LayoutParams.MATCH_PARENT); + speedParams.leftMargin = speedParams.rightMargin = AndroidUtilities.dp(14 + 24); + speedParams.gravity = Gravity.RIGHT; + searchContainer.addView(speedItem, speedParams); + searchItem.setSearchAdditionalButton(speedItem); + + updateSpeedItem(searchViewPager.getCurrentPosition() == 2); + } + } + + @Override public void onSearchExpand() { searching = true; @@ -2313,20 +2339,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. return !actionBar.isActionModeShowed() && databaseMigrationHint == null; } }); - FrameLayout searchContainer = (FrameLayout) searchItem.getSearchClearButton().getParent(); - speedItem = new ActionBarMenuItem(context, menu, Theme.getColor(Theme.key_actionBarActionModeDefaultSelector), Theme.getColor(Theme.key_actionBarActionModeDefaultIcon)); - speedItem.setIcon(R.drawable.avd_speed); - speedItem.getIconView().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarActionModeDefaultIcon), PorterDuff.Mode.SRC_IN)); - speedItem.setTranslationX(AndroidUtilities.dp(32)); - speedItem.setAlpha(0f); - speedItem.setOnClickListener(v -> showDialog(new PremiumFeatureBottomSheet(this, PremiumPreviewFragment.PREMIUM_FEATURE_DOWNLOAD_SPEED, true))); - speedItem.setClickable(false); - speedItem.setFixBackground(true); - FrameLayout.LayoutParams speedParams = new FrameLayout.LayoutParams(AndroidUtilities.dp(42), ViewGroup.LayoutParams.MATCH_PARENT); - speedParams.leftMargin = speedParams.rightMargin = AndroidUtilities.dp(14 + 24); - speedParams.gravity = Gravity.RIGHT; - searchContainer.addView(speedItem, speedParams); - searchItem.setSearchAdditionalButton(speedItem); if (initialDialogsType == 2 || initialDialogsType == DIALOGS_TYPE_START_ATTACH_BOT) { searchItem.setVisibility(View.GONE); @@ -4308,15 +4320,19 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } public void updateSpeedItem(boolean visibleByPosition) { + if (speedItem == null) { + return; + } + boolean visibleByDownload = false; for (MessageObject obj : getDownloadController().downloadingFiles) { - if (obj.getDocument() != null && obj.getDocument().size >= 300 * 1024 * 1024) { + if (obj.getDocument() != null && obj.getDocument().size >= 150 * 1024 * 1024) { visibleByDownload = true; break; } } for (MessageObject obj : getDownloadController().recentDownloadingFiles) { - if (obj.getDocument() != null && obj.getDocument().size >= 300 * 1024 * 1024) { + if (obj.getDocument() != null && obj.getDocument().size >= 150 * 1024 * 1024) { visibleByDownload = true; break; } @@ -8851,6 +8867,14 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundBlue)); arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundPink)); arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundSaved)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundRed)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Orange)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Violet)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Green)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Cyan)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Blue)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Pink)); + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_background2Saved)); arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundArchived)); arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_avatar_backgroundArchivedHidden)); @@ -9237,6 +9261,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } + @Override + public INavigationLayout.BackButtonState getBackButtonState() { + return INavigationLayout.BackButtonState.MENU; + } + @Override public void setProgressToDrawerOpened(float progress) { if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_LOW || isSlideBackTransition) { @@ -9290,6 +9319,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. @Override public List onGetDebugItems() { return Arrays.asList( + new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugDialogsActivity)), new FloatingDebugController.DebugItem(LocaleController.getString(R.string.ClearLocalDatabase), () -> { getMessagesStorage().clearLocalDatabase(); Toast.makeText(getContext(), LocaleController.getString(R.string.DebugClearLocalDatabaseSuccess), Toast.LENGTH_SHORT).show(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java b/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java index 83e415ab6..79d334f82 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java @@ -135,7 +135,7 @@ public class DownloadProgressIcon extends View implements NotificationCenter.Not protected void onDetachedFromWindow() { super.onDetachedFromWindow(); detachCurrentListeners(); - NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.onDownloadingFilesChanged); + NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.onDownloadingFilesChanged); downloadImageReceiver.onDetachedFromWindow(); downloadCompleteImageReceiver.onDetachedFromWindow(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LNavigation/LNavigation.java b/TMessagesProj/src/main/java/org/telegram/ui/LNavigation/LNavigation.java index bd5f3bed3..ccc100497 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LNavigation/LNavigation.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LNavigation/LNavigation.java @@ -55,6 +55,7 @@ import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.BottomSheet; import org.telegram.ui.ActionBar.DrawerLayoutContainer; import org.telegram.ui.ActionBar.INavigationLayout; +import org.telegram.ui.ActionBar.MenuDrawable; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.Cells.CheckBoxCell; @@ -72,6 +73,7 @@ import java.util.Locale; public class LNavigation extends FrameLayout implements INavigationLayout, FloatingDebugProvider { private final static boolean ALLOW_OPEN_STIFFNESS_CONTROL = false; + private final static boolean USE_ACTIONBAR_CROSSFADE = false; private static float SPRING_STIFFNESS = 1000f; private static float SPRING_DAMPING_RATIO = 1f; private final static float SPRING_STIFFNESS_PREVIEW = 650f; @@ -225,6 +227,11 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float */ private Paint blurPaint = new Paint(Paint.DITHER_FLAG | Paint.ANTI_ALIAS_FLAG); + /** + * Back button drawable + */ + private MenuDrawable menuDrawable = new MenuDrawable(MenuDrawable.TYPE_DEFAULT); + /** * View that captured current touch input */ @@ -299,6 +306,8 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float dimmPaint.setColor(0x7a000000); setWillNotDraw(false); + menuDrawable.setRoundCap(); + int touchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); gestureDetector = new GestureDetectorCompat(context, new GestureDetector.SimpleOnGestureListener() { @Override @@ -360,6 +369,8 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float getChildAt(i).dispatchTouchEvent(e); } e.recycle(); + + invalidateActionBars(); } else { isSwipeDisallowed = true; } @@ -488,9 +499,6 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float } fragment.onTransitionAnimationStart(true, true); - if (bgFragment != null) { - bgFragment.onTransitionAnimationStart(false, true); - } FloatValueHolder valueHolder = new FloatValueHolder(swipeProgress * SPRING_MULTIPLIER); currentSpringAnimation = new SpringAnimation(valueHolder) @@ -501,16 +509,10 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float swipeProgress = value / SPRING_MULTIPLIER; invalidateTranslation(); fragment.onTransitionAnimationProgress(true, 1f - swipeProgress); - if (bgFragment != null) { - bgFragment.onTransitionAnimationProgress(false, 1f - swipeProgress); - } }); Runnable onEnd = ()->{ fragment.onTransitionAnimationEnd(true, true); fragment.prepareFragmentToSlide(true, false); - if (bgFragment != null) { - bgFragment.onTransitionAnimationEnd(false, true); - } swipeProgress = 0f; invalidateTranslation(); @@ -526,6 +528,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float } currentSpringAnimation = null; + invalidateActionBars(); }; currentSpringAnimation.addEndListener((animation, canceled, value, velocity) -> { if (animation == currentSpringAnimation) { @@ -539,6 +542,15 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float } } + private void invalidateActionBars() { + if (getLastFragment() != null && getLastFragment().getActionBar() != null) { + getLastFragment().getActionBar().invalidate(); + } + if (getBackgroundFragment() != null && getBackgroundFragment().getActionBar() != null) { + getBackgroundFragment().getActionBar().invalidate(); + } + } + private boolean processTouchEvent(MotionEvent ev) { int act = ev.getActionMasked(); if (isTransitionAnimationInProgress()) { @@ -688,6 +700,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float if (params.removeLast && prevFragment != null) { removeFragmentFromStack(prevFragment); } + invalidateActionBars(); }; if (animate) { if (!params.isFromDelay) { @@ -754,9 +767,6 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float } fragment.onTransitionAnimationStart(true, false); - if (prevFragment != null) { - prevFragment.onTransitionAnimationStart(false, true); - } customAnimation = fragment.onCustomTransitionAnimation(true, ()-> { customAnimation = null; @@ -770,7 +780,6 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float fragment.onBecomeFullyVisible(); if (prevFragment != null) { - prevFragment.onTransitionAnimationEnd(false, true); prevFragment.onBecomeFullyHidden(); } onFragmentOpened.run(); @@ -781,6 +790,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float return true; } + invalidateActionBars(); FloatValueHolder valueHolder = new FloatValueHolder(SPRING_MULTIPLIER); currentSpringAnimation = new SpringAnimation(valueHolder) .setSpring(new SpringForce(0f) @@ -803,7 +813,6 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float fragment.onBecomeFullyVisible(); if (prevFragment != null) { - prevFragment.onTransitionAnimationEnd(false, true); prevFragment.onBecomeFullyHidden(); prevFragment.setPaused(true); } @@ -904,6 +913,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float observeDebugItemsFromView(items, fragment.getFragmentView()); } if (ALLOW_OPEN_STIFFNESS_CONTROL) { + items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugAltNavigation))); items.add(new FloatingDebugController.DebugItem(LocaleController.getString(R.string.DebugAltNavigationToggleControls), () -> getStiffnessControl().setVisibility(getStiffnessControl().getVisibility() == VISIBLE ? GONE : VISIBLE))); } return items; @@ -1201,6 +1211,12 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float this.delegate = delegate; } + @Override + public boolean isActionBarInCrossfade() { + boolean crossfadeNoFragments = USE_ACTIONBAR_CROSSFADE && !isInPreviewMode() && (isSwipeInProgress() || isTransitionAnimationInProgress()) && customAnimation == null; + return crossfadeNoFragments && getLastFragment() != null && getLastFragment().isActionBarCrossfadeEnabled() && getBackgroundFragment() != null && getBackgroundFragment().isActionBarCrossfadeEnabled(); + } + @Override public void draw(Canvas canvas) { if (useAlphaAnimations) { @@ -1238,6 +1254,64 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float canvas.drawBitmap(previewFragmentSnapshot, 0, 0, blurPaint); canvas.restore(); } + + if (isActionBarInCrossfade()) { + BaseFragment foregroundFragment = getLastFragment(); + BaseFragment backgroundFragment = getBackgroundFragment(); + + ActionBar fgActionBar = foregroundFragment.getActionBar(); + ActionBar bgActionBar = backgroundFragment.getActionBar(); + + boolean useBackDrawable = false; + boolean backDrawableReverse = false; + Float backDrawableForcedProgress = null; + + if (backgroundFragment.getBackButtonState() == BackButtonState.MENU && foregroundFragment.getBackButtonState() == BackButtonState.BACK) { + useBackDrawable = true; + backDrawableReverse = false; + } else if (backgroundFragment.getBackButtonState() == BackButtonState.BACK && foregroundFragment.getBackButtonState() == BackButtonState.MENU) { + useBackDrawable = true; + backDrawableReverse = true; + } else if (backgroundFragment.getBackButtonState() == BackButtonState.BACK && foregroundFragment.getBackButtonState() == BackButtonState.BACK) { + useBackDrawable = true; + backDrawableForcedProgress = 0f; + } else if (backgroundFragment.getBackButtonState() == BackButtonState.MENU && foregroundFragment.getBackButtonState() == BackButtonState.MENU) { + useBackDrawable = true; + backDrawableForcedProgress = 1f; + } + + AndroidUtilities.rectTmp.set(0, 0, getWidth(), bgActionBar.getHeight()); + canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (swipeProgress * 0xFF), Canvas.ALL_SAVE_FLAG); + bgActionBar.onDrawCrossfadeBackground(canvas); + canvas.restore(); + + canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) ((1 - swipeProgress) * 0xFF), Canvas.ALL_SAVE_FLAG); + fgActionBar.onDrawCrossfadeBackground(canvas); + canvas.restore(); + + if (useBackDrawable) { + AndroidUtilities.rectTmp.set(0, 0, getWidth(), bgActionBar.getHeight()); + float progress = backDrawableForcedProgress != null ? backDrawableForcedProgress : swipeProgress; + float bgAlpha = 1f - (bgActionBar.getY() / -(bgActionBar.getHeight() - AndroidUtilities.statusBarHeight)); + float fgAlpha = 1f - (fgActionBar.getY() / -(fgActionBar.getHeight() - AndroidUtilities.statusBarHeight)); + canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (AndroidUtilities.lerp(bgAlpha, fgAlpha, 1f - swipeProgress) * 0xFF), Canvas.ALL_SAVE_FLAG); + canvas.translate(AndroidUtilities.dp(16) - AndroidUtilities.dp(2) * (1f - progress), AndroidUtilities.dp(16) + (fgActionBar.getOccupyStatusBar() ? AndroidUtilities.statusBarHeight : 0)); + menuDrawable.setRotation(backDrawableReverse ? progress : 1f - progress, false); + menuDrawable.draw(canvas); + canvas.restore(); + } + + AndroidUtilities.rectTmp.set(0, AndroidUtilities.statusBarHeight, getWidth(), bgActionBar.getHeight()); + canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) (swipeProgress * 0xFF), Canvas.ALL_SAVE_FLAG); + canvas.translate(0, bgActionBar.getY()); + bgActionBar.onDrawCrossfadeContent(canvas, false, useBackDrawable, swipeProgress); + canvas.restore(); + + canvas.saveLayerAlpha(AndroidUtilities.rectTmp, (int) ((1 - swipeProgress) * 0xFF), Canvas.ALL_SAVE_FLAG); + canvas.translate(0, fgActionBar.getY()); + fgActionBar.onDrawCrossfadeContent(canvas, true, useBackDrawable, swipeProgress); + canvas.restore(); + } } @Override @@ -1283,12 +1357,10 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float lastFragment.onTransitionAnimationStart(false, true); if (newLastFragment != null) { newLastFragment.setPaused(false); - newLastFragment.onTransitionAnimationStart(true, false); } if (swipeProgress == 0) { customAnimation = lastFragment.onCustomTransitionAnimation(false, () -> { - lastFragment.onTransitionAnimationEnd(false, true); onCloseAnimationEnd(lastFragment, newLastFragment); customAnimation = null; @@ -1351,7 +1423,6 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float if (newLastFragment != null) { newLastFragment.prepareFragmentToSlide(false, false); - newLastFragment.onTransitionAnimationEnd(true, true); newLastFragment.onBecomeFullyVisible(); } @@ -1372,6 +1443,7 @@ public class LNavigation extends FrameLayout implements INavigationLayout, Float blurredBackFragmentForPreview = null; } previewOpenCallback = null; + invalidateActionBars(); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index c1f1140f5..2111a3f6e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -1534,11 +1534,6 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati @SuppressLint("Range") private boolean handleIntent(Intent intent, boolean isNew, boolean restore, boolean fromPassword) { if (AndroidUtilities.handleProxyIntent(this, intent)) { - actionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - if (AndroidUtilities.isTablet()) { - layersActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - rightActionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST); - } return true; } if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 17569d6b7..07875af54 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1591,6 +1591,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } } + @Override + public boolean isActionBarCrossfadeEnabled() { + return false; + } + @Override public void onFragmentDestroy() { super.onFragmentDestroy(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java b/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java index 6bb01656e..6b87c86a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/TopicsFragment.java @@ -38,7 +38,6 @@ import androidx.collection.LongSparseArray; import androidx.core.content.ContextCompat; import androidx.core.graphics.ColorUtils; import androidx.recyclerview.widget.DefaultItemAnimator; -import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.ItemTouchHelper; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -55,6 +54,7 @@ import org.telegram.messenger.NotificationsController; import org.telegram.messenger.R; import org.telegram.messenger.SharedConfig; import org.telegram.messenger.TopicsController; +import org.telegram.messenger.UserConfig; import org.telegram.messenger.Utilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLObject; @@ -68,10 +68,16 @@ import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BackDrawable; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.Theme; +import org.telegram.ui.ActionBar.ThemeDescription; import org.telegram.ui.Adapters.FiltersView; import org.telegram.ui.Cells.DialogCell; +import org.telegram.ui.Cells.DrawerProfileCell; import org.telegram.ui.Cells.GraySectionCell; +import org.telegram.ui.Cells.HeaderCell; +import org.telegram.ui.Cells.HintDialogCell; +import org.telegram.ui.Cells.ProfileSearchCell; import org.telegram.ui.Cells.TopicSearchCell; +import org.telegram.ui.Cells.UserCell; import org.telegram.ui.Components.AlertsCreator; import org.telegram.ui.Components.AnimatedEmojiDrawable; import org.telegram.ui.Components.Bulletin; @@ -106,6 +112,8 @@ import java.util.Iterator; public class TopicsFragment extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, ChatActivityInterface { + private final static int BOTTOM_BUTTON_TYPE_JOIN = 0; + private final static int BOTTOM_BUTTON_TYPE_REPORT = 1; final long chatId; ArrayList forumTopics = new ArrayList<>(); @@ -145,6 +153,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N TLRPC.ChatFull chatFull; boolean canShowCreateTopic; private UnreadCounterTextView bottomOverlayChatText; + private int bottomButtonType; private RecyclerListView recyclerListView; private ItemTouchHelper itemTouchHelper; private ActionBarMenuSubItem createTopicSubmenu; @@ -203,6 +212,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N ValueAnimator slideBackTransitionAnimator; private FrameLayout topView; + private RLottieImageView floatingButton; public TopicsFragment(Bundle bundle) { super(bundle); @@ -468,7 +478,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N TLRPC.TL_forumTopic topic = topicsController.findTopic(chatId, list.get(i)); if (topic != null) { getMessagesController().markMentionsAsRead(-chatId, topic.id); - getMessagesController().markDialogAsRead(-chatId, topic.top_message, 0, topic.topMessage.date, false, topic.id, 0, true, 0); + getMessagesController().markDialogAsRead(-chatId, topic.top_message, 0, topic.topMessage != null ? topic.topMessage.date : 0, false, topic.id, 0, true, 0); getMessagesStorage().updateRepliesMaxReadId(chatId, topic.id, topic.top_message, 0, true); } } @@ -713,7 +723,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N }); } floatingButtonContainer.setBackground(drawable); - RLottieImageView floatingButton = new RLottieImageView(context); + floatingButton = new RLottieImageView(context); floatingButton.setImageResource(R.drawable.ic_chatlist_add_2); floatingButtonContainer.setContentDescription(LocaleController.getString("CreateTopic", R.string.CreateTopic)); @@ -745,7 +755,8 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N }; try { topicsEmptyView.stickerView.getImageReceiver().setAutoRepeat(2); - } catch (Exception ignore) {} + } catch (Exception ignore) { + } topicsEmptyView.showProgress(loadingTopics, fragmentBeginToShow); topicsEmptyView.title.setText(LocaleController.getString("NoTopics", R.string.NoTopics)); SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder("d"); @@ -778,33 +789,31 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N bottomOverlayChatText.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - joinToGroup(); + if (bottomButtonType == BOTTOM_BUTTON_TYPE_REPORT) { + AlertsCreator.showBlockReportSpamAlert(TopicsFragment.this, -chatId, null, getCurrentChat(), null, false, chatFull, param -> { + if (param == 0) { + updateChatInfo(); + } else { + finishFragment(); + } + }, getResourceProvider()); + } else { + joinToGroup(); + } } }); bottomOverlayProgress = new RadialProgressView(context, themeDelegate); bottomOverlayProgress.setSize(AndroidUtilities.dp(22)); - bottomOverlayProgress.setProgressColor(getThemedColor(Theme.key_chat_fieldOverlayText)); bottomOverlayProgress.setVisibility(View.INVISIBLE); bottomOverlayContainer.addView(bottomOverlayProgress, LayoutHelper.createFrame(30, 30, Gravity.CENTER)); updateChatInfo(); - bottomOverlayChatText.setBackground(Theme.createSelectorDrawable(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_chat_fieldOverlayText), 26), Theme.RIPPLE_MASK_ALL)); - floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY)); - bottomOverlayContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); - actionBar.setActionModeColor(Theme.getColor(Theme.key_windowBackgroundWhite)); - actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault)); searchContainer = new SearchContainer(context); searchContainer.setVisibility(View.GONE); contentView.addView(searchContainer); - EditTextBoldCursor editText = searchItem.getSearchField(); - - searchContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); -// editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); -// editText.setHintTextColor(Theme.getColor(Theme.key_player_time)); -// editText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor)); actionBar.setDrawBlurBackground(contentView); @@ -859,10 +868,23 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N bottomPannelVisible = true; updateChatInfo(); + updateColors(); return fragmentView; } + private void updateColors() { + if (bottomOverlayProgress == null) { + return; + } + bottomOverlayProgress.setProgressColor(getThemedColor(Theme.key_chat_fieldOverlayText)); + floatingButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionIcon), PorterDuff.Mode.MULTIPLY)); + bottomOverlayContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); + actionBar.setActionModeColor(Theme.getColor(Theme.key_windowBackgroundWhite)); + actionBar.setBackgroundColor(Theme.getColor(Theme.key_actionBarDefault)); + searchContainer.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite)); + } + private void openProfile(boolean byAvatar) { Bundle args = new Bundle(); args.putLong("chat_id", chatId); @@ -1266,6 +1288,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N unpinItem.setVisibility(canUnpinCount == 1 && canPinCount == 0 ? View.VISIBLE : View.GONE); } else { actionBar.hideActionMode(); + return; } selectedDialogsCountTextView.setNumber(selectedTopics.size(), true); @@ -1414,6 +1437,11 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N TLRPC.Chat chatLocal = getMessagesController().getChat(chatId); avatarContainer.setChatAvatar(chatLocal); + + SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount); + boolean showReport = preferences.getBoolean("dialog_bar_report" + (-chatId), false); + boolean showBlock = preferences.getBoolean("dialog_bar_block" + (-chatId), false); + if (!opnendForSelect) { if (chatLocal != null) { avatarContainer.setTitle(chatLocal.title); @@ -1447,6 +1475,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N bottomOverlayChatText.setEnabled(false); AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayProgress, false, 0.5f, animated); AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayChatText, true, 0.5f, animated); + setButtonType(BOTTOM_BUTTON_TYPE_JOIN); } else if (chatLocal != null && !opnendForSelect && (ChatObject.isNotInChat(chatLocal) || getMessagesController().isJoiningChannel(chatLocal.id))) { bottomPannelVisibleLocal = true; @@ -1465,6 +1494,17 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayProgress, showProgress, 0.5f, animated); AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayChatText, !showProgress, 0.5f, animated); + setButtonType(BOTTOM_BUTTON_TYPE_JOIN); + } else if (showBlock || showReport) { + bottomOverlayChatText.setText(LocaleController.getString("ReportSpamAndLeave", R.string.ReportSpamAndLeave)); + bottomOverlayChatText.setClickable(true); + bottomOverlayChatText.setEnabled(true); + + AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayProgress, false, 0.5f, false); + AndroidUtilities.updateViewVisibilityAnimated(bottomOverlayChatText, true, 0.5f, false); + + setButtonType(BOTTOM_BUTTON_TYPE_REPORT); + bottomPannelVisibleLocal = true; } else { bottomPannelVisibleLocal = false; } @@ -1496,6 +1536,13 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N groupCall = getMessagesController().getGroupCall(chatId, true); } + private void setButtonType(int bottomButtonType) { + if (this.bottomButtonType != bottomButtonType) { + this.bottomButtonType = bottomButtonType; + bottomOverlayChatText.setTextColorKey(bottomButtonType == BOTTOM_BUTTON_TYPE_JOIN ? Theme.key_chat_fieldOverlayText : Theme.key_chat_reportSpam); + } + } + private void updateSubtitle() { TLRPC.ChatFull chatFull = getMessagesController().getChatFull(chatId); if (this.chatFull != null && this.chatFull.participants != null) { @@ -2410,7 +2457,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N public void onTransitionAnimationStart(boolean isOpen, boolean backward) { super.onTransitionAnimationStart(isOpen, backward); - transitionAnimationIndex = getNotificationCenter().setAnimationInProgress(transitionAnimationIndex, new int[] {NotificationCenter.topicsDidLoaded}); + transitionAnimationIndex = getNotificationCenter().setAnimationInProgress(transitionAnimationIndex, new int[]{NotificationCenter.topicsDidLoaded}); transitionAnimationGlobalIndex = NotificationCenter.getGlobalInstance().setAnimationInProgress(transitionAnimationGlobalIndex, new int[0]); } @@ -2427,7 +2474,7 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N getNotificationCenter().onAnimationFinish(transitionAnimationIndex); NotificationCenter.getGlobalInstance().onAnimationFinish(transitionAnimationGlobalIndex); - if (!isOpen && (opnendForSelect || removeFragmentOnTransitionEnd)) { + if (!isOpen && (opnendForSelect && removeFragmentOnTransitionEnd)) { removeSelfFromStack(); if (dialogsActivity != null) { dialogsActivity.removeSelfFromStack(); @@ -2528,4 +2575,57 @@ public class TopicsFragment extends BaseFragment implements NotificationCenter.N public SizeNotifierFrameLayout getContentView() { return contentView; } + + @Override + public ArrayList getThemeDescriptions() { + ThemeDescription.ThemeDescriptionDelegate cellDelegate = () -> { + for (int b = 0; b < 2; b++) { + RecyclerListView list = null; + if (b == 0) { + list = recyclerListView; + } else if (searchContainer != null) { + list = searchContainer.recyclerView; + } + if (list == null) { + continue; + } + int count = list.getChildCount(); + for (int a = 0; a < count; a++) { + View child = list.getChildAt(a); + if (child instanceof ProfileSearchCell) { + ((ProfileSearchCell) child).update(0); + } else if (child instanceof DialogCell) { + ((DialogCell) child).update(0); + } else if (child instanceof UserCell) { + ((UserCell) child).update(0); + } + } + } + if (actionBar != null) { + actionBar.setPopupBackgroundColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuBackground), true); + actionBar.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem), false, true); + actionBar.setPopupItemsColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItemIcon), true, true); + actionBar.setPopupItemsSelectorColor(Theme.getColor(Theme.key_dialogButtonSelector), true); + } + if (blurredView != null) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + blurredView.setForeground(new ColorDrawable(ColorUtils.setAlphaComponent(getThemedColor(Theme.key_windowBackgroundWhite), 100))); + } + } + updateColors(); + }; + + ArrayList arrayList = new ArrayList<>(); + + arrayList.add(new ThemeDescription(null, 0, null, null, null, cellDelegate, Theme.key_windowBackgroundWhite)); + arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault)); + arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon)); + arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle)); + arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector)); + + if (searchContainer != null && searchContainer.recyclerView != null) { + GraySectionCell.createThemeDescriptions(arrayList, searchContainer.recyclerView); + } + return arrayList; + } } diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index d716c6181..fe6b7c60e 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -5735,7 +5735,7 @@ Enable floating debug Disable floating debug Cleared local database. - Toggle navigation stiffness controls + Toggle stiffness controls Clear Send Message As... peers Switch sharing alert dialogs mode (%1$s) Normal @@ -5781,4 +5781,11 @@ Make the caption shorter or subscribe to *Telegram Premium* to double the limit to **%1$s** characters. Make the caption shorter or subscribe to *Telegram Premium* to double the limit to **%1$s** characters. All Chats + Share Alert + Dialogs Activity + Message Skeletons + Light overlay alpha + Saturation + Alternative navigation + General diff --git a/TMessagesProj_App/build.gradle b/TMessagesProj_App/build.gradle index 55e3189df..62ecb8b93 100644 --- a/TMessagesProj_App/build.gradle +++ b/TMessagesProj_App/build.gradle @@ -21,20 +21,9 @@ dependencies { implementation files('../TMessagesProj/libs/libgsaverification-client.aar') } -def getProps(String propName) { - def propsFile = rootProject.file('local.properties') - if (propsFile.exists()) { - def props = new Properties() - props.load(new FileInputStream(propsFile)) - return props[propName] - } else { - return "" - } -} - android { - compileSdkVersion 31 - buildToolsVersion '31.0.0' + compileSdkVersion 33 + buildToolsVersion '33.0.0' defaultConfig.applicationId = APP_PACKAGE @@ -186,8 +175,8 @@ android { } defaultConfig { - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion 19 + targetSdkVersion 31 versionName APP_VERSION_NAME ndkVersion "21.4.7075529" diff --git a/TMessagesProj_App/src/main/AndroidManifest.xml b/TMessagesProj_App/src/main/AndroidManifest.xml index 0e501a7e8..bbc327df1 100644 --- a/TMessagesProj_App/src/main/AndroidManifest.xml +++ b/TMessagesProj_App/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ android:installLocation="auto"> - + diff --git a/TMessagesProj_AppHockeyApp/build.gradle b/TMessagesProj_AppHockeyApp/build.gradle index 1c213becd..d055126a9 100644 --- a/TMessagesProj_AppHockeyApp/build.gradle +++ b/TMessagesProj_AppHockeyApp/build.gradle @@ -25,8 +25,8 @@ dependencies { } android { - compileSdkVersion 31 - buildToolsVersion '31.0.0' + compileSdkVersion 33 + buildToolsVersion '33.0.0' defaultConfig.applicationId = APP_PACKAGE @@ -142,8 +142,8 @@ android { } defaultConfig { - minSdkVersion 16 - targetSdkVersion 30 + minSdkVersion 19 + targetSdkVersion 31 versionName APP_VERSION_NAME ndkVersion "21.4.7075529" diff --git a/TMessagesProj_AppHockeyApp/src/main/AndroidManifest.xml b/TMessagesProj_AppHockeyApp/src/main/AndroidManifest.xml index 0e501a7e8..ed5db2290 100644 --- a/TMessagesProj_AppHockeyApp/src/main/AndroidManifest.xml +++ b/TMessagesProj_AppHockeyApp/src/main/AndroidManifest.xml @@ -5,7 +5,7 @@ android:installLocation="auto"> - + @@ -15,5 +15,31 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/TMessagesProj_AppHuawei/build.gradle b/TMessagesProj_AppHuawei/build.gradle index 9589d9b8c..b9ac4c354 100644 --- a/TMessagesProj_AppHuawei/build.gradle +++ b/TMessagesProj_AppHuawei/build.gradle @@ -29,8 +29,8 @@ dependencies { } android { - compileSdkVersion 31 - buildToolsVersion '31.0.0' + compileSdkVersion 33 + buildToolsVersion '33.0.0' defaultConfig.applicationId = APP_PACKAGE @@ -137,7 +137,7 @@ android { defaultConfig { minSdkVersion 19 - targetSdkVersion 30 + targetSdkVersion 31 versionName APP_VERSION_NAME ndkVersion "21.4.7075529" diff --git a/TMessagesProj_AppHuawei/src/main/AndroidManifest.xml b/TMessagesProj_AppHuawei/src/main/AndroidManifest.xml index 942a9fc68..bc567a7d9 100644 --- a/TMessagesProj_AppHuawei/src/main/AndroidManifest.xml +++ b/TMessagesProj_AppHuawei/src/main/AndroidManifest.xml @@ -11,7 +11,7 @@ - + diff --git a/gradle.properties b/gradle.properties index fc2d4f3d9..550457674 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_NAME=9.1.3 -APP_VERSION_CODE=2917 +APP_VERSION_NAME=9.1.4 +APP_VERSION_CODE=2927 APP_PACKAGE=org.telegram.messenger RELEASE_KEY_PASSWORD=TelegramAndroidPswd RELEASE_KEY_ALIAS=tmessages