This project is mainly used to collect utils classes useful in Android development, for example, log, crash collection, resources, attr, runtime permission, toast etc so that to accelerate your Android evelopment.
This project is published to jCenter, so you can easily use it in your project.
First, you need to add jcenter in your project:
repositories { mavenCentral() }
then, add dependencies in your project:
implementation "com.github.Shouheng88:utils-core:$latest-version"
If you want to use the kotlin extension based on utils classes, use the dependency below:
implementation "com.github.Shouheng88:utils-ktx:$latest-version"
You need initialize utils in your application. This is mainly used to get a global context to make utils methods more convenient, and it will cost too much time of launching your App.
public class SampleApp extends Application {
@Override
public void onCreate() {
super.onCreate();
// initialize your library
UtilsApp.init(this);
}
}
The utils classes was divided into multiple groups:
No | Class | Group | Desc |
---|---|---|---|
1 | ActivityUtils | App | Activity start, close, aniation, builder |
2 | AppUtils | App | App install, uninstall, get information |
3 | IntentUtils | App | Intent to launch App, market etc |
4 | ResUtils | Resources | Image, Text, and other resources |
5 | EncodeUtils | Encode | base64 and url encode |
6 | EncryptUtils | Encrypt | md5 sha256 encrypt |
7 | RegexUtils | Data | Regex |
8 | StringUtils | Data | String process |
9 | TimeUtils | Data | Date and time process |
10 | DeviceUtils | Device | Device info, imei, model etc |
11 | NetworkUtils | Device | Network info, type etc |
12 | ShellUtils | Device | Shell |
13 | PermissionUtils | Permission | Android runtime permission |
14 | CrashHelper | Stability | crash |
15 | L | Stability | log output, format etc |
16 | FileUtils | Storage | File, visit, move, delete etc |
17 | PathUtils | Storage | Get directory paths |
18 | IOUtils | Storage | IO |
19 | KV | Storage | Sharedpreference |
20 | ImageUtils | ui | Image process, scale, roate etc |
21 | ToastUtils | ui | Toast |
22 | ViewUtils | ui | View info etc |
utils-ktx
is a kotlin extension based on Android-Utils, which is used to simplify usages of utils classes. For example, if you want to get a drawable, tint it and then display it in ImageView. One line is enough:
iv.icon = drawableOf(R.drawable.ic_add_circle).tint(Color.WHITE)
If you want to request runtime permission in Activity, what you need to do is only writing one line below,
checkStoragePermission { /* got permission */ }
As for avoding continous click, you only need one line,
btnRateIntro.onDebouncedClick { /* do something */ }
All in all, by utils-ktx you can significantly lower the difficulty of development.
# Add MMKV classname
-keepnames class com.tencent.mmkv.MMKV
Copyright (c) 2019-2021 wsh.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.