@@ -33,11 +33,11 @@ object ShowIdInProfile : CommonDynamicHook(), ProfileActivityRowHook.Callback {
33
33
(Reflex .getInstanceObjectOrNull(holder, " itemView" ) as ? FrameLayout )?.let { textCell ->
34
34
Parasitics .injectModuleResources(HostInfo .getApplication().resources)
35
35
val userId = getUserId(profileActivity)
36
- val realId = if (userId == 0L ) getChatId (profileActivity) else userId
36
+ val realId = if (userId == 0L ) getChatOrTopicId (profileActivity) else userId.toString()
37
37
val isUser = userId != 0L
38
38
val title = if (isUser) LocaleController .getString(" UserId" , R .string.UserId )
39
39
else LocaleController .getString(" GroupOrChannelId" , R .string.GroupOrChannelId )
40
- XposedHelpers .callMethod(textCell, " setTextAndValue" , realId.toString() , title, false )
40
+ XposedHelpers .callMethod(textCell, " setTextAndValue" , realId, title, false )
41
41
}
42
42
return true
43
43
}
@@ -50,10 +50,10 @@ object ShowIdInProfile : CommonDynamicHook(), ProfileActivityRowHook.Callback {
50
50
override fun onItemClicked (key : String , adapter : Any , profileActivity : Any ): Boolean {
51
51
if (rowName != key) return false
52
52
val userId = getUserId(profileActivity)
53
- val realId = if (userId == 0L ) getChatId (profileActivity) else userId
53
+ val realId = if (userId == 0L ) getChatOrTopicId (profileActivity) else userId.toString()
54
54
val context = HostInfo .getApplication()
55
55
context.getSystemService(ClipboardManager ::class .java)
56
- .setPrimaryClip(ClipData .newPlainText(" " , realId.toString() ))
56
+ .setPrimaryClip(ClipData .newPlainText(" " , realId))
57
57
Toast .makeText(context, LocaleController .getString(" IdCopied" , R .string.IdCopied ), Toast .LENGTH_SHORT ).show()
58
58
return true
59
59
}
@@ -62,20 +62,36 @@ object ShowIdInProfile : CommonDynamicHook(), ProfileActivityRowHook.Callback {
62
62
manipulator : ProfileActivityRowHook .RowManipulator ,
63
63
profileActivity : Any
64
64
) {
65
- var row = manipulator.getRowIdForField(" infoHeaderRow" )
66
- row = if (row == - 1 ) 1 else row + 1
65
+ val row = manipulator.getRowIdForField(" notificationsRow" )
66
+ .let { nr ->
67
+ if (nr != - 1 ) nr
68
+ else manipulator.getRowIdForField(" infoHeaderRow" ).let { ihr ->
69
+ if (ihr == - 1 ) 1 else ihr + 1
70
+ }
71
+ }
67
72
manipulator.insertRowAtPosition(rowName, row)
68
73
}
69
74
70
75
private fun getUserId (profileActivity : Any ): Long {
71
- return XposedHelpers .getObjectField(profileActivity, " userId" ) as Long
76
+ return ( XposedHelpers .getObjectField(profileActivity, " userId" ) as Number ).toLong()
72
77
}
73
78
74
79
private fun getChatId (profileActivity : Any ): Long {
75
80
val chat = XposedHelpers .getObjectField(profileActivity, " currentChat" )
76
81
if (chat != null ) {
77
- return XposedHelpers .getObjectField(chat, " id" ) as Long
82
+ return ( XposedHelpers .getObjectField(chat, " id" ) as Number ).toLong()
78
83
}
79
84
return 0L
80
85
}
86
+
87
+ private fun getTopicId (profileActivity : Any ): Long {
88
+ return (XposedHelpers .getObjectField(profileActivity, " topicId" ) as Number ).toLong()
89
+ }
90
+
91
+ private fun getChatOrTopicId (profileActivity : Any ): String {
92
+ val chatId = getChatId(profileActivity)
93
+ val topicId = getTopicId(profileActivity)
94
+ if (topicId == 0L ) return chatId.toString()
95
+ return " $chatId /$topicId "
96
+ }
81
97
}
0 commit comments