aboutsummaryrefslogtreecommitdiff
path: root/sample/src
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
parent58c69c343396ae18eb3c7e241b2c0618bd830c44 (diff)
downloadkau-75dd060f2c265a069a0794ed659d780909df92ec.tar.gz
kau-75dd060f2c265a069a0794ed659d780909df92ec.tar.bz2
kau-75dd060f2c265a069a0794ed659d780909df92ec.zip
init
Diffstat (limited to 'sample/src')
-rw-r--r--sample/src/androidTest/java/ca/allanwang/kprefs/ExampleInstrumentedTest.java26
-rw-r--r--sample/src/main/AndroidManifest.xml23
-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
-rw-r--r--sample/src/main/res/layout/activity_main.xml9
-rw-r--r--sample/src/main/res/menu/menu_main.xml31
-rw-r--r--sample/src/main/res/mipmap-hdpi/ic_launcher.pngbin0 -> 3418 bytes
-rw-r--r--sample/src/main/res/mipmap-hdpi/ic_launcher_round.pngbin0 -> 4208 bytes
-rw-r--r--sample/src/main/res/mipmap-mdpi/ic_launcher.pngbin0 -> 2206 bytes
-rw-r--r--sample/src/main/res/mipmap-mdpi/ic_launcher_round.pngbin0 -> 2555 bytes
-rw-r--r--sample/src/main/res/mipmap-xhdpi/ic_launcher.pngbin0 -> 4842 bytes
-rw-r--r--sample/src/main/res/mipmap-xhdpi/ic_launcher_round.pngbin0 -> 6114 bytes
-rw-r--r--sample/src/main/res/mipmap-xxhdpi/ic_launcher.pngbin0 -> 7718 bytes
-rw-r--r--sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.pngbin0 -> 10056 bytes
-rw-r--r--sample/src/main/res/mipmap-xxxhdpi/ic_launcher.pngbin0 -> 10486 bytes
-rw-r--r--sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.pngbin0 -> 14696 bytes
-rw-r--r--sample/src/main/res/values/colors.xml6
-rw-r--r--sample/src/main/res/values/strings.xml10
-rw-r--r--sample/src/main/res/values/styles.xml11
-rw-r--r--sample/src/main/res/xml/changelog.xml20
-rw-r--r--sample/src/test/java/ca/allanwang/kprefs/ExampleUnitTest.java17
22 files changed, 237 insertions, 0 deletions
diff --git a/sample/src/androidTest/java/ca/allanwang/kprefs/ExampleInstrumentedTest.java b/sample/src/androidTest/java/ca/allanwang/kprefs/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..e3d17e9
--- /dev/null
+++ b/sample/src/androidTest/java/ca/allanwang/kprefs/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package ca.allanwang.kprefs;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumentation test, which will execute on an Android device.
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("ca.allanwang.kprefs", appContext.getPackageName());
+ }
+}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..4b31b50
--- /dev/null
+++ b/sample/src/main/AndroidManifest.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="ca.allanwang.kau.sample">
+
+ <application
+ android:name=".SampleApp"
+ android:allowBackup="true"
+ android:icon="@mipmap/ic_launcher"
+ android:label="@string/app_name"
+ android:roundIcon="@mipmap/ic_launcher_round"
+ android:supportsRtl="true"
+ android:theme="@style/AppTheme">
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/title_activity_main">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest> \ No newline at end of file
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
diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..7254add
--- /dev/null
+++ b/sample/src/main/res/layout/activity_main.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ tools:context="ca.allanwang.kau.sample.MainActivity">
+
+</android.support.constraint.ConstraintLayout>
diff --git a/sample/src/main/res/menu/menu_main.xml b/sample/src/main/res/menu/menu_main.xml
new file mode 100644
index 0000000..5562ea4
--- /dev/null
+++ b/sample/src/main/res/menu/menu_main.xml
@@ -0,0 +1,31 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ xmlns:tools="http://schemas.android.com/tools"
+ tools:context="com.pitchedapps.myapplication.MainActivity">
+ <item
+ android:id="@+id/action_settings"
+ android:orderInCategory="100"
+ android:title="Settings"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_changelog"
+ android:orderInCategory="200"
+ android:title="@string/kau_changelog"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_restart"
+ android:orderInCategory="220"
+ android:title="Restart"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_call"
+ android:orderInCategory="300"
+ android:title="Call"
+ app:showAsAction="never" />
+ <item
+ android:id="@+id/action_db"
+ android:orderInCategory="400"
+ android:title="DB"
+ app:showAsAction="never" />
+</menu>
+
diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher.png b/sample/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..cde69bc
--- /dev/null
+++ b/sample/src/main/res/mipmap-hdpi/ic_launcher.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9a078e3
--- /dev/null
+++ b/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c133a0c
--- /dev/null
+++ b/sample/src/main/res/mipmap-mdpi/ic_launcher.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..efc028a
--- /dev/null
+++ b/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..bfa42f0
--- /dev/null
+++ b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..3af2608
--- /dev/null
+++ b/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..324e72c
--- /dev/null
+++ b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..9bec2e6
--- /dev/null
+++ b/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..aee44e1
--- /dev/null
+++ b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Binary files differ
diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..34947cd
--- /dev/null
+++ b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
Binary files differ
diff --git a/sample/src/main/res/values/colors.xml b/sample/src/main/res/values/colors.xml
new file mode 100644
index 0000000..3ab3e9c
--- /dev/null
+++ b/sample/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="colorPrimary">#3F51B5</color>
+ <color name="colorPrimaryDark">#303F9F</color>
+ <color name="colorAccent">#FF4081</color>
+</resources>
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
new file mode 100644
index 0000000..ea9712f
--- /dev/null
+++ b/sample/src/main/res/values/strings.xml
@@ -0,0 +1,10 @@
+<resources>
+ <string name="app_name">KPrefs</string>
+ <string name="title_activity_main">MainActivity</string>
+ <string name="header">This is a header</string>
+ <string name="desc">This is a description</string>
+ <string name="checkbox_1">Checkbox 1</string>
+ <string name="checkbox_2">Checkbox 2</string>
+ <string name="checkbox_3">Checkbox 3</string>
+ <string name="text_color">Text Color</string>
+</resources>
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
new file mode 100644
index 0000000..daa2a5c
--- /dev/null
+++ b/sample/src/main/res/values/styles.xml
@@ -0,0 +1,11 @@
+<resources>
+
+ <!-- Base application theme. -->
+ <style name="AppTheme" parent="Theme.AppCompat">
+ <!-- Customize your theme here. -->
+ <item name="colorPrimary">@color/colorPrimary</item>
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
+ <item name="colorAccent">@color/colorAccent</item>
+ </style>
+
+</resources>
diff --git a/sample/src/main/res/xml/changelog.xml b/sample/src/main/res/xml/changelog.xml
new file mode 100644
index 0000000..7569fb2
--- /dev/null
+++ b/sample/src/main/res/xml/changelog.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!--
+ <version title="v"/>
+ <item text="" />
+ -->
+
+ <version title="v0.1" />
+ <item text="Initial Changelog" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+ <item text="" />
+</resources> \ No newline at end of file
diff --git a/sample/src/test/java/ca/allanwang/kprefs/ExampleUnitTest.java b/sample/src/test/java/ca/allanwang/kprefs/ExampleUnitTest.java
new file mode 100644
index 0000000..4c029fd
--- /dev/null
+++ b/sample/src/test/java/ca/allanwang/kprefs/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package ca.allanwang.kprefs;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+} \ No newline at end of file