From 3e7f62f89bc4e95cfae7394463e3fd503777011f Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 15:34:01 -0800 Subject: Move config builder out of constructor --- .../kotlin/ca/allanwang/kau/sample/AboutActivity.kt | 20 +++++++++++--------- sample/src/main/res/xml/kau_changelog.xml | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'sample') 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) { 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 @@ --> + - -- cgit v1.2.3 From 5038b93102949bb127b6cb9cb26809490739b3fa Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Sun, 23 Feb 2020 15:34:59 -0800 Subject: Apply spotless --- .../kotlin/ca/allanwang/kau/about/AboutActivityBase.kt | 2 +- core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt | 17 ++++++++++++++++- .../kotlin/ca/allanwang/kau/kpref/KPrefTest.kt | 2 +- .../kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt | 2 +- .../main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt | 17 ++++++++++++++++- .../kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt | 6 +++--- .../kotlin/ca/allanwang/kau/sample/SampleTestApp.kt | 18 ++++++++++++++++-- .../ca/allanwang/kau/sample/utils/EspressoUtils.kt | 2 -- 8 files changed, 54 insertions(+), 12 deletions(-) (limited to 'sample') 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 71f7d78..4fe97da 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -57,7 +57,7 @@ abstract class AboutActivityBase(val rClass: Class<*>?) : * 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{buildConfigs()} } + val configs: Configs by lazy { Configs().apply { buildConfigs() } } open fun Configs.buildConfigs() = Unit diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt index 33252d6..c9d4e31 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/Utils.kt @@ -1,7 +1,22 @@ +/* + * Copyright 2020 Allan Wang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ca.allanwang.kau import android.content.Context import androidx.test.platform.app.InstrumentationRegistry val context: Context - get() = InstrumentationRegistry.getInstrumentation().context \ No newline at end of file + get() = InstrumentationRegistry.getInstrumentation().context diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt index 222f0f5..70558df 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt @@ -20,10 +20,10 @@ import android.content.SharedPreferences import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import ca.allanwang.kau.context +import kotlin.test.assertEquals import org.junit.Before import org.junit.Test import org.junit.runner.RunWith -import kotlin.test.assertEquals /** * Created by Allan Wang on 2017-08-01. diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt index c17d3df..217bc6e 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefDelegate.kt @@ -104,7 +104,7 @@ class KPrefDelegateInMemory internal constructor( private val lock = this init { - pref.add(this) + pref.add(this) } override fun invalidate() { diff --git a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt index 0c49b88..dd6da29 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kpref/KPrefFactory.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Allan Wang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ca.allanwang.kau.kpref import android.content.Context @@ -19,4 +34,4 @@ class KPrefFactoryAndroid(context: Context) : KPrefFactory { object KPrefFactoryInMemory : KPrefFactory { override fun createBuilder(preferenceName: String): KPrefBuilder = KPrefBuilderInMemory -} \ No newline at end of file +} diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt index 156b66f..88a0402 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt @@ -27,6 +27,9 @@ import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import androidx.test.rule.ActivityTestRule +import kotlin.test.BeforeTest +import kotlin.test.assertFalse +import kotlin.test.assertTrue import org.hamcrest.BaseMatcher import org.hamcrest.Description import org.hamcrest.Matcher @@ -39,9 +42,6 @@ import org.junit.rules.TestRule import org.junit.runner.RunWith import org.koin.test.KoinTest import org.koin.test.inject -import kotlin.test.BeforeTest -import kotlin.test.assertFalse -import kotlin.test.assertTrue /** * Created by Allan Wang on 21/12/2018. diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt index 8705fbc..ceb551b 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2020 Allan Wang + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package ca.allanwang.kau.sample import android.app.Application @@ -5,7 +20,6 @@ import android.content.Context import androidx.test.runner.AndroidJUnitRunner import ca.allanwang.kau.kpref.KPrefFactory import ca.allanwang.kau.kpref.KPrefFactoryInMemory -import ca.allanwang.kau.logging.KL import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement @@ -57,4 +71,4 @@ class SampleTestApp : Application() { KPrefFactoryInMemory } } -} \ No newline at end of file +} diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt index 2a6f0a9..09ad00a 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt @@ -15,8 +15,6 @@ */ package ca.allanwang.kau.sample.utils -import android.content.Context -import androidx.test.platform.app.InstrumentationRegistry import org.hamcrest.BaseMatcher import org.hamcrest.Description import org.hamcrest.Matcher -- cgit v1.2.3