Skip to content

Commit

Permalink
Update current tab using mActivityTabProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
JingMatrix committed Nov 25, 2023
1 parent b969aaf commit aa2a4c9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/org/matrix/chromext/hook/PageMenu.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.matrix.chromext.hook

import android.content.Context
import android.os.Handler
import android.util.DisplayMetrics
import android.view.Menu
import android.view.MenuInflater
Expand Down Expand Up @@ -112,6 +113,12 @@ object PageMenuHook : BaseHook() {
val mContext =
findField(appMenuPropertiesDelegateImpl, true) { type == Context::class.java }
mContext.setAccessible(true)
val mActivityTabProvider =
findField(appMenuPropertiesDelegateImpl, true) {
type.interfaces.size == 1 &&
findFieldOrNull(type.superclass) { type == Handler::class.java } != null
}
mActivityTabProvider.setAccessible(true)

if (Chrome.isBrave) {
// Brave browser replaces the first row menu with class AppMenuIconRowFooter,
Expand Down Expand Up @@ -142,6 +149,8 @@ object PageMenuHook : BaseHook() {
}
// public void prepareMenu(Menu menu, AppMenuHandler handler)
.hookAfter inflate@{
val tabProvider = mActivityTabProvider.get(it.thisObject)!!
Chrome.updateTab(tabProvider.invokeMethod { name == "get" })
val ctx = mContext.get(it.thisObject) as Context
Resource.enrich(ctx)

Expand Down

0 comments on commit aa2a4c9

Please sign in to comment.