Skip to content

Commit c089266

Browse files
committed
see 04/10 log
1 parent 58fd6bd commit c089266

File tree

18 files changed

+188
-132
lines changed

18 files changed

+188
-132
lines changed

README-CN.md

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

33
## [README of English][readme.md]
44

5-
为方便查找,已进行大致归类,其目录如下所示:
5+
## API
66

77
* ### Activity相关→[ActivityUtils.java][activity.java][Demo][activity.demo]
88
```
@@ -206,6 +206,7 @@ getFileExtension : 根据全路径获取文件拓展名
206206
* ### Fragment相关→[FragmentUtils.java][fragment.java][Demo][fragment.demo]
207207
```
208208
addFragment : 新增fragment
209+
hideAddFragment : 先隐藏后新增fragment
209210
addFragments : 新增多个fragment
210211
removeFragment : 移除fragment
211212
removeToFragment : 移除到指定fragment
@@ -308,6 +309,13 @@ getStreet : 根据经纬度获取所在街道
308309

309310
* ### 日志相关→[LogUtils.java][log.java][Demo][log.demo]
310311
```
312+
Builder.setLogSwitch : 设置log总开关
313+
Builder.setGlobalTag : 设置log全局tag
314+
Builder.setLogHeadSwitch : 设置log头开关
315+
Builder.setLog2FileSwitch: 设置log文件开关
316+
Builder.setBorderSwitch : 设置log边框开关
317+
Builder.setLogFilter : 设置log过滤器
318+
311319
v : Verbose日志
312320
d : Debug日志
313321
i : Info日志
@@ -451,7 +459,7 @@ addView : 为SnackBar添加布局
451459
dismissSnackbar : 取消snackbar显示
452460
```
453461

454-
* ### SpannableString相关工具类[SpannableStringUtils.java][spannable.java][Demo][spannable.demo]
462+
* ### SpannableString相关[SpannableStringUtils.java][spannable.java][Demo][spannable.demo]
455463
```
456464
getBuilder : 获取建造者
457465
setFlag : 设置标识
@@ -597,7 +605,7 @@ getEntries : 获取压缩文件中的文件对象
597605

598606
Gradle:
599607
``` groovy
600-
compile 'com.blankj:utilcode:1.3.7'
608+
compile 'com.blankj:utilcode:1.3.8'
601609
```
602610

603611
## How to use

app/build.gradle

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ android {
2121

2222
dependencies {
2323
compile fileTree(include: ['*.jar'], dir: 'libs')
24-
compile "com.android.support:design:$rootProject.supportVersion"
25-
compile "com.android.support:support-v4:$rootProject.supportVersion"
26-
compile "com.android.support:appcompat-v7:$rootProject.supportVersion"
24+
compile deps.appcompatv7
25+
compile deps.supportv4
26+
compile deps.design
2727

2828
compile project(':utilcode')
2929

3030
// LeakCanary
31-
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
32-
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
33-
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
31+
debugCompile deps.leakcanaryandroid
32+
releaseCompile deps.leakcanaryandroidnoop
3433
}

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void onCreate() {
3636
}
3737
LeakCanary.install(this);
3838
appContext = this;
39-
Utils.init(appContext);
39+
Utils.init(this);
4040
CrashUtils.getInstance().init();
4141
lBuilder = new LogUtils.Builder()
4242
.setLogSwitch(BuildConfig.DEBUG)// 设置log总开关,默认开

app/src/main/java/com/blankj/androidutilcode/activity/LogActivity.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ public class LogActivity extends Activity
2929
private TextView tvAboutLog;
3030

3131
private String globalTag = "";
32-
private boolean border = true;
32+
private boolean head = true;
3333
private boolean file = false;
34+
private boolean border = true;
3435
private int filter = LogUtils.V;
3536

36-
private static final int UPDATE_TAG = 0x01;
37-
private static final int UPDATE_FILE = 0x01 << 1;
38-
private static final int UPDATE_BORDER = 0x01 << 2;
39-
private static final int UPDATE_FILTER = 0x01 << 3;
37+
private static final int UPDATE_TAG = 0x01 << 0;
38+
private static final int UPDATE_HEAD = 0x01 << 1;
39+
private static final int UPDATE_FILE = 0x01 << 2;
40+
private static final int UPDATE_BORDER = 0x01 << 3;
41+
private static final int UPDATE_FILTER = 0x01 << 4;
4042

4143
private Runnable mRunnable = new Runnable() {
4244
@Override
@@ -72,6 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {
7274

7375
mBuilder = UtilsApp.lBuilder;
7476
findViewById(R.id.btn_toggle_tag).setOnClickListener(this);
77+
findViewById(R.id.btn_toggle_head).setOnClickListener(this);
7578
findViewById(R.id.btn_toggle_border).setOnClickListener(this);
7679
findViewById(R.id.btn_toggle_file).setOnClickListener(this);
7780
findViewById(R.id.btn_toggle_filter).setOnClickListener(this);
@@ -94,6 +97,9 @@ public void onClick(View view) {
9497
case R.id.btn_toggle_tag:
9598
updateAbout(UPDATE_TAG);
9699
break;
100+
case R.id.btn_toggle_head:
101+
updateAbout(UPDATE_HEAD);
102+
break;
97103
case R.id.btn_toggle_file:
98104
updateAbout(UPDATE_FILE);
99105
break;
@@ -143,7 +149,9 @@ public void onClick(View view) {
143149
LogUtils.d(longStr);
144150
break;
145151
case R.id.btn_log_file:
146-
LogUtils.file(longStr);
152+
LogUtils.file("test0 log to file");
153+
LogUtils.file("test1 log to file");
154+
LogUtils.file("test2 log to file");
147155
break;
148156
case R.id.btn_log_json:
149157
LogUtils.json(json);
@@ -159,6 +167,9 @@ private void updateAbout(int args) {
159167
case UPDATE_TAG:
160168
globalTag = globalTag.equals(TAG) ? "" : TAG;
161169
break;
170+
case UPDATE_HEAD:
171+
head = !head;
172+
break;
162173
case UPDATE_FILE:
163174
file = !file;
164175
break;
@@ -170,10 +181,12 @@ private void updateAbout(int args) {
170181
break;
171182
}
172183
mBuilder.setGlobalTag(globalTag)
184+
.setLogHeadSwitch(head)
173185
.setLog2FileSwitch(file)
174186
.setBorderSwitch(border)
175187
.setLogFilter(filter);
176188
tvAboutLog.setText("tag: " + (globalTag.equals("") ? "null" : TAG)
189+
+ "\nhead: " + String.valueOf(head)
177190
+ "\nfile: " + String.valueOf(file)
178191
+ "\nborder: " + String.valueOf(border)
179192
+ "\nfilter: " + (filter == LogUtils.V ? "Verbose" : "Warn")

app/src/main/java/com/blankj/androidutilcode/activity/MainActivity.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,25 @@ public void toastClick(View view) {
119119

120120
@Override
121121
public boolean onCreateOptionsMenu(Menu menu) {
122-
getMenuInflater().inflate(R.menu.menu_about, menu);
122+
getMenuInflater().inflate(R.menu.about, menu);
123123
return true;
124124
}
125125

126126
@Override
127127
public boolean onOptionsItemSelected(MenuItem item) {
128-
129-
switch (item.getItemId()) {
130-
case R.id.action_git_hub:
131-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Blankj/AndroidUtilCode")));
132-
break;
133-
case R.id.action_blog:
134-
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.jianshu.com/u/46702d5c6978")));
135-
break;
128+
try {
129+
switch (item.getItemId()) {
130+
131+
case R.id.action_git_hub:
132+
133+
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Blankj/AndroidUtilCode")));
134+
break;
135+
case R.id.action_blog:
136+
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.jianshu.com/u/46702d5c6978")));
137+
break;
138+
}
139+
} catch (Exception e) {
140+
e.printStackTrace();
136141
}
137142

138143
return super.onOptionsItemSelected(item);

app/src/main/res/layout/activity_log.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
android:layout_height="wrap_content"
2525
android:text="@string/log.toggle_tag" />
2626

27+
<Button
28+
android:id="@+id/btn_toggle_head"
29+
style="@style/BtnFont"
30+
android:layout_width="match_parent"
31+
android:layout_height="wrap_content"
32+
android:text="@string/log.toggle_head"/>
33+
2734
<Button
2835
android:id="@+id/btn_toggle_file"
2936
style="@style/BtnFont"

app/src/main/res/values/dimens.xml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
<resources>
22
<!-- Default screen margins, per the Android Design guidelines. -->
33

4-
<dimen name="spacing_huge">64dp</dimen>
5-
<dimen name="spacing_large">32dp</dimen>
4+
<dimen name="spacing_xxlarge">64dp</dimen>
5+
<dimen name="spacing_xlarge">32dp</dimen>
6+
<dimen name="spacing_large">24dp</dimen>
67
<dimen name="spacing_normal">16dp</dimen>
78
<dimen name="spacing_small">8dp</dimen>
89
<dimen name="spacing_tiny">4dp</dimen>
10+
<dimen name="spacing_thin">1dp</dimen>
11+
<dimen name="spacing_half">0.5dp</dimen>
912

10-
<dimen name="font_small">12sp</dimen>
11-
<dimen name="font_normal">18sp</dimen>
13+
<dimen name="font_xlarge">40sp</dimen>
14+
<dimen name="font_large">36sp</dimen>
15+
<dimen name="font_normal">32sp</dimen>
16+
<dimen name="font_small">28sp</dimen>
17+
<dimen name="font_tiny">24sp</dimen>
18+
<dimen name="font_thin">20sp</dimen>
1219
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
<!--Log相关-->
8080
<string name="log.toggle_tag">Toggle Tag</string>
81+
<string name="log.toggle_head">Toggle Head</string>
8182
<string name="log.toggle_border">Toggle Border</string>
8283
<string name="log.toggle_filter">Toggle Filter</string>
8384
<string name="log.toggle_file">Toggle File</string>

build.gradle

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
jcenter()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:2.3.0'
7+
classpath 'com.android.tools.build:gradle:2.3.1'
88
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
99
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
1010
// NOTE: Do not place your application dependencies here; they belong
@@ -26,17 +26,29 @@ ext {
2626
// Sdk and tools
2727
compileSdkVersion = 25
2828
buildToolsVersion = "25.0.0"
29-
minSdkVersion = 15
30-
targetSdkVersion = 19
31-
versionCode = 16
32-
versionName = "1.3.7"
29+
minSdkVersion = 15
30+
targetSdkVersion = 19
31+
versionCode = 16
32+
versionName = "1.4.0"
3333

3434
// App dependencies
3535
supportVersion = '25.0.0'
3636
rxjavaVersion = '1.1.8'
3737
rxandroidVersion = '1.2.1'
38-
brvahVersion = '2.9.2'
38+
leakcanaryVersion = '1.5'
3939
junitVersion = '4.12'
4040
truthVersion = '0.29'
4141
robolectricVersion = '3.1.2'
42+
43+
deps = [
44+
appcompatv7: "com.android.support:appcompat-v7:$supportVersion",
45+
supportv4 : "com.android.support:support-v4:$supportVersion",
46+
design : "com.android.support:design:$supportVersion",
47+
junit : "junit:junit:$junitVersion",
48+
truth : "com.google.truth:truth:$truthVersion",
49+
robolectric: "org.robolectric:robolectric:$robolectricVersion",
50+
51+
leakcanaryandroid : "com.squareup.leakcanary:leakcanary-android:$leakcanaryVersion",
52+
leakcanaryandroidnoop: "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanaryVersion"
53+
]
4254
}

utilcode/.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
/build
2-
project.properties
3-
local.properties
4-
utilcode.iml
2+
local.properties

utilcode/build.gradle

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ android {
1818
}
1919

2020
dependencies {
21-
provided "com.android.support:design:$rootProject.supportVersion"
22-
provided "com.android.support:support-v4:$rootProject.supportVersion"
23-
provided "com.android.support:appcompat-v7:$rootProject.supportVersion"
24-
testCompile "junit:junit:$rootProject.junitVersion"
25-
testCompile "com.google.truth:truth:$rootProject.truthVersion"
26-
testCompile "org.robolectric:robolectric:$rootProject.robolectricVersion"
21+
provided deps.appcompatv7
22+
provided deps.supportv4
23+
provided deps.design
24+
testCompile deps.junit
25+
testCompile deps.truth
26+
testCompile deps.robolectric
2727
}
2828
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
2929
//gradlew bintrayUpload

utilcode/project.properties

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#project
2+
project.name=ALog
3+
project.groupId=com.blankj
4+
project.artifactId=alog
5+
project.packaging=aar
6+
project.siteUrl=https://github.com/Blankj/ALog
7+
project.gitUrl=https://github.com/Blankj/ALog.git
8+
9+
#javadoc
10+
javadoc.name=ALog

0 commit comments

Comments
 (0)