aboutsummaryrefslogtreecommitdiff
path: root/sample/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-10 16:11:24 -0700
committerAllan Wang <me@allanwang.ca>2017-06-10 16:11:24 -0700
commit75dd060f2c265a069a0794ed659d780909df92ec (patch)
tree0614dce65845e9dc89358f12795e659dc1c2971b /sample/src/main/kotlin/ca/allanwang
parent58c69c343396ae18eb3c7e241b2c0618bd830c44 (diff)
downloadkau-75dd060f2c265a069a0794ed659d780909df92ec.tar.gz
kau-75dd060f2c265a069a0794ed659d780909df92ec.tar.bz2
kau-75dd060f2c265a069a0794ed659d780909df92ec.zip
init
Diffstat (limited to 'sample/src/main/kotlin/ca/allanwang')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt16
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt53
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt15
3 files changed, 84 insertions, 0 deletions
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
new file mode 100644
index 0000000..d63e533
--- /dev/null
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
@@ -0,0 +1,16 @@
+package ca.allanwang.kau.sample
+
+import android.graphics.Color
+import ca.allanwang.kau.kpref.KPref
+import ca.allanwang.kau.kpref.kpref
+
+/**
+ * Created by Allan Wang on 2017-06-07.
+ */
+object KPrefSample : KPref() {
+ var textColor: Int by kpref("TEXT_COLOR", Color.WHITE)
+ var bgColor: Int by kpref("BG_COLOR", Color.BLACK)
+ var check1: Boolean by kpref("check1", true)
+ var check2: Boolean by kpref("check2", false)
+ var check3: Boolean by kpref("check3", false)
+} \ No newline at end of file
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
new file mode 100644
index 0000000..c8207a3
--- /dev/null
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -0,0 +1,53 @@
+package ca.allanwang.kau.sample
+
+import android.os.Bundle
+import android.support.v7.app.AppCompatActivity
+import android.support.v7.widget.RecyclerView
+import android.view.Menu
+import android.view.MenuItem
+import ca.allanwang.kau.kpref.setKPrefAdapter
+import ca.allanwang.kau.utils.showChangelog
+
+class MainActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ val recycler = RecyclerView(this)
+// recycler.matchParent()
+ setContentView(recycler)
+ recycler.setKPrefAdapter {
+ header(R.string.header)
+ checkbox(title = R.string.checkbox_1, description = R.string.desc,
+ getter = { KPrefSample.check1 }, setter = { KPrefSample.check1 = it })
+ checkbox(title = R.string.checkbox_2,
+ getter = { KPrefSample.check2 }, setter = { KPrefSample.check2 = it })
+ checkbox(title = R.string.checkbox_3, enabled = false,
+ getter = { KPrefSample.check3 }, setter = { KPrefSample.check3 = it })
+ colorPicker(title = R.string.text_color,
+ getter = { KPrefSample.textColor }, setter = { KPrefSample.textColor = it })
+ }
+ }
+
+ override fun onCreateOptionsMenu(menu: Menu): Boolean {
+ menuInflater.inflate(R.menu.menu_main, menu)
+ return true
+ }
+
+ override fun onOptionsItemSelected(item: MenuItem): Boolean {
+ when (item.itemId) {
+ R.id.action_settings -> {
+
+ }
+ R.id.action_changelog -> showChangelog(R.xml.kau_changelog)
+ R.id.action_call -> {
+ }
+ R.id.action_db -> {
+ }
+ R.id.action_restart -> {
+ }
+ else -> return super.onOptionsItemSelected(item)
+ }
+ return true
+ }
+
+}
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
new file mode 100644
index 0000000..7fdc83d
--- /dev/null
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
@@ -0,0 +1,15 @@
+package ca.allanwang.kau.sample
+
+import android.app.Application
+import timber.log.Timber
+
+/**
+ * Created by Allan Wang on 2017-06-08.
+ */
+class SampleApp : Application() {
+ override fun onCreate() {
+ super.onCreate()
+ Timber.plant(Timber.DebugTree())
+ KPrefSample.initialize(this, "pref_sample")
+ }
+} \ No newline at end of file