aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2020-02-23 15:34:01 -0800
committerAllan Wang <me@allanwang.ca>2020-02-23 15:34:01 -0800
commit3e7f62f89bc4e95cfae7394463e3fd503777011f (patch)
tree0df25ed277c2084d22005bc48be17e05f88dd539
parent3fa13a3a84d34fd0d96f26d6c5dea0e0671dd6c4 (diff)
downloadkau-3e7f62f89bc4e95cfae7394463e3fd503777011f.tar.gz
kau-3e7f62f89bc4e95cfae7394463e3fd503777011f.tar.bz2
kau-3e7f62f89bc4e95cfae7394463e3fd503777011f.zip
Move config builder out of constructor
-rw-r--r--about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt11
-rw-r--r--docs/Changelog.md1
-rw-r--r--docs/Migration.md4
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt20
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml2
5 files changed, 22 insertions, 16 deletions
diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
index 6b57825..71f7d78 100644
--- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
+++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt
@@ -40,17 +40,14 @@ import kotlinx.android.synthetic.main.kau_activity_about.*
* Created by Allan Wang on 2017-06-28.
*
* Floating About Activity Panel for your app
- * This contains all the necessary layouts, and can be extended and configured using the [configBuilder]
+ * This contains all the necessary layouts, and can be extended and configured using [buildConfigs]
* The [rClass] is necessary to generate the list of libraries used in your app, and should point to your app's
* R.string::class.java
* If you don't need auto detect, you can pass null instead
* Note that for the auto detection to work, the R fields must be excluded from Proguard
* Manual lib listings and other extra modifications can be done so by overriding the open functions
*/
-abstract class AboutActivityBase(
- val rClass: Class<*>?,
- private val configBuilder: Configs.() -> Unit = {}
-) :
+abstract class AboutActivityBase(val rClass: Class<*>?) :
KauBaseActivity(), ViewPager.OnPageChangeListener {
val currentPage: Int
@@ -60,7 +57,9 @@ abstract class AboutActivityBase(
* Holds some common configurations that may be added directly from the constructor
* Applied lazily since it needs the context to fetch resources
*/
- val configs: Configs by lazy { Configs().apply { configBuilder() } }
+ val configs: Configs by lazy { Configs().apply{buildConfigs()} }
+
+ open fun Configs.buildConfigs() = Unit
/**
* Holds that status of each page
diff --git a/docs/Changelog.md b/docs/Changelog.md
index 576ac96..2f9e591 100644
--- a/docs/Changelog.md
+++ b/docs/Changelog.md
@@ -1,6 +1,7 @@
# Changelog
## v5.3.0
+* :about: Moved config builder inside activity
* :color: Allow option to disable selected ring
* :core: Breaking KPref changes; see migration
diff --git a/docs/Migration.md b/docs/Migration.md
index b0d0079..0941667 100644
--- a/docs/Migration.md
+++ b/docs/Migration.md
@@ -14,6 +14,10 @@ An example can be found in the sample app test class.
Also note that to better support in memory preferences, `reset()` will clear the in memory content for both variants,
meaning that in memory preferences will reset to default. Previously, in memory `reset()` did nothing.
+## AboutActivityBase
+
+`configBuilder` was previously required in the constructor, but is now an open function so that activity fields can be used in the builder.
+
# v5.1.0
## KPref
diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt
index ffe769a..59f1c92 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt
@@ -23,15 +23,17 @@ import com.mikepenz.fastadapter.GenericItem
/**
* Created by Allan Wang on 2017-06-27.
*/
-class AboutActivity : AboutActivityBase(R.string::class.java, {
- cutoutDrawableRes = R.drawable.kau
- textColor = 0xde000000.toInt()
- backgroundColor = 0xfffafafa.toInt()
- accentColor = 0xff00838F.toInt()
- cutoutForeground = 0xff18FFFF.toInt()
- faqXmlRes = R.xml.kau_faq
- faqParseNewLine = false
-}) {
+class AboutActivity : AboutActivityBase(R.string::class.java) {
+
+ override fun Configs.buildConfigs() {
+ cutoutDrawableRes = R.drawable.kau
+ textColor = 0xde000000.toInt()
+ backgroundColor = 0xfffafafa.toInt()
+ accentColor = 0xff00838F.toInt()
+ cutoutForeground = 0xff18FFFF.toInt()
+ faqXmlRes = R.xml.kau_faq
+ faqParseNewLine = false
+ }
override fun postInflateMainPage(adapter: FastItemThemedAdapter<GenericItem>) {
adapter.add(CardIItem {
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index 55adabc..a40e70e 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -7,10 +7,10 @@
-->
<version title="v5.3.0" />
+ <item text=":about: Moved config builder inside activity" />
<item text=":color: Allow option to disable selected ring" />
<item text=":core: Breaking KPref changes; see migration" />
<item text="" />
- <item text="" />
<version title="v5.2.0" />
<item text=":about: Migrate about libraries to v7.x.x" />