Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/src/main/java/moe/ono/activity/OUOSettingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ import java.lang.Integer.max
import androidx.core.graphics.drawable.toDrawable
import moe.ono.creator.center.ClickableFunctionDialog.showCFGDialogMessageEncryptor
import moe.ono.creator.center.ClickableFunctionDialog.showCFGDialogQQBubbleRedirect
import moe.ono.creator.center.ClickableFunctionDialog.showCFGDialogQQPacketHelperEntry
import moe.ono.creator.center.ClickableFunctionDialog.showCFGDialogSelfMessageReactor
import moe.ono.hooks.item.chat.MessageEncryptor
import moe.ono.hooks.item.chat.QQBubbleRedirect
import moe.ono.hooks.item.chat.SelfMessageReactor
import moe.ono.hooks.item.developer.QQPacketHelperEntry

open class OUOSettingActivity : BaseActivity() {
private var mAppBarLayoutHeight: Int = 0
Expand Down Expand Up @@ -436,6 +438,9 @@ open class OUOSettingActivity : BaseActivity() {
getItem(QQBubbleRedirect::class.java).path -> {
showCFGDialogQQBubbleRedirect(item, requireContext())
}
getItem(QQPacketHelperEntry::class.java).path -> {
showCFGDialogQQPacketHelperEntry(item, requireContext())
}
}
}

Expand Down
84 changes: 84 additions & 0 deletions app/src/main/java/moe/ono/creator/JumpSchemeUriDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package moe.ono.creator;

import static moe.ono.util.analytics.ActionReporter.reportVisitor;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.widget.Button;
import android.widget.EditText;

import androidx.annotation.NonNull;

import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BasePopupView;
import com.lxj.xpopup.core.BottomPopupView;
import com.lxj.xpopup.util.XPopupUtils;

import moe.ono.R;
import moe.ono.ui.CommonContextWrapper;
import moe.ono.util.AppRuntimeHelper;

@SuppressLint("ResourceType")
public class JumpSchemeUriDialog extends BottomPopupView {
private static BasePopupView popupView;

public JumpSchemeUriDialog(@NonNull Context context) {
super(context);
}

public static void createView(Context context) {
Context fixContext = CommonContextWrapper.createAppCompatContext(context);
XPopup.Builder NewPop = new XPopup.Builder(fixContext).moveUpToKeyboard(true).isDestroyOnDismiss(true);
NewPop.maxHeight((int) (XPopupUtils.getScreenHeight(context) * .7f));
NewPop.popupHeight((int) (XPopupUtils.getScreenHeight(context) * .63f));


reportVisitor(AppRuntimeHelper.getAccount(), "CreateView-JumpSchemeUriDialog");

popupView = NewPop.asCustom(new JumpSchemeUriDialog(fixContext));
popupView.show();
}

@SuppressLint("SetTextI18n")
@Override
protected void onCreate() {
super.onCreate();
new Handler(Looper.getMainLooper()).postDelayed(() -> {
Button btn_jump = findViewById(R.id.btn_jump);
EditText scheme_uri = findViewById(R.id.scheme_uri);

scheme_uri.setVisibility(VISIBLE);
scheme_uri.clearFocus();

btn_jump.setOnClickListener(view -> {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(scheme_uri.getText().toString()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
view.getContext().startActivity(intent);
dismiss();
});
}, 100);
}




@Override
protected void beforeDismiss() {
super.beforeDismiss();
}

@Override
protected void onDismiss() {
super.onDismiss();
}

@Override
protected int getImplLayoutId() {
return R.layout.jump_scheme_uri_dialog;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import moe.ono.hooks._core.factory.HookItemFactory
import moe.ono.hooks.base.util.Toasts
import moe.ono.hooks.item.chat.QQBubbleRedirect
import moe.ono.hooks.item.chat.StickerPanelEntry
import moe.ono.hooks.item.developer.QQPacketHelperEntry
import moe.ono.hooks.item.sigma.QQMessageTracker
import moe.ono.hooks.item.sigma.QQSurnamePredictor
import moe.ono.util.Logger
Expand Down Expand Up @@ -645,9 +646,6 @@ object ClickableFunctionDialog {

builder.setView(layout)

val warningText = TextView(context)
layout.addView(warningText)

builder.setNegativeButton(
"关闭"
) { dialog: DialogInterface, _: Int -> dialog.cancel() }
Expand Down Expand Up @@ -680,4 +678,55 @@ object ClickableFunctionDialog {
builder.show()
}

fun showCFGDialogQQPacketHelperEntry(item: BaseClickableFunctionHookItem, context: Context?) {
if (context == null) return
val builder = MaterialAlertDialogBuilder(context)
builder.setTitle("QQPacketHelper")

val layout = LinearLayout(context)
layout.orientation = LinearLayout.VERTICAL
layout.setPadding(16, 16, 16, 16)

val checkBox = MaterialCheckBox(context)
checkBox.text = "启用"

val hookPanelCheckBox = MaterialCheckBox(context)
hookPanelCheckBox.text = "覆盖加号菜单"

layout.addView(checkBox)
layout.addView(hookPanelCheckBox)

builder.setView(layout)

val warningText = TextView(context)
warningText.text = "开启后长按加号按钮调出 QQPacketHelper\n* 开关需重启生效"
layout.addView(warningText)

builder.setPositiveButton(
"确定"
) { dialog: DialogInterface, _: Int -> dialog.cancel() }

checkBox.isChecked = item.isEnabled

checkBox.setOnCheckedChangeListener { buttonView: CompoundButton?, isChecked: Boolean ->
ConfigManager.dPutBoolean(
Constants.PrekClickableXXX + HookItemFactory.getItem(
QQPacketHelperEntry::class.java
).path, isChecked
)
item.isEnabled = isChecked
if (isChecked) {
item.startLoad()
}
}

hookPanelCheckBox.isChecked = ConfigManager.dGetBooleanDefTrue(Constants.PrekCfgXXX + "QQPacketHelperHookPanel")

hookPanelCheckBox.setOnCheckedChangeListener { view, isCheck ->
ConfigManager.dPutBoolean(Constants.PrekCfgXXX + "QQPacketHelperHookPanel", isCheck)
}

builder.show()
}

}
13 changes: 12 additions & 1 deletion app/src/main/java/moe/ono/hooks/item/chat/BottomShortcutMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import moe.ono.config.ConfigManager
import moe.ono.constants.Constants
import moe.ono.creator.FakeFileSender
import moe.ono.creator.GetChannelArkDialog
import moe.ono.creator.JumpSchemeUriDialog
import moe.ono.creator.PacketHelperDialog
import moe.ono.creator.QQMessageTrackerDialog
import moe.ono.hooks.XHook
Expand All @@ -29,6 +30,7 @@ import moe.ono.hooks._core.factory.HookItemFactory.getItem
import moe.ono.hooks.base.util.Toasts
import moe.ono.hooks.item.developer.GetBknByCookie
import moe.ono.hooks.item.developer.GetCookie
import moe.ono.hooks.item.developer.JumpSchemeUri
import moe.ono.hooks.item.developer.QQHookCodec
import moe.ono.hooks.item.developer.QQPacketHelperEntry
import moe.ono.hooks.item.sigma.QQMessageTracker
Expand Down Expand Up @@ -118,7 +120,7 @@ class BottomShortcutMenu : BaseSwitchFunctionHookItem() {
val sendFakeFile =
ConfigManager.getDefaultConfig().getBooleanOrFalse(Constants.PrekSendFakeFile)
val qqPacketHelper = ConfigManager.getDefaultConfig().getBooleanOrFalse(
Constants.PrekXXX + getItem(
Constants.PrekClickableXXX + getItem(
QQPacketHelperEntry::class.java
).path
)
Expand All @@ -143,6 +145,9 @@ class BottomShortcutMenu : BaseSwitchFunctionHookItem() {
val getChannelArk = ConfigManager.getDefaultConfig().getBooleanOrFalse(Constants.PrekXXX + getItem(
GetChannelArk::class.java).path)

val jumpSchemeUri = ConfigManager.getDefaultConfig().getBooleanOrFalse(Constants.PrekXXX + getItem(
JumpSchemeUri::class.java).path)

val items = ArrayList<String>()
if (qqPacketHelper) {
items.add("QQPacketHelper")
Expand All @@ -162,6 +167,9 @@ class BottomShortcutMenu : BaseSwitchFunctionHookItem() {
if (getChannelArk) {
items.add("GetChannelArk")
}
if (jumpSchemeUri) {
items.add("打开 Scheme 链接")
}

if (getItem(QQHookCodec::class.java).isEnabled) {
if (!messageEncryptor) {
Expand Down Expand Up @@ -264,6 +272,9 @@ class BottomShortcutMenu : BaseSwitchFunctionHookItem() {
"GetChannelArk" -> {
SyncUtils.runOnUiThread { GetChannelArkDialog.createView(view.context) }
}
"打开 Scheme 链接" -> {
SyncUtils.runOnUiThread { JumpSchemeUriDialog.createView(view.context) }
}
}
}
.show()
Expand Down
14 changes: 14 additions & 0 deletions app/src/main/java/moe/ono/hooks/item/developer/JumpSchemeUri.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package moe.ono.hooks.item.developer

import android.annotation.SuppressLint
import moe.ono.hooks._base.BaseSwitchFunctionHookItem
import moe.ono.hooks._core.annotation.HookItem

@SuppressLint("DiscouragedApi")
@HookItem(
path = "开发者选项/打开 Scheme 链接",
description = "* 打开后在快捷菜单使用"
)
class JumpSchemeUri : BaseSwitchFunctionHookItem() {
override fun entry(classLoader: ClassLoader) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

import java.lang.reflect.Method;

import moe.ono.hooks._base.BaseSwitchFunctionHookItem;
import moe.ono.config.ConfigManager;
import moe.ono.constants.Constants;
import moe.ono.hooks._base.BaseClickableFunctionHookItem;
import moe.ono.hooks._core.annotation.HookItem;
import moe.ono.creator.PacketHelperDialog;
import moe.ono.reflex.XMethod;
Expand All @@ -19,21 +21,23 @@
@SuppressLint("DiscouragedApi")
@HookItem(
path = "开发者选项/QQPacketHelper",
description = "* 此功能极度危险,滥用可能会导致您的账号被冻结;为了您的人身安全,请勿发送恶意代码\n\n开启后需在聊天界面长按加号呼出,或长按发送按钮呼出"
description = "* 此功能极度危险,滥用可能会导致您的账号被冻结;为了您的人身安全,请勿发送恶意代码\n\n开启后需在聊天界面长按加号呼出 (可关闭),或长按发送按钮呼出"
)
public class QQPacketHelperEntry extends BaseSwitchFunctionHookItem {
public class QQPacketHelperEntry extends BaseClickableFunctionHookItem {
private void hook() {
try {
Method method = XMethod.clz(CLAZZ_PANEL_ICON_LINEAR_LAYOUT).ret(ImageView.class).ignoreParam().get();
hookAfter(method, param -> {
ImageView imageView = (ImageView) param.getResult();
if ("更多功能".contentEquals(imageView.getContentDescription())){
imageView.setOnLongClickListener(view -> {
runOnUiThread(() -> PacketHelperDialog.createView(null, view.getContext(), ""));
return true;
});
}
});
if (ConfigManager.dGetBooleanDefTrue(Constants.PrekCfgXXX + "QQPacketHelperHookPanel")) {
Method method = XMethod.clz(CLAZZ_PANEL_ICON_LINEAR_LAYOUT).ret(ImageView.class).ignoreParam().get();
hookAfter(method, param -> {
ImageView imageView = (ImageView) param.getResult();
if ("更多功能".contentEquals(imageView.getContentDescription())){
imageView.setOnLongClickListener(view -> {
runOnUiThread(() -> PacketHelperDialog.createView(null, view.getContext(), ""));
return true;
});
}
});
}
} catch (NoSuchMethodException e) {
Logger.e(this.getItemName(), e);
}
Expand Down
Loading