├── .gitattributes
├── .gitignore
├── README.md
├── build.gradle
├── config.gradle
├── demo
├── .gitignore
├── build.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ ├── testFile.txt
│ └── testZip.zip
│ ├── java
│ └── com
│ │ └── liqi
│ │ └── myutils
│ │ └── demo
│ │ ├── JavaTest.java
│ │ ├── TestApplication.java
│ │ ├── TestOtherActivity.java
│ │ └── db
│ │ ├── DBManagerOperation.java
│ │ ├── DatabaseTableHelper.java
│ │ ├── OnDatabaseTableHelperListener.java
│ │ ├── TestDataBaseOperateActivity.java
│ │ └── TestDataBaseOperateP.java
│ └── res
│ ├── layout
│ ├── test_data_base_operate_layout.xml
│ └── test_other_activity.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── utils
├── .gitignore
├── build.gradle
└── src
└── main
├── AndroidManifest.xml
├── java
└── com
│ └── liqi
│ └── utils
│ ├── ActivityUtil.java
│ ├── FDUnitUtil.java
│ ├── NetWorkUtil.java
│ ├── NumericFormatUtils.java
│ ├── StaticUtility.java
│ ├── SystemMemorySpaceGetUtil.java
│ ├── Validation.java
│ ├── VibratorUtil.java
│ ├── ZodiacUtil.java
│ ├── db
│ ├── BaseDBManagerOperation.java
│ ├── DataBaseTypeEnum.java
│ └── DataBaseValuesEnum.java
│ ├── encoding
│ ├── AndroidAESEncryptor.java
│ ├── Base64.java
│ ├── JToAAesEncryptor.java
│ └── MD5Util.java
│ ├── file
│ ├── FileSizeFormattingUtil.java
│ └── StaticFileUtils.java
│ ├── imageloader
│ ├── ImageLoaderUtils.java
│ └── ImageStaticDispose.java
│ ├── spf
│ ├── BaseSharePreference.java
│ └── BaseSharePreferenceTypeEnum.java
│ ├── time
│ ├── FormatTimeUtils.java
│ ├── TimeHMSTransitionEnum.java
│ └── TimeUtil.java
│ ├── wifi
│ ├── OnWifiControllerListener.java
│ └── WifiController.java
│ ├── xml
│ ├── XmlLabelData.java
│ └── XmlUtils.java
│ └── zip
│ └── ZipUtils.java
└── res
└── values
└── strings.xml
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://jitpack.io/#liqinew/myutils)
2 | [](https://github.com/LiqiNew)
3 |
4 | # MyUtils
5 | MyUtils是一个包含全方位的工具的工具项目。项目里面提供时间轴转星座|生肖工具、系统存储空间获取工具、文件大小格式化工具、获取指定文件大小工具、数字格式化工具、
6 | Base64编码解码工具、MD5加密工具、AES加密解码工具(支持android端平台加密解密,java端和android端相互加密解密)、SharePreference操作工具、
7 | File文件操作工具、日期获取和计算工具、界面跳转Intent操作工具、字符串验证和数值转换操作工具、手机震动工具、系统资源操作工具、网络检测工具、
8 | wifi操作工具、单位换算工具、zip压缩和解压操作工具、XML解析操作工具(只支持几种指定格式)、图片加载和处理工具,数据库操作(增删改查)工具。
9 |
10 | **V.1.1.7版本新增功能**
11 | * **FileSizeFormattingUtil** 文件大小格式化工具对象
12 | * **StaticFileUtils** 获取指定文件大小工具对象
13 | * **NumericFormatUtils** 数字格式化工具对象
14 | * **StaticUtility** 获取设备屏幕的高度和宽度,获取状态栏高度,获取导航栏高度,判断是否有导航栏,判断是否已经root,判断是否在模拟器上运行, 跳转到首页面
15 | * **SystemMemorySpaceGetUtil** 系统存储空间获取工具对象
16 | * **ZodiacUtil**时间轴转星座|生肖工具对象
17 |
18 | ### 内部远程依赖Library(已经远程依赖的Library,切勿主项目里重复依赖。)
19 |
20 | **BaseLogger:'com.github.liqinew:baselogger:V.1.0.0'**
21 |
22 | **universal-image-loader:'com.nostra13.universalimageloader:universal-image-loader:1.9.5'**
23 |
24 | **appcompat-v7:'com.android.support:appcompat-v7:25.2.0'**
25 |
26 | ### 关于权限
27 | **项目targetSdkVersion <= 22,不需要做任何操作。
28 | 项目targetSdkVersion >= 23,请自行动态赋予权限。[推荐使用此框架去动态设置权限-AndPermission](https://github.com/yanzhenjie/AndPermission)**
29 |
30 | # 如何使用?
31 |
32 | ### Gradle远程依赖 ###
33 | **1:在项目根目录build.gradley**
34 | ```gradle
35 | allprojects {
36 | repositories {
37 | //依赖仓库
38 | maven { url 'https://jitpack.io' }
39 | }
40 | }
41 | ```
42 | **2:依赖MyUtils**
43 | ```gradle
44 | compile 'com.github.liqinew:myutils:V.1.1.7'
45 | ```
46 |
47 | ### [点击查阅MyUtils-API文档](https://liqinew.github.io/MyUtils/)
48 |
49 | ### 对应的工具对象
50 |
51 | * **Base64**对象是Base64编码解码工具
52 | * **MD5Util**对象是MD5加密工具
53 | * **AndroidAESEncryptor**对象是Android端平台AES加密解密工具
54 | * **JToAAesEncryptor**对象是java端和android端相互AES加密解密工具
55 | * **BaseSharePreference**对象是SharePreference操作工具
56 | * **StaticFileUtils**对象是File文件操作工具
57 | * **TimeUtil**对象是日期获取和计算工具
58 | * **ActivityUtil**对象是界面跳转Intent操作工具
59 | * **Validation**对象是字符串验证和数值转换操作工具
60 | * **VibratorUtil**对象是手机震动工具
61 | * **StaticUtility**对象是系统资源操作工具
62 | * **NetWorkUtil**对象是网络检测工具
63 | * **WifiController**对象是wifi操作工具
64 | * **FDUnitUtil**对象是单位换算工具
65 | * **ZipUtils**对象是zip压缩和解压操作工具
66 | * **ImageLoaderUtils**对象是图片加载工具,采用image-loader框架实现加载。
67 | * **ImageStaticDispose**对象是图片处理工具
68 | * **BaseDBManagerOperation**对象是数据库操作(增删改查)工具
69 | * **XmlUtils**对象是XML解析操作工具,只支持几种指定格式。(建议下载demo查看支持的XML格式)
70 | * **FileSizeFormattingUtil** 文件大小格式化工具对象
71 | * **StaticFileUtils** 获取指定文件大小工具对象
72 | * **NumericFormatUtils** 数字格式化工具对象
73 | * **SystemMemorySpaceGetUtil** 系统存储空间获取工具对象
74 | * **ZodiacUtil**时间轴转星座|生肖工具对象
75 |
76 | #### 如有没有包含的工具,后续会慢慢完善添加进来。如你有好的工具也可以通过QQ:543945827推荐给我。
另外别忘记给我star哦。^_^..谢谢。
77 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | //关联配置gradle
3 | apply from: "config.gradle"
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:2.2.3'
10 |
11 | // NOTE: Do not place your application dependencies here; they belong
12 | // in the individual module build.gradle files
13 | //配置Jitpack插件
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
15 | }
16 | }
17 |
18 | allprojects {
19 | repositories {
20 | maven { url 'https://jitpack.io' }
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | ext {
2 | android = [
3 | compileSdkVersion: 25,
4 | buildToolsVersion: "25.0.1",
5 |
6 | minSdkVersion : 14,
7 | targetSdkVersion : 22,
8 | ]
9 |
10 | dependencies = [
11 | //baselogger远程依赖
12 | log : 'com.github.liqinew:baselogger:V.1.0.0',
13 | //V7依赖
14 | appcompat_v7 : 'com.android.support:appcompat-v7:25.2.0',
15 | //staticutils中image-loader图片加载框架依赖
16 | staticutils_image_loader: 'com.nostra13.universalimageloader:universal-image-loader:1.9.5',
17 | ]
18 | }
--------------------------------------------------------------------------------
/demo/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/demo/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion rootProject.ext.android.compileSdkVersion
5 | buildToolsVersion rootProject.ext.android.buildToolsVersion
6 | defaultConfig {
7 | applicationId "com.liqi.myutils.demo"
8 | minSdkVersion rootProject.ext.android.minSdkVersion
9 | targetSdkVersion rootProject.ext.android.targetSdkVersion
10 | versionCode 1
11 | versionName "1.0"
12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(include: ['*.jar'], dir: 'libs')
24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25 | exclude group: 'com.android.support', module: 'support-annotations'
26 | })
27 | testCompile 'junit:junit:4.12'
28 | compile project(':utils')
29 | }
30 |
--------------------------------------------------------------------------------
/demo/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/demo/src/main/assets/testFile.txt:
--------------------------------------------------------------------------------
1 | 如果你能看到此内容,那么就说明测试文件写入成功。
--------------------------------------------------------------------------------
/demo/src/main/assets/testZip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiqiNew/MyUtils/91a0aa61f18bcc0ea285c89d00edf3a581962f01/demo/src/main/assets/testZip.zip
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/JavaTest.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo;
2 |
3 | import com.liqi.utils.encoding.JToAAesEncryptor;
4 |
5 | /**
6 | * 模拟java端AES加密解密测试
7 | * Created by LiQi on 2018/7/2.
8 | */
9 |
10 | public class JavaTest {
11 | public static final String KEY = "QQ:543945827----";
12 |
13 | public static void main(String[] args) {
14 | try {
15 | String encryptContent = JToAAesEncryptor.encrypt(KEY, "加密内容");
16 | System.out.print("加密出内容:" + encryptContent);
17 |
18 |
19 | String decryptContent = JToAAesEncryptor.decrypt(KEY, encryptContent);
20 | System.out.print("\n解密出内容:" + decryptContent);
21 | } catch (Exception e) {
22 | e.printStackTrace();
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/TestApplication.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo;
2 |
3 | import android.app.Application;
4 |
5 | import com.liqi.utils.imageloader.ImageLoaderUtils;
6 |
7 | /**
8 | * Created by LiQi on 2018/1/29.
9 | */
10 |
11 | public class TestApplication extends Application {
12 | @Override
13 | public void onCreate() {
14 | super.onCreate();
15 | //ImageLoader图片加载初始化
16 | ImageLoaderUtils.init(getApplicationContext(), "liqi/test/image");
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/db/DBManagerOperation.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo.db;
2 |
3 | import android.content.Context;
4 |
5 | import com.liqi.utils.db.BaseDBManagerOperation;
6 |
7 | /**
8 | * 数据库信息表业务操作对象
9 | */
10 | public class DBManagerOperation {
11 | public static BaseDBManagerOperation BaseDBManagerOperation(Context context) {
12 | return BaseDBManagerOperation.getBaseDBManagerOperation(new DatabaseTableHelper(context.getApplicationContext()));
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/db/DatabaseTableHelper.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo.db;
2 |
3 |
4 | import android.content.Context;
5 | import android.database.sqlite.SQLiteDatabase;
6 | import android.database.sqlite.SQLiteOpenHelper;
7 |
8 | /**
9 | * 创建数据库表对象
10 | *
11 | * @author Liqi
12 | */
13 | public class DatabaseTableHelper extends SQLiteOpenHelper implements OnDatabaseTableHelperListener{
14 |
15 | public DatabaseTableHelper(Context context) {
16 |
17 | // 调用父类构造方法创建数据库
18 | super(context, TABLE_DB, null, TEST_VERSION);
19 | }
20 |
21 | @Override
22 | public void onCreate(SQLiteDatabase db) {
23 | // 营销订单
24 | db.execSQL("CREATE TABLE " + TEST_NAME + " (id integer primary key , "+TEST_CONTENT_ONE+" text, "+TEST_CONTENT_TWO+" text, "+TEST_CONTENT_THREE+" text, "+TEST_CONTENT_FOUR+" text)");
25 |
26 | }
27 |
28 | @Override
29 | public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
30 | // 判断数据库是否存在,存在就删掉然后重新创建表
31 | db.execSQL("DROP TABLE IF EXISTS " + TEST_NAME);
32 | onCreate(db);
33 | }
34 |
35 | }
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/db/OnDatabaseTableHelperListener.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo.db;
2 |
3 | /** 数据库表名和表字段接口
4 | * Created by LiQi on 2017/12/6.
5 | */
6 |
7 | public interface OnDatabaseTableHelperListener {
8 | String TABLE_DB="TEST_TABLE_DB";
9 | int TEST_VERSION=1;
10 | String TEST_NAME="TEST_NAME",
11 | TEST_CONTENT_ONE="TEST_CONTENT_ONE"
12 | ,TEST_CONTENT_TWO="TEST_CONTENT_TWO",
13 | TEST_CONTENT_THREE="TEST_CONTENT_THREE",
14 | TEST_CONTENT_FOUR="TEST_CONTENT_FOUR";
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/demo/src/main/java/com/liqi/myutils/demo/db/TestDataBaseOperateActivity.java:
--------------------------------------------------------------------------------
1 | package com.liqi.myutils.demo.db;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.annotation.Nullable;
6 | import android.support.v7.app.AppCompatActivity;
7 | import android.view.View;
8 | import android.widget.Button;
9 | import android.widget.EditText;
10 | import android.widget.TextView;
11 |
12 | import com.liqi.Logger;
13 | import com.liqi.myutils.demo.R;
14 |
15 | import java.util.ArrayList;
16 | import java.util.List;
17 | import java.util.Map;
18 |
19 | /**
20 | * 数据库操作演示界面
21 | *
22 | * MVP模式
23 | *
24 | * Created by LiQi on 2017/12/6.
25 | */
26 |
27 | public class TestDataBaseOperateActivity extends AppCompatActivity implements View.OnClickListener, TestDataBaseOperateP.OnTestDataBaseOperateListener>> {
28 | private TextView content;
29 | private EditText add_key_one, add_key_two, add_key_three, add_key_four,
30 | query_key_one, query_key_two, query_key_three, query_key_four,
31 | update_key_one, update_key_two, update_key_three, update_key_four,
32 | delete_key_one, delete_key_two, delete_key_three, delete_key_four;
33 | private int queryCode;
34 |
35 | private Button query_key_query;
36 | private TestDataBaseOperateP>> mPresenter;
37 |
38 | @Override
39 | protected void onCreate(@Nullable Bundle savedInstanceState) {
40 | super.onCreate(savedInstanceState);
41 | setContentView(R.layout.test_data_base_operate_layout);
42 | content = (TextView) findViewById(R.id.content);
43 | add_key_one = (EditText) findViewById(R.id.add_key_one);
44 | add_key_two = (EditText) findViewById(R.id.add_key_two);
45 | add_key_three = (EditText) findViewById(R.id.add_key_three);
46 | add_key_four = (EditText) findViewById(R.id.add_key_four);
47 | query_key_one = (EditText) findViewById(R.id.query_key_one);
48 | query_key_two = (EditText) findViewById(R.id.query_key_two);
49 | query_key_three = (EditText) findViewById(R.id.query_key_three);
50 | query_key_four = (EditText) findViewById(R.id.query_key_four);
51 | update_key_one = (EditText) findViewById(R.id.update_key_one);
52 | update_key_two = (EditText) findViewById(R.id.update_key_two);
53 | update_key_three = (EditText) findViewById(R.id.update_key_three);
54 | update_key_four = (EditText) findViewById(R.id.update_key_four);
55 | delete_key_one = (EditText) findViewById(R.id.delete_key_one);
56 | delete_key_two = (EditText) findViewById(R.id.delete_key_two);
57 | delete_key_three = (EditText) findViewById(R.id.delete_key_three);
58 | delete_key_four = (EditText) findViewById(R.id.delete_key_four);
59 | findViewById(R.id.add_key_add).setOnClickListener(this);
60 | query_key_query = (Button) findViewById(R.id.query_key_query);
61 | query_key_query.setOnClickListener(this);
62 | findViewById(R.id.update_key_update).setOnClickListener(this);
63 | findViewById(R.id.delete_key_delete).setOnClickListener(this);
64 | mPresenter = new TestDataBaseOperateP<>(this);
65 | }
66 |
67 | @Override
68 | public void presenterDataOk(ArrayList