()
| 19 | } |
| 20 | |
| 21 | @Override |
| 22 | public boolean initOnce() throws Exception { |
| 23 | Class<?> kChatMessageCell = Initiator.loadClass("org.telegram.ui.Cells.ChatMessageCell"); |
| 24 | Method measureTime = kChatMessageCell.getDeclaredMethod("measureTime", |
| 25 | Initiator.loadClass("org.telegram.messenger.MessageObject")); |
| 26 | Field currentTimeString = kChatMessageCell.getDeclaredField("currentTimeString"); |
| 27 | currentTimeString.setAccessible(true); |
| 28 | Field messageOwner = Initiator.loadClass("org.telegram.messenger.MessageObject").getDeclaredField("messageOwner"); |
| 29 | messageOwner.setAccessible(true); |
| 30 | Field msgId = Initiator.loadClass("org.telegram.tgnet.TLRPC$Message").getDeclaredField("id"); |
| 31 | msgId.setAccessible(true); |
| 32 | Class<?> kTheme = Initiator.loadClass("org.telegram.ui.ActionBar.Theme"); |
| 33 | Field chatTimePaint = kTheme.getDeclaredField("chat_timePaint"); |
| 34 | chatTimePaint.setAccessible(true); |
| 35 | Field timeTextWidth = kChatMessageCell.getDeclaredField("timeTextWidth"); |
| 36 | timeTextWidth.setAccessible(true); |
| 37 | Field timeWidth = kChatMessageCell.getDeclaredField("timeWidth"); |
| 38 | timeWidth.setAccessible(true); |
| 39 | HookUtils.hookAfterIfEnabled(this, measureTime, param -> { |
| 40 | CharSequence time = (CharSequence) currentTimeString.get(param.thisObject); |
| 41 | Object messageObject = param.args[0]; |
| 42 | Object owner = messageOwner.get(messageObject); |
| 43 | int id = msgId.getInt(owner); |
| 44 | String delta = id + " "; |
| 45 | time = delta + time; |
| 46 | currentTimeString.set(param.thisObject, time); |
| 47 | TextPaint paint = (TextPaint) chatTimePaint.get(null); |
| 48 | assert paint != null; |
| 49 | int deltaWidth = (int) Math.ceil(paint.measureText(delta)); |
| 50 | timeTextWidth.setInt(param.thisObject, deltaWidth + timeTextWidth.getInt(param.thisObject)); |
| 51 | timeWidth.setInt(param.thisObject, deltaWidth + timeWidth.getInt(param.thisObject)); |
| 52 | }); |
| 53 | return true; |
| 54 | } |
| 55 | } |
nothing calls this directly
no test coverage detected