Skip to content

Commit 9d96524

Browse files
committed
1. Menu变为contentview的一个View
2. 解决更多Menu弹出的Popupwindow的复选框无效的问题 3. 增加对平板和手机的适配 4. 增加对androidx的支持
1 parent f48764e commit 9d96524

40 files changed

+454
-255
lines changed

app/build.gradle

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ android {
1919
versionCode 1
2020
versionName "1.0"
2121

22-
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
22+
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
2323
}
2424

2525
signingConfigs {
@@ -53,18 +53,18 @@ android {
5353

5454
dependencies {
5555

56-
implementation 'com.android.support:appcompat-v7:28.0.0'
56+
implementation 'androidx.appcompat:appcompat:1.0.0'
5757
implementation 'org.jetbrains:annotations:15.0'
5858
releaseImplementation project(path: ':layoutinspector-no-op')
5959
debugImplementation project(path: ':layoutinspector')
6060
testImplementation 'junit:junit:4.+'
61-
androidTestImplementation 'com.android.support.test:runner:1.0.2'
62-
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
61+
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
62+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
6363

6464
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.3.72"
65-
implementation 'com.android.support:support-annotations:+'
65+
implementation 'androidx.annotation:annotation:1.0.0'
6666
//noinspection GradleCompatible
67-
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
67+
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
6868

6969
// debugImplementation 'com.github.niuxiaowei.LayoutInspector:layoutinspector:2.0.2'
7070
// releaseImplementation 'com.github.niuxiaowei.LayoutInspector:layoutinspector-no-op:2.0.2'
@@ -204,5 +204,19 @@ replaceMethod {
204204
}
205205
}
206206

207+
//ImageView相关操作
208+
register {
209+
replace {
210+
invokeType "ins"
211+
className "android.widget.ImageView"
212+
methodName "setImageResource"
213+
desc "(int)"
214+
}
215+
by {
216+
className = "com.mi.layoutinspector.replacemethod.ImageViewProxy"
217+
addExtraParams = true
218+
}
219+
}
220+
207221
}
208222
}

app/src/androidTest/java/com/example/layoutinspector/ExampleInstrumentedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.example.layoutinspector;
22

33
import android.content.Context;
4-
import android.support.test.InstrumentationRegistry;
5-
import android.support.test.runner.AndroidJUnit4;
4+
import androidx.test.platform.app.InstrumentationRegistry;
5+
import androidx.test.ext.junit.runners.AndroidJUnit4;
66

77
import org.junit.Test;
88
import org.junit.runner.RunWith;

app/src/main/java/com/example/layoutinspector/AddToContentViewFragment.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import android.app.Fragment;
44
import android.os.Bundle;
5-
import android.support.annotation.NonNull;
6-
import android.support.annotation.Nullable;
5+
import androidx.annotation.NonNull;
6+
import androidx.annotation.Nullable;
77
import android.view.LayoutInflater;
88
import android.view.View;
99
import android.view.ViewGroup;

app/src/main/java/com/example/layoutinspector/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.example.layoutinspector;
22
import android.media.projection.MediaProjectionManager;
33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
4+
import androidx.appcompat.app.AppCompatActivity;
55

66

77

app/src/main/java/com/example/layoutinspector/MainFragment.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
import android.content.DialogInterface;
88
import android.os.Build;
99
import android.os.Bundle;
10-
import android.support.annotation.NonNull;
11-
import android.support.annotation.Nullable;
12-
import android.support.annotation.RequiresApi;
10+
import androidx.annotation.NonNull;
11+
import androidx.annotation.Nullable;
12+
import androidx.annotation.RequiresApi;
1313
import android.util.Log;
1414
import android.view.Gravity;
1515
import android.view.LayoutInflater;
1616
import android.view.View;
1717
import android.view.ViewGroup;
18+
import android.widget.ImageView;
1819
import android.widget.LinearLayout;
1920
import android.widget.PopupWindow;
2021
import android.widget.Toast;
@@ -95,6 +96,8 @@ public boolean onLongClick(View v) {
9596
return true;
9697
}
9798
});
99+
100+
((ImageView) view.findViewById(R.id.image)).setImageResource(R.drawable.ic_launcher_background);
98101
}
99102

100103
private void showPopupWindow(View anchor) {

app/src/main/java/com/example/layoutinspector/MyView.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.example.layoutinspector;
22

33
import android.content.Context;
4-
import android.support.annotation.Nullable;
4+
import androidx.annotation.Nullable;
55
import android.util.AttributeSet;
66
import android.widget.LinearLayout;
77

app/src/main/java/com/example/layoutinspector/SecondActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.example.layoutinspector;
22

33
import android.os.Bundle;
4-
import android.support.v7.app.AppCompatActivity;
4+
import androidx.appcompat.app.AppCompatActivity;
55

66

77
public class SecondActivity extends AppCompatActivity {
Lines changed: 131 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,160 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
33
xmlns:app="http://schemas.android.com/apk/res-auto"
44
xmlns:tools="http://schemas.android.com/tools"
5-
android:orientation="vertical"
65
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
8-
9-
<TextView
10-
android:id="@+id/click"
11-
android:layout_marginTop="10dp"
12-
android:layout_gravity="center_horizontal"
13-
android:gravity="center"
14-
android:padding="3dp"
15-
android:textSize="13dp"
16-
android:layout_width="wrap_content"
17-
android:layout_height="wrap_content"
18-
android:textColor="#000000"
19-
android:layout_margin="10dp"
20-
android:text="点击跳入第二个fragment" />
21-
22-
23-
<TextView
24-
android:id="@+id/show_dialog"
25-
android:layout_marginTop="10dp"
26-
android:padding="5dp"
27-
android:textSize="13dp"
28-
android:layout_gravity="center_horizontal"
29-
android:layout_width="wrap_content"
30-
android:layout_height="wrap_content"
31-
android:textColor="#000000"
32-
android:text="弹一个dialog" />
33-
34-
35-
<TextView
36-
android:id="@+id/click3"
37-
android:layout_marginTop="10dp"
38-
android:padding="5dp"
39-
android:textSize="13dp"
40-
android:layout_gravity="center_horizontal"
41-
android:layout_width="wrap_content"
42-
android:layout_height="wrap_content"
43-
android:textColor="@color/teal_200"
44-
android:text="设置了长按事件" />
45-
46-
<com.example.layoutinspector.MyView
47-
android:layout_marginTop="10dp"
48-
android:layout_width="match_parent"
49-
android:layout_height="wrap_content"/>
6+
android:layout_height="match_parent"
7+
android:orientation="vertical">
508

51-
<LinearLayout
52-
android:orientation="vertical"
53-
android:gravity="bottom"
9+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
10+
xmlns:app="http://schemas.android.com/apk/res-auto"
11+
xmlns:tools="http://schemas.android.com/tools"
5412
android:layout_width="match_parent"
55-
android:layout_height="wrap_content">
13+
android:layout_height="match_parent"
14+
android:orientation="vertical">
5615

5716
<TextView
58-
android:layout_marginTop="10dp"
59-
android:layout_marginBottom="20dp"
60-
android:layout_marginLeft="20dp"
61-
android:padding="5dp"
62-
android:textSize="13dp"
63-
android:gravity="center_horizontal"
64-
android:layout_gravity="center_horizontal"
65-
android:id="@+id/show_pupupwindow"
17+
android:id="@+id/click"
6618
android:layout_width="wrap_content"
6719
android:layout_height="wrap_content"
20+
android:layout_gravity="center_horizontal"
21+
android:layout_margin="10dp"
22+
android:layout_marginTop="10dp"
23+
android:gravity="center"
24+
android:padding="3dp"
25+
android:text="点击跳入第二个fragment"
6826
android:textColor="#000000"
69-
android:text="showAsDropDown(anchor)方法弹一个popupwindow" />
27+
android:textSize="13dp" />
28+
7029

7130
<TextView
72-
android:layout_marginTop="10dp"
73-
android:layout_marginBottom="20dp"
74-
android:layout_marginLeft="20dp"
75-
android:padding="5dp"
76-
android:textSize="13dp"
77-
android:gravity="center_horizontal"
78-
android:layout_gravity="center_horizontal"
79-
android:id="@+id/show_pupupwindow1"
31+
android:id="@+id/show_dialog"
8032
android:layout_width="wrap_content"
8133
android:layout_height="wrap_content"
82-
android:textColor="#000000"
83-
android:text="showAsDropDown(anchor,xoff,yoff)方法弹一个popupwindow" />
84-
85-
<TextView
34+
android:layout_gravity="center_horizontal"
8635
android:layout_marginTop="10dp"
87-
android:layout_marginBottom="20dp"
88-
android:layout_marginLeft="20dp"
8936
android:padding="5dp"
90-
android:textSize="13dp"
91-
android:gravity="center_horizontal"
92-
android:layout_gravity="center_horizontal"
93-
android:id="@+id/show_pupupwindow2"
94-
android:layout_width="wrap_content"
95-
android:layout_height="wrap_content"
37+
android:text="弹一个dialog"
9638
android:textColor="#000000"
97-
android:text="showAsDropDown(anchor,xoff,yoff,gravity)方法弹一个popupwindow" />
39+
android:textSize="13dp" />
9840

9941

10042
<TextView
101-
android:layout_marginTop="10dp"
102-
android:layout_marginBottom="20dp"
103-
android:layout_marginLeft="20dp"
104-
android:padding="5dp"
105-
android:textSize="13dp"
106-
android:gravity="center_horizontal"
107-
android:layout_gravity="center_horizontal"
108-
android:id="@+id/show_pupupwindow3"
43+
android:id="@+id/click3"
10944
android:layout_width="wrap_content"
11045
android:layout_height="wrap_content"
111-
android:textColor="#000000"
112-
android:text="showAtLocation方法弹一个popupwindow" />
113-
114-
<TextView
115-
android:id="@+id/show_toast"
46+
android:layout_gravity="center_horizontal"
11647
android:layout_marginTop="10dp"
117-
android:layout_marginBottom="20dp"
11848
android:padding="5dp"
119-
android:textSize="13dp"
120-
android:gravity="center_horizontal"
121-
android:layout_gravity="center_horizontal"
122-
android:layout_width="wrap_content"
49+
android:text="设置了长按事件"
50+
android:textColor="@color/teal_200"
51+
android:textSize="13dp" />
52+
53+
<com.example.layoutinspector.MyView
54+
android:layout_width="match_parent"
12355
android:layout_height="wrap_content"
124-
android:textColor="#000000"
125-
android:text="弹一个toast" />
56+
android:layout_marginTop="10dp" />
57+
58+
<LinearLayout
59+
android:layout_width="match_parent"
60+
android:layout_height="wrap_content"
61+
android:gravity="bottom"
62+
android:orientation="vertical">
63+
64+
<TextView
65+
android:id="@+id/show_pupupwindow"
66+
android:layout_width="wrap_content"
67+
android:layout_height="wrap_content"
68+
android:layout_gravity="center_horizontal"
69+
android:layout_marginLeft="20dp"
70+
android:layout_marginTop="10dp"
71+
android:layout_marginBottom="20dp"
72+
android:gravity="center_horizontal"
73+
android:padding="5dp"
74+
android:text="showAsDropDown(anchor)方法弹一个popupwindow"
75+
android:textColor="#000000"
76+
android:textSize="13dp" />
77+
78+
<TextView
79+
android:id="@+id/show_pupupwindow1"
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:layout_gravity="center_horizontal"
83+
android:layout_marginLeft="20dp"
84+
android:layout_marginTop="10dp"
85+
android:layout_marginBottom="20dp"
86+
android:gravity="center_horizontal"
87+
android:padding="5dp"
88+
android:text="showAsDropDown(anchor,xoff,yoff)方法弹一个popupwindow"
89+
android:textColor="#000000"
90+
android:textSize="13dp" />
91+
92+
<TextView
93+
android:id="@+id/show_pupupwindow2"
94+
android:layout_width="wrap_content"
95+
android:layout_height="wrap_content"
96+
android:layout_gravity="center_horizontal"
97+
android:layout_marginLeft="20dp"
98+
android:layout_marginTop="10dp"
99+
android:layout_marginBottom="20dp"
100+
android:gravity="center_horizontal"
101+
android:padding="5dp"
102+
android:text="showAsDropDown(anchor,xoff,yoff,gravity)方法弹一个popupwindow"
103+
android:textColor="#000000"
104+
android:textSize="13dp" />
105+
106+
107+
<TextView
108+
android:id="@+id/show_pupupwindow3"
109+
android:layout_width="wrap_content"
110+
android:layout_height="wrap_content"
111+
android:layout_gravity="center_horizontal"
112+
android:layout_marginLeft="20dp"
113+
android:layout_marginTop="10dp"
114+
android:layout_marginBottom="20dp"
115+
android:gravity="center_horizontal"
116+
android:padding="5dp"
117+
android:text="showAtLocation方法弹一个popupwindow"
118+
android:textColor="#000000"
119+
android:textSize="13dp" />
120+
121+
<TextView
122+
android:id="@+id/show_toast"
123+
android:layout_width="wrap_content"
124+
android:layout_height="wrap_content"
125+
android:layout_gravity="center_horizontal"
126+
android:layout_marginTop="10dp"
127+
android:layout_marginBottom="20dp"
128+
android:gravity="center_horizontal"
129+
android:padding="5dp"
130+
android:text="弹一个toast"
131+
android:textColor="#000000"
132+
android:textSize="13dp" />
133+
134+
<ImageView
135+
android:id="@+id/image"
136+
android:layout_width="wrap_content"
137+
android:layout_height="wrap_content"
138+
android:layout_gravity="center_horizontal"
139+
android:layout_marginTop="10dp"
140+
android:layout_marginBottom="20dp"
141+
android:gravity="center_horizontal"
142+
android:padding="5dp"
143+
/>
144+
</LinearLayout>
145+
146+
126147
</LinearLayout>
127148

149+
<LinearLayout
150+
android:id="@+id/line1"
151+
android:orientation="vertical"
152+
android:layout_width="match_parent"
153+
android:layout_height="match_parent" />
128154

129-
</LinearLayout>
155+
<LinearLayout
156+
android:id="@+id/line3"
157+
android:orientation="vertical"
158+
android:layout_width="match_parent"
159+
android:layout_height="match_parent" />
160+
</FrameLayout>

0 commit comments

Comments
 (0)