From 75dd060f2c265a069a0794ed659d780909df92ec Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sat, 10 Jun 2017 16:11:24 -0700 Subject: init --- .../allanwang/kprefs/ExampleInstrumentedTest.java | 26 ++++++++++ sample/src/main/AndroidManifest.xml | 23 +++++++++ .../kotlin/ca/allanwang/kau/sample/KPrefSample.kt | 16 +++++++ .../kotlin/ca/allanwang/kau/sample/MainActivity.kt | 53 +++++++++++++++++++++ .../kotlin/ca/allanwang/kau/sample/SampleApp.kt | 15 ++++++ sample/src/main/res/layout/activity_main.xml | 9 ++++ sample/src/main/res/menu/menu_main.xml | 31 ++++++++++++ sample/src/main/res/mipmap-hdpi/ic_launcher.png | Bin 0 -> 3418 bytes .../src/main/res/mipmap-hdpi/ic_launcher_round.png | Bin 0 -> 4208 bytes sample/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 0 -> 2206 bytes .../src/main/res/mipmap-mdpi/ic_launcher_round.png | Bin 0 -> 2555 bytes sample/src/main/res/mipmap-xhdpi/ic_launcher.png | Bin 0 -> 4842 bytes .../main/res/mipmap-xhdpi/ic_launcher_round.png | Bin 0 -> 6114 bytes sample/src/main/res/mipmap-xxhdpi/ic_launcher.png | Bin 0 -> 7718 bytes .../main/res/mipmap-xxhdpi/ic_launcher_round.png | Bin 0 -> 10056 bytes sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png | Bin 0 -> 10486 bytes .../main/res/mipmap-xxxhdpi/ic_launcher_round.png | Bin 0 -> 14696 bytes sample/src/main/res/values/colors.xml | 6 +++ sample/src/main/res/values/strings.xml | 10 ++++ sample/src/main/res/values/styles.xml | 11 +++++ sample/src/main/res/xml/changelog.xml | 20 ++++++++ .../java/ca/allanwang/kprefs/ExampleUnitTest.java | 17 +++++++ 22 files changed, 237 insertions(+) create mode 100644 sample/src/androidTest/java/ca/allanwang/kprefs/ExampleInstrumentedTest.java create mode 100644 sample/src/main/AndroidManifest.xml create mode 100644 sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt create mode 100644 sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt create mode 100644 sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt create mode 100644 sample/src/main/res/layout/activity_main.xml create mode 100644 sample/src/main/res/menu/menu_main.xml create mode 100644 sample/src/main/res/mipmap-hdpi/ic_launcher.png create mode 100644 sample/src/main/res/mipmap-hdpi/ic_launcher_round.png create mode 100644 sample/src/main/res/mipmap-mdpi/ic_launcher.png create mode 100644 sample/src/main/res/mipmap-mdpi/ic_launcher_round.png create mode 100644 sample/src/main/res/mipmap-xhdpi/ic_launcher.png create mode 100644 sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png create mode 100644 sample/src/main/res/mipmap-xxhdpi/ic_launcher.png create mode 100644 sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png create mode 100644 sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png create mode 100644 sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png create mode 100644 sample/src/main/res/values/colors.xml create mode 100644 sample/src/main/res/values/strings.xml create mode 100644 sample/src/main/res/values/styles.xml create mode 100644 sample/src/main/res/xml/changelog.xml create mode 100644 sample/src/test/java/ca/allanwang/kprefs/ExampleUnitTest.java (limited to 'sample/src') 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 Testing documentation + */ +@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 @@ + + + + + + + + + + + + + \ 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 @@ + + + + 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 @@ + + + + + + + + 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 Binary files /dev/null and b/sample/src/main/res/mipmap-hdpi/ic_launcher.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-mdpi/ic_launcher.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png 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 Binary files /dev/null and b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png 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 @@ + + + #3F51B5 + #303F9F + #FF4081 + 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 @@ + + KPrefs + MainActivity + This is a header + This is a description + Checkbox 1 + Checkbox 2 + Checkbox 3 + Text Color + 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 @@ + + + + + + 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 @@ + + + + + + + + + + + + + + + + + \ 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 Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() throws Exception { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file -- cgit v1.2.3