fix: repeat as copy

This commit is contained in:
NextAlone 2022-03-21 00:46:37 +08:00
parent b867f75e55
commit 8e9b78b66a
No known key found for this signature in database
GPG Key ID: DBA7B0AEF8C1CD2C
8 changed files with 119 additions and 77 deletions

View File

@ -128,7 +128,6 @@ import org.telegram.messenger.FileLog;
import org.telegram.messenger.ForwardingMessagesParams;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
//import org.telegram.messenger.LanguageDetector;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaController;
import org.telegram.messenger.MediaDataController;
@ -287,21 +286,21 @@ import java.util.regex.Pattern;
import cn.hutool.core.util.StrUtil;
import kotlin.Unit;
import tw.nekomimi.nekogram.ui.BottomBuilder;
import tw.nekomimi.nekogram.ui.MessageDetailsActivity;
import tw.nekomimi.nekogram.utils.EnvUtil;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.parts.MessageTransKt;
import tw.nekomimi.nekogram.parts.PollTransUpdatesKt;
import tw.nekomimi.nekogram.settings.NekoSettingsActivity;
import tw.nekomimi.nekogram.transtale.Translator;
import tw.nekomimi.nekogram.ui.BottomBuilder;
import tw.nekomimi.nekogram.ui.MessageDetailsActivity;
import tw.nekomimi.nekogram.utils.AlertUtil;
import tw.nekomimi.nekogram.utils.EnvUtil;
import tw.nekomimi.nekogram.utils.PGPUtil;
import tw.nekomimi.nekogram.utils.ProxyUtil;
import tw.nekomimi.nekogram.utils.TelegramUtil;
import xyz.nextalone.nagram.DoubleTapConfig;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.DoubleTap;
@SuppressWarnings("unchecked")
public class ChatActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, DialogsActivity.DialogsActivityDelegate, LocationActivity.LocationActivityDelegate, ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate {
@ -330,7 +329,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private final static int nkbtn_deldlcache = 2013;
private final static int nkbtn_view_history = 2014;
private final static int nkbtn_repeat = 2015;
private final static int nkbtn_repeatascopy = 2025;
private final static int nkbtn_repeatascopy = 2027;
private final static int nkbtn_stickerdl = 2016;
private final static int nkbtn_unpin = 2017;
private final static int nkbtn_view_in_chat = 2018;
@ -1502,10 +1501,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public boolean hasDoubleTap(View view, int position) {
boolean allowRepeat;
if (NaConfig.INSTANCE.getDoubleTapAction().Int() == DoubleTapConifig.DOUBLE_TAP_ACTION_NONE || !(view instanceof ChatMessageCell)) {
if (NaConfig.INSTANCE.getDoubleTapAction().Int() == DoubleTap.DOUBLE_TAP_ACTION_NONE || !(view instanceof ChatMessageCell)) {
return false;
}
if (NaConfig.INSTANCE.getDoubleTapAction().Int() == DoubleTapConfig.DOUBLE_TAP_ACTION_REACTION) {
if (NaConfig.INSTANCE.getDoubleTapAction().Int() == DoubleTap.DOUBLE_TAP_ACTION_REACTION) {
TLRPC.TL_availableReaction reaction = getMediaDataController().getReactionsMap().get(getMediaDataController().getDoubleTapReaction());
if (reaction == null) {
return false;
@ -1560,21 +1559,21 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
break;
*/
case DoubleTapConfig.DOUBLE_TAP_ACTION_REPLY:
case DoubleTap.DOUBLE_TAP_ACTION_REPLY:
return message.getId() > 0 && allowChatActions;
case DoubleTapConfig.DOUBLE_TAP_ACTION_SAVE:
case DoubleTap.DOUBLE_TAP_ACTION_SAVE:
return !message.isSponsored() && chatMode != MODE_SCHEDULED && !message.needDrawBluredPreview() && !message.isLiveLocation() && message.type != 16 && !getMessagesController().isChatNoForwards(currentChat) && !UserObject.isUserSelf(currentUser);
case DoubleTapConfig.DOUBLE_TAP_ACTION_REPEAT:
case DoubleTap.DOUBLE_TAP_ACTION_REPEAT:
allowRepeat = allowChatActions &&
(!isThreadChat() && !noforwards ||
getMessageHelper().getMessageForRepeat(message, messageGroup) != null);
return allowRepeat && !message.isSponsored() && chatMode != MODE_SCHEDULED && !message.needDrawBluredPreview() && !message.isLiveLocation() && message.type != 16;
case DoubleTapConfig.DOUBLE_TAP_ACTION_REPEATASCOPY:
case DoubleTap.DOUBLE_TAP_ACTION_REPEAT_AS_COPY:
allowRepeat = allowChatActions &&
(!isThreadChat() && !noforwards ||
getMessageHelper().getMessageForRepeat(message, messageGroup) != null);
return allowRepeat && !message.isSponsored() && chatMode != MODE_SCHEDULED && !message.needDrawBluredPreview() && !message.isLiveLocation() && message.type != 16;
case DoubleTapConfig.DOUBLE_TAP_ACTION_EDIT:
case DoubleTap.DOUBLE_TAP_ACTION_EDIT:
return allowEdit;
}
}
@ -3185,10 +3184,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
actionModeOtherItem.addSubItem(nkbtn_unpin, R.drawable.msg_unpin, LocaleController.getString("UnpinMessage", R.string.UnpinMessage));
if (!noforward)
actionModeOtherItem.addSubItem(nkbtn_savemessage, R.drawable.menu_saved, LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages));
if (NekoConfig.showRepeat.Bool() && !noforward)
if (NekoConfig.showRepeat.Bool() && !noforward) {
actionModeOtherItem.addSubItem(nkbtn_repeat, R.drawable.msg_repeat, LocaleController.getString("Repeat", R.string.Repeat));
if(NekoConfig.showRepeatasCopy.Bool() && !noforward)
actionModeOtherItem.addSubItem(nkbtn_repeat, R.drawable.msg_repeat, LocaleController.getString("RepeatasCopy", R.string.Repeat));
}
if (NaConfig.INSTANCE.getShowRepeatAsCopy().Bool() && !noforward) {
actionModeOtherItem.addSubItem(nkbtn_repeatascopy, R.drawable.msg_repeat, LocaleController.getString("RepeatAsCopy", R.string.RepeatAsCopy));
}
if (NekoConfig.showMessageHide.Bool()) {
actionModeOtherItem.addSubItem(nkbtn_hide, R.drawable.baseline_remove_circle_24, LocaleController.getString("Hide", R.string.Hide));
}
@ -22100,16 +22101,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
boolean allowRepeat = currentUser != null
|| (currentChat != null && ChatObject.canSendMessages(currentChat));
if (allowRepeat && NekoConfig.showRepeat.Bool() ) {
if (!noforward){
if (allowRepeat && NekoConfig.showRepeat.Bool()) {
if (!noforward) {
items.add(LocaleController.getString("Repeat", R.string.Repeat));
options.add(nkbtn_repeat);
icons.add(R.drawable.msg_repeat);
items.add(LocaleController.getString("RepeatasCopy", R.string.RepeatasCopy));
items.add(LocaleController.getString("RepeatAsCopy", R.string.RepeatAsCopy));
options.add(nkbtn_repeatascopy);
icons.add(R.drawable.msg_repeat);
}else{
items.add(LocaleController.getString("RepeatasCopy", R.string.RepeatasCopy));
} else {
items.add(LocaleController.getString("RepeatAsCopy", R.string.RepeatAsCopy));
options.add(nkbtn_repeatascopy);
icons.add(R.drawable.msg_repeat);
}

View File

@ -69,7 +69,6 @@ public class NekoConfig {
public static ConfigItem showMessageDetails = addConfig("showMessageDetails", configTypeBool, false);
public static ConfigItem showTranslate = addConfig("showTranslate", configTypeBool, true);
public static ConfigItem showRepeat = addConfig("showRepeat", configTypeBool, false);
public static ConfigItem showRepeatasCopy = addConfig("showRepeatasCopy",configTypeBool,false);
public static ConfigItem showShareMessages = addConfig("showShareMessages", configTypeBool, false);
public static ConfigItem showMessageHide = addConfig("showMessageHide", configTypeBool, false);
@ -290,8 +289,6 @@ public class NekoConfig {
showTranslate.setConfigBool(preferences.getBoolean("showTranslate", true));
if (preferences.contains("showRepeat"))
showRepeat.setConfigBool(preferences.getBoolean("showRepeat", false));
if (preferences.contains("showRepeatasCopy"))
showRepeatasCopy.setConfigBool(preferences.getBoolean("showRepeatasCopy",false));
if (preferences.contains("showShareMessages"))
showShareMessages.setConfigBool(preferences.getBoolean("showShareMessages", false));
if (preferences.contains("showMessageHide"))

View File

@ -45,10 +45,9 @@ import java.util.List;
import java.util.stream.Collectors;
import kotlin.Unit;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.ui.PopupBuilder;
import tw.nekomimi.nekogram.config.CellGroup;
import tw.nekomimi.nekogram.NekoConfig;
import tw.nekomimi.nekogram.NekoXConfig;
import tw.nekomimi.nekogram.config.CellGroup;
import tw.nekomimi.nekogram.config.cell.AbstractConfigCell;
import tw.nekomimi.nekogram.config.cell.ConfigCellCustom;
import tw.nekomimi.nekogram.config.cell.ConfigCellDivider;
@ -57,8 +56,9 @@ import tw.nekomimi.nekogram.config.cell.ConfigCellSelectBox;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextCheck;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextDetail;
import tw.nekomimi.nekogram.config.cell.ConfigCellTextInput;
import xyz.nextalone.nagram.DoubleTapConfig;
import tw.nekomimi.nekogram.ui.PopupBuilder;
import xyz.nextalone.nagram.NaConfig;
import xyz.nextalone.nagram.helper.DoubleTap;
@SuppressLint("RtlHardcoded")
public class NekoChatSettingsActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
@ -238,27 +238,27 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
return Unit.INSTANCE;
});
builder.show();
}else if (position == cellGroup.rows.indexOf(DoubleTapActionRow)) {
} else if (position == cellGroup.rows.indexOf(DoubleTapActionRow)) {
ArrayList<String> arrayList = new ArrayList<>();
ArrayList<Integer> types = new ArrayList<>();
arrayList.add(LocaleController.getString("Disable", R.string.Disable));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_NONE);
types.add(DoubleTap.DOUBLE_TAP_ACTION_NONE);
arrayList.add(LocaleController.getString("Reactions", R.string.Reactions));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_REACTION);
types.add(DoubleTap.DOUBLE_TAP_ACTION_REACTION);
//arrayList.add(LocaleController.getString("TranslateMessage", R.string.TranslateMessage));
//types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_TRANSLATE);
arrayList.add(LocaleController.getString("Reply", R.string.Reply));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_REPLY);
types.add(DoubleTap.DOUBLE_TAP_ACTION_REPLY);
arrayList.add(LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_SAVE);
types.add(DoubleTap.DOUBLE_TAP_ACTION_SAVE);
arrayList.add(LocaleController.getString("Repeat", R.string.Repeat));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_REPEAT);
arrayList.add(LocaleController.getString("RepeatasCopy", R.string.RepeatasCopy));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_REPEATASCOPY);
types.add(DoubleTap.DOUBLE_TAP_ACTION_REPEAT);
arrayList.add(LocaleController.getString("RepeatAsCopy", R.string.RepeatAsCopy));
types.add(DoubleTap.DOUBLE_TAP_ACTION_REPEAT_AS_COPY);
arrayList.add(LocaleController.getString("Edit", R.string.Edit));
types.add(DoubleTapConfig.DOUBLE_TAP_ACTION_EDIT);
types.add(DoubleTap.DOUBLE_TAP_ACTION_EDIT);
PopupBuilder builder = new PopupBuilder(view);
builder.setItems(arrayList, (i,str) -> {
builder.setItems(arrayList, (i, str) -> {
NaConfig.INSTANCE.getDoubleTapAction().setConfigInt(types.get(i));
listAdapter.notifyItemChanged(position);
return Unit.INSTANCE;
@ -379,7 +379,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
break;
}
case 3: {
textCell.setChecked(NekoConfig.showRepeatasCopy.toggleConfigBool());
textCell.setTextAndCheck(LocaleController.getString("RepeatAsCopy", R.string.RepeatAsCopy), NaConfig.INSTANCE.getShowRepeatAsCopy().Bool(), false);
break;
}
case 4: {
@ -442,7 +442,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
break;
}
case 3: {
textCell.setChecked(NekoConfig.showRepeatasCopy.toggleConfigBool());
textCell.setChecked(NaConfig.INSTANCE.getShowRepeatAsCopy().toggleConfigBool());
break;
}
case 4: {
@ -723,8 +723,8 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati
TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
if (position == cellGroup.rows.indexOf(maxRecentStickerCountRow)) {
textCell.setTextAndValue(LocaleController.getString("maxRecentStickerCount", R.string.maxRecentStickerCount), String.valueOf(NekoConfig.maxRecentStickerCount.Int()), true);
}else if ( position == cellGroup.rows.indexOf(DoubleTapActionRow)) {
textCell.setTextAndValue(LocaleController.getString("DoubleTapAction", R.string.DoubleTapAction), new DoubleTapConfig().doubleTapActionMap.get(NaConfig.INSTANCE.getDoubleTapAction().Int()), true);
} else if (position == cellGroup.rows.indexOf(DoubleTapActionRow)) {
textCell.setTextAndValue(LocaleController.getString("DoubleTapAction", R.string.DoubleTapAction), DoubleTap.doubleTapActionMap.get(NaConfig.INSTANCE.getDoubleTapAction().Int()), true);
}
}
} else {

View File

@ -1,31 +0,0 @@
package xyz.nextalone.nagram;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.R;
import java.util.HashMap;
import java.util.Map;
public class DoubleTapConfig {
public static final int DOUBLE_TAP_ACTION_NONE = 0;
public static final int DOUBLE_TAP_ACTION_REACTION = 1;
//public static final int DOUBLE_TAP_ACTION_TRANSLATE = 2;
public static final int DOUBLE_TAP_ACTION_REPLY = 2;
public static final int DOUBLE_TAP_ACTION_SAVE = 3;
public static final int DOUBLE_TAP_ACTION_REPEAT = 4;
public static final int DOUBLE_TAP_ACTION_REPEATASCOPY = 5;
public static final int DOUBLE_TAP_ACTION_EDIT = 6;
public Map<Integer, String> doubleTapActionMap = new HashMap<>();
public DoubleTapConfig() {
doubleTapActionMap.put(DOUBLE_TAP_ACTION_NONE, LocaleController.getString("Disable", R.string.Disable));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_REACTION, LocaleController.getString("Reactions", R.string.Reactions));
//doubleTapActionMap.put(DOUBLE_TAP_ACTION_TRANSLATE, LocaleController.getString("Translate", R.string.Translate));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_REPLY, LocaleController.getString("Reply", R.string.Reply));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_SAVE, LocaleController.getString("Save", R.string.Save));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_REPEAT, LocaleController.getString("Repeat", R.string.Repeat));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_REPEATASCOPY, LocaleController.getString("RepeatasCopy", R.string.RepeatasCopy));
doubleTapActionMap.put(DOUBLE_TAP_ACTION_EDIT, LocaleController.getString("Edit", R.string.Edit));
}
}

View File

@ -115,7 +115,13 @@ object NaConfig {
ConfigItem.configTypeBool,
false
)
var DoubleTapAction =
val showRepeatAsCopy =
addConfig(
"RepeatAsCopy",
ConfigItem.configTypeBool,
false
)
var doubleTapAction =
addConfig(
"DoubleTapAction",
ConfigItem.configTypeInt,

View File

@ -0,0 +1,69 @@
package xyz.nextalone.nagram.helper
import org.telegram.messenger.LocaleController
import org.telegram.messenger.R
object DoubleTap {
@JvmField
var doubleTapActionMap: MutableMap<Int, String> =
HashMap()
const val DOUBLE_TAP_ACTION_NONE =
0
const val DOUBLE_TAP_ACTION_REACTION =
1
// const val DOUBLE_TAP_ACTION_TRANSLATE =
// 2
const val DOUBLE_TAP_ACTION_REPLY =
2
const val DOUBLE_TAP_ACTION_SAVE =
3
const val DOUBLE_TAP_ACTION_REPEAT =
4
const val DOUBLE_TAP_ACTION_REPEAT_AS_COPY =
5
const val DOUBLE_TAP_ACTION_EDIT =
6
init {
doubleTapActionMap[DOUBLE_TAP_ACTION_NONE] =
LocaleController.getString(
"Disable",
R.string.Disable
)
doubleTapActionMap[DOUBLE_TAP_ACTION_REACTION] =
LocaleController.getString(
"Reactions",
R.string.Reactions
)
// doubleTapActionMap[DOUBLE_TAP_ACTION_TRANSLATE] =
// LocaleController.getString(
// "Translate",
// R.string.Translate
// )
doubleTapActionMap[DOUBLE_TAP_ACTION_REPLY] =
LocaleController.getString(
"Reply",
R.string.Reply
)
doubleTapActionMap[DOUBLE_TAP_ACTION_SAVE] =
LocaleController.getString(
"Save",
R.string.Save
)
doubleTapActionMap[DOUBLE_TAP_ACTION_REPEAT] =
LocaleController.getString(
"Repeat",
R.string.Repeat
)
doubleTapActionMap[DOUBLE_TAP_ACTION_REPEAT_AS_COPY] =
LocaleController.getString(
"RepeatAsCopy",
R.string.RepeatAsCopy
)
doubleTapActionMap[DOUBLE_TAP_ACTION_EDIT] =
LocaleController.getString(
"Edit",
R.string.Edit
)
}
}

View File

@ -14,6 +14,6 @@
<string name="TextUndo">撤销</string>
<string name="TextRedo">重做</string>
<string name="NoiseSuppressAndVoiceEnhance">噪音抑制和语音增强</string>
<string name="RepeatasCopy">无引用复读</string>
<string name="DoubleTapAction"></string>
<string name="RepeatAsCopy">无引用复读</string>
<string name="DoubleTapAction">双击操作</string>
</resources>

View File

@ -14,6 +14,6 @@
<string name="TextUndo">Undo</string>
<string name="TextRedo">Redo</string>
<string name="NoiseSuppressAndVoiceEnhance">Noise Suppress And Voice Enhance</string>
<string name="RepeatasCopy">Repeat as Copy</string>
<string name="RepeatAsCopy">Repeat as Copy</string>
<string name="DoubleTapAction">Double Tap Action</string>
</resources>