Skip to content

Commit

Permalink
新增日志单条删除功能
Browse files Browse the repository at this point in the history
新增日志保存本地功能
新增日志搜索文本清空功能
优化请求权限最大次数为3
优化悬浮窗的图片和触摸效果
修复日志暂停和清空功能的 Bug
  • Loading branch information
880634 committed Feb 14, 2020
1 parent 42a5288 commit c9b4329
Show file tree
Hide file tree
Showing 28 changed files with 443 additions and 220 deletions.
Binary file modified Logcat.apk
Binary file not shown.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,19 @@
#### 集成步骤

dependencies {
debugImplementation 'com.hjq:logcat:3.2'
debugImplementation 'com.hjq:logcat:5.0'
}

#### 使用方式

* 在 debug 模式下运行即可,在 release 正式打包的时不会自动集成
* 无需调用,直接运行,然后授予悬浮窗权限即可

* 在 debug 模式下运行即可,在 release 正式打包的时不会集成本库,尽管放心

#### 截图欣赏

![](picture/0.jpg)

![](picture/1.jpg)

![](picture/2.jpg)
Expand Down Expand Up @@ -47,6 +51,8 @@

* 日志长按可复制分享

* 支持将日志保存到本地

* 长日志点击可收缩展开显示

* 日志搜索结果支持文本高亮
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.hjq.logcat.demo"
minSdkVersion 14
targetSdkVersion 28
versionCode 32
versionName "3.2"
versionCode 50
versionName "5.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
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 @@ -7,7 +7,7 @@
<uses-permission android:name="android.permission.INTERNET" />

<application
android:icon="@drawable/ic_launcher"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme"
Expand Down
43 changes: 0 additions & 43 deletions app/src/main/res/drawable/ic_launcher.xml

This file was deleted.

Binary file added app/src/main/res/mipmap-xhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 26
versionCode 32
versionName "3.2"
versionCode 50
versionName "5.0"
}
}

dependencies {
// 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.hjq:xxpermissions:6.0'
implementation 'com.hjq:xxpermissions:6.2'
// 悬浮窗框架:https://github.com/getActivity/XToast
implementation 'com.hjq:xtoast:3.5'
}
Expand All @@ -26,7 +26,7 @@ publish {
userOrg = 'getactivity'
groupId = 'com.hjq'
artifactId = 'logcat'
version = '3.2'
version = '5.0'
description = 'This is to help developers quickly see the logging framework they want'
website = "https://github.com/getActivity/Logcat"
}
Expand Down
4 changes: 4 additions & 0 deletions library/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<!-- 悬浮窗权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

<!-- 外部存储读写权限 -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application>

<provider
Expand Down
1 change: 0 additions & 1 deletion library/src/main/java/com/hjq/logcat/FloatingWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ final class FloatingWindow extends XToast implements OnClickListener {
super(application);
setView(R.layout.logcat_window_floating);
setAnimStyle(android.R.style.Animation_Toast);
setAnimStyle(android.R.style.Animation_Translucent);
setDraggable(new SpringDraggable());
setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
setOnClickListener(android.R.id.icon, this);
Expand Down
3 changes: 1 addition & 2 deletions library/src/main/java/com/hjq/logcat/InitActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ protected void onCreate(Bundle savedInstanceState) {

@Override
public void hasPermission(List<String> granted, boolean all) {
LogcatConfig.init(getApplication());
FloatingLifecycle.with(getApplication(), new FloatingWindow(getApplication()).show());
finish();
}

@Override
public void noPermission(List<String> denied, boolean quick) {
Toast.makeText(getApplicationContext(), "权限申请失败,无法显示弹窗", Toast.LENGTH_LONG).show();
Toast.makeText(getApplicationContext(), "权限申请失败,无法显示 Logcat", Toast.LENGTH_LONG).show();
finish();
}
}
15 changes: 15 additions & 0 deletions library/src/main/java/com/hjq/logcat/InitProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.widget.Toast;

import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;

/**
* author : Android 轮子哥
Expand All @@ -19,6 +23,17 @@ public final class InitProvider extends ContentProvider {
public boolean onCreate() {
Context context = getContext();
if (context != null) {
LogcatConfig.init(context.getApplicationContext());
if (!XXPermissions.isHasPermission(context, Permission.SYSTEM_ALERT_WINDOW)) {
int count = LogcatConfig.getPermissionsCount();
if (count >= 3) {
Toast.makeText(context, "需要显示 Logcat 请先自行授予悬浮权限", Toast.LENGTH_LONG).show();
return true;
}
LogcatConfig.setPermissionsCount(++count);
} else {
LogcatConfig.setPermissionsCount(0);
}
Intent intent = new Intent(context, InitActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
Expand Down
Loading

0 comments on commit c9b4329

Please sign in to comment.