Skip to content

android

muune edited this page Feb 21, 2019 · 24 revisions

Ch.app[목차]

Ch.clipBoard[목차]

Ch.asset[목차]

Ch.keyboard[목차]

Ch.permission[목차]

Ch.shared[목차]


Ch.app

Ch.app.appVersion()

Ch.app.appVersion():String

애플리케이션의 버전을 가져옴

Log.i("ch", Ch.app.appVersion()) //1.0

Ch.app.deviceId()

Ch.app.deviceId():String

단말기 고유 값(디바이스가 최초 Boot 될때 생성 되는 64-bit 값)을 가져옴

Log.i("ch", Ch.app.deviceId()) //9774d56d682e549c

Ch.app.deviceModel()

Ch.app.deviceModel():String

단말기 모델(디바이스 기종)을 가져옴

Log.i("ch", Ch.app.deviceModel()) //SHW-M250S

Ch.app.deviceVersion()

Ch.app.deviceVersion():String

단말기 OS 버전을 가져옴

Log.i("ch", Ch.app.deviceVersion()) //2.3.6

Ch.app.resS2I()

Ch.app.resS2I(type:String, name:String):Int

* type의 종류 "drawable", "id", "layout", "font", "string" ...

리소스 타입과 리소스 이름(문자열)으로 Resource ID 가져오기

resS2I("drawable", "image")

Ch.app.resDrawable()

Ch.app.resDrawable(v: String):Int

리소스 이름(문자열)으로 Drawable Resource ID 가져오기

Ch.app.resDrawable("image")

Ch.app.resId()

Ch.app.resId(v: String):Int

리소스 이름(문자열)으로 Id Resource ID 가져오기

Ch.app.resId("text0")

Ch.app.resLayout()

Ch.app.resLayout(v: String):Int

리소스 이름(문자열)으로 Layout Resource ID 가져오기

Ch.app.resLayout("layout0")

Ch.app.resFont()

Ch.app.resFont(v: String):Int

문자열로 Font Resource ID 가져오기

Ch.app.resFont("font0")

Ch.app.resName()

Ch.app.resName(id: Int):String

Resource ID로 리소스의 EntryName 가져오기

Ch.app.resName(resID)

Ch.app.drawable()

Ch.app.drawable(v:String):Drawable?

리소스 이름(문자열)으로 리소스의 Drawable 가져오기

Ch.app.drawable(Int):Drawable?

리소스 ID로 리소스의 Drawable 가져오기

Ch.app.drawable("image")
Ch.app.drawable(resID)

Ch.app.bitmap2Drawable()

Ch.app.bitmap2Drawable(v:Bitmap): BitmapDrawable

Bitmap 타입을 BitmapDrawable로 변경

Ch.app.bitmap2Drawable(bitmap)

Ch.app.string()

Ch.app.string(v:String):String

리소스 이름(문자열)으로 리소스의 String value 가져오기

Ch.app.string(v:Int):String

리소스 ID로 리소스의 String value 가져오기

Ch.app.string("str0")
Ch.app.string(resID)

Ch.clipBoard

Ch.clipBoard.copy()

Ch.clipBoard.copy(v:String):Unit

임의의 데이터를 시스템 클립보드에 저장

Ch.clipBoard.copy("str")

Ch.asset

Ch.asset.bytes()

Ch.asset.bytes(path:String):ByteArray

안드로이드 Asset 파일 읽어서 ByteArray로 가져오기

Ch.asset.bytes(path: String, block:(ByteArray)->Unit)
FileOutputStream(db).use {
    it.write(Ch.asset.bytes(assetPath))
    it.close()
}

Ch.asset.string()

Ch.asset.string(path:String):String

안드로이드 Asset 파일 읽어서 String으로 가져오기

Ch.asset.string(path: String, block:(String)->Unit)
JSONObject(Ch.asset.string(assetPath))

Ch.keyboard

Ch.keyboard.hide()

Ch.keyboard.hide(act:AppCompatActivity):Unit

안드로이드 키보드를 사라지게 함

Ch.keyboard.hide(activity)

Ch.asset.show()

Ch.asset.show():Unit
Ch.asset.show(et:EditText)

안드로이드 키보드를 보이게 함

Ch.permission

Ch.permission(act:AppCompatActivity, code:Int):Permission

안드로이드 퍼미션 처리기

with(Ch.permission(this, 15)){
    permissions(
        Manifest.permission.READ_CONTACTS,
        Manifest.permission.WRITE_CONTACTS,
        Manifest.permission.CALL_PHONE,
        Manifest.permission.READ_CALENDAR
    )
    ok{Log.i("ch", "all permitted")}
    neverAsk{Log.i("ch", "_never ask:$it")}
    denied{ p, res->
        Log.i("ch", "_denied:$p")
        res.request()
    }
    request()
}
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String>, grantResults: IntArray){
    Ch.permission.result(this, requestCode, permissions, grantResults)
}

Ch.shared

Ch.shared.name()

Ch.shared.name(k:String):Item

SharedPreferences에 저장하고 값 가져오기

Ch.shared.name("ch").s("dp", rsaEncrypt(pw))
var pw = ChShared.name("ch").s("dp")