Skip to content

Commit

Permalink
feat: DisableInstantCamera
Browse files Browse the repository at this point in the history
  • Loading branch information
huajijam committed Dec 13, 2023
1 parent dda1a38 commit d21fe52
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/cc/ioctl/tmoe/fragment/SettingsFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class SettingsFragment : BaseHierarchyFragment() {
functionSwitch(
SendCommand, "SendCommand", R.string.SendCommand
)
functionSwitch(
DisableInstantCamera, "DisableInstantCamera", R.string.DisableInstantCamera
)
functionSwitch(
ForceBlurChatAvailable, "ForceBlurChatAvailable", R.string.ForceBlurChatAvailable
)
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/cc/ioctl/tmoe/hook/func/DisableInstantCamera.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cc.ioctl.tmoe.hook.func

import cc.ioctl.tmoe.base.annotation.FunctionHookEntry
import cc.ioctl.tmoe.hook.base.CommonDynamicHook
import com.github.kyuubiran.ezxhelper.utils.findMethod
import com.github.kyuubiran.ezxhelper.utils.hookBefore
import com.github.kyuubiran.ezxhelper.utils.loadClass
import com.github.kyuubiran.ezxhelper.utils.tryOrLogFalse
import de.robv.android.xposed.XposedBridge
import java.lang.Enum as JEnum

@FunctionHookEntry
object DisableInstantCamera : CommonDynamicHook() {
override fun initOnce(): Boolean = tryOrLogFalse {
findMethod(loadClass("org.telegram.ui.Components.ChatActivityEnterViewAnimatedIconView")) {
name == "setState" && parameterTypes.size == 2
}.hookBefore {

if (!isEnabled) return@hookBefore

try {
val state = it.args[0] as JEnum<*>
if (state.name() == "VIDEO") {
it.args[0] = JEnum.valueOf(state.javaClass as Class<out Enum<*>>, "VOICE")
}
} catch (e: Throwable) {
XposedBridge.log(e)
}
}

findMethod(loadClass("org.telegram.ui.Components.ChatActivityEnterView")) { name == "isInVideoMode" }.hookBefore {
if (isEnabled) it.result = false
}

findMethod(loadClass("org.telegram.ui.Components.ChatActivityEnterView")) { name == "hasRecordVideo" }.hookBefore {
if (isEnabled) it.result = false
}
}
}
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@
<string name="DialogButton_Confirm">确认</string>
<string name="ShowExactLastSeenTime">最后上线精确到秒</string>
<string name="ShowExactLastSeenTimeDesc">仅对有权限查看用户最后上线时间的用户有效</string>
<string name="DisableInstantCamera">禁用即时相机</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,5 @@
<string name="DialogMsg_ConfirmDumpChannelMembers">Fetch group members?</string>
<string name="FuckTrackingHook">Remove tracking</string>
<string name="FuckTrackingHookDesc">If you click on an ad provided by Telegram, they will track it and might use it as the basis for personalizing the ad.This function is to disable it</string>
<string name="DisableInstantCamera">Disable Instant Camera</string>
</resources>

0 comments on commit d21fe52

Please sign in to comment.