Skip to content

Commit

Permalink
update to 10.0.4 (3802)
Browse files Browse the repository at this point in the history
  • Loading branch information
xaxtix committed Aug 25, 2023
1 parent 702839a commit 534f9f6
Show file tree
Hide file tree
Showing 22 changed files with 229 additions and 81 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5460,4 +5460,12 @@ public static ByteBuffer cloneByteBuffer(ByteBuffer original) {
clone.position(position);
return clone;
}

public static void checkAndroidTheme(Context context, boolean open) {
// this hack is done to support prefers-color-scheme in webviews 🤦
if (context == null) {
return;
}
context.setTheme(Theme.isCurrentThemeDark() && open ? R.style.Theme_TMessages_Dark : R.style.Theme_TMessages);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 3801;
public static String BUILD_VERSION_STRING = "10.0.3";
public static int BUILD_VERSION = 3802;
public static String BUILD_VERSION_STRING = "10.0.4";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
private Runnable searchRunnable;
private Runnable searchRunnable2;
private ArrayList<Object> searchResult = new ArrayList<>();
private ArrayList<ContactsController.Contact> searchContacts = new ArrayList<>();
private ArrayList<TLRPC.TL_forumTopic> searchTopics = new ArrayList<>();
private final ArrayList<ContactsController.Contact> searchContacts = new ArrayList<>();
private final ArrayList<TLRPC.TL_forumTopic> searchTopics = new ArrayList<>();
private ArrayList<CharSequence> searchResultNames = new ArrayList<>();
private ArrayList<MessageObject> searchForumResultMessages = new ArrayList<>();
private ArrayList<MessageObject> searchResultMessages = new ArrayList<>();
private ArrayList<String> searchResultHashtags = new ArrayList<>();
private final ArrayList<MessageObject> searchForumResultMessages = new ArrayList<>();
private final ArrayList<MessageObject> searchResultMessages = new ArrayList<>();
private final ArrayList<String> searchResultHashtags = new ArrayList<>();
private String lastSearchText;
private boolean searchWas;
private int reqId = 0;
Expand Down Expand Up @@ -111,12 +111,13 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter {
public View showMoreHeader;
private Runnable cancelShowMoreAnimation;
private ArrayList<Long> filterDialogIds;
private final DialogsActivity dialogsActivity;

private int currentAccount = UserConfig.selectedAccount;

private ArrayList<RecentSearchObject> recentSearchObjects = new ArrayList<>();
private ArrayList<RecentSearchObject> filteredRecentSearchObjects = new ArrayList<>();
private ArrayList<RecentSearchObject> filtered2RecentSearchObjects = new ArrayList<>();
private final ArrayList<RecentSearchObject> filteredRecentSearchObjects = new ArrayList<>();
private final ArrayList<RecentSearchObject> filtered2RecentSearchObjects = new ArrayList<>();
private String filteredRecentQuery = null;
private LongSparseArray<RecentSearchObject> recentSearchObjectsById = new LongSparseArray<>();
private ArrayList<FiltersView.DateData> localTipDates = new ArrayList<>();
Expand Down Expand Up @@ -220,9 +221,38 @@ public int getItemCount() {
}
}

public DialogsSearchAdapter(Context context, int messagesSearch, int type, DefaultItemAnimator itemAnimator, boolean allowGlobalSearch) {
private boolean filter(Object obj) {
if (dialogsType != DialogsActivity.DIALOGS_TYPE_START_ATTACH_BOT) {
return true;
}
// add more filters if needed
if (obj instanceof TLRPC.User) {
if (((TLRPC.User) obj).bot) {
return dialogsActivity.allowBots;
}
return dialogsActivity.allowUsers;
} else if (obj instanceof TLRPC.Chat) {
TLRPC.Chat chat = (TLRPC.Chat) obj;
if (ChatObject.isChannel(chat)) {
return dialogsActivity.allowChannels;
} else if (ChatObject.isMegagroup(chat)) {
return dialogsActivity.allowGroups || dialogsActivity.allowMegagroups;
} else {
return dialogsActivity.allowGroups || dialogsActivity.allowLegacyGroups;
}
}
return false;
}

public DialogsSearchAdapter(Context context, DialogsActivity dialogsActivity, int messagesSearch, int type, DefaultItemAnimator itemAnimator, boolean allowGlobalSearch) {
this.itemAnimator = itemAnimator;
searchAdapterHelper = new SearchAdapterHelper(false);
this.dialogsActivity = dialogsActivity;
searchAdapterHelper = new SearchAdapterHelper(false) {
@Override
protected boolean filter(TLObject obj) {
return DialogsSearchAdapter.this.filter(obj);
}
};
searchAdapterHelper.setDelegate(new SearchAdapterHelper.SearchAdapterHelperDelegate() {
@Override
public void onDataSetChanged(int searchId) {
Expand Down Expand Up @@ -872,6 +902,12 @@ private void updateSearchResults(final ArrayList<Object> result, final ArrayList
searchResultMessages.clear();
}
searchWas = true;
for (int i = 0; i < result.size(); ++i) {
if (!filter(result.get(i))) {
result.remove(i);
i--;
}
}
final int recentCount = filtered2RecentSearchObjects.size();
for (int a = 0; a < result.size(); a++) {
Object obj = result.get(a);
Expand Down Expand Up @@ -1092,7 +1128,7 @@ public void searchDialogs(String text, int folderId) {

public int getRecentItemsCount() {
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
return (!recent.isEmpty() ? recent.size() + 1 : 0) + (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
return (!recent.isEmpty() ? recent.size() + 1 : 0) + (hasHints() ? 1 : 0);
}

public int getRecentResultsCount() {
Expand Down Expand Up @@ -1175,7 +1211,7 @@ public Object getItem(int i) {
}
}
if (isRecentSearchDisplayed()) {
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
int offset = (hasHints() ? 1 : 0);
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
if (i > offset && i - 1 - offset < recent.size()) {
TLObject object = recent.get(i - 1 - offset).object;
Expand Down Expand Up @@ -1263,7 +1299,7 @@ public boolean isGlobalSearch(int i) {
return false;
}
if (isRecentSearchDisplayed()) {
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
int offset = (hasHints() ? 1 : 0);
ArrayList<RecentSearchObject> recent = searchWas ? filtered2RecentSearchObjects : filteredRecentSearchObjects;
if (i > offset && i - 1 - offset < recent.size()) {
return false;
Expand Down Expand Up @@ -1413,6 +1449,10 @@ public boolean supportsPredictiveItemAnimations() {
return new RecyclerListView.Holder(view);
}

private boolean hasHints() {
return !searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() && (dialogsType != DialogsActivity.DIALOGS_TYPE_START_ATTACH_BOT || dialogsActivity.allowUsers);
}

@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
switch (holder.getItemViewType()) {
Expand Down Expand Up @@ -1564,7 +1604,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
} else {
int rawPosition = position;
if (isRecentSearchDisplayed() || !searchTopics.isEmpty() || !searchContacts.isEmpty()) {
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
int offset = hasHints() ? 1 : 0;
if (position < offset) {
cell.setText(LocaleController.getString("ChatHints", R.string.ChatHints));
return;
Expand Down Expand Up @@ -1768,7 +1808,7 @@ public int getItemViewType(int i) {
return i == 0 ? VIEW_TYPE_GRAY_SECTION : VIEW_TYPE_HASHTAG_CELL;
}
if (isRecentSearchDisplayed()) {
int offset = (!searchWas && !MediaDataController.getInstance(currentAccount).hints.isEmpty() ? 1 : 0);
int offset = hasHints() ? 1 : 0;
if (i < offset) {
return VIEW_TYPE_CATEGORY_LIST;
}
Expand Down Expand Up @@ -1889,7 +1929,7 @@ public void filterRecent(String query) {
filteredRecentSearchObjects.clear();
final int count = recentSearchObjects.size();
for (int i = 0; i < count; ++i) {
if (delegate != null && delegate.getSearchForumDialogId() == recentSearchObjects.get(i).did) {
if (delegate != null && delegate.getSearchForumDialogId() == recentSearchObjects.get(i).did || !filter(recentSearchObjects.get(i).object)) {
continue;
}
filteredRecentSearchObjects.add(recentSearchObjects.get(i));
Expand All @@ -1903,7 +1943,7 @@ public void filterRecent(String query) {
if (obj == null || obj.object == null) {
continue;
}
if (delegate != null && delegate.getSearchForumDialogId() == obj.did) {
if (delegate != null && delegate.getSearchForumDialogId() == obj.did || !filter(recentSearchObjects.get(i).object)) {
continue;
}
String title = null, username = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ default boolean canApplySearchResults(int searchId) {

private SearchAdapterHelperDelegate delegate;

private ArrayList<Integer> pendingRequestIds = new ArrayList<>();
private final ArrayList<Integer> pendingRequestIds = new ArrayList<>();
private String lastFoundUsername = null;
private ArrayList<TLObject> localServerSearch = new ArrayList<>();
private ArrayList<TLObject> globalSearch = new ArrayList<>();
private LongSparseArray<TLObject> globalSearchMap = new LongSparseArray<>();
private ArrayList<TLObject> groupSearch = new ArrayList<>();
private LongSparseArray<TLObject> groupSearchMap = new LongSparseArray<>();
private LongSparseArray<TLObject> phoneSearchMap = new LongSparseArray<>();
private ArrayList<Object> phonesSearch = new ArrayList<>();
private final ArrayList<TLObject> localServerSearch = new ArrayList<>();
private final ArrayList<TLObject> globalSearch = new ArrayList<>();
private final LongSparseArray<TLObject> globalSearchMap = new LongSparseArray<>();
private final ArrayList<TLObject> groupSearch = new ArrayList<>();
private final LongSparseArray<TLObject> groupSearchMap = new LongSparseArray<>();
private final LongSparseArray<TLObject> phoneSearchMap = new LongSparseArray<>();
private final ArrayList<Object> phonesSearch = new ArrayList<>();
private ArrayList<Object> localSearchResults;
private ArrayList<DialogsSearchAdapter.RecentSearchObject> localRecentResults;

Expand Down Expand Up @@ -223,13 +223,13 @@ public void queryServerSearch(String query, boolean allowUsername, boolean allow
chat = chatsMap.get(peer.channel_id);
}
if (chat != null) {
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat) || !allowGlobalResults && ChatObject.isNotInChat(chat)) {
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat) || !allowGlobalResults && ChatObject.isNotInChat(chat) || !filter(chat)) {
continue;
}
globalSearch.add(chat);
globalSearchMap.put(-chat.id, chat);
} else if (user != null) {
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self || !allowGlobalResults && b == 1 && !user.contact) {
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self || !allowGlobalResults && b == 1 && !user.contact || !filter(user)) {
continue;
}
globalSearch.add(user);
Expand All @@ -250,13 +250,13 @@ public void queryServerSearch(String query, boolean allowUsername, boolean allow
chat = chatsMap.get(peer.channel_id);
}
if (chat != null) {
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat) || -chat.id == exceptDialogId) {
if (!allowChats || canAddGroupsOnly && !ChatObject.canAddBotsToChat(chat) || -chat.id == exceptDialogId || !filter(chat)) {
continue;
}
localServerSearch.add(chat);
globalSearchMap.put(-chat.id, chat);
} else if (user != null) {
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self || user.id == exceptDialogId) {
if (canAddGroupsOnly || !allowBots && user.bot || !allowSelf && user.self || user.id == exceptDialogId || !filter(user)) {
continue;
}
localServerSearch.add(user);
Expand Down Expand Up @@ -625,4 +625,8 @@ public void setHashtags(ArrayList<HashtagObject> arrayList, HashMap<String, Hash
hashtagsLoadedFromDb = true;
delegate.onSetHashtags(arrayList, hashMap);
}

protected boolean filter(TLObject obj) {
return true;
}
}
20 changes: 11 additions & 9 deletions TMessagesProj/src/main/java/org/telegram/ui/ArticleViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11591,7 +11591,7 @@ private ImageReceiver getImageReceiverView(View view, TLRPC.PageBlock pageBlock,
BlockVideoCell cell = (BlockVideoCell) view;
if (cell.currentBlock == pageBlock) {
view.getLocationInWindow(coords);
if (cell == currentPlayer && videoPlayer != null && videoPlayer.firstFrameRendered) {
if (cell == currentPlayer && videoPlayer != null && videoPlayer.firstFrameRendered && cell.textureView.getSurfaceTexture() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Surface surface = new Surface(cell.textureView.getSurfaceTexture());
Bitmap bitmap = Bitmap.createBitmap(cell.textureView.getMeasuredWidth(), cell.textureView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
Expand Down Expand Up @@ -11651,14 +11651,16 @@ public void onReleasePlayerBeforeClose(int photoIndex) {
videoCell.playFrom = player.getCurrentPosition();
videoCell.firstFrameRendered = false;
videoCell.textureView.setAlpha(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Surface surface = new Surface(textureView.getSurfaceTexture());
Bitmap bitmap = Bitmap.createBitmap(textureView.getMeasuredWidth(), textureView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
AndroidUtilities.getBitmapFromSurface(surface, bitmap);
surface.release();
videoCell.imageView.setImageBitmap(bitmap);
} else {
videoCell.imageView.setImageBitmap(textureView.getBitmap());
if (textureView.getSurfaceTexture() != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
Surface surface = new Surface(textureView.getSurfaceTexture());
Bitmap bitmap = Bitmap.createBitmap(textureView.getMeasuredWidth(), textureView.getMeasuredHeight(), Bitmap.Config.ARGB_8888);
AndroidUtilities.getBitmapFromSurface(surface, bitmap);
surface.release();
videoCell.imageView.setImageBitmap(bitmap);
} else {
videoCell.imageView.setImageBitmap(textureView.getBitmap());
}
}
}
checkVideoPlayer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ public void setText(CharSequence text, BufferType type) {
updateTextColor();
}

public void allowMultiline() {
textView.setLines(3);
textView.setMaxLines(3);
textView.setSingleLine(false);
}

public void updateTextColor() {
textView.setTextColor(getThemedColor(currentType == TYPE_CHECK_BOX_DEFAULT || currentType == TYPE_CHECK_BOX_URL ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
textView.setLinkTextColor(getThemedColor(currentType == TYPE_CHECK_BOX_DEFAULT || currentType == TYPE_CHECK_BOX_URL ? Theme.key_dialogTextLink : Theme.key_windowBackgroundWhiteLinkText));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
allowWrite.set(true);

cell[0] = new CheckBoxCell(context, 1, fragment.getResourceProvider());
cell[0].allowMultiline();
cell[0].setBackgroundDrawable(Theme.getSelectorDrawable(false));
cell[0].setText(AndroidUtilities.replaceTags(LocaleController.formatString("OpenUrlOption2", R.string.OpenUrlOption2, UserObject.getUserName(user))), "", true, false);
cell[0].setPadding(LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(8), 0, LocaleController.isRTL ? AndroidUtilities.dp(8) : AndroidUtilities.dp(16), 0);
Expand Down
Loading

0 comments on commit 534f9f6

Please sign in to comment.