Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Emoji: Part 1 #433

Merged
merged 113 commits into from Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
3bc8094
Custom Emoji: Pre-Alpha
Arseny271 Aug 18, 2023
1af00f1
Fixes
Arseny271 Aug 19, 2023
bf2993a
Inline Search: Emoji Suggestion - main logic
Arseny271 Aug 19, 2023
c90854c
Inline Emoji Suggestions
Arseny271 Aug 20, 2023
7960837
Fixes
Arseny271 Aug 20, 2023
b44c5c7
Large emoji packs
Arseny271 Aug 20, 2023
160f3b6
Fixes
Arseny271 Aug 20, 2023
96a5dd8
EmojiToneHelper Update
Arseny271 Aug 21, 2023
18b9601
Fixes
Arseny271 Aug 21, 2023
1a04d53
Fixes
Arseny271 Aug 21, 2023
8f5d657
Fixes
Arseny271 Aug 21, 2023
6515ef4
Fixes
Arseny271 Aug 22, 2023
4033f1c
Reaction Avatars (non-animated)
Arseny271 Aug 22, 2023
514502e
Support custom font sizes
Arseny271 Aug 22, 2023
1305536
Fixes
Arseny271 Aug 23, 2023
c5712ca
Update Emoji.java
Arseny271 Aug 23, 2023
72e904f
Fixes 23.08.23
Arseny271 Aug 23, 2023
5d778d2
Fixes
Arseny271 Aug 23, 2023
6abd0d5
Update StickerSetWrap.java
Arseny271 Aug 23, 2023
4a0dffb
Scroll fix
Arseny271 Aug 24, 2023
a7a8c22
Theme Invalidate fixes
Arseny271 Aug 24, 2023
e4ba851
Fixes
Arseny271 Aug 24, 2023
46e2da0
Fixes
Arseny271 Aug 24, 2023
2f65d81
Search stickers/emoji packs in settings v1
Arseny271 Aug 24, 2023
2536f6c
Fixes
Arseny271 Aug 25, 2023
e76c407
Update InlineSearchContext.java
Arseny271 Aug 25, 2023
2f9169a
Fixes
Arseny271 Aug 25, 2023
66215d7
Code improvements
Arseny271 Aug 26, 2023
b93554b
Update MessagesController.java
Arseny271 Aug 26, 2023
82274af
Update
Arseny271 Aug 26, 2023
482990d
Fixes
Arseny271 Aug 26, 2023
a82f287
Fixes
Arseny271 Aug 26, 2023
256a14f
Avatar reaction animated
Arseny271 Aug 26, 2023
0978a4d
Update StickersController.java
Arseny271 Aug 27, 2023
2b05864
Fixes
Arseny271 Aug 27, 2023
2839d73
Fixes
Arseny271 Aug 27, 2023
a266c40
Update strings.xml
Arseny271 Aug 27, 2023
b30e1c7
Grouping reactions in reactions list
Arseny271 Aug 27, 2023
83e15c0
Fixes
Arseny271 Aug 28, 2023
8808857
Update
Arseny271 Aug 28, 2023
bf8f485
Update SettingsStickersController.java
Arseny271 Aug 28, 2023
ce63311
Revert "Update"
Arseny271 Aug 28, 2023
c90e755
Update StickersController.java
Arseny271 Aug 28, 2023
90cc44c
Fixes
Arseny271 Aug 28, 2023
6c10059
Fixes
Arseny271 Aug 28, 2023
32e9d90
Fix
Arseny271 Aug 28, 2023
99c3c80
Merge branch 'main' into custom-emoji
vkryl Aug 28, 2023
e14c964
Fixes
Arseny271 Aug 29, 2023
c30bf2c
Merge branch 'custom-emoji' of https://github.com/Arseny271/Telegram-…
Arseny271 Aug 29, 2023
98b0116
Update StickersController.java
Arseny271 Aug 29, 2023
4c96cd3
Fixes
Arseny271 Aug 29, 2023
fc43ff1
Update MessagesController.java
Arseny271 Aug 29, 2023
f6d5fe1
Fixes
Arseny271 Aug 29, 2023
a5463d5
Update ReactionsSelectorRecyclerView.java
Arseny271 Aug 30, 2023
b272dbb
Fixes
Arseny271 Aug 30, 2023
91d39d8
allowMedia
Arseny271 Aug 31, 2023
5425a27
Revert TGReactions.java
Arseny271 Aug 31, 2023
dbb1463
Update EmojiListController.java
Arseny271 Aug 31, 2023
de35d8a
Crash fix
Arseny271 Sep 1, 2023
5a2ef5b
Update StickerPreviewView.java
Arseny271 Sep 1, 2023
c864205
Fixes
Arseny271 Sep 1, 2023
2e5056f
Merge branch 'TGX-Android:main' into custom-emoji
Arseny271 Sep 1, 2023
5f38042
Update StickerPreviewView.java
Arseny271 Sep 1, 2023
ce706a8
Fixes
Arseny271 Sep 2, 2023
62422c3
Update StickerPreviewView.java
Arseny271 Sep 2, 2023
0beec26
Update BaseActivity.java
Arseny271 Sep 2, 2023
008e53d
Update
Arseny271 Sep 3, 2023
8094742
Update
Arseny271 Sep 3, 2023
b7f0744
Update
Arseny271 Sep 3, 2023
ff0075d
Update StickerSuggestionsProvider.java
Arseny271 Sep 3, 2023
e5cc592
Fixes
Arseny271 Sep 3, 2023
7b9903b
Update StickersSuggestionsLayout.java
Arseny271 Sep 3, 2023
5b7c918
Merge branch 'TGX-Android:main' into custom-emoji
Arseny271 Sep 4, 2023
8b8c2b7
Fixes
Arseny271 Sep 4, 2023
a29caca
Update EmojiLayoutRecyclerController.java
Arseny271 Sep 4, 2023
e0f505b
Update EmojiToneListView.java
Arseny271 Sep 4, 2023
018b9dc
Update EmojiToneHelper.java
Arseny271 Sep 4, 2023
750ebab
Update EmojiToneHelper.java
Arseny271 Sep 4, 2023
b8654f4
Update EmojiToneListView.java
Arseny271 Sep 4, 2023
c4f8251
Fix
Arseny271 Sep 4, 2023
7738e10
Move all `t.me` url creation to `Tdlib` context
vkryl Sep 4, 2023
1e30e82
Code style: added missing space before `:` in ternary operator
vkryl Sep 4, 2023
87565f4
Added copyright
vkryl Sep 4, 2023
2a5f628
Fixes
Arseny271 Sep 4, 2023
427a0b3
Update EmojiToneHelper.java
Arseny271 Sep 4, 2023
ecb378d
Update MessagesController.java
Arseny271 Sep 4, 2023
34b878f
Update EmojiToneHelper.java
Arseny271 Sep 4, 2023
741e102
Reworked loading custom emoji suggestsions when holding emoji in the …
vkryl Sep 4, 2023
f5bd1ef
Fix order in recommended stickers
Arseny271 Sep 5, 2023
8d7bfbf
Code style: missing space before `:` in ternary operator
vkryl Sep 5, 2023
742d3a4
Code style: missing space before `:` in foreach statements
vkryl Sep 6, 2023
55ff900
Do not enter long-press if there are no custom emoji suggestions or c…
vkryl Sep 6, 2023
7f094dc
Crushfix
Arseny271 Sep 6, 2023
9925d12
Fixex
Arseny271 Sep 6, 2023
4f7bbe7
Update TGAvatars.java
Arseny271 Sep 7, 2023
6d55952
Update TGUser.java
Arseny271 Sep 10, 2023
2d8d180
Avoid array allocations in `MessagesController.getInputCursorOffset`
vkryl Sep 12, 2023
858b779
Use `Views.save` and `Views.restore` in `StickerSmallView`
vkryl Sep 12, 2023
bcc1ee0
Reworked `StickerSetWrap` progress logic
vkryl Sep 12, 2023
68d17eb
Merge branch 'main' into custom-emoji
vkryl Sep 12, 2023
3fc0e03
Revert `StickerSetWrap.setInProgress`
vkryl Sep 12, 2023
f1b268d
Code style: missing space before `?` in ternary operator
vkryl Sep 12, 2023
1fefdee
Optimized imports
vkryl Sep 12, 2023
e485207
Optimized `Emoji.extractSingleEmoji`
vkryl Sep 12, 2023
8e828c1
Added `Emojis.MAX_EMOJI_LENGTH` & `Emoji.findPrecedingEmojiSpan`
vkryl Sep 12, 2023
34e11ae
Update StickersListController.java
Arseny271 Sep 12, 2023
18e270e
Merge branch 'custom-emoji' of https://github.com/Arseny271/Telegram-…
Arseny271 Sep 12, 2023
6bb6274
Fix
Arseny271 Sep 12, 2023
1268a09
Update InputView.java
Arseny271 Sep 12, 2023
863ec33
Cleanup `EmojiSpan` from replaced text
vkryl Sep 12, 2023
8eea6a9
Optimized detecting emoji preceding the cursor
vkryl Sep 12, 2023
42ee493
Remove `ComplexReceiver` from `DrawModifier` interface
vkryl Sep 12, 2023
897f112
Optimized imports
vkryl Sep 12, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 76 additions & 2 deletions app/src/main/java/org/thunderdog/challegram/BaseActivity.java
Expand Up @@ -62,6 +62,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.SparseArrayCompat;
import androidx.recyclerview.widget.RecyclerView;

import org.drinkless.tdlib.TdApi;
import org.drinkmore.Tracer;
Expand Down Expand Up @@ -130,6 +131,7 @@
import org.thunderdog.challegram.widget.ForceTouchView;
import org.thunderdog.challegram.widget.NetworkStatusBarView;
import org.thunderdog.challegram.widget.PopupLayout;
import org.thunderdog.challegram.widget.StickersSuggestionsLayout;

import java.lang.ref.Reference;
import java.util.ArrayList;
Expand Down Expand Up @@ -235,6 +237,16 @@ public void addToRoot (View view, boolean ignoreStatusBar) {
if (tooltipIndex != -1) {
i = i == -1 ? tooltipIndex : Math.min(tooltipIndex, i);
}

if (view == inlineResultsView) {
View customEmojiSuggestonsView = rootView.findViewById(R.id.view_customEmojiSuggestions);
int customEmojiSuggestionsIndex = customEmojiSuggestonsView != null ?
rootView.indexOfChild(customEmojiSuggestonsView) : -1;
if (customEmojiSuggestionsIndex != -1) {
i = i == -1 ? customEmojiSuggestionsIndex : Math.min(customEmojiSuggestionsIndex, i);
}
}

if (i != -1) {
rootView.addView(view, i);
} else {
Expand Down Expand Up @@ -1946,9 +1958,13 @@ public void closeForceTouch () {

// Inline results

private StickersSuggestionsLayout emojiSuggestionsWrap;
private InlineResultsWrap inlineResultsView;

public void updateHackyOverlaysPositions () {
if (emojiSuggestionsWrap != null && emojiSuggestionsWrap.getParent() != null) {
emojiSuggestionsWrap.updatePosition(true);
}
if (inlineResultsView != null && inlineResultsView.getParent() != null) {
inlineResultsView.updatePosition(true);
}
Expand All @@ -1962,6 +1978,10 @@ public void updateHackyOverlaysPositions () {
}

public void showInlineResults (ViewController<?> context, Tdlib tdlib, @Nullable ArrayList<InlineResult<?>> results, boolean needBackground, @Nullable InlineResultsWrap.LoadMoreCallback callback) {
showInlineResults(context, tdlib, results, needBackground, callback, null, null);
}

public void showInlineResults (ViewController<?> context, Tdlib tdlib, @Nullable ArrayList<InlineResult<?>> results, boolean needBackground, @Nullable InlineResultsWrap.LoadMoreCallback callback, @Nullable RecyclerView.OnScrollListener scrollCallback, @Nullable StickerSmallView.StickerMovementCallback stickerMovementCallback) {
if (inlineResultsView == null) {
if (results == null || results.isEmpty()) {
return;
Expand All @@ -1974,12 +1994,16 @@ public void showInlineResults (ViewController<?> context, Tdlib tdlib, @Nullable
addToRoot(inlineResultsView, false);
}

inlineResultsView.showItems(context, results, needBackground, callback, !context.isFocused());
inlineResultsView.showItems(context, results, needBackground, callback, scrollCallback, stickerMovementCallback, !context.isFocused());
}

public void addInlineResults (ViewController<?> context, ArrayList<InlineResult<?>> results, InlineResultsWrap.LoadMoreCallback callback) {
addInlineResults(context, results, callback, null, null);
}

public void addInlineResults (ViewController<?> context, ArrayList<InlineResult<?>> results, InlineResultsWrap.LoadMoreCallback callback, @Nullable RecyclerView.OnScrollListener scrollCallback, @Nullable StickerSmallView.StickerMovementCallback stickerMovementCallback) {
if (inlineResultsView != null) {
inlineResultsView.addItems(context, results, callback);
inlineResultsView.addItems(context, results, callback, scrollCallback, stickerMovementCallback);
}
}

Expand All @@ -1994,6 +2018,56 @@ public boolean areInlineResultsVisible () {
return inlineResultsView != null && inlineResultsView.isDisplayingItems();
}

@Nullable
public InlineResultsWrap getInlineResultsView () {
return inlineResultsView;
}

public void setEmojiSuggestions (MessagesController context, @Nullable ArrayList<TGStickerObj> stickers, @Nullable RecyclerView.OnScrollListener scrollCallback, StickersSuggestionsLayout.Delegate choosingDelegate) {
if (emojiSuggestionsWrap == null) {
emojiSuggestionsWrap = new StickersSuggestionsLayout(context.context());
emojiSuggestionsWrap.setId(R.id.view_customEmojiSuggestions);
emojiSuggestionsWrap.init(context, true);
}
emojiSuggestionsWrap.setChoosingDelegate(choosingDelegate);
emojiSuggestionsWrap.setOnScrollListener(scrollCallback);
emojiSuggestionsWrap.setStickers(context, stickers);
}

public void updateEmojiSuggestionsPosition (boolean needTranslate) {
if (emojiSuggestionsWrap != null) {
emojiSuggestionsWrap.updatePosition(needTranslate);
}
}

public void addEmojiSuggestions (MessagesController context, ArrayList<TGStickerObj> stickers) {
if (emojiSuggestionsWrap != null && stickers != null && !stickers.isEmpty()) {
emojiSuggestionsWrap.addStickers(context, stickers);
}
}

public void setEmojiSuggestionsVisible (boolean visible) {
if (emojiSuggestionsWrap != null) {
if (visible) {
emojiSuggestionsWrap.updatePosition(false);
}
emojiSuggestionsWrap.setStickersVisible(visible);
}
}

public boolean hasEmojiSuggestions () {
return emojiSuggestionsWrap != null && emojiSuggestionsWrap.hasStickers();
}

public boolean isEmojiSuggestionsVisible () {
return emojiSuggestionsWrap != null && emojiSuggestionsWrap.isStickersVisible();
}

@Nullable
public StickersSuggestionsLayout getEmojiSuggestionsView () {
return emojiSuggestionsWrap;
}

// etc

@Override
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/thunderdog/challegram/U.java
Expand Up @@ -412,7 +412,7 @@ private static File getRootOfInnerSdCardFolder (File file) {
String output = out.toString();
if (!output.trim().isEmpty()) {
String[] devicePoints = output.split("\n");
for (String voldPoint: devicePoints) {
for (String voldPoint : devicePoints) {
String path = voldPoint.split(" ")[2];
if (!StringUtils.equalsOrBothEmpty(ignorePath, path)) {
if (results == null) {
Expand Down
Expand Up @@ -1856,21 +1856,21 @@ public void update (TdApi.MessageSender sender) {
}

private void update (TdApi.MessageSender sender, boolean isPersonal, boolean isAnonymous) {
this.senderAvatarView.setVisibility(sender != null ? VISIBLE: GONE);
this.senderAvatarView.setVisibility(sender != null ? VISIBLE : GONE);
this.senderAvatarView.setMessageSender(tdlib, sender);
this.isAnonymous = isAnonymous;
this.isPersonal = isPersonal;
setVisibility(!isPersonal ? VISIBLE: GONE);
setVisibility(!isPersonal ? VISIBLE : GONE);
invalidate();
}

public HapticMenuHelper.MenuItem createHapticSenderItem (TdApi.Chat chat) {
if (isAnonymous()) {
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId): null, R.drawable.dot_baseline_acc_anon_24);
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId) : null, R.drawable.dot_baseline_acc_anon_24);
} else if (isPersonal()) {
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId): null, R.drawable.dot_baseline_acc_personal_24);
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId) : null, R.drawable.dot_baseline_acc_personal_24);
} else {
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId): null, 0, tdlib, chat != null ? chat.messageSenderId: null, false);
return new HapticMenuHelper.MenuItem(R.id.btn_openSendersMenu, Lang.getString(R.string.SendAs), chat != null ? tdlib.getMessageSenderTitle(chat.messageSenderId) : null, 0, tdlib, chat != null ? chat.messageSenderId : null, false);
}
}
}
Expand Down
Expand Up @@ -40,14 +40,15 @@
import org.thunderdog.challegram.component.user.RemoveHelper;
import org.thunderdog.challegram.core.Lang;
import org.thunderdog.challegram.loader.ComplexReceiver;
import org.thunderdog.challegram.loader.ComplexReceiverProvider;
import org.thunderdog.challegram.loader.ImageReceiver;
import org.thunderdog.challegram.navigation.TooltipOverlayView;
import org.thunderdog.challegram.navigation.ViewController;
import org.thunderdog.challegram.support.RippleSupport;
import org.thunderdog.challegram.telegram.TGLegacyManager;
import org.thunderdog.challegram.telegram.Tdlib;
import org.thunderdog.challegram.theme.Theme;
import org.thunderdog.challegram.theme.ColorId;
import org.thunderdog.challegram.theme.Theme;
import org.thunderdog.challegram.tool.Drawables;
import org.thunderdog.challegram.tool.Paints;
import org.thunderdog.challegram.tool.Screen;
Expand Down Expand Up @@ -79,7 +80,7 @@
import me.vkryl.core.StringUtils;
import me.vkryl.core.lambda.Destroyable;

public class SettingView extends FrameLayoutFix implements FactorAnimator.Target, TGLegacyManager.EmojiLoadListener, AttachDelegate, Destroyable, RemoveHelper.RemoveDelegate, TextColorSet, TooltipOverlayView.LocationProvider {
public class SettingView extends FrameLayoutFix implements FactorAnimator.Target, TGLegacyManager.EmojiLoadListener, AttachDelegate, Destroyable, RemoveHelper.RemoveDelegate, TextColorSet, TooltipOverlayView.LocationProvider, ComplexReceiverProvider {
public static final int TYPE_INFO = 0x01;
public static final int TYPE_SETTING = 0x02;
public static final int TYPE_RADIO = 0x03;
Expand Down Expand Up @@ -238,6 +239,7 @@ public ImageReceiver getReceiver () {
return receiver;
}

@Override
public ComplexReceiver getComplexReceiver () {
return complexReceiver;
}
Expand Down
Expand Up @@ -111,7 +111,7 @@ public void setChat (Tdlib tdlib, TdApi.Chat chat, @Nullable ThreadInfo messageT
setUseRedHighlight(false);
attachChatStatus(messageThread.getChatId(), messageThread.getMessageThreadId());
} else {
setEmojiStatus(tdlib.isSelfChat(chat) ? null: tdlib.chatUser(chat));
setEmojiStatus(tdlib.isSelfChat(chat) ? null : tdlib.chatUser(chat));
setText(tdlib.chatTitle(chat), !StringUtils.isEmpty(forcedSubtitle) ? forcedSubtitle : tdlib.status().chatStatus(chat));
setExpandedSubtitle(tdlib.status().chatStatusExpanded(chat));
setUseRedHighlight(tdlib.isRedTeam(chat.id));
Expand Down
Expand Up @@ -209,7 +209,7 @@ private boolean queryUserCheck (long userId, String query) {
}

private void performRequestForUserChat (long userId, String query, Handler handler) {
long otherUserId = ChatId.isSecret(userId) ? tdlib.chatUserId(userId): userId;
long otherUserId = ChatId.isSecret(userId) ? tdlib.chatUserId(userId) : userId;
long myUserId = tdlib.myUserId();

boolean otherUserOk = queryUserCheck(otherUserId, query);
Expand Down