├── .gitignore
├── .idea
├── gradle.xml
└── misc.xml
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── easyandroid
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── html.html
│ ├── java
│ │ └── com
│ │ │ └── easyandroid
│ │ │ ├── BaseActivity.java
│ │ │ ├── ForegroundAppUtil.java
│ │ │ ├── ItemBean.java
│ │ │ ├── KeyBoardActivity.java
│ │ │ ├── MainActivity.java
│ │ │ ├── MyAdapter.java
│ │ │ ├── PopupKeyboardUtil.java
│ │ │ ├── TestActivity.java
│ │ │ ├── TestConstraintLayoutActivity.java
│ │ │ ├── TestJsActivity.java
│ │ │ ├── TestRunning.java
│ │ │ └── ToastUtils.java
│ └── res
│ │ ├── anim
│ │ ├── down_to_up.xml
│ │ └── up_to_hide.xml
│ │ ├── drawable
│ │ ├── abcd.gif
│ │ ├── bitmap.xml
│ │ ├── blue_s.9.png
│ │ ├── custom_shape_toast.xml
│ │ ├── keyboard_delete.png
│ │ ├── keyboard_key.xml
│ │ ├── keyboard_shift.png
│ │ └── transparency_n.9.png
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ ├── activity_testjs.xml
│ │ ├── activity_testrunning.xml
│ │ ├── custom_toast.xml
│ │ ├── item_check.xml
│ │ ├── keyboardview_layout.xml
│ │ └── test_activity.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── testpic.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── modify_title.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ ├── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ ├── allkeys1.xml
│ │ └── small_keyboard.xml
│ └── test
│ └── java
│ └── com
│ └── easyandroid
│ └── ExampleUnitTest.java
├── build.gradle
├── config.gradle
├── easytools
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── easytools
│ │ ├── constant
│ │ ├── MemoryConstants.java
│ │ ├── PermissionConstants.java
│ │ └── TimeConstants.java
│ │ └── tools
│ │ ├── ACache.java
│ │ ├── ActivityManager.java
│ │ ├── ActivityUtils.java
│ │ ├── AdaptScreenUtils.java
│ │ ├── AndroidUtils.java
│ │ ├── AnimationUtils.java
│ │ ├── AppUtils.java
│ │ ├── ArrayUtils.java
│ │ ├── AssetDatabaseOpenHelper.java
│ │ ├── BadgeUtils.java
│ │ ├── Base64Utils.java
│ │ ├── BitmapUtils.java
│ │ ├── BrightnessUtils.java
│ │ ├── BuildProperties.java
│ │ ├── CheckAdapter.java
│ │ ├── CheckUtils.java
│ │ ├── ClassUtils.java
│ │ ├── CleanUtils.java
│ │ ├── ClipboardUtils.java
│ │ ├── CloseUtils.java
│ │ ├── ConstantUtils.java
│ │ ├── ConvertUtils.java
│ │ ├── Countdown.java
│ │ ├── CrashUtils.java
│ │ ├── DateUtils.java
│ │ ├── DebouncingUtils.java
│ │ ├── DeviceUtils.java
│ │ ├── DeviceUuidFactory.java
│ │ ├── DialogUtils.java
│ │ ├── DisplayUtils.java
│ │ ├── DoubleClickExitDetector.java
│ │ ├── EncodeUtils.java
│ │ ├── EncryptUtils.java
│ │ ├── FileIOUtils.java
│ │ ├── FileProvider7.java
│ │ ├── FileUtils.java
│ │ ├── FlashlightUtils.java
│ │ ├── FragmentUtils.java
│ │ ├── GsonUtils.java
│ │ ├── HexUtils.java
│ │ ├── ImageLoader.java
│ │ ├── IntentUtils.java
│ │ ├── JsonUtils.java
│ │ ├── KeyboardUtils.java
│ │ ├── LanguageUtils.java
│ │ ├── LogUtils.java
│ │ ├── LongLogUtils.java
│ │ ├── LoopTimer.java
│ │ ├── LunarUtils.java
│ │ ├── M3U8ParserUtils.java
│ │ ├── MD5Utils.java
│ │ ├── MapUtils.java
│ │ ├── MediaPlayerUtils.java
│ │ ├── MemoryFileHelper.java
│ │ ├── MetaDataUtils.java
│ │ ├── Money.java
│ │ ├── MyTypefaceSpan.java
│ │ ├── NetworkUtils.java
│ │ ├── NotificationUtils.java
│ │ ├── ObjectUtils.java
│ │ ├── PaletteUtils.java
│ │ ├── PathUtils.java
│ │ ├── PermissionUtils.java
│ │ ├── PollingUtils.java
│ │ ├── Preconditions.java
│ │ ├── ProcessUtils.java
│ │ ├── RandomUtils.java
│ │ ├── ReflectUtils.java
│ │ ├── RegexUtils.java
│ │ ├── ResourceUtils.java
│ │ ├── RomUtils.java
│ │ ├── RoundUtils.java
│ │ ├── SDCardUtils.java
│ │ ├── SMSUtils.java
│ │ ├── ServiceUtils.java
│ │ ├── ShellUtils.java
│ │ ├── SnackbarUtils.java
│ │ ├── SpUtils.java
│ │ ├── SpanSimpleUtils.java
│ │ ├── SpanUtils.java
│ │ ├── StatusBarUtils.java
│ │ ├── StatusTextUtils.java
│ │ ├── StringUtils.java
│ │ ├── ThreadPoolUtils.java
│ │ ├── TimeUtils.java
│ │ ├── ToastUtils.java
│ │ ├── TouchUtils.java
│ │ ├── UriUtils.java
│ │ ├── Utils.java
│ │ ├── UtilsActivityLifecycleImpl.java
│ │ ├── UtilsBridge.java
│ │ ├── ViewUtils.java
│ │ ├── WeakHandler.java
│ │ ├── WebViewUtils.java
│ │ ├── ZipUtils.java
│ │ └── log
│ │ ├── EasyLog.java
│ │ └── LogPrinterParser.java
│ └── res
│ ├── animator
│ └── loading.xml
│ ├── drawable
│ └── loading_d.png
│ ├── layout
│ └── loading_dialog.xml
│ ├── values
│ ├── ids.xml
│ ├── strings.xml
│ └── styles.xml
│ └── xml
│ └── file_paths.xml
├── fingerprintrecognition
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── css
│ │ └── fingerprint
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── css
│ │ │ ├── fingerdemo
│ │ │ └── DemoActivity.java
│ │ │ └── fingerprint
│ │ │ ├── CipherHelper.java
│ │ │ ├── FingerManager.java
│ │ │ ├── FingerManagerBuilder.java
│ │ │ ├── SharePreferenceUtil.java
│ │ │ ├── callback
│ │ │ └── SimpleFingerCallback.java
│ │ │ ├── dialog
│ │ │ ├── BaseFingerDialog.java
│ │ │ ├── CommonTipDialog.java
│ │ │ └── DefaultFingerDialog.java
│ │ │ ├── impl
│ │ │ ├── BiometricPromptImpl23.java
│ │ │ └── BiometricPromptImpl28.java
│ │ │ ├── interfaces
│ │ │ ├── IBiometricPrompt.java
│ │ │ └── IFingerCallback.java
│ │ │ └── util
│ │ │ └── PhoneInfoCheck.java
│ └── res
│ │ ├── anim
│ │ ├── fade_in.xml
│ │ └── fade_out.xml
│ │ ├── drawable-v24
│ │ └── ic_launcher_foreground.xml
│ │ ├── drawable
│ │ ├── common_round_corner_white_bg.xml
│ │ ├── gray_round_bg.xml
│ │ ├── ic_launcher_background.xml
│ │ ├── icon_fingerprint.png
│ │ └── top_round_white_bg.xml
│ │ ├── layout
│ │ ├── activity_demo.xml
│ │ ├── common_tip_dialog.xml
│ │ └── dialog_finger.xml
│ │ ├── mipmap-anydpi-v26
│ │ ├── ic_launcher.xml
│ │ └── ic_launcher_round.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.webp
│ │ └── ic_launcher_round.webp
│ │ ├── values-night
│ │ └── themes.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ ├── styles.xml
│ │ └── themes.xml
│ └── test
│ └── java
│ └── com
│ └── css
│ └── fingerprint
│ └── ExampleUnitTest.java
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── pictures
└── fileprovider.png
├── publish-mavencentral.gradle
├── secring.gpg
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | .idea/gradle.xml
4 | /local.properties
5 | /.idea/caches
6 | /.idea/libraries
7 | /.idea/modules.xml
8 | /.idea/workspace.xml
9 | /.idea/navEditor.xml
10 | /.idea/assetWizardSettings.xml
11 | .DS_Store
12 | /build
13 | /captures
14 | .externalNativeBuild
15 |
16 |
17 | # Built application files
18 | *.apk
19 | *.ap_
20 |
21 | # Files for the ART/Dalvik VM
22 | *.dex
23 |
24 | # Java class files
25 | *.class
26 |
27 | # Generated files
28 | bin/
29 | gen/
30 | out/
31 |
32 | # Gradle files
33 | .gradle/
34 | build/
35 |
36 | # Local configuration file (sdk path, etc)
37 | local.properties
38 |
39 | # Proguard folder generated by Eclipse
40 | proguard/
41 |
42 | # Log Files
43 | *.log
44 |
45 | # Android Studio Navigation editor temp files
46 | .navigation/
47 |
48 | # Android Studio captures folder
49 | captures/
50 |
51 | # Intellij
52 | *.iml
53 | .idea/workspace.xml
54 | .idea/tasks.xml
55 | .idea/gradle.xml
56 | .idea/dictionaries
57 | .idea/libraries
58 | .idea/dictigitonaries
59 | .idea/misc.xml
60 | #.idea/modules.xml
61 | .idea/vcs.xml
62 | .idea/encodings.xml
63 | .DS_Store
64 |
65 | # Keystore files
66 | # *.jks
67 |
68 | # External native build folder generated in Android Studio 2.2 and later
69 | .externalNativeBuild
70 |
71 | # Google Services (e.g. APIs or Firebase)
72 | google-services.json
73 |
74 | # Freeline
75 | freeline.py
76 | freeline/
77 | freeline_project_description.json
78 | /.idea
79 | /gradlew.bat
80 | /gradlew
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
20 |
21 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/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.easyandroid"
8 | minSdkVersion rootProject.ext.android["minSdkVersion"]
9 | targetSdkVersion rootProject.ext.android["targetSdkVersion"]
10 | versionCode rootProject.ext.android["versionCode"]
11 | versionName rootProject.ext.android["versionName"]
12 | flavorDimensions "versionCode"
13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
14 | }
15 | buildTypes {
16 | release {
17 | minifyEnabled false
18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
19 | }
20 | }
21 |
22 | compileOptions {
23 | sourceCompatibility = rootProject.ext.jdk["sourceCompatibility"]
24 | targetCompatibility = rootProject.ext.jdk["targetCompatibility"]
25 | }
26 |
27 | lintOptions {
28 | abortOnError false
29 | }
30 | }
31 |
32 | dependencies {
33 | implementation fileTree(include: ['*.jar'], dir: 'libs')
34 | androidTestImplementation rootProject.ext.dependencies["espresso-core"]
35 | implementation rootProject.ext.dependencies["appcompat"]
36 | implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
37 | implementation 'com.jaredrummler:android-processes:1.1.1'
38 | implementation 'com.github.lzyzsd:jsbridge:1.0.4'
39 | testImplementation rootProject.ext.dependencies["junit"]
40 | implementation project(':easytools')
41 | }
42 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/easyandroid/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.easyandroid", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/assets/html.html:
--------------------------------------------------------------------------------
1 |
2 | html模块
3 |
4 |
5 |
6 |
7 |
8 |
9 |
59 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.os.Bundle;
4 | import android.util.Log;
5 |
6 | import androidx.annotation.Nullable;
7 | import androidx.appcompat.app.AppCompatActivity;
8 |
9 | /**
10 | * package: com.easyandroid.BaseActivity
11 | * author: gyc
12 | * description:
13 | * time: create at 2017/2/13 10:52
14 | */
15 |
16 | public abstract class BaseActivity extends AppCompatActivity {
17 |
18 | @Override
19 | protected void onCreate(@Nullable Bundle savedInstanceState) {
20 | super.onCreate(savedInstanceState);
21 | Log.d("******************Super", "onCreate");
22 | }
23 |
24 | @Override
25 | protected void onDestroy() {
26 | super.onDestroy();
27 | Log.d("******************Super", "onDestroy");
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/ForegroundAppUtil.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.app.ActivityManager;
4 | import android.app.usage.UsageStats;
5 | import android.app.usage.UsageStatsManager;
6 | import android.content.Context;
7 | import android.content.Intent;
8 | import android.os.Build;
9 | import android.provider.Settings;
10 | import android.text.TextUtils;
11 |
12 | import java.util.List;
13 |
14 | /**
15 | * package: com.easyandroid.ForegroundAppUtil
16 | * author: gyc
17 | * description:
18 | * time: create at 2019/12/12 11:11
19 | */
20 | public class ForegroundAppUtil {
21 | private static final long END_TIME = System.currentTimeMillis();
22 | private static final long TIME_INTERVAL = 7 * 24 * 60 * 60 * 1000L;
23 | private static final long START_TIME = END_TIME - TIME_INTERVAL;
24 |
25 | /**
26 | * 获取栈顶的应用包名
27 | */
28 | public static String getForegroundActivityName(Context context) {
29 | String currentClassName = "";
30 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
31 | ActivityManager manager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
32 | currentClassName = manager.getRunningTasks(1).get(0).topActivity.getPackageName();
33 | } else if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP_MR1){
34 | ActivityManager manager = (ActivityManager) context.getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
35 | currentClassName = manager.getRunningAppProcesses().get(0).processName;
36 | } else {
37 | UsageStats initStat = getForegroundUsageStats(context, START_TIME, END_TIME);
38 | if (initStat != null) {
39 | currentClassName = initStat.getPackageName();
40 | }
41 | }
42 | return currentClassName;
43 | }
44 |
45 | /**
46 | * 判断当前应用是否在前台
47 | */
48 | public static boolean isForegroundApp(Context context) {
49 | return TextUtils.equals(getForegroundActivityName(context), context.getPackageName());
50 | }
51 |
52 | /**
53 | * 获取时间段内,
54 | */
55 | public static long getTotleForegroundTime(Context context) {
56 | UsageStats usageStats = getCurrentUsageStats(context, START_TIME, END_TIME);
57 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
58 | return usageStats != null ? usageStats.getTotalTimeInForeground() : 0;
59 | }
60 | return 0;
61 | }
62 |
63 | /**
64 | * 获取记录前台应用的UsageStats对象
65 | */
66 | private static UsageStats getForegroundUsageStats(Context context, long startTime, long endTime) {
67 | UsageStats usageStatsResult = null;
68 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
69 | List usageStatses = getUsageStatsList(context, startTime, endTime);
70 | if (usageStatses == null || usageStatses.isEmpty()) return null;
71 | for (UsageStats usageStats : usageStatses) {
72 | if (usageStatsResult == null || usageStatsResult.getLastTimeUsed() < usageStats.getLastTimeUsed()) {
73 | usageStatsResult = usageStats;
74 | }
75 | }
76 | }
77 | return usageStatsResult;
78 | }
79 |
80 | /**
81 | * 获取记录当前应用的UsageStats对象
82 | */
83 | public static UsageStats getCurrentUsageStats(Context context, long startTime, long endTime) {
84 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
85 | List usageStatses = getUsageStatsList(context, startTime, endTime);
86 | if (usageStatses == null || usageStatses.isEmpty()) return null;
87 | for (UsageStats usageStats : usageStatses) {
88 | if (TextUtils.equals(usageStats.getPackageName(), context.getPackageName())) {
89 | return usageStats;
90 | }
91 | }
92 | }
93 | return null;
94 | }
95 |
96 | /**
97 | * 通过UsageStatsManager获取List集合
98 | */
99 | public static List getUsageStatsList(Context context, long startTime, long endTime) {
100 | if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
101 | UsageStatsManager manager = (UsageStatsManager) context.getApplicationContext().getSystemService(Context.USAGE_STATS_SERVICE);
102 | //UsageStatsManager.INTERVAL_WEEKLY,UsageStatsManager的参数定义了5个,具体查阅源码
103 | List usageStatses = manager.queryUsageStats(UsageStatsManager.INTERVAL_DAILY, startTime, endTime);
104 | if (usageStatses == null || usageStatses.size() == 0) {// 没有权限,获取不到数据
105 | Intent intent = new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS);
106 | intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
107 | context.getApplicationContext().startActivity(intent);
108 | return null;
109 | }
110 | return usageStatses;
111 | }
112 | return null;
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/ItemBean.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import com.easytools.tools.CheckAdapter;
4 |
5 | /**
6 | * package: com.easyandroid.ItemBean
7 | * author: gyc
8 | * description:
9 | * time: create at 2017/1/8 15:38
10 | */
11 |
12 | public class ItemBean implements CheckAdapter.CheckItem{
13 |
14 | private String name;
15 | private String age;
16 | private boolean isChecked;
17 |
18 | public String getName() {
19 | return name;
20 | }
21 |
22 | public void setName(String name) {
23 | this.name = name;
24 | }
25 |
26 | public String getAge() {
27 | return age;
28 | }
29 |
30 | public void setAge(String age) {
31 | this.age = age;
32 | }
33 |
34 | @Override
35 | public boolean isChecked() {
36 | return isChecked;
37 | }
38 |
39 | @Override
40 | public void setChecked(boolean checked) {
41 | this.isChecked = checked;
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/KeyBoardActivity.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.view.View;
6 | import android.widget.EditText;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | /**
12 | * package: com.easyandroid.KeyBoardActivity
13 | * author: gyc
14 | * description:
15 | * time: create at 2018/10/10 11:43
16 | */
17 | public class KeyBoardActivity extends AppCompatActivity {
18 | EditText edittext1;
19 | PopupKeyboardUtil smallKeyboardUtil;
20 | private View viewContainer;
21 |
22 | @Override
23 | protected void onCreate(@Nullable Bundle savedInstanceState) {
24 | super.onCreate(savedInstanceState);
25 | setContentView(R.layout.test_activity);
26 |
27 | edittext1 = findViewById(R.id.edittext1);
28 |
29 | smallKeyboardUtil = new PopupKeyboardUtil(self());
30 | smallKeyboardUtil.attachTo(edittext1, false);
31 | }
32 |
33 | public void onClickView(View view) {
34 | if (view.getId() == R.id.btn1)
35 | smallKeyboardUtil.showSoftKeyboard();
36 | if (view.getId() == R.id.btn2)
37 | smallKeyboardUtil.hideSoftKeyboard();
38 |
39 | }
40 |
41 | private Activity self() {
42 | return this;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/MyAdapter.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.content.Context;
4 | import android.view.LayoutInflater;
5 | import android.view.View;
6 | import android.view.ViewGroup;
7 | import android.widget.CheckBox;
8 | import android.widget.CompoundButton;
9 | import android.widget.TextView;
10 |
11 | import com.easytools.tools.CheckAdapter;
12 |
13 | import java.util.List;
14 |
15 | /**
16 | * package: com.easyandroid.MyAdapter
17 | * author: gyc
18 | * description:
19 | * time: create at 2017/1/8 15:39
20 | */
21 |
22 | public class MyAdapter extends CheckAdapter{
23 |
24 | private List items;
25 | private LayoutInflater inflater;
26 |
27 | public MyAdapter(Context context,List items) {
28 | super(items);
29 | inflater = LayoutInflater.from(context);
30 | this.items = items;
31 | }
32 |
33 | @Override
34 | public View getView(int position, View convertView, ViewGroup parent) {
35 | ViewHolder holder = null;
36 | if (convertView == null) {
37 | holder = new ViewHolder();
38 | convertView = inflater.inflate(R.layout.item_check, parent, false);
39 | holder.checkBox = (CheckBox) convertView.findViewById(R.id.cb);
40 | holder.tvName = (TextView) convertView.findViewById(R.id.tv_name);
41 | holder.tvAge = (TextView) convertView.findViewById(R.id.tv_age);
42 | convertView.setTag(holder);
43 | } else {
44 | holder = (ViewHolder) convertView.getTag();
45 | }
46 | holder.checkBox.setChecked(items.get(position).isChecked());
47 | holder.tvName.setText(items.get(position).getName());
48 | holder.tvAge.setText(items.get(position).getAge());
49 | handleCompoundButton(holder.checkBox,items.get(position));
50 | return convertView;
51 | }
52 |
53 | public class ViewHolder{
54 | CheckBox checkBox;
55 | TextView tvName, tvAge;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/TestConstraintLayoutActivity.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.os.Bundle;
4 |
5 | import androidx.annotation.Nullable;
6 | import androidx.appcompat.app.AppCompatActivity;
7 |
8 | /**
9 | * package: com.easyandroid.TestConstraintLayoutActivity
10 | * author: gyc
11 | * description:
12 | * time: create at 2020/11/6 15:00
13 | */
14 | public class TestConstraintLayoutActivity extends AppCompatActivity {
15 |
16 | @Override
17 | protected void onCreate(@Nullable Bundle savedInstanceState) {
18 | super.onCreate(savedInstanceState);
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/TestJsActivity.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.webkit.WebSettings;
6 | import android.widget.TextView;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | import com.easytools.tools.PathUtils;
12 | import com.github.lzyzsd.jsbridge.BridgeHandler;
13 | import com.github.lzyzsd.jsbridge.BridgeWebView;
14 | import com.github.lzyzsd.jsbridge.CallBackFunction;
15 |
16 | import java.io.BufferedWriter;
17 | import java.io.File;
18 | import java.io.FileWriter;
19 | import java.io.IOException;
20 |
21 | /**
22 | * package: com.easyandroid.TestJsActivity
23 | * author: gyc
24 | * description:
25 | * time: create at 2019/12/16 11:51
26 | */
27 | public class TestJsActivity extends AppCompatActivity {
28 |
29 | TextView tvJs, tvShowmsg;
30 | BridgeWebView webview;
31 |
32 | FileWriter fw = null;
33 | BufferedWriter bw = null;
34 |
35 | @Override
36 | protected void onCreate(@Nullable Bundle savedInstanceState) {
37 | super.onCreate(savedInstanceState);
38 | setContentView(R.layout.activity_testjs);
39 |
40 | tvJs = (TextView) findViewById(R.id.tv_androidcalljs);
41 | tvShowmsg = (TextView) findViewById(R.id.tv_showmsg);
42 |
43 | webview = (BridgeWebView) findViewById(R.id.webview);
44 | WebSettings webSettings = webview.getSettings();
45 | webSettings.setBuiltInZoomControls(true);
46 | webSettings.setSupportZoom(true);
47 | //与js交互必须设置
48 | webSettings.setJavaScriptEnabled(true);
49 | webview.loadUrl("file:///android_asset/html.html");
50 |
51 | callJs();
52 | registerInJs();
53 |
54 |
55 | int type = 0;
56 | String logPath = PathUtils.getExternalStoragePath() + File.separator + "公文下载路径WIFI版.txt";
57 | try {
58 | fw = new FileWriter(logPath, true);
59 | bw = new BufferedWriter(fw);
60 |
61 | for (int i = 0; i < 10; i++) {
62 | String url = "";
63 | if (type == 0) {//批件
64 | url = "http://www.baidu.com" + i;
65 | }
66 | bw.write(url + "\n");
67 | }
68 | } catch (IOException e) {
69 | } finally {
70 | try {
71 | bw.close();
72 | fw.close();
73 | } catch (IOException e) {
74 | e.printStackTrace();
75 | }
76 | }
77 |
78 | }
79 |
80 | private void callJs() {
81 | tvJs.setOnClickListener(new View.OnClickListener() {
82 | @Override
83 | public void onClick(View v) {
84 | webview.callHandler("functionInJs", "Android传递给js的数据", new CallBackFunction() {
85 | @Override
86 | public void onCallBack(String data) {
87 | tvShowmsg.setText(data);
88 | }
89 | });
90 | }
91 | });
92 | }
93 |
94 | private void registerInJs() {
95 | webview.registerHandler("functionInAndroid", new BridgeHandler() {
96 | @Override
97 | public void handler(String data, CallBackFunction function) {
98 | tvShowmsg.setText("js调用了Android");
99 | //返回给html
100 | function.onCallBack("Android回传给js的数据");
101 | }
102 | });
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/TestRunning.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.content.pm.PackageInfo;
4 | import android.content.pm.PackageManager;
5 | import android.os.Bundle;
6 | import android.widget.TextView;
7 |
8 | import androidx.annotation.Nullable;
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | import com.jaredrummler.android.processes.AndroidProcesses;
12 | import com.jaredrummler.android.processes.models.AndroidAppProcess;
13 | import com.jaredrummler.android.processes.models.Stat;
14 | import com.jaredrummler.android.processes.models.Statm;
15 |
16 | import java.util.List;
17 |
18 | /**
19 | * package: com.easyandroid.TestRunning
20 | * author: gyc
21 | * description:
22 | * time: create at 2019/12/12 10:23
23 | */
24 | public class TestRunning extends AppCompatActivity {
25 |
26 | @Override
27 | protected void onCreate(@Nullable Bundle savedInstanceState) {
28 | super.onCreate(savedInstanceState);
29 | setContentView(R.layout.activity_testrunning);
30 |
31 | TextView tv = findViewById(R.id.tv);
32 |
33 | StringBuilder sb = new StringBuilder();
34 |
35 | List processes = AndroidProcesses.getRunningAppProcesses();
36 |
37 | for (AndroidAppProcess process : processes) {
38 | // Get some information about the process
39 | String processName = process.name;
40 |
41 | try {
42 | Stat stat = process.stat();
43 | int pid = stat.getPid();
44 | int parentProcessId = stat.ppid();
45 | long startTime = stat.stime();
46 | int policy = stat.policy();
47 | char state = stat.state();
48 |
49 | Statm statm = process.statm();
50 | long totalSizeOfProcess = statm.getSize();
51 | long residentSetSize = statm.getResidentSetSize();
52 |
53 | PackageManager pm = getPackageManager();
54 | PackageInfo packageInfo = process.getPackageInfo(this, 0);
55 | String appName = packageInfo.applicationInfo.loadLabel(pm).toString();
56 |
57 | sb.append("processName:" + processName + "," + "appName:" + appName + "\n");
58 |
59 | } catch (Exception e) {
60 | }
61 |
62 | tv.setText(sb.toString());
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/app/src/main/java/com/easyandroid/ToastUtils.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import android.content.Context;
4 | import android.view.Gravity;
5 | import android.view.LayoutInflater;
6 | import android.view.View;
7 | import android.widget.TextView;
8 | import android.widget.Toast;
9 |
10 | /**
11 | * ToastUtils
12 | *
13 | * @author Trinea 2013-12-9
14 | */
15 | public class ToastUtils {
16 | private static Toast toast = null; //Toast的对象!
17 |
18 | public static void showToast(Context context, String msg) {
19 | if (toast == null) {
20 | View toastview = LayoutInflater.from(context).inflate(R.layout.custom_toast, null);
21 | TextView text = toastview.findViewById(R.id.tv_content);
22 | text.setText(msg);
23 | toast = new Toast(context);
24 | toast.setGravity(Gravity.CENTER, 0, 0);
25 | toast.setDuration(Toast.LENGTH_SHORT);
26 | toast.setView(toastview);
27 | } else {
28 | View toastview = toast.getView();
29 | TextView text = toastview.findViewById(R.id.tv_content);
30 | text.setText(msg);
31 | }
32 | if (toast.getView().isShown()) return;
33 | toast.show();
34 | }
35 |
36 |
37 | public static void cancel() {
38 | if (toast != null) {
39 | toast.cancel();
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/app/src/main/res/anim/down_to_up.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/anim/up_to_hide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/abcd.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/drawable/abcd.gif
--------------------------------------------------------------------------------
/app/src/main/res/drawable/bitmap.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/blue_s.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/drawable/blue_s.9.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/custom_shape_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/keyboard_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/drawable/keyboard_delete.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/keyboard_key.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/keyboard_shift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/drawable/keyboard_shift.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/transparency_n.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/drawable/transparency_n.9.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
19 |
20 |
24 |
25 |
29 |
30 |
34 |
35 |
39 |
40 |
44 |
45 |
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_testjs.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
15 |
16 |
23 |
24 |
33 |
34 |
41 |
42 |
43 |
47 |
48 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_testrunning.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
15 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/custom_toast.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
20 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/item_check.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
21 |
22 |
28 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/keyboardview_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
17 |
18 |
30 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/test_activity.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
19 |
20 |
26 |
27 |
28 |
33 |
38 |
39 |
44 |
45 |
50 |
51 |
56 |
57 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/testpic.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-hdpi/testpic.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/modify_title.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-xxhdpi/modify_title.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gycold/EasyAndroid/9cb415afabedaa80014e99bf2e98972b417223c6/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | EasyAndroid
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/allkeys1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
13 |
16 |
19 |
22 |
25 |
28 |
31 |
34 |
37 |
40 |
41 |
45 |
48 |
51 |
52 |
53 |
56 |
59 |
62 |
65 |
68 |
71 |
74 |
77 |
80 |
83 |
87 |
90 |
93 |
94 |
95 |
96 |
101 |
104 |
107 |
110 |
113 |
116 |
119 |
122 |
125 |
129 |
132 |
135 |
136 |
137 |
143 |
146 |
149 |
152 |
155 |
158 |
161 |
164 |
169 |
170 |
174 |
179 |
180 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/small_keyboard.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
15 |
18 |
19 |
20 |
24 |
27 |
30 |
31 |
32 |
36 |
39 |
42 |
43 |
44 |
48 |
53 |
54 |
--------------------------------------------------------------------------------
/app/src/test/java/com/easyandroid/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.easyandroid;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: "config.gradle"
3 | // buildscript该闭包用于给该脚本本身的配置
4 | buildscript {
5 | // buildScript块的repositories主要是为了Gradle脚本自身的执行,获取脚本依赖插件
6 | repositories {
7 | /** 声明使用Google和jcenter的代码托管仓库
8 | 大部分的Android开源项目都会将代码托管到这两个仓库
9 | 声明这两个仓库之后,需要引入开源项目而本地缓存没有的情况下
10 | 便会按照先后顺序去这些仓库寻找,从仓库将相关项目下载到本地**/
11 | // 但是因为网络原因,这两个仓库对于国内来说不太友好,所以通常使用阿里云等镜像站代替使用
12 | // 按需求添加如下几行即可
13 | //方式一
14 | maven { url 'https://maven.aliyun.com/repository/google' }
15 | maven { url 'https://maven.aliyun.com/repository/jcenter' }
16 | //方式二
17 | // maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
18 | // maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
19 | google()
20 | mavenCentral()
21 | jcenter()
22 | }
23 | dependencies {
24 | classpath 'com.android.tools.build:gradle:7.2.1'
25 | // classpath 'com.novoda:bintray-release:0.9.2'//此仓库暂不支持gradle6.0以上版本,使用下面仓库代替
26 | // classpath 'com.github.panpf.bintray-publish:bintray-publish:1.0.0'
27 | // NOTE: Do not place your application dependencies here; they belong
28 | // in the individual module build.gradle files
29 | }
30 | }
31 |
32 | allprojects {
33 | tasks.withType(Javadoc) {
34 | options.addStringOption('Xdoclint:none', '-quiet')
35 | options.addStringOption('encoding', 'UTF-8')
36 | }
37 |
38 | repositories {
39 | //方式一
40 | maven { url 'https://maven.aliyun.com/repository/google' }
41 | maven { url 'https://maven.aliyun.com/repository/jcenter' }
42 | //方式二
43 | // maven { url 'https://maven.aliyun.com/nexus/content/groups/public/' }
44 | // maven { url 'https://maven.aliyun.com/nexus/content/repositories/jcenter' }
45 | google()
46 | mavenCentral()
47 | jcenter()
48 | maven { url "https://jitpack.io" }
49 | }
50 | }
51 |
52 |
53 | // 运行gradle clean时,执行此处定义的task
54 | // 该任务继承自Delete,删除根目录中的build目录
55 | // 相当于执行Delete.delete(rootProject.buildDir)
56 | // gradle使用groovy语言,调用method时可以不用加()
57 | //task clean(type: Delete) {
58 | // delete rootProject.buildDir
59 | //}
60 |
--------------------------------------------------------------------------------
/easytools/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/easytools/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | //apply plugin: 'com.github.panpf.bintray-publish'
3 |
4 | android {
5 | compileSdkVersion rootProject.ext.android["compileSdkVersion"]
6 | buildToolsVersion rootProject.ext.android["buildToolsVersion"]
7 |
8 | defaultConfig {
9 | minSdkVersion rootProject.ext.android["minSdkVersion"]
10 | targetSdkVersion rootProject.ext.android["targetSdkVersion"]
11 | versionCode rootProject.ext.android["versionCode"]
12 | versionName rootProject.ext.android["versionName"]
13 | flavorDimensions "versionCode"
14 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
15 | }
16 |
17 | buildTypes {
18 | release {
19 | consumerProguardFiles 'proguard-rules.pro'
20 | }
21 | debug {
22 | consumerProguardFiles 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | lintOptions {
27 | abortOnError false
28 | }
29 |
30 | compileOptions {
31 | sourceCompatibility = rootProject.ext.jdk["sourceCompatibility"]
32 | targetCompatibility = rootProject.ext.jdk["targetCompatibility"]
33 | }
34 |
35 | }
36 |
37 | dependencies {
38 | implementation fileTree(include: ['*.jar'], dir: 'libs')
39 | // //以下是系统支持库
40 | // compileOnly rootProject.ext.dependencies["appcompat-v7"]
41 | // compileOnly rootProject.ext.dependencies["design"]
42 | // compileOnly rootProject.ext.dependencies["palette-v7"]
43 | // compileOnly rootProject.ext.dependencies["gson"]
44 |
45 | //从2.0.0开始,升级为AndroidX,放弃support库
46 | //以下是系统支持库
47 | compileOnly rootProject.ext.dependencies["appcompat"]
48 | compileOnly rootProject.ext.dependencies["material"]
49 | compileOnly rootProject.ext.dependencies["palette"]
50 | compileOnly rootProject.ext.dependencies["gson"]
51 | }
52 |
53 | ////添加
54 | //publish {
55 | // userOrg = 'easyandroid'//bintray.com用户名
56 | // groupId = 'com.easyandroid'//jcenter上的路径
57 | // artifactId = 'easytools'//项目名称
58 | // publishVersion = '2.0.3'//版本号
59 | // desc = 'Oh hi, this is a nice description for a project, right?'//描述
60 | // website = 'https://github.com/gycold/EasyAndroid.git'//网站
61 | //}
62 |
63 |
64 | //先ext,再apply from
65 | ext {
66 | PUBLISH_ARTIFACT_ID = "easyandroid" //你的artifact_id,一般是module的名字
67 | PUBLISH_VERSION = "2.0.7" //发布版本号
68 | PUBLISH_GROUP_ID = 'io.github.gycold' //你的sonatype的group_id
69 | }
70 | apply from: rootProject.file('publish-mavencentral.gradle')
--------------------------------------------------------------------------------
/easytools/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in G:\AndroidSDK/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 | -keep class com.easytools.tools.DialogUtils {*;}
19 | -dontwarn com.easytools.tools.**
20 | -keep class com.easytools.constant.**{*;}
21 | -keep class com.easytools.**{*;}
--------------------------------------------------------------------------------
/easytools/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
17 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/constant/MemoryConstants.java:
--------------------------------------------------------------------------------
1 | package com.easytools.constant;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import androidx.annotation.IntDef;
7 |
8 | /**
9 | * package: com.easytools.constant.MemoryConstants
10 | * author: gyc
11 | * description:
12 | * time: create at 2024/6/19 14:16
13 | */
14 | public final class MemoryConstants {
15 | public static final int BYTE = 1;
16 | public static final int KB = 1024;
17 | public static final int MB = 1048576;
18 | public static final int GB = 1073741824;
19 |
20 | @IntDef({BYTE, KB, MB, GB})
21 | @Retention(RetentionPolicy.SOURCE)
22 | public @interface Unit {
23 | }
24 | }
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/constant/PermissionConstants.java:
--------------------------------------------------------------------------------
1 | package com.easytools.constant;
2 |
3 | import android.Manifest;
4 | import android.Manifest.permission;
5 |
6 | import androidx.annotation.StringDef;
7 |
8 | import java.lang.annotation.Retention;
9 | import java.lang.annotation.RetentionPolicy;
10 |
11 | /**
12 | * package: com.easytools.constant.PermissionConstants
13 | * author: gyc
14 | * description:权限相关常量
15 | * time: create at 2018/1/20 0020 09:50
16 | */
17 |
18 | public class PermissionConstants {
19 |
20 | public static final String CALENDAR = Manifest.permission_group.CALENDAR;
21 | public static final String CAMERA = Manifest.permission_group.CAMERA;
22 | public static final String CONTACTS = Manifest.permission_group.CONTACTS;
23 | public static final String LOCATION = Manifest.permission_group.LOCATION;
24 | public static final String MICROPHONE = Manifest.permission_group.MICROPHONE;
25 | public static final String PHONE = Manifest.permission_group.PHONE;
26 | public static final String SENSORS = Manifest.permission_group.SENSORS;
27 | public static final String SMS = Manifest.permission_group.SMS;
28 | public static final String STORAGE = Manifest.permission_group.STORAGE;
29 |
30 | private static final String[] GROUP_CALENDAR = {
31 | permission.READ_CALENDAR, permission.WRITE_CALENDAR
32 | };
33 | private static final String[] GROUP_CAMERA = {
34 | permission.CAMERA
35 | };
36 | private static final String[] GROUP_CONTACTS = {
37 | permission.READ_CONTACTS, permission.WRITE_CONTACTS, permission.GET_ACCOUNTS
38 | };
39 | private static final String[] GROUP_LOCATION = {
40 | permission.ACCESS_FINE_LOCATION, permission.ACCESS_COARSE_LOCATION
41 | };
42 | private static final String[] GROUP_MICROPHONE = {
43 | permission.RECORD_AUDIO
44 | };
45 | private static final String[] GROUP_PHONE = {
46 | permission.READ_PHONE_STATE, permission.READ_PHONE_NUMBERS, permission.CALL_PHONE,
47 | permission.ANSWER_PHONE_CALLS, permission.READ_CALL_LOG, permission.WRITE_CALL_LOG,
48 | permission.ADD_VOICEMAIL, permission.USE_SIP, permission.PROCESS_OUTGOING_CALLS
49 | };
50 | private static final String[] GROUP_SENSORS = {
51 | permission.BODY_SENSORS
52 | };
53 | private static final String[] GROUP_SMS = {
54 | permission.SEND_SMS, permission.RECEIVE_SMS, permission.READ_SMS,
55 | permission.RECEIVE_WAP_PUSH, permission.RECEIVE_MMS,
56 | };
57 | private static final String[] GROUP_STORAGE = {
58 | permission.READ_EXTERNAL_STORAGE, permission.WRITE_EXTERNAL_STORAGE
59 | };
60 |
61 | @StringDef({CALENDAR, CAMERA, CONTACTS, LOCATION, MICROPHONE, PHONE, SENSORS, SMS, STORAGE,})
62 | @Retention(RetentionPolicy.SOURCE)
63 | public @interface Permission {
64 | }
65 |
66 | public static String[] getPermissions(@Permission final String permission) {
67 | switch (permission) {
68 | case CALENDAR:
69 | return GROUP_CALENDAR;
70 | case CAMERA:
71 | return GROUP_CAMERA;
72 | case CONTACTS:
73 | return GROUP_CONTACTS;
74 | case LOCATION:
75 | return GROUP_LOCATION;
76 | case MICROPHONE:
77 | return GROUP_MICROPHONE;
78 | case PHONE:
79 | return GROUP_PHONE;
80 | case SENSORS:
81 | return GROUP_SENSORS;
82 | case SMS:
83 | return GROUP_SMS;
84 | case STORAGE:
85 | return GROUP_STORAGE;
86 | }
87 | return new String[]{permission};
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/constant/TimeConstants.java:
--------------------------------------------------------------------------------
1 | package com.easytools.constant;
2 |
3 | import java.lang.annotation.Retention;
4 | import java.lang.annotation.RetentionPolicy;
5 |
6 | import androidx.annotation.IntDef;
7 |
8 | /**
9 | * package: com.easytools.constant.TimeConstants
10 | * author: gyc
11 | * description:
12 | * time: create at 2024/6/19 14:17
13 | */
14 | public class TimeConstants {
15 | public static final int MSEC = 1;
16 | public static final int SEC = 1000;
17 | public static final int MIN = 60000;
18 | public static final int HOUR = 3600000;
19 | public static final int DAY = 86400000;
20 |
21 | @IntDef({MSEC, SEC, MIN, HOUR, DAY})
22 | @Retention(RetentionPolicy.SOURCE)
23 | public @interface Unit {
24 | }
25 | }
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/tools/ActivityManager.java:
--------------------------------------------------------------------------------
1 | package com.easytools.tools;
2 |
3 | import android.app.Activity;
4 | import android.app.Application;
5 | import android.os.Bundle;
6 | import android.text.TextUtils;
7 |
8 | import java.util.Stack;
9 |
10 | /**
11 | * package: com.easytools.tools.ActivityUtil
12 | * author: gyc
13 | * description: 管理Activity生命周期的类,使用:
14 | * 在自己的Application注册:registerActivityLifecycleCallbacks(ActivityManager.getActivityLifecycleCallbacks());
15 | * 可以指定报名.类打开或者关闭Activity
16 | * time: create at 2016/10/14 13:25
17 | */
18 |
19 | public class ActivityManager {
20 |
21 | private static Stack activityStack = new Stack<>();
22 |
23 | private static final JActivityLifecycleCallbacks instance = new JActivityLifecycleCallbacks();
24 |
25 | public ActivityManager() {
26 | }
27 |
28 | public static Application.ActivityLifecycleCallbacks getActivityLifecycleCallbacks() {
29 | return instance;
30 | }
31 |
32 | /**
33 | * 获得当前栈顶Activity
34 | *
35 | * @return
36 | */
37 | public static Activity currentActivity() {
38 | Activity activity = null;
39 | if (!activityStack.isEmpty())
40 | activity = activityStack.peek();
41 | return activity;
42 | }
43 |
44 | /**
45 | * 主动退出Activity
46 | *
47 | * @param activity
48 | */
49 | public static void closeActivity(Activity activity) {
50 | if (activity != null) {
51 | activityStack.remove(activity);
52 | activity.finish();
53 | }
54 | }
55 |
56 | public static void closeAllActivity() {
57 | while (true) {
58 | Activity activity = currentActivity();
59 | if (null == activity) {
60 | break;
61 | }
62 | closeActivity(activity);
63 | }
64 | }
65 |
66 | /**
67 | * close a specific activity by its complete name.
68 | *
69 | * @param name For example: com.jude.ui.Activity_B
70 | */
71 | public static void closeActivityByName(String name) throws ClassNotFoundException{
72 | if (activityStack.isEmpty()){
73 | throw new ClassNotFoundException("Activity栈为空");
74 | }
75 |
76 | int index = activityStack.size() - 1;
77 |
78 | while (true) {
79 | Activity activity = activityStack.get(index);
80 |
81 | String activityName = activity.getComponentName().getClassName();
82 | if (!TextUtils.equals(name, activityName)) {
83 | index--;
84 | if (index < 0) {//avoid index out of bound.
85 | throw new ClassNotFoundException(name + "不存在");
86 | }
87 | continue;
88 | }
89 | closeActivity(activity);
90 | break;
91 | }
92 | }
93 |
94 | /**
95 | * close all activities but except the specified activity by name
96 | *
97 | * @param name For example: com.jude.ui.Activity_B
98 | */
99 | public static void closeOtherActivities(String name) throws ClassNotFoundException{
100 | if (activityStack.isEmpty()){
101 | throw new ClassNotFoundException("Activity栈为空");
102 | }
103 |
104 | int index = activityStack.size() - 1;
105 | while (true) {
106 | Activity activity = activityStack.get(index);
107 | String activityName = activity.getComponentName().getClassName();
108 |
109 | index--;
110 | if (TextUtils.equals(name, activityName)) {
111 | if (index < 0) {
112 | break;
113 | }
114 | continue;
115 | }
116 | closeActivity(activity);
117 | if (index < 0) {
118 | break;
119 | }
120 | }
121 | }
122 |
123 | /**
124 | * 获得当前ACTIVITY 名字
125 | */
126 | public static String getCurrentActivityName() {
127 | Activity activity = currentActivity();
128 | String name = "";
129 | if (activity != null) {
130 | name = activity.getComponentName().getClassName();
131 | }
132 | return name;
133 | }
134 |
135 | public static Stack getActivityStack() {
136 | Stack stack = new Stack<>();
137 | stack.addAll(activityStack);
138 | return stack;
139 | }
140 |
141 | private static class JActivityLifecycleCallbacks implements Application.ActivityLifecycleCallbacks {
142 |
143 | @Override
144 | public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
145 |
146 | }
147 |
148 | @Override
149 | public void onActivityStarted(Activity activity) {
150 |
151 | }
152 |
153 | @Override
154 | public void onActivityResumed(Activity activity) {
155 | activityStack.remove(activity);
156 | activityStack.push(activity);
157 | }
158 |
159 | @Override
160 | public void onActivityPaused(Activity activity) {
161 |
162 | }
163 |
164 | @Override
165 | public void onActivityStopped(Activity activity) {
166 |
167 | }
168 |
169 | @Override
170 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
171 |
172 | }
173 |
174 | @Override
175 | public void onActivityDestroyed(Activity activity) {
176 | activityStack.remove(activity);
177 | }
178 | }
179 |
180 | }
181 |
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/tools/AssetDatabaseOpenHelper.java:
--------------------------------------------------------------------------------
1 | package com.easytools.tools;
2 |
3 | import android.content.Context;
4 | import android.database.sqlite.SQLiteDatabase;
5 |
6 | import java.io.BufferedReader;
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 | import java.io.InputStreamReader;
11 |
12 | /**
13 | * package: com.easytools.tools.AssetDatabaseOpenHelper
14 | * author: gyc
15 | * description:目录资源获取,获取assets目录下数据库
16 | * time: create at 2017/1/7 15:39
17 | */
18 |
19 | public class AssetDatabaseOpenHelper {
20 |
21 | private Context context;
22 | private String databaseName;
23 |
24 | public AssetDatabaseOpenHelper(Context context, String databaseName) {
25 | this.context = context;
26 | this.databaseName = databaseName;
27 | }
28 |
29 | /**
30 | * 创建或打开一个数据库
31 | *
32 | * @return 返回数据库的对象
33 | */
34 | public synchronized SQLiteDatabase getWriteableDatabase() {
35 | File dbFile = context.getDatabasePath(databaseName);
36 | if (dbFile != null && !dbFile.exists()) {
37 | try {
38 | copyDatabase(dbFile);
39 | } catch (IOException e) {
40 | throw new RuntimeException("Error creating source database", e);
41 | }
42 | }
43 | return SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READWRITE);
44 | }
45 |
46 | /**
47 | * 创建或打开一个只读数据库
48 | *
49 | * @return 返回数据库的对象
50 | */
51 | public synchronized SQLiteDatabase getReadableDatabase() {
52 | File dbFile = context.getDatabasePath(databaseName);
53 | if (dbFile != null && !dbFile.exists()) {
54 | try {
55 | copyDatabase(dbFile);
56 | } catch (IOException e) {
57 | throw new RuntimeException("Error creating source database", e);
58 | }
59 | }
60 |
61 | return SQLiteDatabase.openDatabase(dbFile.getPath(), null, SQLiteDatabase.OPEN_READONLY);
62 | }
63 |
64 | /**
65 | * 返回数据库名称
66 | *
67 | * @return
68 | */
69 | public String getDatabaseName() {
70 | return databaseName;
71 | }
72 |
73 | /**
74 | * @param dbFile
75 | * @throws IOException
76 | */
77 | private void copyDatabase(File dbFile) throws IOException {
78 | InputStream is = context.getAssets().open(databaseName);
79 | FileUtils.writeFile(dbFile, is);
80 | is.close();
81 | }
82 |
83 | /**
84 | * 获取asset文件下的资源文件信息
85 | *
86 | * @param fileName 文件名
87 | * @param context 上下文
88 | * @return 文件信息
89 | */
90 | public static String getFromAssets(String fileName, Context context) {
91 | InputStreamReader inputReader = null;
92 | BufferedReader bufReader = null;
93 | try {
94 | inputReader = new InputStreamReader(context
95 | .getResources().getAssets().open(fileName));
96 |
97 | bufReader = new BufferedReader(inputReader);
98 |
99 | String line = "";
100 | StringBuffer result = new StringBuffer();
101 | while ((line = bufReader.readLine()) != null) {
102 | result.append(line);
103 | }
104 | return result.toString();
105 | } catch (IOException e) {
106 | e.printStackTrace();
107 | } finally {
108 | try {
109 | if (inputReader != null) {
110 | inputReader.close();
111 | }
112 | if (bufReader != null) {
113 | bufReader.close();
114 | }
115 | } catch (IOException e) {
116 | e.printStackTrace();
117 | }
118 | }
119 | return "";
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/tools/BrightnessUtils.java:
--------------------------------------------------------------------------------
1 | package com.easytools.tools;
2 |
3 | import android.content.ContentResolver;
4 | import android.provider.Settings;
5 | import android.view.Window;
6 | import android.view.WindowManager;
7 |
8 | import androidx.annotation.IntRange;
9 | import androidx.annotation.NonNull;
10 |
11 | /**
12 | * package: com.easytools.tools.BrightnessUtils
13 | * author: gyc
14 | * description:屏幕亮度的工具类
15 | * time: create at 2024/6/17 16:58
16 | */
17 | public class BrightnessUtils {
18 | private BrightnessUtils() {
19 | throw new UnsupportedOperationException("u can't instantiate me...");
20 | }
21 |
22 | /**
23 | * Return whether automatic brightness mode is enabled.
24 | *
25 | * @return {@code true}: yes
{@code false}: no
26 | */
27 | public static boolean isAutoBrightnessEnabled() {
28 | try {
29 | int mode = Settings.System.getInt(
30 | Utils.getApp().getContentResolver(),
31 | Settings.System.SCREEN_BRIGHTNESS_MODE
32 | );
33 | return mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
34 | } catch (Settings.SettingNotFoundException e) {
35 | e.printStackTrace();
36 | return false;
37 | }
38 | }
39 |
40 | /**
41 | * Enable or disable automatic brightness mode.
42 | * Must hold {@code }
43 | *
44 | * @param enabled True to enabled, false otherwise.
45 | * @return {@code true}: success
{@code false}: fail
46 | */
47 | public static boolean setAutoBrightnessEnabled(final boolean enabled) {
48 | return Settings.System.putInt(
49 | Utils.getApp().getContentResolver(),
50 | Settings.System.SCREEN_BRIGHTNESS_MODE,
51 | enabled ? Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC
52 | : Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL
53 | );
54 | }
55 |
56 | /**
57 | * 获取屏幕亮度
58 | *
59 | * @return 屏幕亮度 0-255
60 | */
61 | public static int getBrightness() {
62 | try {
63 | return Settings.System.getInt(
64 | Utils.getApp().getContentResolver(),
65 | Settings.System.SCREEN_BRIGHTNESS
66 | );
67 | } catch (Settings.SettingNotFoundException e) {
68 | e.printStackTrace();
69 | return 0;
70 | }
71 | }
72 |
73 | /**
74 | * 设置屏幕亮度
75 | * 需添加权限 {@code }
76 | * 并得到授权
77 | *
78 | * @param brightness 亮度值
79 | */
80 | public static boolean setBrightness(@IntRange(from = 0, to = 255) final int brightness) {
81 | ContentResolver resolver = Utils.getApp().getContentResolver();
82 | boolean b = Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, brightness);
83 | resolver.notifyChange(Settings.System.getUriFor("screen_brightness"), null);
84 | return b;
85 | }
86 |
87 | /**
88 | * 设置窗口亮度
89 | *
90 | * @param window 窗口
91 | * @param brightness 亮度值
92 | */
93 | public static void setWindowBrightness(@NonNull final Window window,
94 | @IntRange(from = 0, to = 255) final int brightness) {
95 | WindowManager.LayoutParams lp = window.getAttributes();
96 | lp.screenBrightness = brightness / 255f;
97 | window.setAttributes(lp);
98 | }
99 |
100 | /**
101 | * 获取窗口亮度
102 | *
103 | * @param window 窗口
104 | * @return 屏幕亮度 0-255
105 | */
106 | public static int getWindowBrightness(@NonNull final Window window) {
107 | WindowManager.LayoutParams lp = window.getAttributes();
108 | float brightness = lp.screenBrightness;
109 | if (brightness < 0) return getBrightness();
110 | return (int) (brightness * 255);
111 | }
112 | }
--------------------------------------------------------------------------------
/easytools/src/main/java/com/easytools/tools/BuildProperties.java:
--------------------------------------------------------------------------------
1 | package com.easytools.tools;
2 |
3 | import android.os.Environment;
4 |
5 | import java.io.File;
6 | import java.io.FileInputStream;
7 | import java.io.IOException;
8 | import java.util.Collection;
9 | import java.util.Enumeration;
10 | import java.util.Properties;
11 | import java.util.Set;
12 | import java.util.Map.Entry;
13 |
14 | /**
15 | * package: com.easytools.tools.BuildProperties
16 | * author: gyc
17 | * description:构造Properties
18 | * time: create at 2019/6/26 10:14
19 | */
20 | public class BuildProperties {
21 |
22 | private final Properties properties;
23 |
24 | private BuildProperties() throws IOException {
25 | properties = new Properties();
26 | properties.load(new FileInputStream(new File(Environment.getRootDirectory(), "build.prop")));
27 | }
28 |
29 | public boolean containsKey(final Object key) {
30 | return properties.containsKey(key);
31 | }
32 |
33 | public boolean containsValue(final Object value) {
34 | return properties.containsValue(value);
35 | }
36 |
37 | public Set> entrySet() {
38 | return properties.entrySet();
39 | }
40 |
41 | public String getProperty(final String name) {
42 | return properties.getProperty(name);
43 | }
44 |
45 | public String getProperty(final String name, final String defaultValue) {
46 | return properties.getProperty(name, defaultValue);
47 | }
48 |
49 | public boolean isEmpty() {
50 | return properties.isEmpty();
51 | }
52 |
53 | public Enumeration