aboutsummaryrefslogtreecommitdiff
path: root/sample/src
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-06-10 22:04:03 -0700
committerAllan Wang <me@allanwang.ca>2017-06-10 22:04:03 -0700
commitc0550e9892ae454e1f244dd2980c633d85803a25 (patch)
tree0adf61391859f3a71c50a9d499135248916d691c /sample/src
parent6dc743c0ba91904d27fba42a4e8e2de6a72c719a (diff)
downloadkau-c0550e9892ae454e1f244dd2980c633d85803a25.tar.gz
kau-c0550e9892ae454e1f244dd2980c633d85803a25.tar.bz2
kau-c0550e9892ae454e1f244dd2980c633d85803a25.zip
Support transparent backgrounds in the ripple canvas
Diffstat (limited to 'sample/src')
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt2
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt35
-rw-r--r--sample/src/main/res/values/strings.xml2
-rw-r--r--sample/src/main/res/values/styles.xml2
4 files changed, 35 insertions, 6 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
index d63e533..a752ea2 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
@@ -9,7 +9,7 @@ import ca.allanwang.kau.kpref.kpref
*/
object KPrefSample : KPref() {
var textColor: Int by kpref("TEXT_COLOR", Color.WHITE)
- var bgColor: Int by kpref("BG_COLOR", Color.BLACK)
+ var bgColor: Int by kpref("BG_COLOR", 0xff303030.toInt())
var check1: Boolean by kpref("check1", true)
var check2: Boolean by kpref("check2", false)
var check3: Boolean by kpref("check3", false)
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
index c8207a3..6c36626 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt
@@ -5,29 +5,54 @@ import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.RecyclerView
import android.view.Menu
import android.view.MenuItem
+import android.view.ViewGroup
+import ca.allanwang.kau.kpref.KPrefAdapterBuilder
+import ca.allanwang.kau.kpref.items.KPrefItemCore
import ca.allanwang.kau.kpref.setKPrefAdapter
import ca.allanwang.kau.utils.showChangelog
+import ca.allanwang.kau.views.RippleCanvas
+import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
class MainActivity : AppCompatActivity() {
+ lateinit var adapter: FastItemAdapter<KPrefItemCore>
+ lateinit var builder: KPrefAdapterBuilder
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val recycler = RecyclerView(this)
-// recycler.matchParent()
- setContentView(recycler)
- recycler.setKPrefAdapter {
+ val bgCanvas = RippleCanvas(this)
+ setContentView(bgCanvas)
+ addContentView(recycler, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
+ bgCanvas.set(KPrefSample.bgColor)
+ adapter = recycler.setKPrefAdapter {
+ builder = this
+ textColor = KPrefSample.textColor
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,
+ checkbox(title = R.string.checkbox_3, description = R.string.desc_disabled, enabled = false,
getter = { KPrefSample.check3 }, setter = { KPrefSample.check3 = it })
colorPicker(title = R.string.text_color,
- getter = { KPrefSample.textColor }, setter = { KPrefSample.textColor = it })
+ getter = { KPrefSample.textColor }, setter = { KPrefSample.textColor = it; builder.textColor = it; refresh() },
+ configs = {
+ allowCustom = false
+ })
+ colorPicker(title = R.string.background_color,
+ getter = { KPrefSample.bgColor }, setter = { KPrefSample.bgColor = it; bgCanvas.ripple(it, duration = 500) },
+ configs = {
+ allowCustomAlpha = true
+ allowCustom = true
+ })
}
}
+ fun refresh() {
+ adapter.notifyAdapterDataSetChanged()
+ }
+
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.menu_main, menu)
return true
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
index ea9712f..44421fe 100644
--- a/sample/src/main/res/values/strings.xml
+++ b/sample/src/main/res/values/strings.xml
@@ -6,5 +6,7 @@
<string name="checkbox_1">Checkbox 1</string>
<string name="checkbox_2">Checkbox 2</string>
<string name="checkbox_3">Checkbox 3</string>
+ <string name="desc_disabled">I am disabled</string>
<string name="text_color">Text Color</string>
+ <string name="background_color">Background Color</string>
</resources>
diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml
index daa2a5c..8a4c98f 100644
--- a/sample/src/main/res/values/styles.xml
+++ b/sample/src/main/res/values/styles.xml
@@ -6,6 +6,8 @@
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
+ <item name="android:windowShowWallpaper">true</item>
+ <item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>