aboutsummaryrefslogtreecommitdiff
path: root/sample
diff options
context:
space:
mode:
Diffstat (limited to 'sample')
-rw-r--r--sample/build.gradle63
-rw-r--r--sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt47
-rw-r--r--sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt63
-rw-r--r--sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/BaseTest.kt32
-rw-r--r--sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt33
-rw-r--r--sample/src/main/AndroidManifest.xml3
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt20
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt8
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt24
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt622
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt4
-rw-r--r--sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt12
-rw-r--r--sample/src/main/res/xml/kau_changelog.xml26
13 files changed, 821 insertions, 136 deletions
diff --git a/sample/build.gradle b/sample/build.gradle
index 47baed2..ff25f50 100644
--- a/sample/build.gradle
+++ b/sample/build.gradle
@@ -1,9 +1,14 @@
import kau.Dependencies
+import kau.Versions
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
-apply plugin: 'kotlin-android-extensions'
+apply plugin: 'kotlin-kapt'
+apply plugin: 'kotlin-parcelize'
+//apply plugin: 'com.bugsnag.android.gradle'
apply plugin: 'com.github.triplet.play'
+apply plugin: 'dagger.hilt.android.plugin'
+apply plugin: 'com.mikepenz.aboutlibraries.plugin'
play {
serviceAccountCredentials = file('../files/gplay-keys.json')
@@ -11,8 +16,7 @@ play {
}
android {
- compileSdkVersion kau.Versions.targetSdk
- buildToolsVersion kau.Versions.buildTools
+ compileSdkVersion Versions.targetSdk
androidGitVersion {
codeFormat = 'MMNNPPXX'
@@ -21,15 +25,15 @@ android {
defaultConfig {
applicationId "ca.allanwang.kau.sample"
- minSdkVersion kau.Versions.minSdk
- targetSdkVersion kau.Versions.targetSdk
+ minSdkVersion Versions.minSdk
+ targetSdkVersion Versions.targetSdk
versionName androidGitVersion.name()
versionCode androidGitVersion.code()
multiDexEnabled true
- testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ testInstrumentationRunner "ca.allanwang.kau.sample.SampleTestRunner"
}
viewBinding {
- enabled = true
+ enabled true
}
def releaseSigning = file("../files/kau.properties")
@@ -63,6 +67,7 @@ android {
versionNameSuffix "-debug"
signingConfig signingConfigs.debug
resValue "string", "app_name", "KAU Debug"
+ ext.enableBugsnag = false
}
release {
@@ -82,11 +87,16 @@ android {
pickFirst 'META-INF/core_release.kotlin_module'
pickFirst 'META-INF/library_release.kotlin_module'
pickFirst 'META-INF/library-core_release.kotlin_module'
+ exclude "**/module-info.class"
}
compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_8
- targetCompatibility JavaVersion.VERSION_1_8
+ sourceCompatibility Versions.java
+ targetCompatibility Versions.java
+ }
+
+ kotlinOptions {
+ jvmTarget = Versions.java.toString()
}
sourceSets {
@@ -96,25 +106,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
-
- // Always show the result of every unit test, even if it passes.
- all {
- testLogging {
- events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
- }
- }
- }
+ testOptions {
+ unitTests {
+ // Don't throw runtime exceptions for android calls that are not mocked
+ returnDefaultValues = true
- // 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'
}
}
}
@@ -132,10 +132,17 @@ dependencies {
implementation project(':searchview')
implementation project(':mediapicker')
+ implementation Dependencies.hilt
+ kapt Dependencies.hiltCompiler
+
+ implementation Dependencies.bugsnag
+
implementation Dependencies.materialDialog("input")
testImplementation Dependencies.kotlinTest
testImplementation Dependencies.junit
+ testImplementation Dependencies.hiltTest
+ kaptTest Dependencies.hiltCompiler
androidTestImplementation Dependencies.kotlinTest
androidTestImplementation Dependencies.espresso
@@ -143,4 +150,6 @@ dependencies {
androidTestImplementation Dependencies.espresso("contrib")
androidTestImplementation Dependencies.testRules
androidTestImplementation Dependencies.testRunner
+ androidTestImplementation Dependencies.hiltTest
+ kaptAndroidTest 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 72199cf..fb360b9 100644
--- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt
+++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt
@@ -25,8 +25,12 @@ 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 ca.allanwang.kau.sample.test.BaseTest
+import dagger.hilt.android.testing.HiltAndroidTest
+import javax.inject.Inject
+import kotlin.test.assertFalse
+import kotlin.test.assertTrue
import org.hamcrest.BaseMatcher
import org.hamcrest.Description
import org.hamcrest.Matcher
@@ -34,6 +38,8 @@ import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.instanceOf
import org.junit.Rule
import org.junit.Test
+import org.junit.rules.RuleChain
+import org.junit.rules.TestRule
import org.junit.runner.RunWith
/**
@@ -42,12 +48,16 @@ import org.junit.runner.RunWith
* Tests related to the :kpref-activity module
*/
@RunWith(AndroidJUnit4::class)
-@MediumTest
-class KPrefViewTest {
+@HiltAndroidTest
+class KPrefViewTest : BaseTest() {
- @get:Rule
val activity: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java)
+ @get:Rule
+ val rule: TestRule = RuleChain.outerRule(SampleTestRule()).around(activity)
+
+ @Inject lateinit var pref: KPrefSample
+
fun verifyCheck(checked: Boolean): Matcher<View> {
return object : BoundedMatcher<View, View>(View::class.java) {
@@ -93,11 +103,11 @@ class KPrefViewTest {
fun basicCheckboxToggle() {
val checkbox1 = onCheckboxView(withChild(withText(R.string.checkbox_1)))
- val initiallyChecked = KPrefSample.check1
+ assertTrue(pref.check1, "check1 not normalized")
- checkbox1.verifyCheck("checkbox1 init", initiallyChecked)
+ checkbox1.verifyCheck("checkbox1 init", true)
checkbox1.perform(click())
- checkbox1.verifyCheck("checkbox1 after click", !initiallyChecked)
+ checkbox1.verifyCheck("checkbox1 after click", false)
}
/**
@@ -107,23 +117,24 @@ class KPrefViewTest {
fun dependentCheckboxToggle() {
val checkbox2 = onCheckboxView(withChild(withText(R.string.checkbox_2)))
val checkbox3 =
- onCheckboxView(withChild(withText(R.string.checkbox_3)), withChild(withText(R.string.desc_dependent)))
+ onCheckboxView(
+ withChild(withText(R.string.checkbox_3)),
+ withChild(withText(R.string.desc_dependent))
+ )
- // normalize so that both are checked
- if (!KPrefSample.check2)
- checkbox2.perform(click())
- if (!KPrefSample.check3)
- checkbox3.perform(click())
+ assertFalse(pref.check2, "check2 not normalized")
+ assertFalse(pref.check3, "check3 not normalized")
- checkbox3.verifyCheck("checkbox3 init", true, true)
+ checkbox2.verifyCheck("checkbox2 init", checked = false, enabled = true)
+ checkbox3.verifyCheck("checkbox3 init", checked = false, enabled = false)
checkbox3.perform(click())
- checkbox3.verifyCheck("checkbox3 after click", false, true)
+ checkbox3.verifyCheck("checkbox3 after disabled click", checked = false, enabled = false)
checkbox2.perform(click())
- checkbox2.verifyCheck("checkbox2 after click", false, true)
- checkbox3.verifyCheck("checkbox3 after checkbox2 click", false, false)
+ checkbox2.verifyCheck("checkbox2 after click", checked = true, enabled = true)
+ checkbox3.verifyCheck("checkbox3 after checkbox2 click", checked = false, enabled = true)
checkbox3.perform(click())
- checkbox3.verifyCheck("checkbox3 after disabled click", false, false)
+ checkbox3.verifyCheck("checkbox3 after enabled click", checked = true, enabled = true)
}
}
diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt
new file mode 100644
index 0000000..f6ffdb1
--- /dev/null
+++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/SampleTestApp.kt
@@ -0,0 +1,63 @@
+/*
+ * 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
+import android.content.Context
+import androidx.test.core.app.ApplicationProvider
+import androidx.test.runner.AndroidJUnitRunner
+import dagger.hilt.EntryPoint
+import dagger.hilt.InstallIn
+import dagger.hilt.android.EntryPointAccessors
+import dagger.hilt.android.testing.HiltTestApplication
+import dagger.hilt.components.SingletonComponent
+import org.junit.rules.TestRule
+import org.junit.runner.Description
+import org.junit.runners.model.Statement
+
+class SampleTestRunner : AndroidJUnitRunner() {
+ override fun newApplication(
+ cl: ClassLoader?,
+ className: String?,
+ context: Context?
+ ): Application {
+ return super.newApplication(cl, HiltTestApplication::class.java.name, context)
+ }
+}
+
+class SampleTestRule : TestRule {
+
+ @EntryPoint
+ @InstallIn(SingletonComponent::class)
+ interface SampleTestRuleEntryPoint {
+ fun pref(): KPrefSample
+ }
+
+ override fun apply(base: Statement, description: Description): Statement =
+ object : Statement() {
+ override fun evaluate() {
+ val entryPoint = EntryPointAccessors.fromApplication(
+ ApplicationProvider.getApplicationContext(),
+ SampleTestRuleEntryPoint::class.java
+ )
+
+ // Reset prefs
+ entryPoint.pref().reset()
+
+ base.evaluate()
+ }
+ }
+}
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..1615d2f
--- /dev/null
+++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/test/TestModules.kt
@@ -0,0 +1,33 @@
+/*
+ * 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 ca.allanwang.kau.sample.PrefFactoryModule
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.components.SingletonComponent
+import dagger.hilt.testing.TestInstallIn
+
+@Module
+@TestInstallIn(
+ components = [SingletonComponent::class],
+ replaces = [PrefFactoryModule::class])
+object PrefFactoryTestModule {
+ @Provides
+ fun factory(): KPrefFactory = KPrefFactoryInMemory
+}
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
index 5846c6b..b205c51 100644
--- a/sample/src/main/AndroidManifest.xml
+++ b/sample/src/main/AndroidManifest.xml
@@ -57,6 +57,9 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/kau_file_paths" />
</provider>
+ <meta-data
+ android:name="com.bugsnag.android.API_KEY"
+ android:value="0a09e498a253b98237500fb5f948e5c6"/>
</application>
</manifest> \ No newline at end of file
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/kotlin/ca/allanwang/kau/sample/AnimActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt
index a472f09..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,6 +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 dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
/**
* Created by Allan Wang on 2017-06-12.
@@ -35,14 +37,18 @@ import ca.allanwang.kau.utils.withSlideOut
* Activity for animations
* Now also showcases permissions
*/
+@AndroidEntryPoint
class AnimActivity : KauBaseActivity() {
+ @Inject
+ lateinit var pref: KPrefSample
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val adapter = SingleFastAdapter()
setContentView(fullLinearRecycler(adapter).apply {
setBackgroundColor(
- KPrefSample.bgColor.withAlpha(255)
+ pref.bgColor.withAlpha(255)
)
})
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 80a75bf..970d3eb 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt
@@ -15,13 +15,21 @@
*/
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 ca.allanwang.kau.kpref.KPrefFactoryAndroid
+import dagger.Module
+import dagger.Provides
+import dagger.hilt.InstallIn
+import dagger.hilt.android.qualifiers.ApplicationContext
+import dagger.hilt.components.SingletonComponent
/**
* Created by Allan Wang on 2017-06-07.
*/
-object KPrefSample : KPref() {
+class KPrefSample(factory: KPrefFactory) : KPref("pref_sample", factory = factory) {
var version: Int by kpref("version", -1)
var textColor: Int by kpref("TEXT_COLOR", Color.WHITE)
var accentColor: Int by kpref("ACCENT_COLOR", 0xffff8900.toInt())
@@ -34,3 +42,17 @@ object KPrefSample : KPref() {
var time12: Int by kpref("time_12", 315)
var time24: Int by kpref("time_24", 2220)
}
+
+@Module
+@InstallIn(SingletonComponent::class)
+object PrefModule {
+ @Provides
+ fun pref(factory: KPrefFactory): KPrefSample = KPrefSample(factory)
+}
+
+@Module
+@InstallIn(SingletonComponent::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 4fe941b..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,7 +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 dagger.hilt.android.AndroidEntryPoint
+import javax.inject.Inject
+@AndroidEntryPoint
class MainActivity : KPrefActivity() {
var searchView: SearchView? = null
@@ -50,60 +53,518 @@ 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
}
+ @Inject
+ lateinit var pref: KPrefSample
+
override fun kPrefCoreAttributes(): CoreAttributeContract.() -> Unit = {
- textColor = KPrefSample::textColor
- accentColor = KPrefSample::accentColor
+ textColor = pref::textColor
+ accentColor = pref::accentColor
}
override fun onCreateKPrefs(savedInstanceState: Bundle?): KPrefAdapterBuilder.() -> Unit = {
@@ -113,7 +574,7 @@ class MainActivity : KPrefActivity() {
/**
* This is how the setup looks like with all the proper tags
*/
- checkbox(title = R.string.checkbox_1, getter = KPrefSample::check1, setter = { KPrefSample.check1 = it },
+ checkbox(title = R.string.checkbox_1, getter = pref::check1, setter = { pref.check1 = it },
builder = {
descRes = R.string.desc
})
@@ -123,25 +584,25 @@ class MainActivity : KPrefActivity() {
*/
checkbox(
R.string.checkbox_2,
- KPrefSample::check2,
- { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) })
+ pref::check2,
+ { pref.check2 = it; reloadByTitle(R.string.checkbox_3) })
/**
* Since the builder is the last argument and is a lambda, we may write the setup cleanly like so:
*/
- checkbox(R.string.checkbox_3, KPrefSample::check3, { KPrefSample.check3 = it }) {
+ checkbox(R.string.checkbox_3, pref::check3, { pref.check3 = it }) {
descRes = R.string.desc_dependent
- enabler = { KPrefSample.check2 }
+ enabler = { pref.check2 }
onDisabledClick = { itemView.context.toast("I am still disabled") }
}
- colorPicker(R.string.text_color, KPrefSample::textColor, { KPrefSample.textColor = it; reload() }) {
+ colorPicker(R.string.text_color, pref::textColor, { pref.textColor = it; reload() }) {
descRes = R.string.color_custom
allowCustom = true
}
- colorPicker(R.string.accent_color, KPrefSample::accentColor, {
- KPrefSample.accentColor = it
+ colorPicker(R.string.accent_color, pref::accentColor, {
+ pref.accentColor = it
reload()
this@MainActivity.navigationBarColor = it
toolbarCanvas.ripple(it, RippleCanvas.MIDDLE, RippleCanvas.END, duration = 500L)
@@ -150,8 +611,8 @@ class MainActivity : KPrefActivity() {
allowCustom = false
}
- colorPicker(R.string.background_color, KPrefSample::bgColor, {
- KPrefSample.bgColor = it; bgCanvas.ripple(it, duration = 500L)
+ colorPicker(R.string.background_color, pref::bgColor, {
+ pref.bgColor = it; bgCanvas.ripple(it, duration = 500L)
}) {
iicon = GoogleMaterial.Icon.gmd_colorize
descRes = R.string.color_custom_alpha
@@ -159,19 +620,24 @@ class MainActivity : KPrefActivity() {
allowCustom = true
}
- text(R.string.text, KPrefSample::text, { KPrefSample.text = it }) {
+ text(R.string.text, pref::text, { pref.text = it }) {
descRes = R.string.text_desc
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()
}
}
}
}
- seekbar(R.string.seekbar, KPrefSample::seekbar, { KPrefSample.seekbar = it }) {
+ seekbar(R.string.seekbar, pref::seekbar, { pref.seekbar = it }) {
descRes = R.string.kau_lorem_ipsum
increments = 5
textViewConfigs = {
@@ -215,35 +681,40 @@ class MainActivity : KPrefActivity() {
*/
checkbox(
R.string.checkbox_2,
- KPrefSample::check2,
- { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) {
+ pref::check2,
+ { pref.check2 = it; reloadByTitle(R.string.checkbox_3) }) {
titleFun = { R.string.checkbox_3 }
descRes = R.string.kau_lorem_ipsum
}
- text(R.string.text, KPrefSample::text, { KPrefSample.text = it }) {
+ text(R.string.text, pref::text, { pref.text = it }) {
descRes = R.string.kau_lorem_ipsum
textGetter = { string(R.string.kau_lorem_ipsum) }
}
- timePicker(R.string.time, KPrefSample::time12, { KPrefSample.time12 = it }) {
+ timePicker(R.string.time, pref::time12, { pref.time12 = it }) {
descRes = R.string.time_desc_12
use24HourFormat = false
}
- timePicker(R.string.time, KPrefSample::time24, { KPrefSample.time24 = it }) {
+ timePicker(R.string.time, pref::time24, { pref.time24 = it }) {
descRes = R.string.time_desc_24
use24HourFormat = true
}
}
fun subPrefs(): KPrefAdapterBuilder.() -> Unit = {
- text(R.string.text, { KPrefSample.text }, { KPrefSample.text = it }) {
+ text(R.string.text, { pref.text }, { pref.text = it }) {
descRes = R.string.text_desc
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()
}
@@ -254,11 +725,11 @@ class MainActivity : KPrefActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- bgCanvas.set(KPrefSample.bgColor)
- toolbarCanvas.set(KPrefSample.accentColor)
- this.navigationBarColor = KPrefSample.accentColor
- if (KPrefSample.version < BuildConfig.VERSION_CODE) {
- KPrefSample.version = BuildConfig.VERSION_CODE
+ bgCanvas.set(pref.bgColor)
+ toolbarCanvas.set(pref.accentColor)
+ this.navigationBarColor = pref.accentColor
+ if (pref.version < BuildConfig.VERSION_CODE) {
+ pref.version = BuildConfig.VERSION_CODE
if (!BuildConfig.DEBUG)
showChangelog(R.xml.kau_changelog)
}
@@ -308,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/PermissionCheckbox.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
index 50cfe69..7bd2851 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt
@@ -41,7 +41,7 @@ import com.mikepenz.fastadapter.listeners.EventHook
class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox.ViewHolder>(
R.layout.permission_checkbox, { ViewHolder(it) }) {
- override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: List<Any>) {
super.bindView(holder, payloads)
holder.text.text = permission
holder.checkbox.isChecked = holder.itemView.context.hasPermission(permission)
@@ -72,7 +72,7 @@ class PermissionCheckboxViewBinding(
override fun PermissionCheckboxBinding.bindView(
holder: ViewHolder,
- payloads: MutableList<Any>
+ payloads: List<Any>
) {
permText.text = data.permission
permCheckbox.apply {
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 6e6d718..42fbe98 100644
--- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
+++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt
@@ -16,13 +16,23 @@
package ca.allanwang.kau.sample
import android.app.Application
+import com.bugsnag.android.Bugsnag
+import dagger.hilt.android.HiltAndroidApp
/**
* Created by Allan Wang on 2017-06-08.
*/
+@HiltAndroidApp
class SampleApp : Application() {
override fun onCreate() {
super.onCreate()
- KPrefSample.initialize(this, "pref_sample")
+ initBugsnag()
+ }
+
+ private fun initBugsnag() {
+ if (BuildConfig.DEBUG) {
+ return
+ }
+ Bugsnag.start(this)
}
}
diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml
index d61fe63..2d47332 100644
--- a/sample/src/main/res/xml/kau_changelog.xml
+++ b/sample/src/main/res/xml/kau_changelog.xml
@@ -6,11 +6,29 @@
<item text="" />
-->
- <version title="v5.2.1" />
+ <version title="v6.3.0" />
+ <item text="Add support for Arctic Fox 2020.3.1" />
+ <item text="Move to new maven release system" />
+ <item text="Many version bumps" />
+
+ <version title="v6.2.0" />
+ <item text="Add support for Android Studio 4.2" />
+ <item text="Remove all usages of kotlin synthetics" />
+ <item text="Many version bumps" />
+ <item text="Added Hilt dep" />
+
+ <version title="v6.1.0" />
+ <item text="Add support for Android 4.1 RC03" />
+ <item text="Breaking: Updated iconics, buganizer, and spotless dependencies (major version bump)" />
+
+ <version title="v6.0.0" />
+ <item text="Add support for Android 4.1.x" />
+ <item text="Add major version library updates (FastAdapter, AboutLibrary, Iconics)" />
+
+ <version title="v5.3.0" />
+ <item text=":about: Moved config builder inside activity" />
<item text=":color: Allow option to disable selected ring" />
- <item text="" />
- <item text="" />
- <item text="" />
+ <item text=":core: Breaking KPref changes; see migration" />
<version title="v5.2.0" />
<item text=":about: Migrate about libraries to v7.x.x" />