Skip to content

Commit a28bee5

Browse files
committed
see 08/04 log
1 parent a8a722d commit a28bee5

File tree

23 files changed

+721
-207
lines changed

23 files changed

+721
-207
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.0-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.1-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.0-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.18.1-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
android:theme="@style/AppTheme">
5454
<activity
5555
android:name=".MainActivity"
56-
android:screenOrientation="sensor"
56+
android:screenOrientation="user"
5757
android:windowSoftInputMode="stateHidden|adjustPan">
5858
<intent-filter>
5959
<action android:name="android.intent.action.MAIN" />

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
import com.blankj.utilcode.util.LogUtils;
99
import com.squareup.leakcanary.LeakCanary;
1010

11+
import java.util.ArrayList;
12+
import java.util.Arrays;
13+
import java.util.Collection;
14+
import java.util.Collections;
15+
import java.util.LinkedList;
16+
import java.util.List;
17+
1118
/**
1219
* <pre>
1320
* author: Blankj
@@ -62,7 +69,15 @@ public void initLog() {
6269
.setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
6370
.setFileFilter(LogUtils.V)// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
6471
.setStackDeep(1)// log 栈深度,默认为 1
65-
.setStackOffset(0);// 设置栈偏移,比如二次封装的话就需要设置,默认为 0
72+
.setStackOffset(0)// 设置栈偏移,比如二次封装的话就需要设置,默认为 0
73+
.setSaveDays(3)// 设置日志可保留天数,默认为 -1 表示无限时长
74+
// 新增 ArrayList 格式化器,默认已支持 Array, Throwable, Bundle, Intent 的格式化输出
75+
.addFormatter(new LogUtils.IFormatter<ArrayList>() {
76+
@Override
77+
public String format(ArrayList list) {
78+
return "LogUtils Formatter ArrayList { " + list.toString() + " }";
79+
}
80+
});
6681
LogUtils.d(config.toString());
6782
}
6883

app/src/main/java/com/blankj/androidutilcode/feature/core/log/LogActivity.java

Lines changed: 98 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
package com.blankj.androidutilcode.feature.core.log;
22

3+
import android.content.ComponentName;
34
import android.content.Context;
45
import android.content.Intent;
6+
import android.net.Uri;
57
import android.os.Bundle;
68
import android.os.Environment;
79
import android.support.annotation.Nullable;
810
import android.view.View;
911
import android.widget.TextView;
1012

13+
import com.blankj.androidutilcode.Config;
1114
import com.blankj.androidutilcode.R;
1215
import com.blankj.androidutilcode.UtilsApp;
1316
import com.blankj.androidutilcode.base.BaseBackActivity;
1417
import com.blankj.utilcode.util.LogUtils;
1518

19+
import java.util.ArrayList;
20+
1621

1722
/**
1823
* <pre>
@@ -24,7 +29,73 @@
2429
*/
2530
public class LogActivity extends BaseBackActivity {
2631

27-
private static final String TAG = "CMJ";
32+
private static final String TAG = "CMJ";
33+
private static final int UPDATE_LOG = 0x01;
34+
private static final int UPDATE_CONSOLE = 0x01 << 1;
35+
private static final int UPDATE_TAG = 0x01 << 2;
36+
private static final int UPDATE_HEAD = 0x01 << 3;
37+
private static final int UPDATE_FILE = 0x01 << 4;
38+
private static final int UPDATE_DIR = 0x01 << 5;
39+
private static final int UPDATE_BORDER = 0x01 << 6;
40+
private static final int UPDATE_SINGLE = 0x01 << 7;
41+
private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8;
42+
private static final int UPDATE_FILE_FILTER = 0x01 << 9;
43+
44+
private static final String JSON = "{\"tools\": [{ \"name\":\"css format\" , \"site\":\"http://tools.w3cschool.cn/code/css\" },{ \"name\":\"JSON format\" , \"site\":\"http://tools.w3cschool.cn/code/JSON\" },{ \"name\":\"pwd check\" , \"site\":\"http://tools.w3cschool.cn/password/my_password_safe\" }]}";
45+
private static final String XML = "<books><book><author>Jack Herrington</author><title>PHP Hacks</title><publisher>O'Reilly</publisher></book><book><author>Jack Herrington</author><title>Podcasting Hacks</title><publisher>O'Reilly</publisher></book></books>";
46+
private static final int[] ONE_D_ARRAY = new int[]{1, 2, 3};
47+
private static final int[][] TWO_D_ARRAY = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
48+
private static final Throwable THROWABLE = new NullPointerException();
49+
private static final Bundle BUNDLE = new Bundle();
50+
private static final Intent INTENT = new Intent();
51+
private static final ArrayList<String> LIST = new ArrayList<>();
52+
53+
private static final String LONG_STR;
54+
55+
static {
56+
StringBuilder sb = new StringBuilder();
57+
sb.append("len = 10400\ncontent = \"");
58+
for (int i = 0; i < 800; ++i) {
59+
sb.append("Hello world. ");
60+
}
61+
sb.append("\"");
62+
LONG_STR = sb.toString();
63+
64+
BUNDLE.putByte("byte", (byte) -1);
65+
BUNDLE.putChar("char", 'c');
66+
BUNDLE.putCharArray("charArray", new char[]{'c', 'h', 'a', 'r', 'A', 'r', 'r', 'a', 'y'});
67+
BUNDLE.putCharSequence("charSequence", "charSequence");
68+
BUNDLE.putCharSequenceArray("charSequenceArray", new CharSequence[]{"char", "Sequence", "Array"});
69+
BUNDLE.putBundle("bundle", BUNDLE);
70+
BUNDLE.putBoolean("boolean", true);
71+
BUNDLE.putInt("int", 1);
72+
BUNDLE.putFloat("float", 1.f);
73+
BUNDLE.putLong("long", 1L);
74+
BUNDLE.putShort("short", (short) 1);
75+
76+
INTENT.setAction("LogUtils action");
77+
INTENT.addCategory("LogUtils category");
78+
INTENT.setData(Uri.parse(Config.BLOG));
79+
INTENT.setType(Intent.ACTION_DIAL);
80+
INTENT.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
81+
INTENT.setPackage(Config.PKG);
82+
INTENT.setComponent(new ComponentName(Config.PKG, LogActivity.class.toString()));
83+
INTENT.putExtra("int", 1);
84+
INTENT.putExtra("float", 1f);
85+
INTENT.putExtra("char", 'c');
86+
INTENT.putExtra("string", "string");
87+
INTENT.putExtra("intArray", ONE_D_ARRAY);
88+
ArrayList<String> list = new ArrayList<>();
89+
list.add("ArrayList");
90+
list.add("is");
91+
list.add("serializable");
92+
INTENT.putExtra("serializable", list);
93+
INTENT.putExtra("bundle", BUNDLE);
94+
95+
LIST.add("hello");
96+
LIST.add("log");
97+
LIST.add("utils");
98+
}
2899

29100
private TextView tvAboutLog;
30101

@@ -41,16 +112,6 @@ public class LogActivity extends BaseBackActivity {
41112
private int consoleFilter = LogUtils.V;
42113
private int fileFilter = LogUtils.V;
43114

44-
private static final int UPDATE_LOG = 0x01;
45-
private static final int UPDATE_CONSOLE = 0x01 << 1;
46-
private static final int UPDATE_TAG = 0x01 << 2;
47-
private static final int UPDATE_HEAD = 0x01 << 3;
48-
private static final int UPDATE_FILE = 0x01 << 4;
49-
private static final int UPDATE_DIR = 0x01 << 5;
50-
private static final int UPDATE_BORDER = 0x01 << 6;
51-
private static final int UPDATE_SINGLE = 0x01 << 7;
52-
private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8;
53-
private static final int UPDATE_FILE_FILTER = 0x01 << 9;
54115

55116
private Runnable mRunnable = new Runnable() {
56117
@Override
@@ -64,18 +125,6 @@ public void run() {
64125
}
65126
};
66127

67-
private static final String longStr;
68-
69-
static {
70-
StringBuilder sb = new StringBuilder();
71-
sb.append("len = 10400\ncontent = \"");
72-
for (int i = 0; i < 800; ++i) {
73-
sb.append("Hello world. ");
74-
}
75-
sb.append("\"");
76-
longStr = sb.toString();
77-
}
78-
79128
public static void start(Context context) {
80129
Intent starter = new Intent(context, LogActivity.class);
81130
context.startActivity(starter);
@@ -115,6 +164,11 @@ public void initView(Bundle savedInstanceState, View contentView) {
115164
findViewById(R.id.btn_log_file).setOnClickListener(this);
116165
findViewById(R.id.btn_log_json).setOnClickListener(this);
117166
findViewById(R.id.btn_log_xml).setOnClickListener(this);
167+
findViewById(R.id.btn_log_array).setOnClickListener(this);
168+
findViewById(R.id.btn_log_throwable).setOnClickListener(this);
169+
findViewById(R.id.btn_log_bundle).setOnClickListener(this);
170+
findViewById(R.id.btn_log_intent).setOnClickListener(this);
171+
findViewById(R.id.btn_log_array_list).setOnClickListener(this);
118172
updateConfig(0);
119173
}
120174

@@ -199,7 +253,7 @@ public void onWidgetClick(View view) {
199253
LogUtils.aTag("customTag", "assert0", "assert1");
200254
break;
201255
case R.id.btn_log_long:
202-
LogUtils.d(longStr);
256+
LogUtils.d(LONG_STR);
203257
break;
204258
case R.id.btn_log_file:
205259
for (int i = 0; i < 100; i++) {
@@ -208,14 +262,28 @@ public void onWidgetClick(View view) {
208262
}
209263
break;
210264
case R.id.btn_log_json:
211-
String json = "{\"tools\": [{ \"name\":\"css format\" , \"site\":\"http://tools.w3cschool.cn/code/css\" },{ \"name\":\"json format\" , \"site\":\"http://tools.w3cschool.cn/code/json\" },{ \"name\":\"pwd check\" , \"site\":\"http://tools.w3cschool.cn/password/my_password_safe\" }]}";
212-
LogUtils.json(json);
213-
LogUtils.json(LogUtils.I, json);
265+
LogUtils.json(JSON);
266+
LogUtils.json(LogUtils.I, JSON);
214267
break;
215268
case R.id.btn_log_xml:
216-
String xml = "<books><book><author>Jack Herrington</author><title>PHP Hacks</title><publisher>O'Reilly</publisher></book><book><author>Jack Herrington</author><title>Podcasting Hacks</title><publisher>O'Reilly</publisher></book></books>";
217-
LogUtils.xml(xml);
218-
LogUtils.xml(LogUtils.I, xml);
269+
LogUtils.xml(XML);
270+
LogUtils.xml(LogUtils.I, XML);
271+
break;
272+
case R.id.btn_log_array:
273+
LogUtils.e((Object) ONE_D_ARRAY);
274+
LogUtils.e((Object) TWO_D_ARRAY);
275+
break;
276+
case R.id.btn_log_throwable:
277+
LogUtils.e(THROWABLE);
278+
break;
279+
case R.id.btn_log_bundle:
280+
LogUtils.e(BUNDLE);
281+
break;
282+
case R.id.btn_log_intent:
283+
LogUtils.e(INTENT);
284+
break;
285+
case R.id.btn_log_array_list:
286+
LogUtils.e(LIST);
219287
break;
220288
}
221289
}

app/src/main/java/com/blankj/androidutilcode/feature/core/screen/ScreenActivity.java

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

1111
import com.blankj.androidutilcode.R;
1212
import com.blankj.androidutilcode.base.BaseActivity;
13+
import com.blankj.utilcode.util.LogUtils;
1314
import com.blankj.utilcode.util.ScreenUtils;
1415
import com.blankj.utilcode.util.SpanUtils;
1516

app/src/main/java/com/blankj/androidutilcode/feature/core/screen/ScreenAdaptActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.blankj.androidutilcode.R;
1212
import com.blankj.androidutilcode.base.BaseActivity;
1313
import com.blankj.utilcode.util.BarUtils;
14+
import com.blankj.utilcode.util.LogUtils;
1415
import com.blankj.utilcode.util.ScreenUtils;
1516
import com.blankj.utilcode.util.SizeUtils;
1617

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<resources xmlns:tools="http://schemas.android.com/tools">
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5+
<!-- Customize your theme here. -->
6+
<item name="colorPrimary">@color/colorPrimary</item>
7+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
8+
<item name="colorAccent">@color/colorAccent</item>
9+
<item name="android:windowAnimationStyle">@style/AnimationActivity</item>
10+
<item name="android:windowActionBar">false</item>
11+
<!--slider-->
12+
<item name="android:windowIsTranslucent">false</item>
13+
<item name="android:windowBackground">@android:color/transparent</item>
14+
</style>
15+
16+
<style name="TextStyle">
17+
<item name="android:textSize">@dimen/font_24</item>
18+
<item name="android:textColor">@color/light_black</item>
19+
</style>
20+
21+
<style name="WideBtnStyle">
22+
<item name="android:textSize">@dimen/font_24</item>
23+
<item name="android:textColor">@color/light_black</item>
24+
<item name="android:textAllCaps">false</item>
25+
</style>
26+
27+
<style name="AnimationActivity" parent="@android:style/Animation.Translucent">
28+
<item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item>
29+
<item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
30+
<item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
31+
<item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
32+
</style>
33+
</resources>

app/src/main/res_core/layout-land/activity_screen_adapt.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@
1919

2020
<TextView
2121
android:id="@+id/tv_up"
22+
style="@style/TextStyle"
2223
android:layout_width="2000dp"
2324
android:layout_height="1dp"
2425
android:layout_alignParentTop="true"
2526
android:layout_toRightOf="@id/tv_fullscreen"
2627
android:background="@color/colorAccentHalfTrans"
2728
android:gravity="center_vertical"
28-
android:text="180dp"
29-
android:textSize="@dimen/font_40" />
29+
android:text="180dp" />
3030

3131
<TextView
3232
android:id="@+id/tv_down"
33+
style="@style/TextStyle"
3334
android:layout_width="2000dp"
3435
android:layout_height="1dp"
3536
android:layout_alignParentBottom="true"
3637
android:layout_toRightOf="@id/tv_fullscreen"
3738
android:background="@color/colorPrimaryHalfTrans"
3839
android:gravity="center_vertical"
39-
android:text="180dp"
40-
android:textSize="@dimen/font_40" />
40+
android:text="180dp" />
4141

4242

4343
</RelativeLayout>

app/src/main/res_core/layout-port/activity_screen_adapt.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@
99
android:layout_height="2000dp">
1010

1111
<TextView
12+
style="@style/TextStyle"
1213
android:layout_width="180dp"
1314
android:layout_height="2000dp"
1415
android:layout_alignParentLeft="true"
1516
android:layout_below="@id/tv_fullscreen"
1617
android:background="@color/colorAccentHalfTrans"
1718
android:gravity="center_horizontal"
18-
android:text="180dp"
19-
android:textSize="@dimen/font_40" />
19+
android:text="180dp" />
2020

2121
<TextView
22+
style="@style/TextStyle"
2223
android:layout_width="180dp"
2324
android:layout_height="2000dp"
2425
android:layout_alignParentRight="true"
2526
android:layout_below="@id/tv_fullscreen"
2627
android:background="@color/colorPrimaryHalfTrans"
2728
android:gravity="center_horizontal"
28-
android:text="180dp"
29-
android:textSize="@dimen/font_40" />
29+
android:text="180dp" />
3030

3131
</RelativeLayout>
3232
</ScrollView>

app/src/main/res_core/layout/activity_bar_nav.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
style="@style/WideBtnStyle"
4141
android:layout_width="match_parent"
4242
android:layout_height="wrap_content"
43-
android:text="@string/bar_nav_color"
44-
tools:targetApi="lollipop" />
43+
android:text="@string/bar_nav_color" />
4544

4645
</LinearLayout>

0 commit comments

Comments
 (0)