├── .gitignore ├── .idea ├── codeStyles │ └── Project.xml ├── compiler.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ └── Project_Default.xml ├── jarRepositories.xml ├── misc.xml ├── sonarlint │ └── issuestore │ │ └── index.pb └── vcs.xml ├── README.md ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xzy │ │ └── utils │ │ ├── ExampleInstrumentedTest.java │ │ ├── app │ │ └── AppUtilsTest.java │ │ ├── log │ │ └── LTest.java │ │ ├── system │ │ └── SystemUtilsTest.java │ │ └── xml │ │ └── XmlUtilsTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── test.xml │ ├── java │ │ └── com │ │ │ └── xzy │ │ │ └── test │ │ │ ├── MainActivity.kt │ │ │ ├── activity │ │ │ ├── ActivityUtilsTest.kt │ │ │ └── ActivityUtilsTest2.kt │ │ │ ├── app │ │ │ └── AppUtilsActivity.kt │ │ │ ├── constant │ │ │ ├── Configs.kt │ │ │ └── Per.java │ │ │ ├── hex │ │ │ └── HexUtilTest.java │ │ │ └── xml │ │ │ └── XmlUtilsTest.kt │ └── res │ │ ├── anim │ │ ├── in_from_left.xml │ │ ├── in_from_right.xml │ │ ├── out_to_left.xml │ │ └── out_to_right.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ ├── activity_app_utils.xml │ │ ├── activity_main.xml │ │ ├── activity_utils_test.xml │ │ ├── activity_utils_test2.xml │ │ ├── activity_xml_utils_test.xml │ │ └── gridview_item.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ ├── icon_file_excel.png │ │ ├── icon_file_mp4.png │ │ ├── icon_file_music.png │ │ ├── icon_file_pdf.png │ │ ├── icon_file_ppt.png │ │ ├── icon_file_txt.png │ │ ├── icon_file_video.png │ │ ├── icon_file_word.png │ │ └── icon_file_zip.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── xzy │ └── utils │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── lib_util ├── .gitignore ├── build.gradle ├── libs │ └── pinyin4j-2.5.0.jar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── xzy │ │ └── utils │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── xzy │ │ │ └── utils │ │ │ ├── Constants.kt │ │ │ ├── UtilsApp.java │ │ │ ├── activity │ │ │ └── ActivityUtils.java │ │ │ ├── adaptscreen │ │ │ └── AdaptScreenUtils.java │ │ │ ├── app │ │ │ └── AppUtils.java │ │ │ ├── appctx │ │ │ ├── AppCtx.kt │ │ │ └── AppCtxInitProvider.kt │ │ │ ├── array │ │ │ └── ArrayUtils.java │ │ │ ├── asserts │ │ │ ├── AssertProvider.java │ │ │ └── Functions.kt │ │ │ ├── bar │ │ │ └── BarUtils.java │ │ │ ├── barcode │ │ │ └── BarCode.kt │ │ │ ├── brightness │ │ │ └── BrightnessUtils.java │ │ │ ├── broadcast │ │ │ └── BroadcastUtils.java │ │ │ ├── bundle │ │ │ ├── Bundle.kt │ │ │ ├── BundleAccessors.kt │ │ │ ├── BundleDelegates.kt │ │ │ └── BundleSpec.kt │ │ │ ├── cache │ │ │ ├── CacheDiskStaticUtils.java │ │ │ ├── CacheDiskUtils.java │ │ │ ├── CacheDoubleStaticUtils.java │ │ │ ├── CacheDoubleUtils.java │ │ │ ├── CacheMemoryStaticUtils.java │ │ │ └── CacheMemoryUtils.java │ │ │ ├── calendar │ │ │ ├── CalendarUtils.java │ │ │ └── Functions.kt │ │ │ ├── camera │ │ │ └── CameraUtils.java │ │ │ ├── clear │ │ │ └── CleanUtils.java │ │ │ ├── click │ │ │ ├── ClickUtils.java │ │ │ └── ClickUtils2.java │ │ │ ├── clone │ │ │ └── CloneUtils.java │ │ │ ├── color │ │ │ └── ColorUtils.java │ │ │ ├── common │ │ │ └── Utils.java │ │ │ ├── connection │ │ │ └── CollectionUtils.java │ │ │ ├── constants │ │ │ ├── CacheConstants.java │ │ │ ├── MemoryConstants.java │ │ │ ├── PermissionConstants.java │ │ │ ├── RegexConstants.java │ │ │ └── TimeConstants.java │ │ │ ├── container │ │ │ └── ContainerUtils.java │ │ │ ├── context │ │ │ ├── Activity.kt │ │ │ └── Intent.kt │ │ │ ├── convert │ │ │ └── ConvertUtils.java │ │ │ ├── countdown │ │ │ └── CountdownUtils.java │ │ │ ├── crash │ │ │ ├── CrashHandler.java │ │ │ └── CrashUtils.java │ │ │ ├── crypto │ │ │ ├── Crypto.kt │ │ │ └── Serialization.kt │ │ │ ├── date │ │ │ └── DateUtils.java │ │ │ ├── density │ │ │ └── DensityUtils.java │ │ │ ├── deviceinfo │ │ │ ├── DeviceInfoUtils.java │ │ │ └── Functions.kt │ │ │ ├── devicestatus │ │ │ └── DeviceStatusUtils.java │ │ │ ├── dimension │ │ │ └── Dimensions.kt │ │ │ ├── encode │ │ │ └── EncodeUtils.java │ │ │ ├── encrypt │ │ │ └── EncryptUtils.java │ │ │ ├── exception │ │ │ └── Exception.kt │ │ │ ├── file │ │ │ ├── File.kt │ │ │ ├── FileManager.java │ │ │ ├── FileUtils.java │ │ │ └── bean │ │ │ │ ├── AppInfo.java │ │ │ │ ├── FileBean.java │ │ │ │ ├── FileItem.java │ │ │ │ ├── ImgFolderBean.java │ │ │ │ ├── Music.java │ │ │ │ └── Video.java │ │ │ ├── flashlight │ │ │ └── FlashlightUtils.java │ │ │ ├── fragment │ │ │ └── FragmentUtils.java │ │ │ ├── gson │ │ │ └── GsonUtils.java │ │ │ ├── hex │ │ │ ├── HexUtil.java │ │ │ └── HexUtil.kt │ │ │ ├── http │ │ │ ├── HttpUtils.java │ │ │ ├── apache │ │ │ │ └── HttpUtils.java │ │ │ └── net │ │ │ │ ├── HttpGetUtil.java │ │ │ │ └── HttpPostUtil.java │ │ │ ├── image │ │ │ └── ImageUtils.java │ │ │ ├── initprovider │ │ │ └── InitProvider.kt │ │ │ ├── intent │ │ │ └── IntentUtils.java │ │ │ ├── io │ │ │ ├── IO.kt │ │ │ └── IOUtils.java │ │ │ ├── json │ │ │ ├── Functions.kt │ │ │ └── JsonUtils.java │ │ │ ├── keyboard │ │ │ ├── TouchEmptyCloseKeyBoardUtils.kt │ │ │ ├── realize_1 │ │ │ │ └── KeyboardUtils.java │ │ │ └── realize_2 │ │ │ │ └── KeyboardUtils.java │ │ │ ├── language │ │ │ └── LanguageUtils.java │ │ │ ├── log │ │ │ ├── L.java │ │ │ └── LogUtils.java │ │ │ ├── map │ │ │ └── MapUtils.java │ │ │ ├── mask │ │ │ └── MaskUtils.java │ │ │ ├── match │ │ │ └── MatchUtil.java │ │ │ ├── md5 │ │ │ └── MD5Utils.java │ │ │ ├── meta │ │ │ └── MetaDataUtils.java │ │ │ ├── network │ │ │ ├── Mobile4GUtils.java │ │ │ ├── Net.kt │ │ │ └── NetworkUtils.java │ │ │ ├── nfc │ │ │ └── NfcUtils.java │ │ │ ├── object │ │ │ └── ObjectUtils.java │ │ │ ├── os │ │ │ ├── Package.kt │ │ │ ├── System.kt │ │ │ └── SystemService.kt │ │ │ ├── path │ │ │ └── PathUtils.java │ │ │ ├── permission │ │ │ ├── FloatTool.java │ │ │ ├── PermissionConstants.java │ │ │ ├── realize_1 │ │ │ │ ├── OnPermissionListener.java │ │ │ │ ├── PermissionRequest.java │ │ │ │ └── PermissionUtils.java │ │ │ ├── realize_2 │ │ │ │ └── PermissionUtils.java │ │ │ └── realize_3 │ │ │ │ └── Permission.java │ │ │ ├── phone │ │ │ └── PhoneUtils.java │ │ │ ├── pinyin │ │ │ └── PinyinUtils.java │ │ │ ├── process │ │ │ └── ProcessUtils.java │ │ │ ├── reflect │ │ │ └── ReflectUtils.java │ │ │ ├── resource │ │ │ ├── ColorResources.kt │ │ │ ├── DimenResources.kt │ │ │ ├── DrawableResources.kt │ │ │ ├── PrimitiveResources.kt │ │ │ ├── ResourceUtils.java │ │ │ ├── StyledAttributes.kt │ │ │ └── TextResources.kt │ │ │ ├── rom │ │ │ └── RomUtils.java │ │ │ ├── screen │ │ │ └── ScreenUtils.java │ │ │ ├── sdcard │ │ │ └── SDCardUtils.java │ │ │ ├── service │ │ │ └── ServiceUtils.java │ │ │ ├── shake │ │ │ └── ShakeUtils.java │ │ │ ├── shape │ │ │ └── ShapeUtils.java │ │ │ ├── shell │ │ │ └── ShellUtils.java │ │ │ ├── size │ │ │ └── SizeUtils.java │ │ │ ├── snackbar │ │ │ └── SnackbarUtils.java │ │ │ ├── sp │ │ │ ├── Sp.kt │ │ │ ├── SpUtils.java │ │ │ ├── User.java │ │ │ └── kotlin │ │ │ │ ├── Edit.kt │ │ │ │ ├── Preferences.kt │ │ │ │ ├── ResettableLazy.kt │ │ │ │ └── Sp.kt │ │ │ ├── spannablestring │ │ │ └── SpanUtils.java │ │ │ ├── storage │ │ │ └── StorageUtils.java │ │ │ ├── string │ │ │ └── StringUtils.java │ │ │ ├── theme │ │ │ └── ThemeUtils.java │ │ │ ├── thread │ │ │ ├── MainThread.kt │ │ │ └── ThreadUtils.java │ │ │ ├── threadpool │ │ │ └── ThreadPoolExecutors.java │ │ │ ├── throwable │ │ │ └── ThrowableUtils.java │ │ │ ├── time │ │ │ └── TimeUtils.java │ │ │ ├── toast │ │ │ ├── Toast.kt │ │ │ └── ToastUtils.java │ │ │ ├── uri │ │ │ └── UriUtils.java │ │ │ ├── vibrate │ │ │ └── VibrateUtils.java │ │ │ ├── video │ │ │ └── VideoUtils.java │ │ │ ├── view │ │ │ └── ViewUtils.java │ │ │ ├── xml │ │ │ └── XmlUtils.java │ │ │ └── zip │ │ │ └── ZipUtils.java │ └── res │ │ ├── anim │ │ ├── in_from_left.xml │ │ ├── in_from_right.xml │ │ ├── out_to_left.xml │ │ └── out_to_right.xml │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_round.png │ │ ├── icon_file_excel.png │ │ ├── icon_file_mp4.png │ │ ├── icon_file_music.png │ │ ├── icon_file_pdf.png │ │ ├── icon_file_ppt.png │ │ ├── icon_file_txt.png │ │ ├── icon_file_video.png │ │ ├── icon_file_word.png │ │ └── icon_file_zip.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ │ └── xml │ │ └── provider_path.xml │ └── test │ └── java │ └── com │ └── xzy │ └── utils │ └── ExampleUnitTest.java └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | xmlns:android 14 | 15 | ^$ 16 | 17 | 18 | 19 |
20 |
21 | 22 | 23 | 24 | xmlns:.* 25 | 26 | ^$ 27 | 28 | 29 | BY_NAME 30 | 31 |
32 |
33 | 34 | 35 | 36 | .*:id 37 | 38 | http://schemas.android.com/apk/res/android 39 | 40 | 41 | 42 |
43 |
44 | 45 | 46 | 47 | .*:name 48 | 49 | http://schemas.android.com/apk/res/android 50 | 51 | 52 | 53 |
54 |
55 | 56 | 57 | 58 | name 59 | 60 | ^$ 61 | 62 | 63 | 64 |
65 |
66 | 67 | 68 | 69 | style 70 | 71 | ^$ 72 | 73 | 74 | 75 |
76 |
77 | 78 | 79 | 80 | .* 81 | 82 | ^$ 83 | 84 | 85 | BY_NAME 86 | 87 |
88 |
89 | 90 | 91 | 92 | .* 93 | 94 | http://schemas.android.com/apk/res/android 95 | 96 | 97 | ANDROID_ATTRIBUTE_ORDER 98 | 99 |
100 |
101 | 102 | 103 | 104 | .* 105 | 106 | .* 107 | 108 | 109 | BY_NAME 110 | 111 |
112 |
113 |
114 |
115 |
116 |
-------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 43 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | 39 | 40 | 44 | 45 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | -------------------------------------------------------------------------------- /.idea/sonarlint/issuestore/index.pb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hgncxzy/AndroidUtils/7e0ea98ebf5521c7ae2c1320167e570af2593dd2/.idea/sonarlint/issuestore/index.pb -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | android { 5 | compileSdkVersion 29 6 | buildToolsVersion "29.0.2" 7 | defaultConfig { 8 | applicationId "com.xzy.test" 9 | minSdkVersion 19 10 | targetSdkVersion 29 11 | versionCode 1 12 | versionName "0.0.1" 13 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 14 | multiDexEnabled true 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation 'androidx.appcompat:appcompat:1.0.2' 27 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' 28 | testImplementation 'junit:junit:4.12' 29 | androidTestImplementation 'androidx.test:runner:1.2.0' 30 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' 31 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 32 | implementation project(':lib_util') 33 | } 34 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xzy/utils/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.xzy.utils; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.InstrumentationRegistry; 6 | import androidx.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getTargetContext(); 24 | 25 | assertEquals("com.xzy.utils", appContext.getPackageName()); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xzy/utils/log/LTest.java: -------------------------------------------------------------------------------- 1 | package com.xzy.utils.log; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.InstrumentationRegistry; 6 | import androidx.test.runner.AndroidJUnit4; 7 | 8 | import org.junit.After; 9 | import org.junit.Assert; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | 14 | import static org.junit.Assert.*; 15 | @RunWith(AndroidJUnit4.class) 16 | public class LTest { 17 | private Context mContext; 18 | private L mLog; 19 | 20 | @Before 21 | public void setUp() { 22 | mContext = InstrumentationRegistry.getTargetContext(); 23 | mLog = L.getInstance(mContext) 24 | .setDebug(true) 25 | .setLog2File(true) 26 | .setTAG("test"); 27 | } 28 | 29 | @After 30 | public void tearDown() { 31 | } 32 | 33 | 34 | @Test 35 | public void isDebug() { 36 | assertTrue(mLog.isDebug()); 37 | } 38 | 39 | @Test 40 | public void getTAG() { 41 | Assert.assertEquals(mLog.getTAG(), mLog.TAG); 42 | } 43 | 44 | @Test 45 | public void isIsLog2File() { 46 | mLog.isLog2File = true; 47 | assertTrue(mLog.isIsLog2File()); 48 | } 49 | 50 | @Test 51 | public void setIsLog2File() { 52 | mLog.setLog2File(false); 53 | assertFalse(mLog.isIsLog2File()); 54 | } 55 | 56 | @Test 57 | public void i() { 58 | mLog.i("hello world"); 59 | } 60 | 61 | @Test 62 | public void d() { 63 | mLog.d("hello world"); 64 | } 65 | 66 | @Test 67 | public void e() { 68 | mLog.e("hello world"); 69 | } 70 | 71 | @Test 72 | public void w() { 73 | mLog.w(new NullPointerException()); 74 | } 75 | 76 | @Test 77 | public void i1() { 78 | mLog.i("test", "hello world"); 79 | } 80 | 81 | @Test 82 | public void d1() { 83 | mLog.d("test", "hello world"); 84 | } 85 | 86 | @Test 87 | public void e1() { 88 | mLog.e("test", "hello world"); 89 | } 90 | 91 | @Test 92 | public void w1() { 93 | mLog.w("test", new NumberFormatException()); 94 | } 95 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xzy/utils/system/SystemUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.xzy.utils.system; 2 | 3 | import android.content.Context; 4 | import android.util.Log; 5 | 6 | import androidx.test.InstrumentationRegistry; 7 | import androidx.test.runner.AndroidJUnit4; 8 | 9 | import org.junit.After; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | 14 | @RunWith(AndroidJUnit4.class) 15 | public class SystemUtilsTest { 16 | private Context context; 17 | @Before 18 | public void setUp() { 19 | context = InstrumentationRegistry.getTargetContext(); 20 | } 21 | 22 | @After 23 | public void tearDown() { 24 | } 25 | 26 | @Test 27 | public void getSystem() { 28 | Log.d("getSystem()",SystemUtils.getSystem()); 29 | } 30 | 31 | @Test 32 | public void getMeizuFlymeOSFlag() { 33 | Log.d("getMeizuFlymeOSFlag()",SystemUtils.getMeizuFlymeOSFlag()); 34 | } 35 | 36 | @Test 37 | public void getCpuInfo() { 38 | Log.d("getCpuInfo()",SystemUtils.getCpuInfo()); 39 | } 40 | 41 | @Test 42 | public void getMemoInfo() { 43 | Log.d("getMemoInfo()",SystemUtils.getMemoInfo(context)); 44 | } 45 | 46 | @Test 47 | public void getSysVersionInfo() { 48 | Log.d("getSysVersionInfo()",SystemUtils.getSysVersionInfo()); 49 | } 50 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xzy/utils/xml/XmlUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.xzy.utils.xml; 2 | 3 | 4 | import android.content.Context; 5 | 6 | import androidx.test.InstrumentationRegistry; 7 | import androidx.test.runner.AndroidJUnit4; 8 | 9 | import org.junit.After; 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | 14 | @RunWith(AndroidJUnit4.class) 15 | public class XmlUtilsTest { 16 | 17 | private Context context; 18 | 19 | @Before 20 | public void setUp() { 21 | context = InstrumentationRegistry.getTargetContext(); 22 | } 23 | 24 | @After 25 | public void tearDown() { 26 | 27 | } 28 | 29 | @Test 30 | public void parseXMLFromAsserts() { 31 | XmlUtils.parseXMLFromAsserts(context, "test.xml"); 32 | } 33 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/assets/test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | test 4 | 411525152242417185276 5 | 1314456788 6 | 7 | 1444444 8 | xzy 9 | 10 | 222222 11 | 12 | 23 13 | 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.xzy.test 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import android.util.Log 6 | import android.widget.SimpleAdapter 7 | import androidx.appcompat.app.AppCompatActivity 8 | import com.xzy.test.activity.ActivityUtilsTest 9 | import com.xzy.test.app.AppUtilsActivity 10 | import com.xzy.test.constant.Configs 11 | import com.xzy.test.constant.Per 12 | import com.xzy.test.hex.HexUtilTest 13 | import com.xzy.test.xml.XmlUtilsTest 14 | import com.xzy.utils.activity.ActivityUtils 15 | import com.xzy.utils.sp.Sp 16 | import com.xzy.utils.sp.SpUtils 17 | import com.xzy.utils.sp.User 18 | import kotlinx.android.synthetic.main.activity_main.* 19 | import kotlinx.android.synthetic.main.activity_utils_test2.* 20 | import java.util.* 21 | 22 | /** 23 | * 程序入口,包含测试用例入口 24 | * @author xzy 25 | * */ 26 | class MainActivity : AppCompatActivity() { 27 | 28 | override fun onCreate(savedInstanceState: Bundle?) { 29 | super.onCreate(savedInstanceState) 30 | setContentView(R.layout.activity_main) 31 | Per.isGrantExternalRW(this) 32 | initView() 33 | HexUtilTest().test() 34 | // test SpUtils 35 | testSpUtils() 36 | 37 | } 38 | 39 | private fun testSpUtils() { 40 | val user = User() 41 | user.age = 29 42 | user.name = "xzy" 43 | SpUtils.getInstance().putObejct("user", user) 44 | val user1 = SpUtils.getInstance().getObeject("user") 45 | Log.i("xzy", user1.toString()) 46 | } 47 | 48 | private fun initView() { 49 | val simpleAdapter = SimpleAdapter( 50 | this, getData(), R.layout.gridview_item, arrayOf("text"), 51 | intArrayOf(R.id.item_tv) 52 | ) 53 | gridView.adapter = simpleAdapter 54 | gridView.setOnItemClickListener { _, _, i, _ -> 55 | when (i) { 56 | 0 -> { 57 | // ActivityUtilsTest 58 | ActivityUtils.startActivity(Intent(this, 59 | ActivityUtilsTest::class.java)) 60 | } 61 | 1 -> { 62 | // AdaptScreenUtilsActivity 63 | ActivityUtils.startActivity(Intent(this, 64 | XmlUtilsTest::class.java)) 65 | } 66 | 2 -> { 67 | // AppUtilsActivity 68 | ActivityUtils.startActivity(Intent(this, 69 | AppUtilsActivity::class.java)) 70 | } 71 | 72 | } 73 | } 74 | } 75 | 76 | private fun getData(): List> { 77 | val dataList = ArrayList>() 78 | val len = Configs.Number.items.size - 1 79 | for (i in 0..len) { 80 | val map = HashMap() 81 | map["text"] = Configs.Number.items[i] 82 | dataList.add(map) 83 | } 84 | return dataList 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/activity/ActivityUtilsTest2.kt: -------------------------------------------------------------------------------- 1 | package com.xzy.test.activity 2 | 3 | import android.app.Activity 4 | import android.content.Intent 5 | import androidx.appcompat.app.AppCompatActivity 6 | import android.os.Bundle 7 | import com.xzy.test.R 8 | import kotlinx.android.synthetic.main.activity_utils_test2.* 9 | 10 | /** 11 | * ActivityUtils 工具测试类。 12 | * @author xzy 13 | * **/ 14 | class ActivityUtilsTest2 : AppCompatActivity() { 15 | 16 | override fun onCreate(savedInstanceState: Bundle?) { 17 | super.onCreate(savedInstanceState) 18 | setContentView(R.layout.activity_utils_test2) 19 | test.setOnClickListener { 20 | val intent = Intent(this@ActivityUtilsTest2, ActivityUtilsTest::class.java) 21 | intent.putExtra("test", "xzy") 22 | setResult(Activity.RESULT_OK, intent) 23 | finish() 24 | } 25 | test2.setOnClickListener { 26 | val intent = Intent(this@ActivityUtilsTest2, ActivityUtilsTest::class.java) 27 | val bundle = Bundle() 28 | bundle.putString("key1","xzy") 29 | intent.putExtra("bundle1",bundle) 30 | setResult(Activity.RESULT_OK, intent) 31 | finish() 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/app/AppUtilsActivity.kt: -------------------------------------------------------------------------------- 1 | package com.xzy.test.app 2 | 3 | 4 | import androidx.appcompat.app.AppCompatActivity 5 | import android.os.Bundle 6 | import com.xzy.utils.path.PathUtils 7 | import kotlinx.android.synthetic.main.activity_app_utils.* 8 | import android.os.Environment 9 | 10 | import com.xzy.utils.app.AppUtils.* 11 | import com.xzy.utils.common.Utils 12 | import com.xzy.utils.toast.ToastUtils.showShort 13 | import java.io.File 14 | 15 | 16 | /** 17 | * AppUtils 工具测试类,请结合测试用例 AppUtilsTest 一起查看。 18 | * @author xzy 19 | * **/ 20 | @Suppress("unused") 21 | class AppUtilsActivity : AppCompatActivity(), Utils.OnAppStatusChangedListener { 22 | override fun onForeground() { 23 | showShort(this, "app onForeground") 24 | } 25 | 26 | override fun onBackground() { 27 | showShort(this, "app onBackground") 28 | } 29 | 30 | override fun onCreate(savedInstanceState: Bundle?) { 31 | super.onCreate(savedInstanceState) 32 | setContentView(com.xzy.test.R.layout.activity_app_utils) 33 | //动态申请权限 34 | // openApp 35 | openApp.setOnClickListener { 36 | openApp(this, getAppPackageName()) 37 | } 38 | // installAPK 39 | // 需要先动态申请读写权限 40 | installAPK.setOnClickListener { 41 | @Suppress("DEPRECATION") 42 | installApp(Environment.getExternalStorageDirectory().absolutePath + "/test.apk") 43 | } 44 | 45 | // 监听 object 的状态 (onForeground or onBackground) 46 | registerAppStatusChangedListener(this, this) 47 | 48 | // unInstallAPK 49 | unInstallAPK.setOnClickListener { 50 | uninstallApp("com.xzy.utils") 51 | } 52 | 53 | // unInstallAPK2 54 | unInstallAPK2.setOnClickListener { 55 | uninstallApp(this, "com.xzy.utils", UNINSTALL_APK) 56 | } 57 | 58 | // launchApp 59 | launchApp.setOnClickListener { 60 | launchAppDetailsSettings() 61 | } 62 | 63 | //exitApp 64 | exitApp.setOnClickListener { 65 | exitApp() 66 | } 67 | // getApkInfo 68 | getApkInfo.setOnClickListener { 69 | getApkInfo(PathUtils.getDataPath() + "/test.apk") 70 | } 71 | // getApkInfo2 72 | getApkInfo2.setOnClickListener { 73 | val path = PathUtils.getDataPath() + "/test.apk" 74 | if (File(path).exists()) { 75 | getApkInfo(File(PathUtils.getDataPath() + "/test.apk")) 76 | } else { 77 | showShort(this, "file not exist") 78 | } 79 | } 80 | } 81 | 82 | override fun onDestroy() { 83 | super.onDestroy() 84 | unregisterAppStatusChangedListener(this) 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/constant/Configs.kt: -------------------------------------------------------------------------------- 1 | package com.xzy.test.constant 2 | 3 | class Configs { 4 | object Number { 5 | var items = arrayOf("activity", 6 | "adaptscreen", 7 | "app", 8 | "asserts", 9 | "bar", 10 | "brightness", 11 | "cache", 12 | "calendar", 13 | "camera", 14 | "clear", 15 | "click", 16 | "clone", 17 | "color", 18 | "common", 19 | "constants", 20 | "container", 21 | "convert", 22 | "crash", 23 | "date", 24 | "density", 25 | "device", 26 | "encode", 27 | "encrypt", 28 | "file", 29 | "flashlight", 30 | "fragment", 31 | "gson", 32 | "http", 33 | "image", 34 | "intent", 35 | "io", 36 | "jinzhi", 37 | "keyboard", 38 | "language", 39 | "log", 40 | "match", 41 | "md5", 42 | "meta", 43 | "network", 44 | "object", 45 | "parseJSON", 46 | "path", 47 | "permission", 48 | "phone", 49 | "pinyin", 50 | "process", 51 | "reflect", 52 | "regex", 53 | "resource", 54 | "rom", 55 | "screen", 56 | "sdcard", 57 | "service", 58 | "shake", 59 | "share", 60 | "shell", 61 | "size", 62 | "snackbar", 63 | "sp", 64 | "spannablestring", 65 | "statusbar", 66 | "storage", 67 | "string", 68 | "system", 69 | "thread", 70 | "throwable", 71 | "time", 72 | "toast", 73 | "uri", 74 | "vibrate", 75 | "video", 76 | "view", 77 | "xml", 78 | "zip" 79 | ) 80 | } 81 | } -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/constant/Per.java: -------------------------------------------------------------------------------- 1 | package com.xzy.test.constant; 2 | 3 | import android.Manifest; 4 | import android.app.Activity; 5 | import android.content.pm.PackageManager; 6 | import android.os.Build; 7 | 8 | public class Per { 9 | public static void main(String[] args) { 10 | System.out.println('I' + 'T'); 11 | } 12 | 13 | 14 | public static boolean isGrantExternalRW(Activity activity) { 15 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && activity.checkSelfPermission( 16 | Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { 17 | 18 | activity.requestPermissions(new String[]{ 19 | Manifest.permission.READ_EXTERNAL_STORAGE, 20 | Manifest.permission.WRITE_EXTERNAL_STORAGE 21 | }, 1); 22 | 23 | return false; 24 | } 25 | 26 | return true; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/hex/HexUtilTest.java: -------------------------------------------------------------------------------- 1 | package com.xzy.test.hex; 2 | 3 | import com.xzy.utils.hex.HexUtil; 4 | import com.xzy.utils.log.LogUtils; 5 | 6 | /** 7 | * Author: xzy 8 | * Date: 9 | * Description: 10 | */ 11 | public class HexUtilTest { 12 | private static final String TAG = "HexUtilTest"; 13 | 14 | public void test() { 15 | // 字节数组转 16 进制字符串 16 | byte[] byte1 = {0x11}; 17 | LogUtils.dTag(TAG, "Test HexUtil.parseBytesToHexString ->" + HexUtil.parseBytesToHexString(byte1)); 18 | 19 | // 16 进制字符串转 10 进制整数 20 | // 不能带 0x 21 | String hexString = "11"; 22 | LogUtils.dTag(TAG, "Test HexUtil.hexStringToInt ->" + HexUtil.hexStringToInt(hexString)); 23 | 24 | // 字节数组合并 25 | byte[] bytea = {0x11, 0x22}; 26 | byte[] byteb = {0x33, 0x44}; 27 | LogUtils.dTag(TAG, "Test HexUtil.byteMerger ->" + HexUtil.byteMerger(bytea, byteb).length); 28 | 29 | // 将字节数组转换为十六进制字符串 30 | LogUtils.dTag(TAG, "Test HexUtil.bin2HexStr ->" + HexUtil.bin2HexStr(bytea)); 31 | 32 | // 将十六进制字符串转换为二进制字符串 33 | LogUtils.dTag(TAG, "Test HexUtil.hexStr2BinStr ->" + HexUtil.hexStr2BinStr(hexString)); 34 | 35 | // 将十六进制字符串转换为二进制字符串 36 | LogUtils.dTag(TAG, "Test HexUtil.hexString2binaryString ->" + HexUtil.hexString2binaryString(hexString)); 37 | 38 | // 将二进制字符串转换为 16 进制字符串 39 | String bStr = "00001001"; 40 | LogUtils.dTag(TAG, "Test HexUtil.binaryString2hexString ->" + HexUtil.binaryString2hexString(bStr)); 41 | 42 | // 整数值转 2 进制字符串(不足 8 位,自动补零) 43 | LogUtils.dTag(TAG, "Test HexUtil.intValueToBinary ->" + HexUtil.intValueToBinary(1)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/java/com/xzy/test/xml/XmlUtilsTest.kt: -------------------------------------------------------------------------------- 1 | package com.xzy.test.xml 2 | 3 | import android.os.Bundle 4 | import androidx.appcompat.app.AppCompatActivity 5 | import com.xzy.test.R 6 | import com.xzy.utils.toast.ToastUtils 7 | import com.xzy.utils.xml.XmlUtils 8 | 9 | class XmlUtilsTest : AppCompatActivity() { 10 | 11 | override fun onCreate(savedInstanceState: Bundle?) { 12 | super.onCreate(savedInstanceState) 13 | setContentView(R.layout.activity_xml_utils_test) 14 | 15 | val map = XmlUtils.parseXMLFromAsserts(this, "test.xml") 16 | val realName = map.get("realName").toString() 17 | ToastUtils.showShort(realName) 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/src/main/res/anim/in_from_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/anim/in_from_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/out_to_left.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/anim/out_to_right.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_utils.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 |