Skip to content

Commit 5c95d75

Browse files
committed
publish v1.0.10
1 parent ddfa894 commit 5c95d75

File tree

8 files changed

+87
-150
lines changed

8 files changed

+87
-150
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@
77
/captures
88
.externalNativeBuild
99
.cxx
10+
local.properties
1011
*.apk
12+
/repo

DebugBanner/src/main/java/com/wyjson/debug_banner/DebugBanner.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ public class DebugBanner implements Application.ActivityLifecycleCallbacks {
2020
public static DebugBanner.Companion Companion = new DebugBanner.Companion();
2121

2222
public static final class Companion {
23+
24+
public void init(Application application) {
25+
new DebugBanner(application, new Banner(), false);
26+
}
27+
2328
public void init(Application application, Banner banner) {
2429
new DebugBanner(application, banner, false);
2530
}
@@ -70,7 +75,8 @@ public void onActivityCreated(Activity activity, Bundle bundle) {
7075
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
7176

7277
Banner localBanner = activity instanceof BannerView ? ((BannerView) activity).newBanner() : this.banner;
73-
78+
if (localBanner == null)
79+
return;
7480
DebugBannerView debugBannerView = new DebugBannerView(activity, null);
7581
debugBannerView.updateText(localBanner.getBannerText(), localBanner.getTextColorRes());
7682
debugBannerView.updateBannerColor(localBanner.getBannerColorRes());

README.md

Lines changed: 46 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,127 +1,86 @@
1-
# DebugBanner
1+
# [DebugBanner](https://github.com/wyjsonGo/DebugBanner)
2+
23
[![License](https://img.shields.io/badge/license-Apache%202-green.svg)](https://www.apache.org/licenses/LICENSE-2.0)
3-
[![Download](https://jitpack.io/v/wyjsonGo/DebugBanner.svg)](https://jitpack.io/#wyjsonGo/DebugBanner)
44

5-
调试横幅标签(debug show checked mode banner label),看到flutter有这个功能.
5+
> 调试横幅标签(debug show checked mode banner label)看到flutter有这个功能
66
7-
![](screenshots/1.png)
7+
![sample1.png](screenshots/sample1.png)
88

9-
![](screenshots/4.png)
9+
![sample2.png](screenshots/sample2.png)
1010

1111
## 使用
12-
Gradle:
12+
13+
添加依赖
1314

1415
```groovy
15-
allprojects {
16+
dependencyResolutionManagement {
17+
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
1618
repositories {
1719
...
1820
maven { url 'https://jitpack.io' }
1921
}
2022
}
2123
```
2224

25+
[![Release Version](https://jitpack.io/v/wyjsonGo/DebugBanner.svg)](https://jitpack.io/#wyjsonGo/DebugBanner)
26+
2327
```groovy
2428
dependencies {
25-
implementation 'com.github.wyjsonGo:DebugBanner:1.0.9'
29+
implementation 'com.github.wyjsonGo:DebugBanner:1.0.10'
2630
}
2731
```
2832

2933
### 初始化
30-
在Application里
3134

32-
```java
33-
/**
34-
* 默认,全部页面显示
35-
*/
36-
DebugBanner.Companion.init(MyApplication.this, new Banner());
37-
```
38-
or
35+
在Application里
3936

4037
```java
41-
/**
42-
* 过滤不显示的页面
43-
*/
44-
DebugBanner.Companion.init(MyApplication.this,
45-
new Banner(),
46-
false,
47-
"MainActivity",
48-
"ThreeActivity"
49-
);
38+
// 默认,全部页面显示
39+
DebugBanner.Companion.init(this);
5040
```
51-
or
5241

53-
```java
54-
/**
55-
* 过滤显示的页面
56-
*/
57-
DebugBanner.Companion.init(
58-
MyApplication.this,
59-
new Banner(),
60-
true,
61-
"MainActivity",
62-
"TwoActivity"
63-
);
64-
```
42+
### 进阶用法
6543

66-
or
44+
自定义初始化
6745

6846
```java
69-
/**
70-
* 自定义样式
71-
*/
72-
DebugBanner.Companion.init(
73-
MyApplication.this,
74-
new Banner(BannerGravity.START, android.R.color.holo_blue_bright, android.R.color.holo_red_light, "BETA")
75-
);
47+
// 过滤不显示的页面
48+
DebugBanner.Companion.init(
49+
this,
50+
new Banner(),
51+
false,
52+
"MainActivity",
53+
"ThreeActivity"
54+
);
55+
56+
// 过滤显示的页面
57+
DebugBanner.Companion.init(
58+
this,
59+
new Banner(),
60+
true,
61+
"MainActivity",
62+
"TwoActivity"
63+
);
64+
65+
// 自定义样式
66+
DebugBanner.Companion.init(
67+
this,
68+
new Banner(BannerGravity.START, android.R.color.holo_blue_bright, android.R.color.holo_red_light, "BETA")
69+
);
7670
```
7771

78-
79-
## 额外
80-
优化启动
81-
82-
```java
83-
public class MyApplication extends Application {
84-
85-
@Override
86-
public void onCreate() {
87-
super.onCreate();
88-
runOnWorkThread(initThirdServiceRunnable);
89-
}
90-
91-
private void runOnWorkThread(Runnable action) {
92-
new Thread(action).start();
93-
}
94-
95-
/**
96-
* 子线程初始化,优化启动
97-
*/
98-
private Runnable initThirdServiceRunnable = new Runnable() {
99-
@Override
100-
public void run() {
101-
//设置线程的优先级,不与主线程抢资源
102-
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
103-
/**
104-
* release打包不显示
105-
*/
106-
if (BuildConfig.DEBUG) {
107-
DebugBanner.Companion.init(MyApplication.this, new Banner());
108-
}
109-
}
110-
};
111-
}
112-
```
113-
按照页面分别设置不同样式
72+
不同页面设置不同样式,实现`BannerView`接口
11473

11574
```java
116-
public class ExampleActivity extends AppCompatActivity implements BannerView {
75+
public class ExampleActivity extends AppCompatActivity implements BannerView {
11776

11877
@Override
11978
public Banner newBanner() {
12079
return new Banner(
121-
BannerGravity.START,
122-
android.R.color.holo_blue_light,
123-
android.R.color.black,
124-
"BETA"
80+
BannerGravity.START,
81+
android.R.color.holo_blue_light,
82+
android.R.color.black,
83+
"BETA"
12584
);
12685
}
12786
}

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ android {
3030
dependencies {
3131
implementation "androidx.appcompat:appcompat:1.6.1"
3232
implementation project(path: ':DebugBanner')
33-
// implementation 'com.github.wyjsonGo:DebugBanner:1.0.5'
33+
// implementation 'com.github.wyjsonGo:DebugBanner:1.0.10'
3434
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
<category android:name="android.intent.category.LAUNCHER" />
2323
</intent-filter>
2424
</activity>
25-
26-
<activity android:name="com.wyjson.debug_banner.demo.activity.TwoActivity" />
27-
28-
<activity android:name="com.wyjson.debug_banner.demo.activity.ThreeActivity" />
25+
<activity android:name=".activity.TwoActivity" />
26+
<activity android:name=".activity.ThreeActivity" />
2927

3028
</application>
3129

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.wyjson.debug_banner.demo;
22

33
import android.app.Application;
4-
import android.os.Process;
54

65
import com.wyjson.debug_banner.Banner;
6+
import com.wyjson.debug_banner.BannerGravity;
77
import com.wyjson.debug_banner.DebugBanner;
88

99
/**
@@ -19,63 +19,35 @@ public class MyApplication extends Application {
1919
@Override
2020
public void onCreate() {
2121
super.onCreate();
22-
runOnWorkThread(initThirdServiceRunnable);
23-
}
24-
25-
private void runOnWorkThread(Runnable action) {
26-
new Thread(action).start();
27-
}
28-
29-
/**
30-
* 子线程初始化,优化启动
31-
*/
32-
private final Runnable initThirdServiceRunnable = new Runnable() {
33-
@Override
34-
public void run() {
35-
//设置线程的优先级,不与主线程抢资源
36-
Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
37-
38-
/**
39-
* 默认,全部页面显示
40-
*/
41-
// DebugBanner.Companion.init(MyApplication.this, new Banner());
4222

43-
/**
44-
* 过滤不显示的页面
45-
*/
46-
// DebugBanner.Companion.init(MyApplication.this,
47-
// new Banner(),
48-
// false,
49-
// "MainActivity",
50-
// "ThreeActivity"
51-
// );
52-
53-
/**
54-
* 过滤显示的页面
55-
*/
56-
DebugBanner.Companion.init(
57-
MyApplication.this,
58-
new Banner(),
59-
true,
60-
"MainActivity",
61-
"TwoActivity"
62-
);
63-
64-
/**
65-
* 自定义样式
66-
*/
67-
// DebugBanner.Companion.init(
68-
// MyApplication.this,
69-
// new Banner(BannerGravity.START, android.R.color.holo_blue_bright, android.R.color.holo_red_light, "BETA")
70-
// );
23+
if (BuildConfig.DEBUG) {
24+
// 默认,全部页面显示
25+
DebugBanner.Companion.init(this);
26+
}
7127

72-
/**
73-
* release打包不显示
74-
*/
75-
// if (BuildConfig.DEBUG) {
76-
// DebugBanner.Companion.init(MyApplication.this, new Banner());
77-
// }
28+
// 过滤不显示的页面
29+
// DebugBanner.Companion.init(
30+
// this,
31+
// new Banner(),
32+
// false,
33+
// "MainActivity",
34+
// "ThreeActivity"
35+
// );
36+
37+
// 过滤显示的页面
38+
// DebugBanner.Companion.init(
39+
// this,
40+
// new Banner(),
41+
// true,
42+
// "MainActivity",
43+
// "TwoActivity"
44+
// );
45+
46+
// 自定义样式
47+
// DebugBanner.Companion.init(
48+
// this,
49+
// new Banner(BannerGravity.START, android.R.color.holo_blue_bright, android.R.color.holo_red_light, "BETA")
50+
// );
51+
}
7852

79-
}
80-
};
8153
}

0 commit comments

Comments
 (0)