Skip to content

Commit

Permalink
see 08/04 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Aug 4, 2018
1 parent a8a722d commit a28bee5
Show file tree
Hide file tree
Showing 23 changed files with 721 additions and 207 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

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

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

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If this project helps you a lot and you want to support the project's developmen

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

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

[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
android:theme="@style/AppTheme">
<activity
android:name=".MainActivity"
android:screenOrientation="sensor"
android:screenOrientation="user"
android:windowSoftInputMode="stateHidden|adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
import com.blankj.utilcode.util.LogUtils;
import com.squareup.leakcanary.LeakCanary;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

/**
* <pre>
* author: Blankj
Expand Down Expand Up @@ -62,7 +69,15 @@ public void initLog() {
.setConsoleFilter(LogUtils.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
.setFileFilter(LogUtils.V)// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
.setStackDeep(1)// log 栈深度,默认为 1
.setStackOffset(0);// 设置栈偏移,比如二次封装的话就需要设置,默认为 0
.setStackOffset(0)// 设置栈偏移,比如二次封装的话就需要设置,默认为 0
.setSaveDays(3)// 设置日志可保留天数,默认为 -1 表示无限时长
// 新增 ArrayList 格式化器,默认已支持 Array, Throwable, Bundle, Intent 的格式化输出
.addFormatter(new LogUtils.IFormatter<ArrayList>() {
@Override
public String format(ArrayList list) {
return "LogUtils Formatter ArrayList { " + list.toString() + " }";
}
});
LogUtils.d(config.toString());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
package com.blankj.androidutilcode.feature.core.log;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.blankj.androidutilcode.Config;
import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.UtilsApp;
import com.blankj.androidutilcode.base.BaseBackActivity;
import com.blankj.utilcode.util.LogUtils;

import java.util.ArrayList;


/**
* <pre>
Expand All @@ -24,7 +29,73 @@
*/
public class LogActivity extends BaseBackActivity {

private static final String TAG = "CMJ";
private static final String TAG = "CMJ";
private static final int UPDATE_LOG = 0x01;
private static final int UPDATE_CONSOLE = 0x01 << 1;
private static final int UPDATE_TAG = 0x01 << 2;
private static final int UPDATE_HEAD = 0x01 << 3;
private static final int UPDATE_FILE = 0x01 << 4;
private static final int UPDATE_DIR = 0x01 << 5;
private static final int UPDATE_BORDER = 0x01 << 6;
private static final int UPDATE_SINGLE = 0x01 << 7;
private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8;
private static final int UPDATE_FILE_FILTER = 0x01 << 9;

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\" }]}";
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>";
private static final int[] ONE_D_ARRAY = new int[]{1, 2, 3};
private static final int[][] TWO_D_ARRAY = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
private static final Throwable THROWABLE = new NullPointerException();
private static final Bundle BUNDLE = new Bundle();
private static final Intent INTENT = new Intent();
private static final ArrayList<String> LIST = new ArrayList<>();

private static final String LONG_STR;

static {
StringBuilder sb = new StringBuilder();
sb.append("len = 10400\ncontent = \"");
for (int i = 0; i < 800; ++i) {
sb.append("Hello world. ");
}
sb.append("\"");
LONG_STR = sb.toString();

BUNDLE.putByte("byte", (byte) -1);
BUNDLE.putChar("char", 'c');
BUNDLE.putCharArray("charArray", new char[]{'c', 'h', 'a', 'r', 'A', 'r', 'r', 'a', 'y'});
BUNDLE.putCharSequence("charSequence", "charSequence");
BUNDLE.putCharSequenceArray("charSequenceArray", new CharSequence[]{"char", "Sequence", "Array"});
BUNDLE.putBundle("bundle", BUNDLE);
BUNDLE.putBoolean("boolean", true);
BUNDLE.putInt("int", 1);
BUNDLE.putFloat("float", 1.f);
BUNDLE.putLong("long", 1L);
BUNDLE.putShort("short", (short) 1);

INTENT.setAction("LogUtils action");
INTENT.addCategory("LogUtils category");
INTENT.setData(Uri.parse(Config.BLOG));
INTENT.setType(Intent.ACTION_DIAL);
INTENT.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
INTENT.setPackage(Config.PKG);
INTENT.setComponent(new ComponentName(Config.PKG, LogActivity.class.toString()));
INTENT.putExtra("int", 1);
INTENT.putExtra("float", 1f);
INTENT.putExtra("char", 'c');
INTENT.putExtra("string", "string");
INTENT.putExtra("intArray", ONE_D_ARRAY);
ArrayList<String> list = new ArrayList<>();
list.add("ArrayList");
list.add("is");
list.add("serializable");
INTENT.putExtra("serializable", list);
INTENT.putExtra("bundle", BUNDLE);

LIST.add("hello");
LIST.add("log");
LIST.add("utils");
}

private TextView tvAboutLog;

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

private static final int UPDATE_LOG = 0x01;
private static final int UPDATE_CONSOLE = 0x01 << 1;
private static final int UPDATE_TAG = 0x01 << 2;
private static final int UPDATE_HEAD = 0x01 << 3;
private static final int UPDATE_FILE = 0x01 << 4;
private static final int UPDATE_DIR = 0x01 << 5;
private static final int UPDATE_BORDER = 0x01 << 6;
private static final int UPDATE_SINGLE = 0x01 << 7;
private static final int UPDATE_CONSOLE_FILTER = 0x01 << 8;
private static final int UPDATE_FILE_FILTER = 0x01 << 9;

private Runnable mRunnable = new Runnable() {
@Override
Expand All @@ -64,18 +125,6 @@ public void run() {
}
};

private static final String longStr;

static {
StringBuilder sb = new StringBuilder();
sb.append("len = 10400\ncontent = \"");
for (int i = 0; i < 800; ++i) {
sb.append("Hello world. ");
}
sb.append("\"");
longStr = sb.toString();
}

public static void start(Context context) {
Intent starter = new Intent(context, LogActivity.class);
context.startActivity(starter);
Expand Down Expand Up @@ -115,6 +164,11 @@ public void initView(Bundle savedInstanceState, View contentView) {
findViewById(R.id.btn_log_file).setOnClickListener(this);
findViewById(R.id.btn_log_json).setOnClickListener(this);
findViewById(R.id.btn_log_xml).setOnClickListener(this);
findViewById(R.id.btn_log_array).setOnClickListener(this);
findViewById(R.id.btn_log_throwable).setOnClickListener(this);
findViewById(R.id.btn_log_bundle).setOnClickListener(this);
findViewById(R.id.btn_log_intent).setOnClickListener(this);
findViewById(R.id.btn_log_array_list).setOnClickListener(this);
updateConfig(0);
}

Expand Down Expand Up @@ -199,7 +253,7 @@ public void onWidgetClick(View view) {
LogUtils.aTag("customTag", "assert0", "assert1");
break;
case R.id.btn_log_long:
LogUtils.d(longStr);
LogUtils.d(LONG_STR);
break;
case R.id.btn_log_file:
for (int i = 0; i < 100; i++) {
Expand All @@ -208,14 +262,28 @@ public void onWidgetClick(View view) {
}
break;
case R.id.btn_log_json:
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\" }]}";
LogUtils.json(json);
LogUtils.json(LogUtils.I, json);
LogUtils.json(JSON);
LogUtils.json(LogUtils.I, JSON);
break;
case R.id.btn_log_xml:
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>";
LogUtils.xml(xml);
LogUtils.xml(LogUtils.I, xml);
LogUtils.xml(XML);
LogUtils.xml(LogUtils.I, XML);
break;
case R.id.btn_log_array:
LogUtils.e((Object) ONE_D_ARRAY);
LogUtils.e((Object) TWO_D_ARRAY);
break;
case R.id.btn_log_throwable:
LogUtils.e(THROWABLE);
break;
case R.id.btn_log_bundle:
LogUtils.e(BUNDLE);
break;
case R.id.btn_log_intent:
LogUtils.e(INTENT);
break;
case R.id.btn_log_array_list:
LogUtils.e(LIST);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.base.BaseActivity;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.SpanUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.blankj.androidutilcode.R;
import com.blankj.androidutilcode.base.BaseActivity;
import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.LogUtils;
import com.blankj.utilcode.util.ScreenUtils;
import com.blankj.utilcode.util.SizeUtils;

Expand Down
33 changes: 33 additions & 0 deletions app/src/main/res/values-v26/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<resources xmlns:tools="http://schemas.android.com/tools">

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:windowAnimationStyle">@style/AnimationActivity</item>
<item name="android:windowActionBar">false</item>
<!--slider-->
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>

<style name="TextStyle">
<item name="android:textSize">@dimen/font_24</item>
<item name="android:textColor">@color/light_black</item>
</style>

<style name="WideBtnStyle">
<item name="android:textSize">@dimen/font_24</item>
<item name="android:textColor">@color/light_black</item>
<item name="android:textAllCaps">false</item>
</style>

<style name="AnimationActivity" parent="@android:style/Animation.Translucent">
<item name="android:activityOpenEnterAnimation">@anim/slide_in_left</item>
<item name="android:activityOpenExitAnimation">@anim/slide_out_left</item>
<item name="android:activityCloseEnterAnimation">@anim/slide_in_right</item>
<item name="android:activityCloseExitAnimation">@anim/slide_out_right</item>
</style>
</resources>
8 changes: 4 additions & 4 deletions app/src/main/res_core/layout-land/activity_screen_adapt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@

<TextView
android:id="@+id/tv_up"
style="@style/TextStyle"
android:layout_width="2000dp"
android:layout_height="1dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/tv_fullscreen"
android:background="@color/colorAccentHalfTrans"
android:gravity="center_vertical"
android:text="180dp"
android:textSize="@dimen/font_40" />
android:text="180dp" />

<TextView
android:id="@+id/tv_down"
style="@style/TextStyle"
android:layout_width="2000dp"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:layout_toRightOf="@id/tv_fullscreen"
android:background="@color/colorPrimaryHalfTrans"
android:gravity="center_vertical"
android:text="180dp"
android:textSize="@dimen/font_40" />
android:text="180dp" />


</RelativeLayout>
Expand Down
8 changes: 4 additions & 4 deletions app/src/main/res_core/layout-port/activity_screen_adapt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,24 @@
android:layout_height="2000dp">

<TextView
style="@style/TextStyle"
android:layout_width="180dp"
android:layout_height="2000dp"
android:layout_alignParentLeft="true"
android:layout_below="@id/tv_fullscreen"
android:background="@color/colorAccentHalfTrans"
android:gravity="center_horizontal"
android:text="180dp"
android:textSize="@dimen/font_40" />
android:text="180dp" />

<TextView
style="@style/TextStyle"
android:layout_width="180dp"
android:layout_height="2000dp"
android:layout_alignParentRight="true"
android:layout_below="@id/tv_fullscreen"
android:background="@color/colorPrimaryHalfTrans"
android:gravity="center_horizontal"
android:text="180dp"
android:textSize="@dimen/font_40" />
android:text="180dp" />

</RelativeLayout>
</ScrollView>
3 changes: 1 addition & 2 deletions app/src/main/res_core/layout/activity_bar_nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
style="@style/WideBtnStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/bar_nav_color"
tools:targetApi="lollipop" />
android:text="@string/bar_nav_color" />

</LinearLayout>
Loading

0 comments on commit a28bee5

Please sign in to comment.