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
38 changes: 4 additions & 34 deletions app/src/main/java/moe/ono/creator/JsonViewerDialog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import android.os.Handler
import android.os.Looper
import android.widget.Button
import android.widget.RadioGroup
import android.widget.TextView
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.core.BasePopupView
import com.lxj.xpopup.core.BottomPopupView
Expand All @@ -29,8 +30,11 @@ class JsonViewerDialog(context: Context) : BottomPopupView(context) {
val jsonViewer = findViewById<JsonViewer>(R.id.rv_json)
val btnCopy = findViewById<Button>(R.id.btn_copy)
val rgType = findViewById<RadioGroup>(R.id.rg_type)
val title = findViewById<TextView>(R.id.title)
var copyText: String

title.text = "Json Viewer"

jsonViewer.setJson(content)

copyText = jsonViewer.getJSONString()
Expand All @@ -47,40 +51,6 @@ class JsonViewerDialog(context: Context) : BottomPopupView(context) {
}, 100)
}

private fun formatMsgRecord(input: String): String {
var indentLevel = 0
val indentStep = " "
val result = StringBuilder()

input.forEach { char ->
when (char) {
'{' -> {
result.append(char)
result.append("\n")
indentLevel++
result.append(indentStep.repeat(indentLevel))
}
'}' -> {
result.append("\n")
indentLevel = if (indentLevel > 0) indentLevel - 1 else 0
result.append(indentStep.repeat(indentLevel))
result.append(char)
}
',' -> {
result.append(char)
result.append("\n")
result.append(indentStep.repeat(indentLevel))
}
else -> {
result.append(char)
}
}
}
return result.toString()
}




override fun getImplLayoutId(): Int {
return R.layout.layout_qq_message_fetcher_result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,11 @@ object ClickableFunctionDialog {
checkBox.isChecked = item.isEnabled
root.addView(checkBox)

val manualDecryptCheckBox = MaterialCheckBox(context)
manualDecryptCheckBox.text = "启用手动解密"
manualDecryptCheckBox.isChecked = ConfigManager.dGetBoolean(Constants.PrekCfgXXX + "manualDecrypt")
root.addView(manualDecryptCheckBox)

val inputMarginTop = (8 * context.resources.displayMetrics.density).toInt()

val tilKey = TextInputLayout(context)
Expand Down Expand Up @@ -569,6 +574,10 @@ object ClickableFunctionDialog {
}
}

manualDecryptCheckBox.setOnCheckedChangeListener { _, isChecked ->
ConfigManager.dPutBoolean(Constants.PrekCfgXXX + "manualDecrypt", isChecked)
}

val keyWatcher: TextWatcher = object : TextWatcher {
override fun beforeTextChanged(s: CharSequence, st: Int, c: Int, a: Int) {}
override fun afterTextChanged(s: Editable) {}
Expand Down
61 changes: 48 additions & 13 deletions app/src/main/java/moe/ono/hooks/item/chat/BottomShortcutMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,38 @@ import android.annotation.SuppressLint
import android.content.Context
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import com.lxj.xpopup.XPopup
import de.robv.android.xposed.XC_MethodHook
import de.robv.android.xposed.XC_MethodHook.MethodHookParam
import de.robv.android.xposed.XposedHelpers
import moe.ono.bridge.ntapi.ChatTypeConstants.GROUP
import moe.ono.R
import moe.ono.config.CacheConfig
import moe.ono.config.ConfigManager
import moe.ono.constants.Constants
import moe.ono.creator.PacketHelperDialog
import moe.ono.creator.FakeFileSender
import moe.ono.creator.PacketHelperDialog
import moe.ono.creator.QQMessageTrackerDialog
import moe.ono.hooks.XHook
import moe.ono.hooks._base.BaseSwitchFunctionHookItem
import moe.ono.hooks._core.annotation.HookItem
import moe.ono.hooks._core.factory.HookItemFactory
import moe.ono.hooks._core.factory.HookItemFactory.getItem
import moe.ono.hooks.base.util.Toasts
import moe.ono.hooks.item.developer.QQHookCodec
import moe.ono.hooks.item.developer.QQPacketHelperEntry
import moe.ono.hooks.item.sigma.QQMessageTracker
import moe.ono.reflex.XMethod
import moe.ono.ui.CommonContextWrapper
import moe.ono.util.ContactUtils
import moe.ono.util.Initiator
import moe.ono.util.Logger
import moe.ono.util.Session
import moe.ono.util.SyncUtils

@SuppressLint("DiscouragedApi")
@HookItem(
path = "聊天与消息/快捷菜单",
description = "长按红包或拍照按钮调出快捷菜单,部分功能依赖此选项,推荐开启"
description = "点击聊天页面下方 ONO 图标调出快捷菜单,部分功能依赖此选项,推荐开启"
)
class BottomShortcutMenu : BaseSwitchFunctionHookItem() {
private val classNames: List<String> = mutableListOf(
Expand All @@ -52,13 +51,49 @@ class BottomShortcutMenu : BaseSwitchFunctionHookItem() {

hookAfter(method) { param: MethodHookParam ->
val imageView = param.result as ImageView
if ("红包".contentEquals(imageView.contentDescription) || "拍照".contentEquals(imageView.contentDescription)) {
imageView.setOnLongClickListener { view: View ->
val fixContext =
CommonContextWrapper.createAppCompatContext(imageView.context)
popMenu(fixContext, view)
true
}
if ("拍照".contentEquals(imageView.contentDescription)) {
imageView.addOnAttachStateChangeListener(object : View.OnAttachStateChangeListener {
override fun onViewAttachedToWindow(v: View) {
val parent = v.parent
if (parent is ViewGroup) {
Logger.d(parent::class.java.name)

fun foundONO(view: ViewGroup) : Boolean {
for (i in 0 until view.childCount) {
val child = view.getChildAt(i)
if (child.contentDescription == "ONO") {
return true
}
}
return false
}

if (!foundONO(parent)) {
val onoImageView = ImageView(parent.context)
onoImageView.setImageResource(R.drawable.ic_ouo)
onoImageView.contentDescription = "ONO"

val layoutParams = LinearLayout.LayoutParams(0, (28.0f * parent.resources.displayMetrics.density + 0.5f).toInt())
layoutParams.weight = 1.0f
layoutParams.gravity = 16

onoImageView.layoutParams = layoutParams

onoImageView.setOnClickListener { view ->
val fixContext =
CommonContextWrapper.createAppCompatContext(imageView.context)
popMenu(fixContext, view)
true
}

parent.addView(onoImageView, 4)
}
}
}

override fun onViewDetachedFromWindow(v: View) {
}
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/moe/ono/hooks/item/chat/MessageEncryptor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ import moe.ono.bridge.ntapi.ChatTypeConstants.GROUP
import moe.ono.bridge.ntapi.MsgServiceHelper
import moe.ono.config.ConfigManager
import moe.ono.config.DailySaying
import moe.ono.constants.Constants
import moe.ono.ext.getUnknownObject
import moe.ono.ext.getUnknownObjects
import moe.ono.ext.toInnerValuesString
import moe.ono.hooks._base.BaseClickableFunctionHookItem
import moe.ono.hooks._core.annotation.HookItem
import moe.ono.hooks._core.factory.HookItemFactory.getItem
import moe.ono.hooks.base.util.Toasts
import moe.ono.hooks.dispatcher.OnMenuBuilder
import moe.ono.hooks.item.developer.QQHookCodec
Expand All @@ -42,7 +42,7 @@ import moe.ono.util.Session
import moe.ono.util.SyncUtils

@SuppressLint("DiscouragedApi")
@HookItem(path = "聊天与消息/群聊加密消息", description = "发送的消息将加密抄送,仅针对群聊\n* 长按文本消息可手动解密\n* 手动解密功能依赖 娱乐功能/修改文本消息\n* 开启需重启\n* 禁止用于非法用途,违者后果自负\n* 需开启 '开发者选项/注入 CodecWarpper'")
@HookItem(path = "聊天与消息/群聊加密消息", description = "发送的消息将加密抄送,仅针对群聊\n* 长按文本消息可手动解密(需开启手动解密)\n* 手动解密功能依赖 娱乐功能/修改文本消息\n* 开启需重启\n* 禁止用于非法用途,违者后果自负\n* 需开启 '开发者选项/注入 CodecWarpper'")
class MessageEncryptor : BaseClickableFunctionHookItem(), OnMenuBuilder {
companion object {
var decryptMsg = false
Expand Down Expand Up @@ -199,7 +199,7 @@ class MessageEncryptor : BaseClickableFunctionHookItem(), OnMenuBuilder {
)

override fun onGetMenu(aioMsgItem: Any, targetType: String, param: XC_MethodHook.MethodHookParam) {
if (!getItem(this.javaClass).isEnabled) {
if (!ConfigManager.dGetBoolean(Constants.PrekCfgXXX + "manualDecrypt")) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/title"
android:layout_gravity="center_horizontal"
android:text="原始消息"
android:textSize="19sp"
Expand Down