Go to file
luyao 8a237a1156 add ActivityExt 2019-07-09 16:13:12 +08:00
app add ActivityExt 2019-07-09 16:13:12 +08:00
gradle/wrapper build(add library): 2019-05-31 15:36:27 +08:00
ktx add ActivityExt 2019-07-09 16:13:12 +08:00
.gitignore build(add library): 2019-05-31 15:36:27 +08:00
LICENSE Initial commit 2019-05-31 14:58:57 +08:00
README.md update readme 2019-07-06 16:54:23 +08:00
build.gradle change module name 2019-06-27 16:53:14 +08:00
gradle.properties build(add library): 2019-05-31 15:36:27 +08:00
gradlew build(add library): 2019-05-31 15:36:27 +08:00
gradlew.bat build(add library): 2019-05-31 15:36:27 +08:00
package.json build(add library): 2019-05-31 15:36:27 +08:00
settings.gradle change module name 2019-06-27 16:53:14 +08:00

README.md

AndroidUtilCodeKTX

一直有关注 Blankj 的开源项目 AndroidUtilCode, 到目前为止将近有 24k star。在以往的开发过程中我也经常参考其中的工具类实现。但是自从切换到 Kotlin 作为主力开发语言以来,仍然生搬硬套其中的工具类显得并不是那么优雅,没有很好的利用 Kotlin 的语言特性,遂决定整理 AndroidUtilCodeKTX 这个库,完全基于 Kotlin 实现,收集 Android 开发中常用的工具类。

该库不会是 AndroidUtilCode 的 Kotlin 翻译版本,更多的还是基于我在开发过程中的需求进行完善,由于个人精力有限,可能并不是那么完善,欢迎大家通过 issue 提出自己的意见

APIS (keep updating...)


权限相关 [Demo]

fun FragmentActivity.request()  权限请求

AppExt

fun Context.getVersionName()    : 获取应用版本名称
fun Context.getVersionCode()    获取应用版本号
fun Context.getAppSignature()   获取应用签名
fun Context.getAppInfo() 根据安装包获取应用信息
fun Context.getAppInfos()

CommonExt

fun Context.dp2px()             : dp  px
fun Context.px2dp()             px  dp
fun View.dp2px()                dp  px
fun View.px2dp()                px  dp
fun Context.getWidth()          获取屏幕宽度
fun Context.getHeight()         获取屏幕高度
fun Context.copyToClipboard()   复制到粘贴板

HashExt [Demo]

fun ByteArray.hash()          获取字节数组哈希值
fun String.hash()             获取字符串哈希值
fun File.hash()               获取文件哈希值
fun ByteArray.md5Bytes()     
fun ByteArray.md5()           获取字节数组 md5 
fun String.md5()              获取字符串 md5 
fun ByteArray.sha1Bytes()     
fun ByteArray.sha1()          获取字节数组 sha1 
fun String.sha1()             获取字符串 sha1 
fun ByteArray.sha224Bytes()
fun ByteArray.sha224()        获取字节数组 sha224 
fun String.sha224()           获取字符串 sha224 
fun ByteArray.sha256Bytes()
fun ByteArray.sha256()        获取字节数组 sha256 
fun String.sha256()           获取字符串 sha256 
fun ByteArray.sha384Bytes()
fun ByteArray.sha384()        获取字节数组 sha384 
fun String.sha384()           获取字符串 sha384 
fun ByteArray.sha512Bytes()
fun ByteArray.sha512()        获取字节数组 sha512 
fun String.sha512()           获取字符串 sha512 

AesExt [Demo]

fun ByteArray.aesEncrypt()  加密字节数组默认 CFB
fun ByteArray.aesDecrypt()  解密字节数组默认 CFB
fun File.aesEncrypt()       加密文件CFB 流加密模式
fun File.aesDecrypt()       解密文件CFB 流加密模式

IntentExt [Demo]

fun Context.goToAppInfoPage()           : 跳转到应用信息页面
fun Context.goToDateAndTimePage()       : 跳转到日期和时间设置页面
fun Context.goToLanguagePage()          : 跳转到语言设置页面   
fun Context.goToAccessibilitySetting()  : 跳转到无障碍服务设置页面
fun Context.openApp()                   : 打开 app
fun Context.openInAppStore()            : 在应用商店打开 app
fun Context.installApk()                : 安装 apk
fun Context.openBrowser(url:String)     打开浏览器跳转到指定网页
fun Context.uninstallApp()              : 卸载 app

ToastExt [Demo]

fun Context.toast()
fun Context.longToast()
fun Any.toast()
fun Any.longToast()

TransformExt

fun ByteArray.toHexString() : 字节数组转十六进制字符串