mirror of
https://github.com/MGislv/NekoX.git
synced 2024-07-02 10:33:36 +00:00
Bug fixes
This commit is contained in:
parent
77b6fe7eff
commit
ddf1841ed1
|
@ -1,8 +1,6 @@
|
|||
MY_LOCAL_PATH := $(call my-dir)
|
||||
LOCAL_PATH := $(MY_LOCAL_PATH)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := avutil
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include <sys/epoll.h>
|
||||
#include <map>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include "Defines.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "Defines.h"
|
||||
|
||||
class TL_future_salt;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <functional>
|
||||
#include <list>
|
||||
#include <limits.h>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <inttypes.h>
|
||||
#include "ByteArray.h"
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include "Defines.h"
|
||||
|
||||
#ifdef ANDROID
|
||||
|
|
|
@ -345,7 +345,7 @@ public class ContactsController extends BaseController {
|
|||
readContacts();
|
||||
if (systemAccount == null && !NekoConfig.disableSystemAccount) {
|
||||
try {
|
||||
TLRPC.User user = UserConfig.getInstance(currentAccount).getCurrentUser();
|
||||
TLRPC.User user = getUserConfig().getCurrentUser();
|
||||
systemAccount = new Account(formatName(user.first_name, user.last_name), BuildConfig.APPLICATION_ID);
|
||||
am.addAccountExplicitly(systemAccount, "", null);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -92,10 +92,6 @@ public class DialogsAdapter extends RecyclerListView.SelectionAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
public int getDialogsType() {
|
||||
return dialogsType;
|
||||
}
|
||||
|
||||
public void setOpenedDialogId(long id) {
|
||||
openedDialogId = id;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import android.graphics.drawable.RippleDrawable;
|
|||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.SystemClock;
|
||||
import android.text.Layout;
|
||||
import android.text.Spannable;
|
||||
|
@ -54,7 +53,6 @@ import android.view.HapticFeedbackConstants;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.SoundEffectConstants;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStructure;
|
||||
import android.view.accessibility.AccessibilityEvent;
|
||||
|
@ -64,8 +62,6 @@ import android.view.accessibility.AccessibilityNodeProvider;
|
|||
import android.view.animation.Interpolator;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import org.telegram.PhoneFormat.PhoneFormat;
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ChatObject;
|
||||
|
@ -94,7 +90,6 @@ import org.telegram.messenger.browser.Browser;
|
|||
import org.telegram.tgnet.ConnectionsManager;
|
||||
import org.telegram.tgnet.TLObject;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.AlertDialog;
|
||||
import org.telegram.ui.ActionBar.Theme;
|
||||
import org.telegram.ui.ChatActivity;
|
||||
import org.telegram.ui.Components.AnimatedFileDrawable;
|
||||
|
@ -1625,75 +1620,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
int y = (int) event.getY();
|
||||
|
||||
boolean result = false;
|
||||
final Handler handler = new Handler();
|
||||
Runnable mLongPressed = () -> {
|
||||
if (pressedBotButton != -1) {
|
||||
BotButton button = botButtons.get(pressedBotButton);
|
||||
Gson gson = new Gson();
|
||||
if (button.button != null) {
|
||||
if (!TextUtils.isEmpty(button.button.url)) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("CopyLink", R.string.CopyLink), LocaleController.getString("CopyDetails", R.string.CopyDetails)}, (dialogInterface, i) -> {
|
||||
if (i == 0) {
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(button.button.text);
|
||||
Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
} else if (i == 1) {
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(button.button.url);
|
||||
Toast.makeText(getContext(), LocaleController.getString("LinkCopied", R.string.LinkCopied), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
} else if (i == 2) {
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(gson.toJson(button.button));
|
||||
Toast.makeText(getContext(), LocaleController.getString("TextCopied", R.string.TextCopied), Toast.LENGTH_SHORT).show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
// nekox change: avoid BTE
|
||||
try {
|
||||
builder.show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
} else {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setItems(new CharSequence[]{LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("CopyDetails", R.string.CopyDetails)}, (dialogInterface, i) -> {
|
||||
if (i == 0) {
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(button.button.text);
|
||||
AlertUtil.showToast(LocaleController.getString("TextCopied", R.string.TextCopied));
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
} else if (i == 1) {
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(gson.toJson(button.button));
|
||||
AlertUtil.showToast(LocaleController.getString("TextCopied", R.string.TextCopied));
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
// nekox change: avoid BTE
|
||||
try {
|
||||
builder.show();
|
||||
} catch (Exception e) {
|
||||
FileLog.e(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
pressedBotButton = -1;
|
||||
invalidate();
|
||||
}
|
||||
};
|
||||
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||
int addX;
|
||||
if (currentMessageObject.isOutOwner()) {
|
||||
|
@ -1708,7 +1634,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
pressedBotButton = a;
|
||||
invalidate();
|
||||
result = true;
|
||||
handler.postDelayed(mLongPressed, ViewConfiguration.getLongPressTimeout());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1778,7 +1703,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
|
|||
}
|
||||
if (!result) {
|
||||
result = checkBotButtonMotionEvent(event);
|
||||
disallowLongPress = result;
|
||||
}
|
||||
if (!result) {
|
||||
result = checkPollButtonMotionEvent(event);
|
||||
|
|
|
@ -207,6 +207,11 @@ import org.telegram.ui.Components.URLSpanUserMention;
|
|||
import org.telegram.ui.Components.UndoView;
|
||||
import org.telegram.ui.Components.voip.VoIPHelper;
|
||||
|
||||
import tw.nekomimi.nekogram.MessageDetailsActivity;
|
||||
import tw.nekomimi.nekogram.MessageHelper;
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
import tw.nekomimi.nekogram.settings.NekoGeneralSettingsActivity;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
@ -249,7 +254,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
protected ChatActivityEnterView chatActivityEnterView;
|
||||
int chatActivityEnterViewAnimateFromTop;
|
||||
private View timeItem2;
|
||||
private ActionBarMenuSubItem fakeScreenshotItem;
|
||||
private ActionBarMenuItem attachItem;
|
||||
private ActionBarMenuItem headerItem;
|
||||
private ActionBarMenuItem editTextItem;
|
||||
|
@ -936,7 +940,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
private final static int show_pinned = 25;
|
||||
private final static int translate = 101;
|
||||
|
||||
private final static int fake_screenshot = 27;
|
||||
private final static int delete_all = 28;
|
||||
|
||||
private final static int bot_help = 30;
|
||||
|
@ -1763,8 +1766,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
SharedPreferences preferences = MessagesController.getNotificationsSettings(currentAccount);
|
||||
preferences.edit().putInt("pin_" + dialog_id, 0).apply();
|
||||
updatePinnedMessageView(true);
|
||||
} else if (id == fake_screenshot) {
|
||||
getSecretChatHelper().sendScreenshotMessage(currentEncryptedChat, getMediaController().getLastVisibleMessageIds(), null);
|
||||
} else if (id == linked_chat) {
|
||||
if (chatInfo == null) {
|
||||
return;
|
||||
|
@ -1970,14 +1971,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (searchItem != null) {
|
||||
headerItem.addSubItem(search, R.drawable.baseline_search_24, LocaleController.getString("Search", R.string.Search));
|
||||
}
|
||||
if (currentUser != null) {
|
||||
addContactItem = headerItem.addSubItem(share_contact, R.drawable.baseline_person_add_24, "");
|
||||
}
|
||||
if (currentEncryptedChat != null) {
|
||||
timeItem2 = headerItem.addSubItem(chat_enc_timer, R.drawable.baseline_timer_24, LocaleController.getString("SetTimer", R.string.SetTimer));
|
||||
fakeScreenshotItem = headerItem.addSubItem(fake_screenshot, R.drawable.baseline_star_24, LocaleController.getString("FakeScreenshot", R.string.FakeScreenshot));
|
||||
}
|
||||
|
||||
boolean allowShowPinned;
|
||||
if (currentChat != null) {
|
||||
allowShowPinned = ChatObject.canUserDoAction(currentChat, ChatObject.ACTION_PIN) || ChatObject.isChannel(currentChat);
|
||||
|
@ -1991,28 +1984,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (allowShowPinned) {
|
||||
headerItem.addSubItem(show_pinned, R.drawable.deproko_baseline_pin_24, LocaleController.getString("PinnedMessage", R.string.PinnedMessage));
|
||||
}
|
||||
|
||||
if (currentUser == null || !currentUser.self) {
|
||||
muteItem = headerItem.addSubItem(mute, R.drawable.baseline_volume_off_24_white, null);
|
||||
}
|
||||
|
||||
if (currentChat != null && !currentChat.creator) {
|
||||
headerItem.addSubItem(report, R.drawable.baseline_report_24, LocaleController.getString("ReportChat", R.string.ReportChat));
|
||||
}
|
||||
|
||||
if (currentChat != null && (currentChat.has_link || (chatInfo != null && chatInfo.linked_chat_id != 0))) {
|
||||
String text;
|
||||
if (!currentChat.megagroup) {
|
||||
text = LocaleController.getString("LinkedGroupChat", R.string.LinkedGroupChat);
|
||||
} else {
|
||||
text = LocaleController.getString("LinkedChannelChat", R.string.LinkedChannelChat);
|
||||
}
|
||||
headerItem.addSubItem(linked_chat, R.drawable.baseline_layers_24, text);
|
||||
if (currentUser != null) {
|
||||
addContactItem = headerItem.addSubItem(share_contact, R.drawable.msg_addcontact, "");
|
||||
}
|
||||
if (currentEncryptedChat != null) {
|
||||
timeItem2 = headerItem.addSubItem(chat_enc_timer, R.drawable.msg_timer, LocaleController.getString("SetTimer", R.string.SetTimer));
|
||||
}
|
||||
|
||||
if (!ChatObject.isChannel(currentChat) || currentChat != null && currentChat.megagroup && TextUtils.isEmpty(currentChat.username)) {
|
||||
headerItem.addSubItem(clear_history, R.drawable.baseline_delete_sweep_24, LocaleController.getString("ClearHistory", R.string.ClearHistory));
|
||||
}
|
||||
if (currentUser == null || !currentUser.self) {
|
||||
muteItem = headerItem.addSubItem(mute, R.drawable.msg_mute, null);
|
||||
}
|
||||
if (ChatObject.isChannel(currentChat) && currentChat.megagroup) {
|
||||
headerItem.addSubItem(delete_history, R.drawable.baseline_delete_24, LocaleController.getString("DeleteAllFromSelf", R.string.DeleteAllFromSelf));
|
||||
}
|
||||
|
@ -2020,7 +2006,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
if (ChatObject.isChannel(currentChat) && ChatObject.canUserDoAction(currentChat, ChatObject.ACTION_DELETE_MESSAGES)) {
|
||||
headerItem.addSubItem(delete_all, R.drawable.baseline_delete_24, LocaleController.getString("DeleteAllInChat", R.string.DeleteAllInChat));
|
||||
}
|
||||
|
||||
if (ChatObject.isChannel(currentChat)) {
|
||||
if (!ChatObject.isNotInChat(currentChat)) {
|
||||
if (currentChat.megagroup) {
|
||||
|
@ -14951,9 +14936,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
items.add(LocaleController.getString("Forward", R.string.Forward));
|
||||
options.add(2);
|
||||
icons.add(R.drawable.msg_forward);
|
||||
}
|
||||
if (!selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16) {
|
||||
items.add(LocaleController.getString("NoQuoteForward", R.string.NoQuoteForward));
|
||||
options.add(95);
|
||||
icons.add(R.drawable.msg_forward_noquote);
|
||||
}
|
||||
if (!inScheduleMode && !selectedObject.needDrawBluredPreview() && !selectedObject.isLiveLocation() && selectedObject.type != 16) {
|
||||
if (!UserObject.isUserSelf(currentUser) && NekoConfig.showAddToSavedMessages) {
|
||||
items.add(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages));
|
||||
options.add(93);
|
||||
|
@ -14979,17 +14968,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
options.add(90);
|
||||
icons.add(R.drawable.baseline_schedule_24);
|
||||
}
|
||||
if (NekoConfig.showMessageDetails) {
|
||||
items.add(LocaleController.getString("MessageDetails", R.string.MessageDetails));
|
||||
options.add(89);
|
||||
icons.add(R.drawable.menu_info);
|
||||
}
|
||||
if ((StrUtil.isNotBlank(selectedObject.messageOwner.message) || selectedObject.isPoll()) && NekoConfig.showTranslate) {
|
||||
items.add(selectedObject.messageOwner.translated ? LocaleController.getString("UndoTranslate", R.string.UndoTranslate) : LocaleController.getString("Translate", R.string.Translate));
|
||||
options.add(88);
|
||||
icons.add(R.drawable.ic_translate);
|
||||
}
|
||||
}
|
||||
if (NekoConfig.showMessageDetails) {
|
||||
items.add(LocaleController.getString("MessageDetails", R.string.MessageDetails));
|
||||
options.add(89);
|
||||
icons.add(R.drawable.menu_info);
|
||||
}
|
||||
if (allowUnpin) {
|
||||
items.add(LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
|
||||
options.add(14);
|
||||
|
@ -16039,7 +16028,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
}
|
||||
case 88: {
|
||||
|
||||
MessageTransKt.translateMessages(this, new MessageObject[] { selectedObject });
|
||||
MessageTransKt.translateMessages(this, new MessageObject[]{selectedObject});
|
||||
|
||||
break;
|
||||
|
||||
|
@ -16104,6 +16093,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
break;
|
||||
}
|
||||
case 94: {
|
||||
if (checkSlowMode(chatActivityEnterView.getSendButton())) {
|
||||
return;
|
||||
}
|
||||
ArrayList<MessageObject> messages = new ArrayList<>();
|
||||
messages.add(selectedObject);
|
||||
forwardMessages(messages, false, true, 0);
|
||||
|
@ -16212,7 +16204,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
|||
scrimPopupWindowItems = null;
|
||||
}
|
||||
|
||||
MessageTransKt.translateMessages(this, new MessageObject[] { selectedObject }, locale);
|
||||
MessageTransKt.translateMessages(this, new MessageObject[]{selectedObject}, locale);
|
||||
|
||||
return Unit.INSTANCE;
|
||||
|
||||
|
|
|
@ -69,8 +69,6 @@ import androidx.recyclerview.widget.DefaultItemAnimator;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import tw.nekomimi.nekogram.NekoConfig;
|
||||
|
||||
public class ChatRightsEditActivity extends BaseFragment {
|
||||
|
||||
private ListAdapter listViewAdapter;
|
||||
|
|
|
@ -3948,6 +3948,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
|||
delegate.needStartRecordVideo(4, notify, scheduleDate);
|
||||
hideRecordedAudioPanel(true);
|
||||
checkSendButton(true);
|
||||
return;
|
||||
} else if (audioToSend != null) {
|
||||
MessageObject playing = MediaController.getInstance().getPlayingMessageObject();
|
||||
if (playing != null && playing == audioToSendMessageObject) {
|
||||
|
@ -3959,6 +3960,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
|
|||
}
|
||||
hideRecordedAudioPanel(true);
|
||||
checkSendButton(true);
|
||||
return;
|
||||
}
|
||||
CharSequence message = messageEditText.getText();
|
||||
if (parentFragment != null) {
|
||||
|
|
|
@ -911,9 +911,7 @@ public class ThemeEditorView {
|
|||
saveButton.setText(LocaleController.getString("Save", R.string.Save).toUpperCase());
|
||||
saveButton.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
linearLayout.addView(saveButton, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT));
|
||||
saveButton.setOnClickListener(v -> {
|
||||
setColorPickerVisible(false);
|
||||
});
|
||||
saveButton.setOnClickListener(v -> setColorPickerVisible(false));
|
||||
}
|
||||
|
||||
private void runShadowAnimation(final int num, final boolean show) {
|
||||
|
|
|
@ -3166,6 +3166,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
}
|
||||
if (prevWidth != layoutParams.width) {
|
||||
onlineTextView[1].requestLayout();
|
||||
onlineTextView[2].requestLayout();
|
||||
}
|
||||
|
||||
width2 = idTextView.getPaint().measureText(idTextView.getText().toString());
|
||||
|
@ -3182,20 +3183,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
|||
}
|
||||
}
|
||||
|
||||
private void loadMediaCounts() {
|
||||
if (dialog_id != 0) {
|
||||
MediaDataController.getInstance(currentAccount).getMediaCounts(dialog_id, classGuid);
|
||||
} else if (user_id != 0) {
|
||||
MediaDataController.getInstance(currentAccount).getMediaCounts(user_id, classGuid);
|
||||
} else if (chat_id > 0) {
|
||||
MediaDataController.getInstance(currentAccount).getMediaCounts(-chat_id, classGuid);
|
||||
if (mergeDialogId != 0) {
|
||||
MediaDataController.getInstance(currentAccount).getMediaCounts(mergeDialogId, classGuid);
|
||||
}
|
||||
onlineTextView[2].requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
private void fixLayout() {
|
||||
if (fragmentView == null) {
|
||||
return;
|
||||
|
|
|
@ -69,6 +69,8 @@ import org.telegram.ui.Components.RLottieImageView;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import tw.nekomimi.nekogram.EditTextAutoFill;
|
||||
|
||||
public class TwoStepVerificationSetupActivity extends BaseFragment {
|
||||
|
||||
private RLottieImageView imageView;
|
||||
|
@ -714,7 +716,7 @@ public class TwoStepVerificationSetupActivity extends BaseFragment {
|
|||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
scrollViewLinearLayout.addView(frameLayout, LayoutHelper.createLinear(220, 36, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 40, 32, 40, 0));
|
||||
|
||||
passwordEditText = new EditTextBoldCursor(context);
|
||||
passwordEditText = new EditTextAutoFill(context);
|
||||
passwordEditText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 17);
|
||||
passwordEditText.setPadding(0, AndroidUtilities.dp(2), 0, 0);
|
||||
passwordEditText.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
||||
|
|
|
@ -7,6 +7,7 @@ import android.net.Uri;
|
|||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -16,7 +17,17 @@ import androidx.core.content.FileProvider;
|
|||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.gson.ExclusionStrategy;
|
||||
import com.google.gson.FieldAttributes;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.BuildConfig;
|
||||
|
@ -25,6 +36,7 @@ import org.telegram.messenger.FileLoader;
|
|||
import org.telegram.messenger.FileLog;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.MessageObject;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
import org.telegram.messenger.R;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
|
@ -44,10 +56,11 @@ import org.telegram.ui.Components.UndoView;
|
|||
import org.telegram.ui.ProfileActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
public class MessageDetailsActivity extends BaseFragment {
|
||||
public class MessageDetailsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
|
@ -61,6 +74,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
private int rowCount;
|
||||
|
||||
private int idRow;
|
||||
private int scheduledRow;
|
||||
private int messageRow;
|
||||
private int captionRow;
|
||||
private int groupRow;
|
||||
|
@ -74,12 +88,37 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
private int filePathRow;
|
||||
private int fileSizeRow;
|
||||
private int dcRow;
|
||||
private int buttonsRow;
|
||||
private int emptyRow;
|
||||
private int exportRow;
|
||||
private int endRow;
|
||||
|
||||
private UndoView copyTooltip;
|
||||
|
||||
public static final Gson gson = new GsonBuilder()
|
||||
.setExclusionStrategies(new Exclusion())
|
||||
.registerTypeHierarchyAdapter(byte[].class, new ByteArrayToBase64TypeAdapter()).create();
|
||||
|
||||
private static class ByteArrayToBase64TypeAdapter implements JsonSerializer<byte[]>, JsonDeserializer<byte[]> {
|
||||
public byte[] deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||
return Base64.decode(json.getAsString(), Base64.NO_WRAP);
|
||||
}
|
||||
|
||||
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(Base64.encodeToString(src, Base64.NO_WRAP));
|
||||
}
|
||||
}
|
||||
|
||||
public static class Exclusion implements ExclusionStrategy {
|
||||
public boolean shouldSkipClass(Class<?> arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean shouldSkipField(FieldAttributes f) {
|
||||
return f.getName().equals("disableFree") || f.getName().equals("networkType");
|
||||
}
|
||||
}
|
||||
|
||||
public MessageDetailsActivity(MessageObject messageObject) {
|
||||
this.messageObject = messageObject;
|
||||
if (messageObject.messageOwner.to_id != null && messageObject.messageOwner.to_id.channel_id != 0) {
|
||||
|
@ -129,6 +168,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
|
||||
updateRows();
|
||||
|
||||
return true;
|
||||
|
@ -165,7 +205,6 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
listView.setAdapter(listAdapter);
|
||||
listView.setOnItemClickListener((view, position, x, y) -> {
|
||||
if (position == exportRow) {
|
||||
Gson gson = new Gson();
|
||||
try {
|
||||
AndroidUtilities.addToClipboard(gson.toJson(messageObject.messageOwner));
|
||||
copyTooltip.showWithAction(0, UndoView.ACTION_CACHE_WAS_CLEARED, null, null);
|
||||
|
@ -238,6 +277,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
private void updateRows() {
|
||||
rowCount = 0;
|
||||
idRow = rowCount++;
|
||||
scheduledRow = messageObject.scheduled ? rowCount++ : -1;
|
||||
messageRow = TextUtils.isEmpty(messageObject.messageText) ? -1 : rowCount++;
|
||||
captionRow = TextUtils.isEmpty(messageObject.caption) ? -1 : rowCount++;
|
||||
groupRow = fromChat != null && !fromChat.broadcast ? rowCount++ : -1;
|
||||
|
@ -258,6 +298,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
} else {
|
||||
dcRow = -1;
|
||||
}
|
||||
buttonsRow = messageObject.messageOwner.reply_markup instanceof TLRPC.TL_replyInlineMarkup ? rowCount++ : -1;
|
||||
emptyRow = rowCount++;
|
||||
exportRow = rowCount++;
|
||||
endRow = rowCount++;
|
||||
|
@ -307,6 +348,21 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
return themeDescriptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.emojiDidLoad) {
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
|
||||
}
|
||||
|
||||
private class ListAdapter extends RecyclerListView.SelectionAdapter {
|
||||
|
||||
private Context mContext;
|
||||
|
@ -338,9 +394,9 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
if (position == idRow) {
|
||||
textCell.setTextAndValue("ID", String.valueOf(messageObject.messageOwner.id), divider);
|
||||
} else if (position == messageRow) {
|
||||
textCell.setTextWithEmojiAnd21Value("Message", messageObject.messageText, divider);
|
||||
textCell.setTextAndValue("Message", messageObject.messageText, divider);
|
||||
} else if (position == captionRow) {
|
||||
textCell.setTextWithEmojiAnd21Value("Caption", messageObject.caption, divider);
|
||||
textCell.setTextAndValue("Caption", messageObject.caption, divider);
|
||||
} else if (position == channelRow || position == groupRow) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(fromChat.title);
|
||||
|
@ -351,7 +407,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
builder.append("\n");
|
||||
}
|
||||
builder.append(fromChat.id);
|
||||
textCell.setTextWithEmojiAnd21Value(position == channelRow ? "Channel" : "Group", builder.toString(), divider);
|
||||
textCell.setTextAndValue(position == channelRow ? "Channel" : "Group", builder.toString(), divider);
|
||||
} else if (position == fromRow) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (fromUser != null) {
|
||||
|
@ -366,14 +422,14 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
} else {
|
||||
builder.append(messageObject.messageOwner.post_author);
|
||||
}
|
||||
textCell.setTextWithEmojiAnd21Value("From", builder.toString(), divider);
|
||||
textCell.setTextAndValue("From", builder.toString(), divider);
|
||||
} else if (position == botRow) {
|
||||
textCell.setTextAndValue("Bot", "Yes", divider);
|
||||
} else if (position == dateRow) {
|
||||
long date = (long) messageObject.messageOwner.date * 1000;
|
||||
textCell.setTextAndValue("Date", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
|
||||
textCell.setTextAndValue(messageObject.scheduled ? "Scheduled date" : "Date", messageObject.messageOwner.date == 0x7ffffffe ? "When online" : LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
|
||||
} else if (position == editedRow) {
|
||||
long date = (long) messageObject.messageOwner.date * 1000;
|
||||
long date = (long) messageObject.messageOwner.edit_date * 1000;
|
||||
textCell.setTextAndValue("Edited", LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date))), divider);
|
||||
} else if (position == forwardRow) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
@ -400,7 +456,7 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
} else if (!TextUtils.isEmpty(messageObject.messageOwner.fwd_from.from_name)) {
|
||||
builder.append(messageObject.messageOwner.fwd_from.from_name);
|
||||
}
|
||||
textCell.setTextWithEmojiAnd21Value("Forward from", builder.toString(), divider);
|
||||
textCell.setTextAndValue("Forward from", builder.toString(), divider);
|
||||
} else if (position == fileNameRow) {
|
||||
textCell.setTextAndValue("File name", fileName, divider);
|
||||
} else if (position == filePathRow) {
|
||||
|
@ -413,6 +469,10 @@ public class MessageDetailsActivity extends BaseFragment {
|
|||
} else if (messageObject.messageOwner.media.document != null && messageObject.messageOwner.media.document.dc_id > 0) {
|
||||
textCell.setTextAndValue("DC", String.valueOf(messageObject.messageOwner.media.document.dc_id), divider);
|
||||
}
|
||||
} else if (position == scheduledRow) {
|
||||
textCell.setTextAndValue("Scheduled", "Yes", divider);
|
||||
} else if (position == buttonsRow) {
|
||||
textCell.setTextAndValue("Buttons", gson.toJson(messageObject.messageOwner.reply_markup), divider);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import tw.nekomimi.nekogram.NekoXConfig;
|
|||
import tw.nekomimi.nekogram.PopupBuilder;
|
||||
|
||||
@SuppressLint("RtlHardcoded")
|
||||
public class NekoChatSettingsActivity extends BaseFragment {
|
||||
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private RecyclerListView listView;
|
||||
private ListAdapter listAdapter;
|
||||
|
@ -82,6 +82,7 @@ public class NekoChatSettingsActivity extends BaseFragment {
|
|||
public boolean onFragmentCreate() {
|
||||
super.onFragmentCreate();
|
||||
|
||||
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiDidLoad);
|
||||
updateRows();
|
||||
|
||||
return true;
|
||||
|
@ -420,6 +421,21 @@ public class NekoChatSettingsActivity extends BaseFragment {
|
|||
showDialog(builder.create());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, int account, Object... args) {
|
||||
if (id == NotificationCenter.emojiDidLoad) {
|
||||
if (listView != null) {
|
||||
listView.invalidateViews();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiDidLoad);
|
||||
}
|
||||
|
||||
private class StickerSizeCell extends FrameLayout {
|
||||
|
||||
private StickerSizePreviewMessagesCell messagesCell;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
<string name="NekogramBeta" translatable="false">Nekogram Beta</string>
|
||||
<string name="NekogramWithEmoji" translatable="false">😶 Nekogram</string>
|
||||
<string name="NekogramEmojiDialogs" translatable="false">😶</string>
|
||||
<string name="NekogramEmojiDialogsUnread" translatable="false">🤔</string>
|
||||
<string name="NekoSettings">Neko Settings</string>
|
||||
<string name="IPv6">Try connecting through IPv6</string>
|
||||
<string name="MessageMenu">Message menu</string>
|
||||
|
@ -66,14 +65,10 @@
|
|||
<string name="TranslateFailed">Translate server error</string>
|
||||
<string name="TranslationProvider">Translation provider</string>
|
||||
<string name="ProviderGoogleTranslate">Google Translate</string>
|
||||
<string name="ProviderGoogleTranslateWeb">Google Translate (Web)</string>
|
||||
<string name="ProviderGoogleTranslateCN">Google Translate CN</string>
|
||||
<string name="ProviderGoogleTranslateCNWeb">Google Translate CN (Web)</string>
|
||||
<string name="ProviderBaiduFanyiWeb">Baidu Translate (Web)</string>
|
||||
<string name="TranslateApiUnsupported">The translation provider you selected don\'t support your language.</string>
|
||||
<string name="ProviderLingocloud">Lingocloud</string>
|
||||
<string name="UndoTranslate">Undo translate</string>
|
||||
<string name="CopyDetails">Copy Details</string>
|
||||
<string name="DisablePhotoViewerSideAction">Disable Flip Photos by tapping</string>
|
||||
<string name="BotToken">Token</string>
|
||||
<string name="UnlimitedPinnedDialogs">Unlimited pinned dialogs</string>
|
||||
|
@ -85,8 +80,6 @@
|
|||
<string name="UseAvatarAsDrawerBackground">Use avatar as drawer background</string>
|
||||
<string name="ShowTabsOnForward">Show tabs on forward</string>
|
||||
<string name="CheckAllAdministrated">Add administrated</string>
|
||||
<string name="ProviderDeepLWeb">DeepL Translator (Web)</string>
|
||||
<string name="ChatMessageAnimation">Animate new messages</string>
|
||||
<string name="RearVideoMessages">Rear camera in Video Messages</string>
|
||||
<string name="HideAllTab">Hide \"All Chats\" tab</string>
|
||||
<string name="HideAllTabAbout">Press \"Back\" on home page to open it.</string>
|
||||
|
|
Loading…
Reference in New Issue
Block a user