diff options
Diffstat (limited to 'sample/src/main')
20 files changed, 194 insertions, 0 deletions
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 Binary files differnew file mode 100644 index 0000000..cde69bc --- /dev/null +++ b/sample/src/main/res/mipmap-hdpi/ic_launcher.png diff --git a/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..9a078e3 --- /dev/null +++ b/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher.png b/sample/src/main/res/mipmap-mdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..c133a0c --- /dev/null +++ b/sample/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..efc028a --- /dev/null +++ b/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..bfa42f0 --- /dev/null +++ b/sample/src/main/res/mipmap-xhdpi/ic_launcher.png diff --git a/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..3af2608 --- /dev/null +++ b/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..324e72c --- /dev/null +++ b/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png diff --git a/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..9bec2e6 --- /dev/null +++ b/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png Binary files differnew file mode 100644 index 0000000..aee44e1 --- /dev/null +++ b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png diff --git a/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png Binary files differnew file mode 100644 index 0000000..34947cd --- /dev/null +++ b/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png 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 |