Skip to content

Commit

Permalink
feat: hide stories from service notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry-ZHR committed Apr 27, 2024
1 parent ea20b5e commit cf92e9f
Show file tree
Hide file tree
Showing 5 changed files with 42 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 @@ -125,6 +125,9 @@ class SettingsFragment : BaseHierarchyFragment() {
ShowExactLastSeenTime, "ShowExactLastSeenTime", R.string.ShowExactLastSeenTime,
"ShowExactLastSeenTimeDesc", R.string.ShowExactLastSeenTimeDesc
)
functionSwitch(
HideServiceStories, "HideServiceStories", R.string.HideServiceStories
)
}
category("LostMsgMitigation", R.string.LostMsgMitigation) {
functionSwitch(
Expand Down
36 changes: 36 additions & 0 deletions app/src/main/java/cc/ioctl/tmoe/hook/func/HideServiceStories.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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.argTypes
import com.github.kyuubiran.ezxhelper.utils.field
import com.github.kyuubiran.ezxhelper.utils.hookAfter
import com.github.kyuubiran.ezxhelper.utils.loadClass
import com.github.kyuubiran.ezxhelper.utils.method
import com.github.kyuubiran.ezxhelper.utils.staticMethod
import com.github.kyuubiran.ezxhelper.utils.tryOrLogFalse

@FunctionHookEntry
object HideServiceStories : CommonDynamicHook() {
override fun initOnce(): Boolean = tryOrLogFalse {
// Telegram uses this method to decide if users can hide the stories
// https://github.com/DrKLO/Telegram/blob/a906f12aaec2768969c77650a7e4b377baa6cf2a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java#L4913-L4916
val mIsService = loadClass("org.telegram.messenger.UserObject").staticMethod(
"isService",
Boolean::class.java,
argTypes(Long::class.java)
)
val kUser = loadClass("org.telegram.tgnet.TLRPC\$User")
val fHidden = kUser.field("stories_hidden", false, Boolean::class.java)
loadClass("org.telegram.messenger.MessagesController").method(
"getUser",
kUser,
false,
argTypes(Long::class.javaObjectType)
).hookAfter { param ->
if (isEnabled && mIsService.invoke(null, param.args[0]) == true) {
fHidden.set(param.result, true)
}
}
}
}
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 @@ -63,4 +63,5 @@
<string name="ShowExactLastSeenTime">最后上线精确到秒</string>
<string name="ShowExactLastSeenTimeDesc">仅对有权限查看用户最后上线时间的用户有效</string>
<string name="DisableInstantCamera">禁用即时相机</string>
<string name="HideServiceStories">隐藏“服务通知”的动态</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
<string name="AddReloadMsgBtn">新增重新整理訊息按鈕</string>
<string name="AddReloadMsgBtnDesc">在聊天選單新增重新整理訊息按鈕</string>
<string name="KeepVideoMuted">按音量鍵時保持影片靜音</string>
<string name="HideServiceStories">隱藏“服務通知”的動態</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 @@ -91,4 +91,5 @@
<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>
<string name="HideServiceStories">Hide stories from service notifications</string>
</resources>

0 comments on commit cf92e9f

Please sign in to comment.