Skip to content

Repository files navigation

AndroidUtilCodeKTX ! 专注提升 Android 开发效率 !

该类库利用 Kotlin 语言特性合理封装了 Android 开发中的常用操作,同时也收集了开发过程中的常用工具类。 旨在做同样的事情,写最少的代码,提升开发效率。

Use

implementation 'luyao.util.ktx:AndroidUtilKTX:0.0.5'

APIS (keep updating...)


FragmentActivity.request(vararg permissions:String, callbacks:PermissionsCallbackDSL.() ->Unit)
Context.versionName:StringContext.versionCode:LongContext.getAppInfo(apkPath:String):AppInfoContext.getAppInfos(apkFolderPath:String):List<AppInfo>
Context.getAppSignature(packageName:String=this.packageName):ByteArray?
Context.dp2px(dp:Float):IntContext.px2dp(px:Float):IntView.dp2px(dp:Float):IntView.px2dp(px:Float):IntContext.screenWidth
Context.screenHeight
Context.copyToClipboard(label:String, text:String)
ByteArray.hash(algorithm:Hash):StringString.hash(algorithm:Hash, charset:Charset=Charset.forName("utf-8")):StringByteArray.md5Bytes():ByteArrayByteArray.md5():StringString.md5(charset:Charset=Charset.forName("utf-8")):StringByteArray.sha1Bytes():ByteArrayByteArray.sha1():StringString.sha1(charset:Charset=Charset.forName("utf-8")):StringByteArray.sha224Bytes():ByteArrayByteArray.sha224():StringString.sha224(charset:Charset=Charset.forName("utf-8")):StringByteArray.sha256Bytes():ByteArrayByteArray.sha256():StringString.sha256(charset:Charset=Charset.forName("utf-8")):StringByteArray.sha384Bytes():ByteArrayByteArray.sha384():StringString.sha384(charset:Charset=Charset.forName("utf-8")):StringByteArray.sha512Bytes():ByteArrayByteArray.sha512():StringString.sha512(charset:Charset=Charset.forName("utf-8")):StringFile.hash(algorithm:Hash=Hash.SHA1):String
ByteArray.aesEncrypt(key:ByteArray, iv:ByteArray, cipherAlgotirhm:String=AES_CFB_NOPADDING):ByteArrayByteArray.aesDecrypt(key:ByteArray, iv:ByteArray, cipherAlgotirhm:String=AES_CFB_NOPADDING):ByteArrayFile.aesEncrypt(key:ByteArray, iv:ByteArray, destFilePath:String):File?File.aesDecrypt(key:ByteArray, iv:ByteArray, destFilePath:String):File?
Context.getAppInfoIntent(packageName:String=this.packageName):IntentContext.goToAppInfoPage(packageName:String=this.packageName)
Context.getDateAndTimeIntent():IntentContext.goToDateAndTimePage()
Context.getLanguageIntent()
Context.goToLanguagePage() Context.getInstallIntent(apkFile:File):Intent?Context.goToAccessibilitySetting()
Context.installApk(apkFile:File)
Context.openBrowser(url:String)
Context.openInAppStore(packageName:String=this.packageName)
Context.openApp(packageName:String)
Context.uninstallApp(packageName:String) 
String.logv(tag:String=TAG)
String.logd(tag:String=TAG)
String.logi(tag:String=TAG)
String.logw(tag:String=TAG)
String.loge(tag:String=TAG)
Context.toast(content:String, duration:Int=Toast.LENGTH_SHORT)
Context.toast(@StringRes id:Int, duration:Int=Toast.LENGTH_SHORT)
Context.longToast(content:String)
Context.longToast(@StringRes id:Int)
Any.toast(context:Context, content:String, duration:Int=Toast.LENGTH_SHORT)
Any.toast(context:Context, @StringRes id:Int, duration:Int=Toast.LENGTH_SHORT) Any.longToast(context:Context, content:String)
Any.longToast(context:Context, @StringRes id:Int)
fun <T> Context.putSpValue(key:String, value:T, name:String = packageName)
fun <T> Activity.putSpValue(key:String, value:T, name:String = packageName)
fun <T> Context.getSpValue(key:String, default:T, name:String = packageName ): Tfun <T> Activity.getSpValue(key:String, default:T, name:String = packageName): T
valContext.windowManager
valContext.clipboardManager
valContext.layoutInflater
valContext.activityManager
valContext.powerManager
valContext.alarmManager
valContext.notificationManager
valContext.keyguardManager
valContext.locationManager
valContext.searchManager
valContext.storageManager
valContext.vibrator
valContext.connectivityManager
valContext.wifiManager
valContext.audioManager
valContext.mediaRouter
valContext.telephonyManager
valContext.sensorManager
valContext.subscriptionManager
valContext.carrierConfigManager
valContext.inputMethodManager
valContext.uiModeManager
valContext.downloadManager
valContext.batteryManager
valContext.jobScheduler
ByteArray.toHexString() : 字节数组转十六进制字符串
View.visible()
View.invisible()
View.gone()
varView.isVisible:BooleanvarView.isInvisible:BooleanvarView.isGone:BooleanView.setPadding(@Px size:Int)
View.postDelayed(delayInMillis:Long, crossinline action: () ->Unit):RunnableView.toBitmap(config:Bitmap.Config=Bitmap.Config.ARGB_8888):Bitmap

About

Kotlin Android Util Code

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages