Skip to content

Commit

Permalink
Merge pull request #88 from maqli/master
Browse files Browse the repository at this point in the history
support targetSdkVersion 30
  • Loading branch information
JeasonWong authored Dec 21, 2021
2 parents c924978 + 0db5cc9 commit 6adcb4e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions uetool/src/main/java/me/ele/uetool/CollectViewsLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,18 @@ public Void call() {
for (int i = viewRootImpls.size() - 1; i >= 0; i--) {
Class clazz = Class.forName("android.view.ViewRootImpl");
Object object = viewRootImpls.get(i);
Field mWindowAttributesField = clazz.getDeclaredField("mWindowAttributes");
mWindowAttributesField.setAccessible(true);
WindowManager.LayoutParams layoutParams = null;
try {
Field mWindowAttributesField = clazz.getDeclaredField("mWindowAttributes");
mWindowAttributesField.setAccessible(true);
layoutParams = (WindowManager.LayoutParams) mWindowAttributesField.get(object);
} catch (Exception e) {
e.printStackTrace();
}
Field mViewField = clazz.getDeclaredField("mView");
mViewField.setAccessible(true);
View decorView = (View) mViewField.get(object);
WindowManager.LayoutParams layoutParams = (WindowManager.LayoutParams) mWindowAttributesField.get(object);
if (layoutParams.getTitle().toString().contains(targetActivity.getClass().getName())
if ((layoutParams != null && layoutParams.getTitle().toString().contains(targetActivity.getClass().getName()))
|| getTargetDecorView(targetActivity, decorView) != null) {
createElements(decorView);
break;
Expand Down

0 comments on commit 6adcb4e

Please sign in to comment.