Merge branch 'dev' into m_10.14.0

This commit is contained in:
xtaodada 2024-07-14 20:42:25 +08:00
commit a0c032050c
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
7 changed files with 117 additions and 27 deletions

View File

@ -34083,8 +34083,14 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
final int finalTimestamp = timestamp;
// boolean noforwards = getMessagesController().isChatNoForwards(currentChat) || (messageObject != null && messageObject.messageOwner != null && messageObject.messageOwner.noforwards);
boolean noforwards = false;
builder.setItems(noforwards ? new CharSequence[] {LocaleController.getString("Open", R.string.Open)} : new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
CharSequence[] items = new CharSequence[]{
LocaleController.getString("Open", R.string.Open),
LocaleController.getString("Copy", R.string.Copy),
LocaleController.getString("ShareQRCode", R.string.ShareQRCode),
LocaleController.getString("ShareMessages", R.string.ShareMessages)
};
// builder.setItems(noforwards ? new CharSequence[] {LocaleController.getString("Open", R.string.Open)} : new CharSequence[]{LocaleController.getString("Open", R.string.Open), LocaleController.getString("Copy", R.string.Copy)}, (dialog, which) -> {
builder.setItems(items, (dialog, which) -> {
if (which == 0) {
if (str.startsWith("video?")) {
didPressMessageUrl(url, false, messageObject, cell);
@ -34092,7 +34098,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
logSponsoredClicked(messageObject);
openClickableLink(url, str, false, cell, messageObject, true);
}
} else if (which == 1) {
} else if (which == 1 || which == 3) {
String urlFinal = str;
if (str.startsWith("video?") && messageObject != null && !messageObject.scheduled) {
MessageObject messageObject1 = messageObject;
boolean isMedia = messageObject.isVideo() || messageObject.isRoundVideo() || messageObject.isVoice() || messageObject.isMusic();
@ -34129,21 +34136,36 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (link == null) {
return;
}
AndroidUtilities.addToClipboard(link);
urlFinal = link;
// AndroidUtilities.addToClipboard(link);
} else {
AndroidUtilities.addToClipboard(str);
// AndroidUtilities.addToClipboard(str);
}
createUndoView();
if (undoView == null) {
return;
}
if (str.startsWith("@")) {
undoView.showWithAction(0, UndoView.ACTION_USERNAME_COPIED, null);
} else if (str.startsWith("#") || str.startsWith("$")) {
undoView.showWithAction(0, UndoView.ACTION_HASHTAG_COPIED, null);
if (which == 1) {
AndroidUtilities.addToClipboard(urlFinal);
createUndoView();
if (undoView == null) {
return;
}
if (str.startsWith("@")) {
undoView.showWithAction(0, UndoView.ACTION_USERNAME_COPIED, null);
} else if (str.startsWith("#") || str.startsWith("$")) {
undoView.showWithAction(0, UndoView.ACTION_HASHTAG_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
// ShareMessage
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, urlFinal);
Intent chooserIntent = Intent.createChooser(shareIntent, LocaleController.getString("ShareFile", R.string.ShareFile));
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ApplicationLoader.applicationContext.startActivity(chooserIntent);
}
} else if (which == 2) {
// QRCode
ProxyUtil.showQrDialog(getParentActivity(), str);
}
});
builder.setOnPreDismissListener(di -> {
@ -41643,6 +41665,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
).setDuration(8000).show(true);
}
interface NagramCopyMesage {
void run(boolean isCopy);
}
public void didLongPressLink(ChatMessageCell cell, MessageObject messageObject, CharacterStyle span, String str) {
final ItemOptions options = ItemOptions.makeOptions(ChatActivity.this, cell, true);
final ScrimOptions dialog = new ScrimOptions(getContext(), themeDelegate);
@ -41667,7 +41693,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
});
}
options.add(R.drawable.msg_copy, getString(R.string.CopyLink), () -> {
NagramCopyMesage run1 = (boolean isCopy) -> {
String urlFinal = str;
if (str.startsWith("video?") && messageObject != null && !messageObject.scheduled) {
MessageObject messageObject1 = messageObject;
boolean isMedia = messageObject.isVideo() || messageObject.isRoundVideo() || messageObject.isVoice() || messageObject.isMusic();
@ -41707,22 +41734,47 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (link == null) {
return;
}
AndroidUtilities.addToClipboard(link);
urlFinal = link;
// AndroidUtilities.addToClipboard(link);
} else {
AndroidUtilities.addToClipboard(str);
// AndroidUtilities.addToClipboard(str);
}
createUndoView();
if (undoView == null) {
return;
}
if (str.startsWith("@")) {
undoView.showWithAction(0, UndoView.ACTION_USERNAME_COPIED, null);
} else if (str.startsWith("#") || str.startsWith("$")) {
undoView.showWithAction(0, UndoView.ACTION_HASHTAG_COPIED, null);
if (isCopy) {
AndroidUtilities.addToClipboard(urlFinal);
createUndoView();
if (undoView == null) {
return;
}
if (str.startsWith("@")) {
undoView.showWithAction(0, UndoView.ACTION_USERNAME_COPIED, null);
} else if (str.startsWith("#") || str.startsWith("$")) {
undoView.showWithAction(0, UndoView.ACTION_HASHTAG_COPIED, null);
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
}
} else {
undoView.showWithAction(0, UndoView.ACTION_LINK_COPIED, null);
// ShareMessage
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(Intent.EXTRA_TEXT, urlFinal);
Intent chooserIntent = Intent.createChooser(shareIntent, LocaleController.getString("ShareFile", R.string.ShareFile));
chooserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
ApplicationLoader.applicationContext.startActivity(chooserIntent);
}
};
options.add(R.drawable.msg_copy, getString(R.string.CopyLink), () -> {
run1.run(true);
});
// ----- Nagram Hook start -----
options.add(R.drawable.wallet_qr, getString("ShareQRCode", R.string.ShareQRCode), () -> {
// QRCode
ProxyUtil.showQrDialog(getParentActivity(), str);
});
options.add(R.drawable.msg_shareout, getString("ShareMessages", R.string.ShareMessages), () -> {
// ShareMessage
run1.run(false);
});
// ----- Nagram Hook end -----
dialog.setItemOptions(options);
if (span instanceof URLSpanReplacement) {

View File

@ -10076,8 +10076,11 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
getFileLoader().loadFile(imageLocation, chat, null, FileLoader.PRIORITY_LOW, 1);
}
avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig) && (getLastStoryViewer() == null || getLastStoryViewer().transitionViewHolder.view != avatarImage), storyView != null);
if (chat.photo != null && chat.photo.dc_id != 0) {
dc = chatInfo != null ? chatInfo.stats_dc != 0 ? chatInfo.stats_dc : 0 : 0;
if (dc == 0 && chat.photo != null && chat.photo.dc_id != 0) {
dc = chat.photo.dc_id;
}
if (dc != 0) {
idTextView.setText("ID: " + chatId + ", DC: " + dc);
} else {
idTextView.setText("ID: " + chatId);

View File

@ -100,6 +100,9 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import xyz.nextalone.nagram.NaConfig;
public abstract class BotWebViewContainer extends FrameLayout implements NotificationCenter.NotificationCenterDelegate {
private final static String DURGER_KING_USERNAME = "DurgerKingBot";
@ -1983,6 +1986,19 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uriNew = Uri.parse(url);
// ----- Nagram Hook start -----
String urlPatternStr = NaConfig.INSTANCE.getOpenUrlOutBotWebViewRegex().String();
if (botWebViewContainer != null && !urlPatternStr.isEmpty()) {
Pattern urlPattern = Pattern.compile(urlPatternStr, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
if (urlPattern.matcher(url).find()) {
botWebViewContainer.onOpenUri(uriNew);
d("shouldOverrideUrlLoading("+url+") = true");
return true;
}
}
// ----- Nagram Hook end -----
if (botWebViewContainer != null && Browser.isInternalUri(uriNew, null)) {
if (MessagesController.getInstance(botWebViewContainer.currentAccount).webAppAllowedProtocols != null &&
MessagesController.getInstance(botWebViewContainer.currentAccount).webAppAllowedProtocols.contains(uriNew.getScheme())) {

View File

@ -45,6 +45,7 @@ import org.telegram.ui.Components.UndoView;
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.regex.Pattern;
import kotlin.Unit;
@ -108,6 +109,16 @@ public class NekoExperimentalSettingsActivity extends BaseNekoXSettingsActivity
private final AbstractConfigCell regexFiltersEnableInChatsRow = cellGroup.appendCell(new ConfigCellTextCheck(NaConfig.INSTANCE.getRegexFiltersEnableInChats()));
private final AbstractConfigCell disableChatActionRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChatAction));
private final AbstractConfigCell disableChoosingStickerRow = cellGroup.appendCell(new ConfigCellTextCheck(NekoConfig.disableChoosingSticker));
private final AbstractConfigCell openUrlOutBotWebViewRegexRow = cellGroup.appendCell(new ConfigCellTextInput(null, NaConfig.INSTANCE.getOpenUrlOutBotWebViewRegex(),
null, null,
(input) -> {
try {
Pattern.compile(input, Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);
return input;
} catch (Exception ignored) {
return "";
}
}));
private final AbstractConfigCell divider1 = cellGroup.appendCell(new ConfigCellDivider());
// Story

View File

@ -638,6 +638,12 @@ object NaConfig {
ConfigItem.configTypeInt,
0
)
val openUrlOutBotWebViewRegex =
addConfig(
"OpenUrlOutBotWebViewRegex",
ConfigItem.configTypeString,
""
)
private fun addConfig(
k: String,

View File

@ -158,4 +158,5 @@
<string name="ShowTimeHint">点击消息时间显示详细信息</string>
<string name="SearchHashtagDefaultPageChannel">在频道点击标签默认搜索页面</string>
<string name="SearchHashtagDefaultPageChat">在其他对话点击标签默认搜索页面</string>
<string name="OpenUrlOutBotWebViewRegex">指定 URL Regex 跳出 bot webview</string>
</resources>

View File

@ -158,4 +158,5 @@
<string name="ShowTimeHint">Click message time to display details</string>
<string name="SearchHashtagDefaultPageChannel">Channel Click Hashtag Default Search Page</string>
<string name="SearchHashtagDefaultPageChat">Chat Click Hashtag Default Search Page</string>
<string name="OpenUrlOutBotWebViewRegex">Url regex to jump out of bot webview</string>
</resources>