diff options
Diffstat (limited to 'sample')
16 files changed, 517 insertions, 136 deletions
diff --git a/sample/build.gradle b/sample/build.gradle index d7199a3..bb7cab0 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -4,11 +4,8 @@ apply plugin: 'kotlin-android-extensions' apply plugin: 'com.github.triplet.play' play { - jsonFile = file('../files/gplay-keys.json') + serviceAccountCredentials = file('../files/gplay-keys.json') track = 'beta' - errorOnSizeLimit = true - uploadImages = false - untrackOld = true } android { @@ -27,7 +24,7 @@ android { versionName androidGitVersion.name() versionCode androidGitVersion.code() multiDexEnabled true - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } def releaseSigning = file("../files/kau.properties") @@ -101,6 +98,18 @@ android { } } } + + // 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.+" + } + } + } + } } dependencies { @@ -113,17 +122,15 @@ dependencies { implementation project(':searchview') implementation project(':mediapicker') -// androidTestImplementation("com.android.support.test.espresso:espresso-core:${kau.espresso}") { -// exclude group: 'com.android.support', module: 'support-annotations' -// } -// androidTestImplementation("com.android.support.test:runner:${kau.testRunner}") { -// exclude group: 'com.android.support', module: 'support-annotations' -// } -// androidTestImplementation kauDependency.kotlinTest + implementation "com.afollestad.material-dialogs:input:${kau.materialDialog}" + testImplementation kauDependency.kotlinTest testImplementation kauDependency.junit androidTestImplementation kauDependency.kotlinTest androidTestImplementation kauDependency.espresso + androidTestImplementation "androidx.test.espresso:espresso-intents:${kau.espresso}" + androidTestImplementation "androidx.test.espresso:espresso-contrib:${kau.espresso}" + androidTestImplementation kauDependency.testRules androidTestImplementation kauDependency.testRunner } diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt index 39aee93..ef53817 100644 --- a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/ColorPickerTest.kt @@ -1,16 +1,31 @@ +/* + * Copyright 2018 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.support.test.espresso.DataInteraction -import android.support.test.espresso.Espresso.onData -import android.support.test.espresso.Espresso.onView -import android.support.test.espresso.ViewAssertion -import android.support.test.espresso.action.ViewActions.click -import android.support.test.espresso.matcher.ViewMatchers.withId -import android.support.test.espresso.matcher.ViewMatchers.withText -import android.support.test.filters.MediumTest -import android.support.test.rule.ActivityTestRule -import android.support.test.runner.AndroidJUnit4 import android.view.View +import androidx.test.espresso.DataInteraction +import androidx.test.espresso.Espresso.onData +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.ViewAssertion +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.matcher.ViewMatchers.withId +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.colorpicker.CircleView import org.hamcrest.Matchers.anything import org.junit.Rule @@ -19,9 +34,10 @@ import org.junit.runner.RunWith import kotlin.test.assertEquals import kotlin.test.fail - /** * Created by Allan Wang on 22/02/2018. + * + * Tests related to the :colorpicker module */ @RunWith(AndroidJUnit4::class) @MediumTest @@ -31,11 +47,15 @@ class ColorPickerTest { val activity: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) private fun DataInteraction.click(position: Int) = - atPosition(position).perform(click()) + atPosition(position).perform(click()) private fun View.colorSelected(selected: Boolean) { val circle = this as? CircleView ?: fail("View is not a CircleView") - assertEquals(selected, circle.colorSelected, "CircleView ${circle.tag} ${if (selected) "is not" else "is"} actually selected") + assertEquals( + selected, + circle.colorSelected, + "CircleView ${circle.tag} ${if (selected) "is not" else "is"} actually selected" + ) } private val colorSelected = ViewAssertion { view, _ -> view.colorSelected(true) } @@ -43,7 +63,7 @@ class ColorPickerTest { private val colorNotSelected = ViewAssertion { view, _ -> view.colorSelected(false) } @Test - fun test() { + fun colorClick() { onView(withText(R.string.accent_color)).perform(click()) val colors = onData(anything()).inAdapterView(withId(R.id.md_grid)) @@ -51,11 +71,9 @@ class ColorPickerTest { colors.click(0).check(colorSelected) // click first grid item colors.atPosition(1).check(colorNotSelected) colors.atPosition(2).check(colorNotSelected) - .perform(click()).check(colorSelected) + .perform(click()).check(colorSelected) colors.atPosition(0).check(colorNotSelected) - .perform(click()).check(colorSelected) + .perform(click()).check(colorSelected) // first item is now selected } - - } diff --git a/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt new file mode 100644 index 0000000..72199cf --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt @@ -0,0 +1,129 @@ +/* + * Copyright 2018 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.view.View +import android.widget.CheckBox +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.ViewInteraction +import androidx.test.espresso.action.ViewActions.click +import androidx.test.espresso.assertion.ViewAssertions.matches +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 org.hamcrest.BaseMatcher +import org.hamcrest.Description +import org.hamcrest.Matcher +import org.hamcrest.Matchers.allOf +import org.hamcrest.Matchers.instanceOf +import org.junit.Rule +import org.junit.Test +import org.junit.runner.RunWith + +/** + * Created by Allan Wang on 21/12/2018. + * + * Tests related to the :kpref-activity module + */ +@RunWith(AndroidJUnit4::class) +@MediumTest +class KPrefViewTest { + + @get:Rule + val activity: ActivityTestRule<MainActivity> = ActivityTestRule(MainActivity::class.java) + + fun verifyCheck(checked: Boolean): Matcher<View> { + return object : BoundedMatcher<View, View>(View::class.java) { + + override fun describeTo(description: Description) { + description.appendText("Checkbox is ${if (checked) "checked" else "not checked"}") + } + + override fun matchesSafely(item: View): Boolean = + item.findViewById<CheckBox>(R.id.kau_pref_inner_content).isChecked == checked + } + } + + inline fun <reified T : View> ViewInteraction.checkInnerContent( + desc: String, + crossinline matcher: (T) -> Boolean + ): ViewInteraction { + val viewMatcher = object : BaseMatcher<View>() { + override fun describeTo(description: Description) { + description.appendText(desc) + } + + override fun matches(item: Any?): Boolean { + val view = item as? View ?: return false + val inner = view.findViewById<View>(R.id.kau_pref_inner_content) as? T + ?: return false + return matcher(inner) + } + } + return check(matches(viewMatcher)) + } + + fun ViewInteraction.verifyCheck(tag: String, checked: Boolean, enabled: Boolean = true) = + checkInnerContent<CheckBox>("$tag should be ${if (checked) "checked" else "not checked"}") { + it.isChecked == checked + }.check { view, _ -> + ((view.alpha == 1f) == enabled) + } + + fun onCheckboxView(vararg matchers: Matcher<View>) = + onView(allOf(*matchers, withChild(withChild(instanceOf(CheckBox::class.java))))) + + @Test + fun basicCheckboxToggle() { + val checkbox1 = onCheckboxView(withChild(withText(R.string.checkbox_1))) + + val initiallyChecked = KPrefSample.check1 + + checkbox1.verifyCheck("checkbox1 init", initiallyChecked) + checkbox1.perform(click()) + checkbox1.verifyCheck("checkbox1 after click", !initiallyChecked) + } + + /** + * Note that checkbox3 depends on checkbox2 + */ + @Test + 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))) + + // normalize so that both are checked + if (!KPrefSample.check2) + checkbox2.perform(click()) + if (!KPrefSample.check3) + checkbox3.perform(click()) + + checkbox3.verifyCheck("checkbox3 init", true, true) + checkbox3.perform(click()) + checkbox3.verifyCheck("checkbox3 after click", false, true) + + checkbox2.perform(click()) + checkbox2.verifyCheck("checkbox2 after click", false, true) + checkbox3.verifyCheck("checkbox3 after checkbox2 click", false, false) + + checkbox3.perform(click()) + checkbox3.verifyCheck("checkbox3 after disabled click", false, false) + } +} 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 new file mode 100644 index 0000000..09ad00a --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt @@ -0,0 +1,37 @@ +/* + * Copyright 2018 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.utils + +import org.hamcrest.BaseMatcher +import org.hamcrest.Description +import org.hamcrest.Matcher + +fun <T> index(index: Int, matcher: Matcher<T>): Matcher<T> = + object : BaseMatcher<T>() { + + var current = 0 + + override fun describeTo(description: Description) { + description.appendText("Should return item at index $index") + } + + override fun matches(item: Any?): Boolean { + println("AA") + return matcher.matches(item) && current++ == index + } + } + +fun <T> first(matcher: Matcher<T>): Matcher<T> = index(0, matcher) diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml index d8bbe51..5846c6b 100644 --- a/sample/src/main/AndroidManifest.xml +++ b/sample/src/main/AndroidManifest.xml @@ -49,7 +49,7 @@ android:theme="@style/Kau.Translucent.SlideBottom" /> <provider - android:name="android.support.v4.content.FileProvider" + android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> 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 78f31ae..928070e 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AboutActivity.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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 ca.allanwang.kau.about.AboutActivityBase @@ -24,4 +39,4 @@ class AboutActivity : AboutActivityBase(R.string::class.java, { descRes = R.string.about_kau }) } -}
\ No newline at end of file +} diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt index ada60ca..a11a672 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AdapterActivity.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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.os.Bundle @@ -17,7 +32,8 @@ class AdapterActivity : ElasticRecyclerActivity() { override fun onCreate(savedInstanceState: Bundle?, configs: Configs): Boolean { val adapter = ItemAdapter<IItem<*, *>>() recycler.adapter = fastAdapter(adapter) - adapter.add(listOf( + adapter.add( + listOf( CardIItem { titleRes = R.string.kau_text_copied descRes = R.string.kau_lorem_ipsum @@ -43,8 +59,9 @@ class AdapterActivity : ElasticRecyclerActivity() { titleRes = R.string.kau_text_copied button = "Test" buttonClick = { toast("HI") } - })) + }) + ) setOutsideTapListener { finishAfterTransition() } return true } -}
\ No newline at end of file +} 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 c0f928f..349e3d1 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/AnimActivity.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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.os.Bundle @@ -10,7 +25,11 @@ import ca.allanwang.kau.permissions.kauRequestPermissions import ca.allanwang.kau.swipe.SWIPE_EDGE_LEFT import ca.allanwang.kau.swipe.kauSwipeOnCreate import ca.allanwang.kau.swipe.kauSwipeOnDestroy -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.utils.fullLinearRecycler +import ca.allanwang.kau.utils.startActivity +import ca.allanwang.kau.utils.toast +import ca.allanwang.kau.utils.withAlpha +import ca.allanwang.kau.utils.withSlideOut import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter /** @@ -27,9 +46,9 @@ class AnimActivity : KauBaseActivity() { setContentView(fullLinearRecycler(adapter).apply { setBackgroundColor(KPrefSample.bgColor.withAlpha(255)) }) adapter.add(listOf( - PERMISSION_ACCESS_COARSE_LOCATION, - PERMISSION_ACCESS_FINE_LOCATION, - PERMISSION_CAMERA + PERMISSION_ACCESS_COARSE_LOCATION, + PERMISSION_ACCESS_FINE_LOCATION, + PERMISSION_CAMERA ).map { PermissionCheckbox(it) }) adapter.withOnClickListener { _, _, item, _ -> KL.d { "Perm Click" } @@ -54,5 +73,4 @@ class AnimActivity : KauBaseActivity() { withSlideOut(this@AnimActivity) }) } - -}
\ No newline at end of file +} 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 0c243e4..0f20880 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/KPrefSample.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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.graphics.Color @@ -8,7 +23,7 @@ import ca.allanwang.kau.kpref.kpref * Created by Allan Wang on 2017-06-07. */ object KPrefSample : KPref() { - var version: Int by kpref("version", -1) + 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()) var bgColor: Int by kpref("BG_COLOR", 0xff303030.toInt()) @@ -19,5 +34,4 @@ object KPrefSample : KPref() { var seekbar: Int by kpref("seekbar", 20) var time12: Int by kpref("time_12", 315) var time24: Int by kpref("time_24", 2220) - -}
\ No newline at end of file +} 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 6cd9776..d9586c4 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MainActivity.kt @@ -1,11 +1,25 @@ +/* + * Copyright 2018 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.content.Context import android.content.Intent import android.os.Bundle import android.view.Menu import android.view.MenuItem -import ca.allanwang.kau.about.AboutActivityBase +import ca.allanwang.kau.about.kauLaunchAbout import ca.allanwang.kau.email.sendEmail import ca.allanwang.kau.kpref.activity.CoreAttributeContract import ca.allanwang.kau.kpref.activity.KPrefActivity @@ -17,11 +31,16 @@ import ca.allanwang.kau.searchview.SearchView import ca.allanwang.kau.searchview.bindSearchView import ca.allanwang.kau.swipe.SWIPE_EDGE_LEFT import ca.allanwang.kau.ui.views.RippleCanvas -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.utils.materialDialog +import ca.allanwang.kau.utils.navigationBarColor +import ca.allanwang.kau.utils.startActivity +import ca.allanwang.kau.utils.string +import ca.allanwang.kau.utils.toast +import ca.allanwang.kau.utils.withSceneTransitionAnimation import ca.allanwang.kau.xml.showChangelog +import com.afollestad.materialdialogs.input.input import com.mikepenz.google_material_typeface_library.GoogleMaterial - class MainActivity : KPrefActivity() { var searchView: SearchView? = null @@ -30,51 +49,53 @@ 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") + 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" + ) } const val REQUEST_MEDIA = 27 @@ -93,14 +114,17 @@ 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 }, - builder = { - descRes = R.string.desc - }) + builder = { + descRes = R.string.desc + }) /** * Since we know the order, we may omit the tags */ - checkbox(R.string.checkbox_2, KPrefSample::check2, { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) + checkbox( + R.string.checkbox_2, + KPrefSample::check2, + { KPrefSample.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: @@ -139,11 +163,11 @@ class MainActivity : KPrefActivity() { descRes = R.string.text_desc onClick = { itemView.context.materialDialog { - title("Type Text") - input("Type here", item.pref, { _, input -> item.pref = input.toString() }) - inputRange(0, 20) + title(text = "Type Text") + input("Type here", prefill = item.pref, maxLength = 20, allowEmpty = true) { _, input -> + item.pref = input.toString() + } } - } } @@ -189,7 +213,10 @@ class MainActivity : KPrefActivity() { * Showcases a little trick. The id for reloading is [R.string.checkbox_2], * but the title displayed is still [R.string.checkbox_3] */ - checkbox(R.string.checkbox_2, KPrefSample::check2, { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) { + checkbox( + R.string.checkbox_2, + KPrefSample::check2, + { KPrefSample.check2 = it; reloadByTitle(R.string.checkbox_3) }) { titleFun = { R.string.checkbox_3 } descRes = R.string.kau_lorem_ipsum } @@ -208,7 +235,6 @@ class MainActivity : KPrefActivity() { descRes = R.string.time_desc_24 use24HourFormat = true } - } fun subPrefs(): KPrefAdapterBuilder.() -> Unit = { @@ -216,12 +242,11 @@ class MainActivity : KPrefActivity() { descRes = R.string.text_desc onClick = { itemView.context.materialDialog { - title("Type Text") - input("Type here", item.pref, { _, input -> + title(text = "Type Text") + input("Type here", prefill = item.pref, maxLength = 20, allowEmpty = true) { _, input -> item.pref = input.toString() reloadSelf() - }) - inputRange(0, 20) + } } } } @@ -236,9 +261,10 @@ class MainActivity : KPrefActivity() { KPrefSample.version = BuildConfig.VERSION_CODE if (!BuildConfig.DEBUG) showChangelog(R.xml.kau_changelog, KPrefSample.textColor) { - titleColor(KPrefSample.textColor) - backgroundColor(KPrefSample.bgColor) - positiveColor(KPrefSample.accentColor) + // TODO MD Color +// titleColor(KPrefSample.textColor) +// backgroundColor(KPrefSample.bgColor) +// positiveColor(KPrefSample.accentColor) } } supportActionBar?.apply { @@ -273,9 +299,10 @@ class MainActivity : KPrefActivity() { override fun onOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.action_changelog -> showChangelog(R.xml.kau_changelog, KPrefSample.textColor) { - titleColor(KPrefSample.textColor) - backgroundColor(KPrefSample.bgColor) - positiveColor(KPrefSample.accentColor) + // TODO MD Color +// titleColor(KPrefSample.textColor) +// backgroundColor(KPrefSample.bgColor) +// positiveColor(KPrefSample.accentColor) } R.id.action_settings -> startActivity<AnimActivity>() R.id.action_email -> sendEmail(R.string.your_email, R.string.your_subject) @@ -295,8 +322,3 @@ class MainActivity : KPrefActivity() { } } } - -inline fun <reified T : AboutActivityBase> Context.kauLaunchAbout() = - startActivity<T>(bundleBuilder = { - withSceneTransitionAnimation(this@kauLaunchAbout) - })
\ No newline at end of file diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt index 42de62c..0e6b22f 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt @@ -1,9 +1,29 @@ +/* + * Copyright 2018 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.content.Context import android.net.Uri -import android.support.v4.content.FileProvider -import ca.allanwang.kau.mediapicker.* +import androidx.core.content.FileProvider +import ca.allanwang.kau.mediapicker.MediaActionCamera +import ca.allanwang.kau.mediapicker.MediaActionGallery +import ca.allanwang.kau.mediapicker.MediaPickerActivityBase +import ca.allanwang.kau.mediapicker.MediaPickerActivityOverlayBase +import ca.allanwang.kau.mediapicker.MediaType +import ca.allanwang.kau.mediapicker.createMediaFile import java.io.File /** @@ -13,8 +33,8 @@ private fun actions(multiple: Boolean) = listOf(object : MediaActionCamera() { override fun createFile(context: Context): File = createMediaFile("KAU", ".jpg") - override fun createUri(context: Context, file: File): Uri = FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file) - + override fun createUri(context: Context, file: File): Uri = + FileProvider.getUriForFile(context, BuildConfig.APPLICATION_ID + ".provider", file) }, MediaActionGallery(multiple)) class ImagePickerActivity : MediaPickerActivityBase(MediaType.IMAGE, actions(true)) @@ -23,4 +43,4 @@ class ImagePickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.IMAG class VideoPickerActivity : MediaPickerActivityBase(MediaType.VIDEO, actions(true)) -class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO, actions(false))
\ No newline at end of file +class VideoPickerActivityOverlay : MediaPickerActivityOverlayBase(MediaType.VIDEO, actions(false)) 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 beb1a29..025179d 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt @@ -1,9 +1,24 @@ +/* + * Copyright 2018 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.support.v7.widget.RecyclerView import android.view.View import android.widget.CheckBox import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.iitems.KauIItem import ca.allanwang.kau.utils.hasPermission @@ -11,7 +26,7 @@ import ca.allanwang.kau.utils.hasPermission * Created by Allan Wang on 2017-07-03. */ class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox, PermissionCheckbox.ViewHolder>( - R.layout.permission_checkbox, { ViewHolder(it) }) { + R.layout.permission_checkbox, { ViewHolder(it) }) { override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) { super.bindView(holder, payloads) @@ -25,4 +40,4 @@ class PermissionCheckbox(val permission: String) : KauIItem<PermissionCheckbox, val text: TextView = v.findViewById(R.id.perm_text) val checkbox: CheckBox = v.findViewById(R.id.perm_checkbox) } -}
\ No newline at end of file +} 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 6060245..6e6d718 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SampleApp.kt @@ -1,3 +1,18 @@ +/* + * Copyright 2018 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 @@ -10,4 +25,4 @@ class SampleApp : Application() { super.onCreate() KPrefSample.initialize(this, "pref_sample") } -}
\ No newline at end of file +} diff --git a/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt index 4197b6d..5107e18 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/SwipeActivity.kt @@ -1,10 +1,35 @@ +/* + * Copyright 2018 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.Activity import android.os.Bundle import ca.allanwang.kau.internal.KauBaseActivity -import ca.allanwang.kau.swipe.* -import ca.allanwang.kau.utils.* +import ca.allanwang.kau.swipe.SWIPE_EDGE_BOTTOM +import ca.allanwang.kau.swipe.SWIPE_EDGE_LEFT +import ca.allanwang.kau.swipe.SWIPE_EDGE_RIGHT +import ca.allanwang.kau.swipe.SWIPE_EDGE_TOP +import ca.allanwang.kau.swipe.kauSwipeFinish +import ca.allanwang.kau.swipe.kauSwipeOnCreate +import ca.allanwang.kau.swipe.kauSwipeOnDestroy +import ca.allanwang.kau.utils.darken +import ca.allanwang.kau.utils.navigationBarColor +import ca.allanwang.kau.utils.rndColor +import ca.allanwang.kau.utils.startActivity +import ca.allanwang.kau.utils.statusBarColor import kotlinx.android.synthetic.main.activity_swipe.* /** @@ -24,8 +49,8 @@ class SwipeActivity : KauBaseActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_swipe) listOf(swipe_from_left, swipe_from_right, swipe_from_top, swipe_from_bottom) - .zip(listOf(SWIPE_EDGE_LEFT, SWIPE_EDGE_RIGHT, SWIPE_EDGE_TOP, SWIPE_EDGE_BOTTOM)) - .forEach { (button, edge) -> button.setOnClickListener { startActivityWithEdge(edge) } } + .zip(listOf(SWIPE_EDGE_LEFT, SWIPE_EDGE_RIGHT, SWIPE_EDGE_TOP, SWIPE_EDGE_BOTTOM)) + .forEach { (button, edge) -> button.setOnClickListener { startActivityWithEdge(edge) } } val flag = intent.getIntExtra(SWIPE_EDGE, -1) swipe_toolbar.title = when (flag) { SWIPE_EDGE_LEFT -> "Left Edge Swipe" @@ -54,4 +79,4 @@ class SwipeActivity : KauBaseActivity() { override fun onBackPressed() { kauSwipeFinish() } -}
\ No newline at end of file +} diff --git a/sample/src/main/res/layout/activity_swipe.xml b/sample/src/main/res/layout/activity_swipe.xml index c65bebc..dd52325 100644 --- a/sample/src/main/res/layout/activity_swipe.xml +++ b/sample/src/main/res/layout/activity_swipe.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/swipe_container" @@ -8,7 +8,7 @@ tools:context=".SwipeActivity" tools:ignore="HardcodedText"> - <android.support.v7.widget.Toolbar + <androidx.appcompat.widget.Toolbar android:id="@+id/swipe_toolbar" android:layout_width="0dp" android:layout_height="?attr/actionBarSize" @@ -71,4 +71,4 @@ app:layout_constraintVertical_bias="0.75" /> -</android.support.constraint.ConstraintLayout>
\ No newline at end of file +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/sample/src/main/res/xml/kau_changelog.xml b/sample/src/main/res/xml/kau_changelog.xml index f6ec799..53265d0 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -6,6 +6,36 @@ <item text="" /> --> + <version title="v5.0.0" /> + <item text=":core: Update Material Dialogs to 3.x" /> + <item text=":colorpicker: Strip down to just the interface; unless you require the accent palette, it may be fine to just use MD's color extension" /> + <item text="" /> + <item text="" /> + <item text="" /> + <item text="" /> + + <version title="v4.1.0" /> + <item text=":core: Deprecate NetworkUtils, as the underlying functions are deprecated" /> + <item text=":core: Permission manager no longer synchronized, as all actions should occur in the main thread" /> + <item text=":kpref-activity: Getter and setter now have action context, with the option to reload self" /> + <item text="" /> + + <version title="v4.0.0" /> + <item text="Update translations" /> + + <version title="v4.0.0-alpha02" /> + <item text="Update translations" /> + <item text=":core: Remove anko dependency. Methods that used it now use coroutines; see the migration doc for minor changes" /> + <item text=":core: Add default CoroutineScope implementation to KauBaseActivity" /> + <item text=":core: Remove zip class. Coroutines and join can be used as an alternative" /> + <item text=":core: Delete flyweight implementation. Kotlin already has getOrPut" /> + <item text=":core: Introduce ContextHelper, where you can get the default looper, handler, and dispatcher for Android" /> + <item text=":mediapicker: Use video preloading instead of full async loading" /> + + <version title="v4.0.0-alpha01" /> + <item text="Migrate to androidx. See migration for external dependency changes." /> + <item text=":core: Remove deprecation warning for Kotterknife" /> + <version title="v3.8.0" /> <item text="Update everything to Android Studio 3.1" /> <item text="Fix new lint issues (see Migration for resource related methods)" /> @@ -13,7 +43,6 @@ <item text=":core: Deprecate Kotterknife; use kotlin_android_extensions" /> <item text=":kpref-activity: Fix seekbar increment" /> <item text=":core: Make KPref use Set<String> vs StringSet" /> - <item text="" /> <version title="v3.7.1" /> <item text="Update appcompat to 27.1.0" /> |