diff options
-rw-r--r-- | .idea/compiler.xml | 6 | ||||
-rw-r--r-- | .idea/misc.xml | 10 | ||||
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | android-lib.gradle | 2 | ||||
-rw-r--r-- | build.gradle | 1 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/kau/Dependencies.kt | 12 | ||||
-rw-r--r-- | buildSrc/src/main/kotlin/kau/Versions.kt | 16 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 4 | ||||
-rw-r--r-- | sample/build.gradle | 39 | ||||
-rw-r--r-- | sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt | 20 | ||||
-rw-r--r-- | sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt | 55 | ||||
-rw-r--r-- | sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/BaseTest.kt | 32 | ||||
-rw-r--r-- | sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt | 30 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt | 7 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt | 26 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt | 573 | ||||
-rw-r--r-- | sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt | 36 |
17 files changed, 700 insertions, 173 deletions
diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..61a9130 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project version="4"> + <component name="CompilerConfiguration"> + <bytecodeTargetLevel target="1.8" /> + </component> +</project>
\ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index cc04cd3..38dbd0c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,7 +5,7 @@ <option name="myDefaultNotNull" value="android.support.annotation.NonNull" /> <option name="myNullables"> <value> - <list size="10"> + <list size="12"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" /> <item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" /> @@ -16,12 +16,14 @@ <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" /> <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" /> <item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" /> + <item index="10" class="java.lang.String" itemvalue="com.android.annotations.Nullable" /> + <item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" /> </list> </value> </option> <option name="myNotNulls"> <value> - <list size="9"> + <list size="11"> <item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" /> <item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" /> <item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" /> @@ -31,11 +33,13 @@ <item index="6" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" /> <item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" /> <item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" /> + <item index="9" class="java.lang.String" itemvalue="com.android.annotations.NonNull" /> + <item index="10" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" /> </list> </value> </option> </component> - <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK"> + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <output url="file://$PROJECT_DIR$/build/classes" /> </component> <component name="ProjectType"> diff --git a/.travis.yml b/.travis.yml index bc49082..e873eee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,8 @@ android: script: - chmod +x gradlew - "./gradlew --quiet androidGitVersion" -- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew lintRelease publishRelease; - else ./gradlew lintRelease testReleaseUnitTest; fi +- if [[ "$TRAVIS_BRANCH" == "master" ]]; then ./gradlew spotlessCheck lintRelease publishRelease; + else ./gradlew spotlessCheck lintRelease testReleaseUnitTest; fi branches: except: - gh-pages diff --git a/android-lib.gradle b/android-lib.gradle index bc97f11..429fd46 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -5,7 +5,7 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'com.github.dcendents.android-maven' -apply plugin: 'com.getkeepsafe.dexcount' +//apply plugin: 'com.getkeepsafe.dexcount' group = "ca.allanwang" android { diff --git a/build.gradle b/build.gradle index 3a880b2..bf525cd 100644 --- a/build.gradle +++ b/build.gradle @@ -18,6 +18,7 @@ buildscript { classpath Plugins.dexCount classpath Plugins.gitVersion classpath Plugins.spotless + classpath 'com.google.dagger:hilt-android-gradle-plugin:2.28-alpha' } wrapper.setDistributionType(Wrapper.DistributionType.ALL) diff --git a/buildSrc/src/main/kotlin/kau/Dependencies.kt b/buildSrc/src/main/kotlin/kau/Dependencies.kt index d7a3757..b59ba91 100644 --- a/buildSrc/src/main/kotlin/kau/Dependencies.kt +++ b/buildSrc/src/main/kotlin/kau/Dependencies.kt @@ -59,6 +59,18 @@ object Dependencies { @JvmStatic fun koin(type: String) = "org.koin:koin-$type:${Versions.koin}" + @JvmField + val hilt = "com.google.dagger:hilt-android:${Versions.hilt}" + + @JvmField + val hiltCompiler = hilt("compiler") + + @JvmField + val hiltTest = hilt("testing") + + @JvmStatic + fun hilt(type: String) = "com.google.dagger:hilt-android-$type:${Versions.hilt}" + const val junit = "junit:junit:${Versions.junit}" const val coroutines = "org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.coroutines}" diff --git a/buildSrc/src/main/kotlin/kau/Versions.kt b/buildSrc/src/main/kotlin/kau/Versions.kt index 40f8b70..f0ed129 100644 --- a/buildSrc/src/main/kotlin/kau/Versions.kt +++ b/buildSrc/src/main/kotlin/kau/Versions.kt @@ -54,21 +54,25 @@ object Versions { const val materialDialog = "3.3.0" // https://github.com/InsertKoinIO/koin/blob/master/CHANGELOG.md - const val koin = "2.1.5" + const val koin = "2.1.6" + + // https://mvnrepository.com/artifact/com.google.dagger/hilt-android + const val hilt = "2.28.1-alpha" // https://square.github.io/leakcanary/changelog/ const val leakCanary = "2.2" // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google - const val espresso = "3.2.0" + const val espresso = "3.3.0-rc01" // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api - const val junit = "4.12" + const val junit = "4.13" - const val testRunner = "1.1.0" + // https://mvnrepository.com/artifact/androidx.test.ext/junit + const val testRunner = "1.1.2-rc01" // https://mvnrepository.com/artifact/androidx.test/rules?repo=google - const val testRules = "1.2.0" + const val testRules = "1.3.0-rc01" // Keep version for now, see https://github.com/diffplug/spotless/issues/521 // https://github.com/diffplug/spotless/blob/master/plugin-gradle/CHANGES.md @@ -81,7 +85,7 @@ object Versions { const val bugsnagPlugin="4.7.4" // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google - const val gradlePlugin = "4.0.0-rc01" + const val gradlePlugin = "4.1.0-beta02" // https://github.com/dcendents/android-maven-gradle-plugin/releases const val mavenPlugin = "2.1" // https://github.com/Triple-T/gradle-play-publisher/releases diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e812d50..925dd20 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Feb 29 17:34:02 PST 2020 +#Mon Jun 15 18:28:26 PDT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-rc-1-all.zip diff --git a/sample/build.gradle b/sample/build.gradle index 96ed78f..d620c2a 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -2,8 +2,10 @@ import kau.Dependencies apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' apply plugin: 'kotlin-android-extensions' apply plugin: 'com.github.triplet.play' +apply plugin: 'dagger.hilt.android.plugin' play { serviceAccountCredentials = file('../files/gplay-keys.json') @@ -99,25 +101,15 @@ android { main.res.srcDirs += 'src/main/res-public' } - testOptions.unitTests { - // Don't throw runtime exceptions for android calls that are not mocked - returnDefaultValues = true + testOptions { + unitTests { + // Don't throw runtime exceptions for android calls that are not mocked + returnDefaultValues = true - // Always show the result of every unit test, even if it passes. - all { - testLogging { - events 'passed', 'skipped', 'failed', 'standardOut', 'standardError' - } - } - } - - // See https://github.com/facebook/flipper/issues/146 - configurations.all { - resolutionStrategy.eachDependency { DependencyResolveDetails details -> - def requested = details.requested - if (requested.group == "com.android.support") { - if (!requested.name.startsWith("multidex")) { - details.useVersion "26.+" + // Always show the result of every unit test, even if it passes. + all { + testLogging { + events 'skipped', 'failed', 'standardOut', 'standardError' } } } @@ -135,12 +127,16 @@ dependencies { implementation project(':searchview') implementation project(':mediapicker') + implementation Dependencies.hilt + kapt Dependencies.hiltCompiler + implementation Dependencies.materialDialog("input") - implementation Dependencies.koin testImplementation Dependencies.kotlinTest testImplementation Dependencies.junit - testImplementation Dependencies.koinTest + testImplementation Dependencies.hiltTest + kaptTest Dependencies.hiltCompiler + androidTestImplementation Dependencies.kotlinTest androidTestImplementation Dependencies.espresso @@ -148,5 +144,6 @@ dependencies { androidTestImplementation Dependencies.espresso("contrib") androidTestImplementation Dependencies.testRules androidTestImplementation Dependencies.testRunner - androidTestImplementation Dependencies.koinTest + testImplementation Dependencies.hiltTest + kaptTest Dependencies.hiltCompiler } 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 88a0402..cc45b4e 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt @@ -25,9 +25,11 @@ import androidx.test.espresso.matcher.BoundedMatcher import androidx.test.espresso.matcher.ViewMatchers.withChild 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 ca.allanwang.kau.sample.test.BaseTest +import dagger.hilt.android.testing.HiltAndroidTest +import dagger.hilt.android.testing.UninstallModules +import javax.inject.Inject import kotlin.test.assertFalse import kotlin.test.assertTrue import org.hamcrest.BaseMatcher @@ -40,8 +42,6 @@ import org.junit.Test import org.junit.rules.RuleChain import org.junit.rules.TestRule import org.junit.runner.RunWith -import org.koin.test.KoinTest -import org.koin.test.inject /** * Created by Allan Wang on 21/12/2018. @@ -49,20 +49,16 @@ import org.koin.test.inject * Tests related to the :kpref-activity module */ @RunWith(AndroidJUnit4::class) -@MediumTest -class KPrefViewTest : KoinTest { +@HiltAndroidTest +@UninstallModules(PrefFactoryModule::class) +class KPrefViewTest : BaseTest() { val activity: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) @get:Rule val rule: TestRule = RuleChain.outerRule(SampleTestRule()).around(activity) - private val pref: KPrefSample by inject() - - @BeforeTest - fun before() { - pref.reset() - } + @Inject lateinit var pref: KPrefSample fun verifyCheck(checked: Boolean): Matcher<View> { return object : BoundedMatcher<View, View>(View::class.java) { 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 c6ab259..89e74c7 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt @@ -17,18 +17,16 @@ package ca.allanwang.kau.sample import android.app.Application import android.content.Context +import androidx.test.core.app.ApplicationProvider import androidx.test.runner.AndroidJUnitRunner -import ca.allanwang.kau.kpref.KPrefFactory -import ca.allanwang.kau.kpref.KPrefFactoryInMemory +import dagger.hilt.EntryPoint +import dagger.hilt.InstallIn +import dagger.hilt.android.EntryPointAccessors +import dagger.hilt.android.components.ApplicationComponent +import dagger.hilt.android.testing.HiltTestApplication import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement -import org.koin.android.ext.koin.androidContext -import org.koin.android.ext.koin.androidLogger -import org.koin.core.KoinComponent -import org.koin.core.context.startKoin -import org.koin.core.get -import org.koin.dsl.module class SampleTestRunner : AndroidJUnitRunner() { override fun newApplication( @@ -36,43 +34,30 @@ class SampleTestRunner : AndroidJUnitRunner() { className: String?, context: Context? ): Application { - return super.newApplication(cl, SampleTestApp::class.java.name, context) + return super.newApplication(cl, HiltTestApplication::class.java.name, context) } } class SampleTestRule : TestRule { + + @EntryPoint + @InstallIn(ApplicationComponent::class) + interface SampleTestRuleEntryPoint { + fun pref(): KPrefSample + } + override fun apply(base: Statement, description: Description): Statement = - object : Statement(), KoinComponent { + object : Statement() { override fun evaluate() { + val entryPoint = EntryPointAccessors.fromApplication( + ApplicationProvider.getApplicationContext(), + SampleTestRuleEntryPoint::class.java + ) // Reset prefs - get<KPrefSample>().reset() + entryPoint.pref().reset() base.evaluate() } } } - -class SampleTestApp : Application() { - override fun onCreate() { - super.onCreate() - startKoin { - if (BuildConfig.DEBUG) { - androidLogger() - } - androidContext(this@SampleTestApp) - modules( - listOf( - prefFactoryModule(), - KPrefSample.module() - ) - ) - } - } - - fun prefFactoryModule() = module { - single<KPrefFactory> { - KPrefFactoryInMemory - } - } -} diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/BaseTest.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/BaseTest.kt new file mode 100644 index 0000000..1cba88f --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/BaseTest.kt @@ -0,0 +1,32 @@ +/* + * 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.test + +import dagger.hilt.android.testing.HiltAndroidRule +import kotlin.test.BeforeTest +import org.junit.Rule + +abstract class BaseTest { + @Suppress("LeakingThis") + @get:Rule + val hiltRule: HiltAndroidRule = + HiltAndroidRule(this) + + @BeforeTest + fun before() { + hiltRule.inject() + } +} diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt new file mode 100644 index 0000000..74da014 --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt @@ -0,0 +1,30 @@ +/* + * 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.test + +import ca.allanwang.kau.kpref.KPrefFactory +import ca.allanwang.kau.kpref.KPrefFactoryInMemory +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ApplicationComponent + +@Module +@InstallIn(ApplicationComponent::class) +object PrefFactoryTestModule { + @Provides + fun factory(): KPrefFactory = KPrefFactoryInMemory +} diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt index bd1039b..b3560c5 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt @@ -28,7 +28,8 @@ import ca.allanwang.kau.utils.fullLinearRecycler import ca.allanwang.kau.utils.startActivity import ca.allanwang.kau.utils.withAlpha import ca.allanwang.kau.utils.withSlideOut -import org.koin.android.ext.android.inject +import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject /** * Created by Allan Wang on 2017-06-12. @@ -36,9 +37,11 @@ import org.koin.android.ext.android.inject * Activity for animations * Now also showcases permissions */ +@AndroidEntryPoint class AnimActivity : KauBaseActivity() { - private val pref: KPrefSample by inject() + @Inject + lateinit var pref: KPrefSample override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) 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 4ac9928..ee39184 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt @@ -15,10 +15,16 @@ */ package ca.allanwang.kau.sample +import android.content.Context import android.graphics.Color import ca.allanwang.kau.kpref.KPref import ca.allanwang.kau.kpref.KPrefFactory -import org.koin.dsl.module +import ca.allanwang.kau.kpref.KPrefFactoryAndroid +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.android.components.ApplicationComponent +import dagger.hilt.android.qualifiers.ApplicationContext /** * Created by Allan Wang on 2017-06-07. @@ -35,10 +41,18 @@ class KPrefSample(factory: KPrefFactory) : KPref("pref_sample", factory = factor var seekbar: Int by kpref("seekbar", 20) var time12: Int by kpref("time_12", 315) var time24: Int by kpref("time_24", 2220) +} + +@Module +@InstallIn(ApplicationComponent::class) +object PrefModule { + @Provides + fun pref(factory: KPrefFactory): KPrefSample = KPrefSample(factory) +} - companion object { - fun module() = module { - single { KPrefSample(get()) } - } - } +@Module +@InstallIn(ApplicationComponent::class) +object PrefFactoryModule { + @Provides + fun factory(@ApplicationContext context: Context): KPrefFactory = KPrefFactoryAndroid(context) } 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 4cf632f..e6841c8 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -40,8 +40,10 @@ import ca.allanwang.kau.utils.withSceneTransitionAnimation import ca.allanwang.kau.xml.showChangelog import com.afollestad.materialdialogs.input.input import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial -import org.koin.android.ext.android.inject +import dagger.hilt.android.AndroidEntryPoint +import javax.inject.Inject +@AndroidEntryPoint class MainActivity : KPrefActivity() { var searchView: SearchView? = null @@ -51,58 +53,514 @@ class MainActivity : KPrefActivity() { // some of the most common english words for show val wordBank: List<String> by lazy { listOf( - "the", "name", "of", "very", "to", "through", - "and", "just", "a", "form", "in", "much", "is", "great", "it", "think", "you", "say", - "that", "help", "he", "low", "was", "line", "for", "before", "on", "turn", "are", "cause", - "with", "same", "as", "mean", "I", "differ", "his", "move", "they", "right", "be", "boy", - "at", "old", "one", "too", "have", "does", "this", "tell", "from", "sentence", "or", "set", - "had", "three", "by", "want", "hot", "air", "but", "well", "some", "also", "what", "play", - "there", "small", "we", "end", "can", "put", "out", "home", "other", "read", "were", "hand", - "all", "port", "your", "large", "when", "spell", "up", "add", "use", "even", "word", "land", - "how", "here", "said", "must", "an", "big", "each", "high", "she", "such", "which", "follow", - "do", "act", "their", "why", "time", "ask", "if", "men", "will", "change", "way", "went", - "about", "light", "many", "kind", "then", "off", "them", "need", "would", "house", "write", - "picture", "like", "try", "so", "us", "these", "again", "her", "animal", "long", "point", - "make", "mother", "thing", "world", "see", "near", "him", "build", "two", "self", "has", - "earth", "look", "father", "more", "head", "day", "stand", "could", "own", "go", "page", - "come", "should", "did", "country", "my", "found", "sound", "answer", "no", "school", "most", - "grow", "number", "study", "who", "still", "over", "learn", "know", "plant", "water", "cover", - "than", "food", "call", "sun", "first", "four", "people", "thought", "may", "let", "down", "keep", - "side", "eye", "been", "never", "now", "last", "find", "door", "any", "between", "new", "city", - "work", "tree", "part", "cross", "take", "since", "get", "hard", "place", "start", "made", - "might", "live", "story", "where", "saw", "after", "far", "back", "sea", "little", "draw", - "only", "left", "round", "late", "man", "run", "year", "don't", "came", "while", "show", - "press", "every", "close", "good", "night", "me", "real", "give", "life", "our", "few", "under", - "stopRankWordRankWord", "open", "ten", "seem", "simple", "together", "several", "next", - "vowel", "white", "toward", "children", "war", "begin", "lay", "got", "against", "walk", "pattern", - "example", "slow", "ease", "center", "paper", "love", "often", "person", "always", "money", - "music", "serve", "those", "appear", "both", "road", "mark", "map", "book", "science", "letter", - "rule", "until", "govern", "mile", "pull", "river", "cold", "car", "notice", "feet", "voice", - "care", "fall", "second", "power", "group", "town", "carry", "fine", "took", "certain", "rain", - "fly", "eat", "unit", "room", "lead", "friend", "cry", "began", "dark", "idea", "machine", - "fish", "note", "mountain", "wait", "north", "plan", "once", "figure", "base", "star", "hear", - "box", "horse", "noun", "cut", "field", "sure", "rest", "watch", "correct", "color", "able", - "face", "pound", "wood", "done", "main", "beauty", "enough", "drive", "plain", "stood", "girl", - "contain", "usual", "front", "young", "teach", "ready", "week", "above", "final", "ever", "gave", - "red", "green", "list", "oh", "though", "quick", "feel", "develop", "talk", "sleep", "bird", - "warm", "soon", "free", "body", "minute", "dog", "strong", "family", "special", "direct", "mind", - "pose", "behind", "leave", "clear", "song", "tail", "measure", "produce", "state", "fact", "product", - "street", "black", "inch", "short", "lot", "numeral", "nothing", "class", "course", "wind", "stay", - "question", "wheel", "happen", "full", "complete", "force", "ship", "blue", "area", "object", "half", - "decide", "rock", "surface", "order", "deep", "fire", "moon", "south", "island", "problem", "foot", - "piece", "yet", "told", "busy", "knew", "test", "pass", "record", "farm", "boat", "top", "common", - "whole", "gold", "king", "possible", "size", "plane", "heard", "age", "best", "dry", "hour", "wonder", - "better", "laugh", "true.", "thousand", "during", "ago", "hundred", "ran", "am", "check", "remember", - "game", "step", "shape", "early", "yes", "hold", "hot", "west", "miss", "ground", "brought", "interest", - "heat", "reach", "snow", "fast", "bed", "five", "bring", "sing", "sit", "listen", "perhaps", "six", - "fill", "table", "east", "travel", "weight", "less", "language", "morning", "among" + "the", + "name", + "of", + "very", + "to", + "through", + "and", + "just", + "a", + "form", + "in", + "much", + "is", + "great", + "it", + "think", + "you", + "say", + "that", + "help", + "he", + "low", + "was", + "line", + "for", + "before", + "on", + "turn", + "are", + "cause", + "with", + "same", + "as", + "mean", + "I", + "differ", + "his", + "move", + "they", + "right", + "be", + "boy", + "at", + "old", + "one", + "too", + "have", + "does", + "this", + "tell", + "from", + "sentence", + "or", + "set", + "had", + "three", + "by", + "want", + "hot", + "air", + "but", + "well", + "some", + "also", + "what", + "play", + "there", + "small", + "we", + "end", + "can", + "put", + "out", + "home", + "other", + "read", + "were", + "hand", + "all", + "port", + "your", + "large", + "when", + "spell", + "up", + "add", + "use", + "even", + "word", + "land", + "how", + "here", + "said", + "must", + "an", + "big", + "each", + "high", + "she", + "such", + "which", + "follow", + "do", + "act", + "their", + "why", + "time", + "ask", + "if", + "men", + "will", + "change", + "way", + "went", + "about", + "light", + "many", + "kind", + "then", + "off", + "them", + "need", + "would", + "house", + "write", + "picture", + "like", + "try", + "so", + "us", + "these", + "again", + "her", + "animal", + "long", + "point", + "make", + "mother", + "thing", + "world", + "see", + "near", + "him", + "build", + "two", + "self", + "has", + "earth", + "look", + "father", + "more", + "head", + "day", + "stand", + "could", + "own", + "go", + "page", + "come", + "should", + "did", + "country", + "my", + "found", + "sound", + "answer", + "no", + "school", + "most", + "grow", + "number", + "study", + "who", + "still", + "over", + "learn", + "know", + "plant", + "water", + "cover", + "than", + "food", + "call", + "sun", + "first", + "four", + "people", + "thought", + "may", + "let", + "down", + "keep", + "side", + "eye", + "been", + "never", + "now", + "last", + "find", + "door", + "any", + "between", + "new", + "city", + "work", + "tree", + "part", + "cross", + "take", + "since", + "get", + "hard", + "place", + "start", + "made", + "might", + "live", + "story", + "where", + "saw", + "after", + "far", + "back", + "sea", + "little", + "draw", + "only", + "left", + "round", + "late", + "man", + "run", + "year", + "don't", + "came", + "while", + "show", + "press", + "every", + "close", + "good", + "night", + "me", + "real", + "give", + "life", + "our", + "few", + "under", + "stopRankWordRankWord", + "open", + "ten", + "seem", + "simple", + "together", + "several", + "next", + "vowel", + "white", + "toward", + "children", + "war", + "begin", + "lay", + "got", + "against", + "walk", + "pattern", + "example", + "slow", + "ease", + "center", + "paper", + "love", + "often", + "person", + "always", + "money", + "music", + "serve", + "those", + "appear", + "both", + "road", + "mark", + "map", + "book", + "science", + "letter", + "rule", + "until", + "govern", + "mile", + "pull", + "river", + "cold", + "car", + "notice", + "feet", + "voice", + "care", + "fall", + "second", + "power", + "group", + "town", + "carry", + "fine", + "took", + "certain", + "rain", + "fly", + "eat", + "unit", + "room", + "lead", + "friend", + "cry", + "began", + "dark", + "idea", + "machine", + "fish", + "note", + "mountain", + "wait", + "north", + "plan", + "once", + "figure", + "base", + "star", + "hear", + "box", + "horse", + "noun", + "cut", + "field", + "sure", + "rest", + "watch", + "correct", + "color", + "able", + "face", + "pound", + "wood", + "done", + "main", + "beauty", + "enough", + "drive", + "plain", + "stood", + "girl", + "contain", + "usual", + "front", + "young", + "teach", + "ready", + "week", + "above", + "final", + "ever", + "gave", + "red", + "green", + "list", + "oh", + "though", + "quick", + "feel", + "develop", + "talk", + "sleep", + "bird", + "warm", + "soon", + "free", + "body", + "minute", + "dog", + "strong", + "family", + "special", + "direct", + "mind", + "pose", + "behind", + "leave", + "clear", + "song", + "tail", + "measure", + "produce", + "state", + "fact", + "product", + "street", + "black", + "inch", + "short", + "lot", + "numeral", + "nothing", + "class", + "course", + "wind", + "stay", + "question", + "wheel", + "happen", + "full", + "complete", + "force", + "ship", + "blue", + "area", + "object", + "half", + "decide", + "rock", + "surface", + "order", + "deep", + "fire", + "moon", + "south", + "island", + "problem", + "foot", + "piece", + "yet", + "told", + "busy", + "knew", + "test", + "pass", + "record", + "farm", + "boat", + "top", + "common", + "whole", + "gold", + "king", + "possible", + "size", + "plane", + "heard", + "age", + "best", + "dry", + "hour", + "wonder", + "better", + "laugh", + "true.", + "thousand", + "during", + "ago", + "hundred", + "ran", + "am", + "check", + "remember", + "game", + "step", + "shape", + "early", + "yes", + "hold", + "hot", + "west", + "miss", + "ground", + "brought", + "interest", + "heat", + "reach", + "snow", + "fast", + "bed", + "five", + "bring", + "sing", + "sit", + "listen", + "perhaps", + "six", + "fill", + "table", + "east", + "travel", + "weight", + "less", + "language", + "morning", + "among" ) } const val REQUEST_MEDIA = 27 } - private val pref: KPrefSample by inject() + @Inject + lateinit var pref: KPrefSample override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = { textColor = pref::textColor @@ -167,7 +625,12 @@ class MainActivity : KPrefActivity() { onClick = { itemView.context.materialDialog { title(text = "Type Text") - input("Type here", prefill = item.pref, maxLength = 20, allowEmpty = true) { _, input -> + input( + "Type here", + prefill = item.pref, + maxLength = 20, + allowEmpty = true + ) { _, input -> item.pref = input.toString() } } @@ -246,7 +709,12 @@ class MainActivity : KPrefActivity() { onClick = { itemView.context.materialDialog { title(text = "Type Text") - input("Type here", prefill = item.pref, maxLength = 20, allowEmpty = true) { _, input -> + input( + "Type here", + prefill = item.pref, + maxLength = 20, + allowEmpty = true + ) { _, input -> item.pref = input.toString() reloadSelf() } @@ -311,7 +779,12 @@ class MainActivity : KPrefActivity() { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { - REQUEST_MEDIA -> toast("${kauOnMediaPickerResult(resultCode, data).size} items selected") + REQUEST_MEDIA -> toast( + "${kauOnMediaPickerResult( + resultCode, + data + ).size} items selected" + ) } } } diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt index 597894a..282f9ff 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt @@ -16,40 +16,10 @@ package ca.allanwang.kau.sample import android.app.Application -import ca.allanwang.kau.kpref.KPrefFactory -import ca.allanwang.kau.kpref.KPrefFactoryAndroid -import org.koin.android.ext.koin.androidContext -import org.koin.android.ext.koin.androidLogger -import org.koin.core.context.startKoin -import org.koin.core.module.Module -import org.koin.dsl.module +import dagger.hilt.android.HiltAndroidApp /** * Created by Allan Wang on 2017-06-08. */ -class SampleApp : Application() { - override fun onCreate() { - super.onCreate() - - startKoin { - if (BuildConfig.DEBUG) { - androidLogger() - } - androidContext(this@SampleApp) - modules( - listOf( - prefFactoryModule(), - KPrefSample.module() - ) - ) - } - } - - companion object { - fun prefFactoryModule(): Module = module { - single<KPrefFactory> { - KPrefFactoryAndroid(get()) - } - } - } -} +@HiltAndroidApp +class SampleApp : Application() |