Skip to content

Commit

Permalink
see 04/10 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Apr 10, 2017
1 parent 58fd6bd commit c089266
Show file tree
Hide file tree
Showing 18 changed files with 188 additions and 132 deletions.
14 changes: 11 additions & 3 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

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

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

* ### 日志相关→[LogUtils.java][log.java][Demo][log.demo]
```
Builder.setLogSwitch : 设置log总开关
Builder.setGlobalTag : 设置log全局tag
Builder.setLogHeadSwitch : 设置log头开关
Builder.setLog2FileSwitch: 设置log文件开关
Builder.setBorderSwitch : 设置log边框开关
Builder.setLogFilter : 设置log过滤器
v : Verbose日志
d : Debug日志
i : Info日志
Expand Down Expand Up @@ -451,7 +459,7 @@ addView : 为SnackBar添加布局
dismissSnackbar : 取消snackbar显示
```

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

Gradle:
``` groovy
compile 'com.blankj:utilcode:1.3.7'
compile 'com.blankj:utilcode:1.3.8'
```

## How to use
Expand Down
11 changes: 5 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ android {

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

compile project(':utilcode')

// LeakCanary
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
debugCompile deps.leakcanaryandroid
releaseCompile deps.leakcanaryandroidnoop
}
2 changes: 1 addition & 1 deletion app/src/main/java/com/blankj/androidutilcode/UtilsApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void onCreate() {
}
LeakCanary.install(this);
appContext = this;
Utils.init(appContext);
Utils.init(this);
CrashUtils.getInstance().init();
lBuilder = new LogUtils.Builder()
.setLogSwitch(BuildConfig.DEBUG)// 设置log总开关,默认开
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public class LogActivity extends Activity
private TextView tvAboutLog;

private String globalTag = "";
private boolean border = true;
private boolean head = true;
private boolean file = false;
private boolean border = true;
private int filter = LogUtils.V;

private static final int UPDATE_TAG = 0x01;
private static final int UPDATE_FILE = 0x01 << 1;
private static final int UPDATE_BORDER = 0x01 << 2;
private static final int UPDATE_FILTER = 0x01 << 3;
private static final int UPDATE_TAG = 0x01 << 0;
private static final int UPDATE_HEAD = 0x01 << 1;
private static final int UPDATE_FILE = 0x01 << 2;
private static final int UPDATE_BORDER = 0x01 << 3;
private static final int UPDATE_FILTER = 0x01 << 4;

private Runnable mRunnable = new Runnable() {
@Override
Expand Down Expand Up @@ -72,6 +74,7 @@ protected void onCreate(Bundle savedInstanceState) {

mBuilder = UtilsApp.lBuilder;
findViewById(R.id.btn_toggle_tag).setOnClickListener(this);
findViewById(R.id.btn_toggle_head).setOnClickListener(this);
findViewById(R.id.btn_toggle_border).setOnClickListener(this);
findViewById(R.id.btn_toggle_file).setOnClickListener(this);
findViewById(R.id.btn_toggle_filter).setOnClickListener(this);
Expand All @@ -94,6 +97,9 @@ public void onClick(View view) {
case R.id.btn_toggle_tag:
updateAbout(UPDATE_TAG);
break;
case R.id.btn_toggle_head:
updateAbout(UPDATE_HEAD);
break;
case R.id.btn_toggle_file:
updateAbout(UPDATE_FILE);
break;
Expand Down Expand Up @@ -143,7 +149,9 @@ public void onClick(View view) {
LogUtils.d(longStr);
break;
case R.id.btn_log_file:
LogUtils.file(longStr);
LogUtils.file("test0 log to file");
LogUtils.file("test1 log to file");
LogUtils.file("test2 log to file");
break;
case R.id.btn_log_json:
LogUtils.json(json);
Expand All @@ -159,6 +167,9 @@ private void updateAbout(int args) {
case UPDATE_TAG:
globalTag = globalTag.equals(TAG) ? "" : TAG;
break;
case UPDATE_HEAD:
head = !head;
break;
case UPDATE_FILE:
file = !file;
break;
Expand All @@ -170,10 +181,12 @@ private void updateAbout(int args) {
break;
}
mBuilder.setGlobalTag(globalTag)
.setLogHeadSwitch(head)
.setLog2FileSwitch(file)
.setBorderSwitch(border)
.setLogFilter(filter);
tvAboutLog.setText("tag: " + (globalTag.equals("") ? "null" : TAG)
+ "\nhead: " + String.valueOf(head)
+ "\nfile: " + String.valueOf(file)
+ "\nborder: " + String.valueOf(border)
+ "\nfilter: " + (filter == LogUtils.V ? "Verbose" : "Warn")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,25 @@ public void toastClick(View view) {

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_about, menu);
getMenuInflater().inflate(R.menu.about, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

switch (item.getItemId()) {
case R.id.action_git_hub:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Blankj/AndroidUtilCode")));
break;
case R.id.action_blog:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.jianshu.com/u/46702d5c6978")));
break;
try {
switch (item.getItemId()) {

case R.id.action_git_hub:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/Blankj/AndroidUtilCode")));
break;
case R.id.action_blog:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.jianshu.com/u/46702d5c6978")));
break;
}
} catch (Exception e) {
e.printStackTrace();
}

return super.onOptionsItemSelected(item);
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_log.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
android:layout_height="wrap_content"
android:text="@string/log.toggle_tag" />

<Button
android:id="@+id/btn_toggle_head"
style="@style/BtnFont"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/log.toggle_head"/>

<Button
android:id="@+id/btn_toggle_file"
style="@style/BtnFont"
Expand Down
File renamed without changes.
15 changes: 11 additions & 4 deletions app/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->

<dimen name="spacing_huge">64dp</dimen>
<dimen name="spacing_large">32dp</dimen>
<dimen name="spacing_xxlarge">64dp</dimen>
<dimen name="spacing_xlarge">32dp</dimen>
<dimen name="spacing_large">24dp</dimen>
<dimen name="spacing_normal">16dp</dimen>
<dimen name="spacing_small">8dp</dimen>
<dimen name="spacing_tiny">4dp</dimen>
<dimen name="spacing_thin">1dp</dimen>
<dimen name="spacing_half">0.5dp</dimen>

<dimen name="font_small">12sp</dimen>
<dimen name="font_normal">18sp</dimen>
<dimen name="font_xlarge">40sp</dimen>
<dimen name="font_large">36sp</dimen>
<dimen name="font_normal">32sp</dimen>
<dimen name="font_small">28sp</dimen>
<dimen name="font_tiny">24sp</dimen>
<dimen name="font_thin">20sp</dimen>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

<!--Log相关-->
<string name="log.toggle_tag">Toggle Tag</string>
<string name="log.toggle_head">Toggle Head</string>
<string name="log.toggle_border">Toggle Border</string>
<string name="log.toggle_filter">Toggle Filter</string>
<string name="log.toggle_file">Toggle File</string>
Expand Down
24 changes: 18 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6'
// NOTE: Do not place your application dependencies here; they belong
Expand All @@ -26,17 +26,29 @@ ext {
// Sdk and tools
compileSdkVersion = 25
buildToolsVersion = "25.0.0"
minSdkVersion = 15
targetSdkVersion = 19
versionCode = 16
versionName = "1.3.7"
minSdkVersion = 15
targetSdkVersion = 19
versionCode = 16
versionName = "1.4.0"

// App dependencies
supportVersion = '25.0.0'
rxjavaVersion = '1.1.8'
rxandroidVersion = '1.2.1'
brvahVersion = '2.9.2'
leakcanaryVersion = '1.5'
junitVersion = '4.12'
truthVersion = '0.29'
robolectricVersion = '3.1.2'

deps = [
appcompatv7: "com.android.support:appcompat-v7:$supportVersion",
supportv4 : "com.android.support:support-v4:$supportVersion",
design : "com.android.support:design:$supportVersion",
junit : "junit:junit:$junitVersion",
truth : "com.google.truth:truth:$truthVersion",
robolectric: "org.robolectric:robolectric:$robolectricVersion",

leakcanaryandroid : "com.squareup.leakcanary:leakcanary-android:$leakcanaryVersion",
leakcanaryandroidnoop: "com.squareup.leakcanary:leakcanary-android-no-op:$leakcanaryVersion"
]
}
4 changes: 1 addition & 3 deletions utilcode/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/build
project.properties
local.properties
utilcode.iml
local.properties
12 changes: 6 additions & 6 deletions utilcode/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ android {
}

dependencies {
provided "com.android.support:design:$rootProject.supportVersion"
provided "com.android.support:support-v4:$rootProject.supportVersion"
provided "com.android.support:appcompat-v7:$rootProject.supportVersion"
testCompile "junit:junit:$rootProject.junitVersion"
testCompile "com.google.truth:truth:$rootProject.truthVersion"
testCompile "org.robolectric:robolectric:$rootProject.robolectricVersion"
provided deps.appcompatv7
provided deps.supportv4
provided deps.design
testCompile deps.junit
testCompile deps.truth
testCompile deps.robolectric
}
//apply from: "https://raw.githubusercontent.com/xiaopansky/android-library-publish-to-jcenter/master/bintrayUpload.gradle"
//gradlew bintrayUpload
10 changes: 10 additions & 0 deletions utilcode/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#project
project.name=ALog
project.groupId=com.blankj
project.artifactId=alog
project.packaging=aar
project.siteUrl=https://github.com/Blankj/ALog
project.gitUrl=https://github.com/Blankj/ALog.git

#javadoc
javadoc.name=ALog
Loading

0 comments on commit c089266

Please sign in to comment.