mirror of
https://codeberg.org/monocles/monocles_chat.git
synced 2025-01-25 22:44:11 +01:00
Finalize sticker picker
This commit is contained in:
parent
c543d36a09
commit
6c5aeeafb9
3 changed files with 34 additions and 2 deletions
src
main/java/eu/siacs/conversations
monocleschat/java/de/monocles/chat
|
@ -58,6 +58,7 @@ import androidx.core.app.RemoteInput;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import de.monocles.chat.EmojiSearch;
|
import de.monocles.chat.EmojiSearch;
|
||||||
|
import de.monocles.chat.EmojiSearchOld;
|
||||||
import de.monocles.chat.WebxdcUpdate;
|
import de.monocles.chat.WebxdcUpdate;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
@ -498,6 +499,7 @@ public class XmppConnectionService extends Service {
|
||||||
private final BroadcastReceiver mInternalRestrictedEventReceiver = new RestrictedEventReceiver(Arrays.asList(TorServiceUtils.ACTION_STATUS));
|
private final BroadcastReceiver mInternalRestrictedEventReceiver = new RestrictedEventReceiver(Arrays.asList(TorServiceUtils.ACTION_STATUS));
|
||||||
private final BroadcastReceiver mInternalScreenEventReceiver = new InternalEventReceiver();
|
private final BroadcastReceiver mInternalScreenEventReceiver = new InternalEventReceiver();
|
||||||
private EmojiSearch emojiSearch = null;
|
private EmojiSearch emojiSearch = null;
|
||||||
|
private EmojiSearchOld emojiSearchOld = null;
|
||||||
|
|
||||||
private static String generateFetchKey(Account account, final Avatar avatar) {
|
private static String generateFetchKey(Account account, final Avatar avatar) {
|
||||||
return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
|
return account.getJid().asBareJid() + "_" + avatar.owner + "_" + avatar.sha1sum;
|
||||||
|
@ -784,6 +786,7 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
if (file.length() < 129000) {
|
if (file.length() < 129000) {
|
||||||
emojiSearch.addEmoji(new EmojiSearch.CustomEmoji(filename, cids[0].toString(), icon, file.getParentFile().getName()));
|
emojiSearch.addEmoji(new EmojiSearch.CustomEmoji(filename, cids[0].toString(), icon, file.getParentFile().getName()));
|
||||||
|
emojiSearchOld.addEmoji(new EmojiSearchOld.CustomEmoji(filename, cids[0].toString(), icon, file.getParentFile().getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -1473,6 +1476,7 @@ public class XmppConnectionService extends Service {
|
||||||
java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.FINEST);
|
java.util.logging.Logger.getLogger("").setLevel(java.util.logging.Level.FINEST);
|
||||||
LibIdnXmppStringprep.setup();
|
LibIdnXmppStringprep.setup();
|
||||||
emojiSearch = new EmojiSearch(this);
|
emojiSearch = new EmojiSearch(this);
|
||||||
|
emojiSearchOld = new EmojiSearchOld(this);
|
||||||
setTheme(R.style.Theme_Conversations3);
|
setTheme(R.style.Theme_Conversations3);
|
||||||
ThemeHelper.applyCustomColors(this);
|
ThemeHelper.applyCustomColors(this);
|
||||||
if (Compatibility.runsTwentySix()) {
|
if (Compatibility.runsTwentySix()) {
|
||||||
|
@ -6078,6 +6082,10 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EmojiSearchOld emojiSearchOld() {
|
||||||
|
return emojiSearchOld;
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnMamPreferencesFetched {
|
public interface OnMamPreferencesFetched {
|
||||||
void onPreferencesFetched(Element prefs);
|
void onPreferencesFetched(Element prefs);
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,7 @@ public class ConversationFragment extends XmppFragment
|
||||||
private int identiconWidth = -1;
|
private int identiconWidth = -1;
|
||||||
private File savingAsSticker = null;
|
private File savingAsSticker = null;
|
||||||
private EmojiSearch emojiSearch = null;
|
private EmojiSearch emojiSearch = null;
|
||||||
|
private EmojiSearchOld emojiSearchOld = null;
|
||||||
File dirStickers = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "Stickers");
|
File dirStickers = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + "Stickers");
|
||||||
//Gifspaths
|
//Gifspaths
|
||||||
private File[] files;
|
private File[] files;
|
||||||
|
@ -1859,6 +1860,29 @@ public class ConversationFragment extends XmppFragment
|
||||||
emojiSearch = activity.xmppConnectionService.emojiSearch();
|
emojiSearch = activity.xmppConnectionService.emojiSearch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (emojiSearchOld == null && activity != null && activity.xmppConnectionService != null) {
|
||||||
|
emojiSearchOld = activity.xmppConnectionService.emojiSearchOld();
|
||||||
|
}
|
||||||
|
if (emojiSearchOld == null || binding.stickersview == null) return;
|
||||||
|
|
||||||
|
binding.stickersview.setAdapter(emojiSearchOld.makeAdapter(activity));
|
||||||
|
|
||||||
|
final Pattern lastColonPattern = Pattern.compile("");
|
||||||
|
Editable s = binding.textinput.getText();
|
||||||
|
Handler emojiDebounce = new Handler(Looper.getMainLooper());
|
||||||
|
emojiDebounce.removeCallbacksAndMessages(null);
|
||||||
|
emojiDebounce.postDelayed(() -> {
|
||||||
|
Matcher lastColonMatcher = lastColonPattern.matcher(s);
|
||||||
|
int lastColon = 0;
|
||||||
|
while(lastColonMatcher.find()) lastColon = lastColonMatcher.end();
|
||||||
|
|
||||||
|
final String q = s.toString().substring(lastColon);
|
||||||
|
EmojiSearchOld.EmojiSearchAdapter adapter = ((EmojiSearchOld.EmojiSearchAdapter) binding.stickersview.getAdapter());
|
||||||
|
if (adapter != null) {
|
||||||
|
adapter.search(q);
|
||||||
|
}
|
||||||
|
}, 400L);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void newThreadTutorialToast(String s) {
|
protected void newThreadTutorialToast(String s) {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.databinding.EmojiSearchRowBinding;
|
import eu.siacs.conversations.databinding.EmojiSearchRowOldBinding;
|
||||||
import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor;
|
import eu.siacs.conversations.utils.ReplacingSerialSingleThreadExecutor;
|
||||||
|
|
||||||
public class EmojiSearchOld {
|
public class EmojiSearchOld {
|
||||||
|
@ -209,7 +209,7 @@ public class EmojiSearchOld {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View getView(int position, View view, ViewGroup parent) {
|
public View getView(int position, View view, ViewGroup parent) {
|
||||||
EmojiSearchRowBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.emoji_search_row_old, parent, false);
|
EmojiSearchRowOldBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.emoji_search_row_old, parent, false);
|
||||||
if (getItem(position) instanceof CustomEmoji) {
|
if (getItem(position) instanceof CustomEmoji) {
|
||||||
binding.nonunicode.setText(getItem(position).toInsert());
|
binding.nonunicode.setText(getItem(position).toInsert());
|
||||||
binding.nonunicode.setVisibility(View.VISIBLE);
|
binding.nonunicode.setVisibility(View.VISIBLE);
|
||||||
|
|
Loading…
Add table
Reference in a new issue