diff options
author | Allan Wang <me@allanwang.ca> | 2018-12-24 00:27:25 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-24 00:27:25 -0500 |
commit | a380adea1052d39f23c9c4d432a9380ce347d6c4 (patch) | |
tree | cdbb6835cdc3c04df24af2323341d765f64ab2e3 | |
parent | 98a7f378399546086e23e25514b705e037068058 (diff) | |
download | kau-a380adea1052d39f23c9c4d432a9380ce347d6c4.tar.gz kau-a380adea1052d39f23c9c4d432a9380ce347d6c4.tar.bz2 kau-a380adea1052d39f23c9c4d432a9380ce347d6c4.zip |
Migrate to androidx (#178)
* Initial refactor
* Remove alpha version usages
* Update test code
* Add tests for checkbox
* Fix invalid card import
* Remove more old support content
* Update kotlin version
* Add back kotterknife with new imports
* Update docs
* Use bold notice
* Add changelog
* Remove deprecation for kotterknife
* Remove unused dependencies
* Update changelog
108 files changed, 496 insertions, 365 deletions
@@ -1,4 +1,4 @@ -### I will be migrating this project to androidx during the winter break (Dec 20 2018 - Jan 10 2019), as well as making a bunch of other changes. Stay tuned! +**Note: v3.8.0 is the last release with support dependencies. Starting with 4.0.0-alpha01, androidx will be used** --- diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt index f4ee4c5..9667f47 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutActivityBase.kt @@ -2,12 +2,12 @@ package ca.allanwang.kau.about import android.graphics.drawable.Drawable import android.os.Bundle -import android.support.v4.view.PagerAdapter -import android.support.v4.view.ViewPager import android.transition.TransitionInflater import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.viewpager.widget.PagerAdapter +import androidx.viewpager.widget.ViewPager import ca.allanwang.kau.adapters.FastItemThemedAdapter import ca.allanwang.kau.adapters.ThemableIItemColors import ca.allanwang.kau.adapters.ThemableIItemColorsDelegate diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt index b6ea16b..6698dba 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/AboutPanelDelegate.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.about -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt index f010321..3dbb87e 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CollapsibleTextView.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.about import android.content.Context import android.content.res.Configuration -import android.support.v7.widget.AppCompatTextView +import androidx.appcompat.widget.AppCompatTextView import android.util.AttributeSet import ca.allanwang.kau.ui.views.CollapsibleView import ca.allanwang.kau.ui.views.CollapsibleViewDelegate diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt index 37c13d8..630a48e 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/CutoutIItem.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.about -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import ca.allanwang.kau.adapters.ThemableIItem import ca.allanwang.kau.adapters.ThemableIItemDelegate diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt index 5cf046e..5f5d0c6 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/FaqIItem.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.about import android.annotation.SuppressLint -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.text.method.LinkMovementMethod import android.view.View import android.view.ViewGroup diff --git a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt index 2749c28..e1e9a76 100644 --- a/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt +++ b/about/src/main/kotlin/ca/allanwang/kau/about/LibraryIItem.kt @@ -1,11 +1,11 @@ package ca.allanwang.kau.about import android.os.Build -import android.support.v7.widget.CardView -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.text.Html import android.view.View import android.widget.TextView +import androidx.cardview.widget.CardView import ca.allanwang.kau.adapters.ThemableIItem import ca.allanwang.kau.adapters.ThemableIItemDelegate import ca.allanwang.kau.iitems.KauIItem diff --git a/about/src/main/res/layout/kau_about_section_libraries.xml b/about/src/main/res/layout/kau_about_section_libraries.xml index c14225e..60d1312 100644 --- a/about/src/main/res/layout/kau_about_section_libraries.xml +++ b/about/src/main/res/layout/kau_about_section_libraries.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" android:id="@+id/about_library_container" android:layout_width="match_parent" @@ -15,7 +15,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/about_library_recycler" android:layout_width="0dp" android:layout_height="0dp" @@ -24,4 +24,4 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/about_library_title" /> -</android.support.constraint.ConstraintLayout> +</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/about/src/main/res/layout/kau_about_section_main.xml b/about/src/main/res/layout/kau_about_section_main.xml index e7b83a0..7ea0415 100644 --- a/about/src/main/res/layout/kau_about_section_main.xml +++ b/about/src/main/res/layout/kau_about_section_main.xml @@ -1,12 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.core.widget.NestedScrollView 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:layout_width="match_parent" android:layout_height="match_parent" tools:showIn="@layout/kau_activity_about"> - <android.support.constraint.ConstraintLayout + <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/about_main_container" android:layout_width="match_parent" android:layout_height="wrap_content"> @@ -41,6 +41,6 @@ </FrameLayout> - </android.support.constraint.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> -</android.support.v4.widget.NestedScrollView> +</androidx.core.widget.NestedScrollView> diff --git a/about/src/main/res/layout/kau_activity_about.xml b/about/src/main/res/layout/kau_activity_about.xml index 3d1f9ab..626adda 100644 --- a/about/src/main/res/layout/kau_activity_about.xml +++ b/about/src/main/res/layout/kau_activity_about.xml @@ -9,7 +9,7 @@ app:dragDismissScale="0.95" tools:context=".ui.about.AboutActivityBase"> - <android.support.v4.view.ViewPager + <androidx.viewpager.widget.ViewPager android:id="@+id/about_pager" android:layout_width="match_parent" android:layout_height="match_parent" /> diff --git a/about/src/main/res/layout/kau_iitem_library.xml b/about/src/main/res/layout/kau_iitem_library.xml index 47b4e01..4dd5155 100644 --- a/about/src/main/res/layout/kau_iitem_library.xml +++ b/about/src/main/res/layout/kau_iitem_library.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.cardview.widget.CardView 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/lib_item_card" @@ -8,7 +8,7 @@ android:clickable="true" android:focusable="true"> - <android.support.constraint.ConstraintLayout + <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingBottom="@dimen/kau_padding_normal" @@ -112,6 +112,6 @@ app:layout_constraintTop_toBottomOf="@id/lib_item_bottom_divider" tools:text="License" /> - </android.support.constraint.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> -</android.support.v7.widget.CardView>
\ No newline at end of file +</androidx.cardview.widget.CardView>
\ No newline at end of file diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt index 870861d..75cf876 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/FastItemThemedAdapter.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.adapters import android.content.res.ColorStateList import android.os.Build -import android.support.annotation.RequiresApi +import androidx.annotation.RequiresApi import android.view.View import android.widget.ImageView import android.widget.TextView diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt index aeee94c..a23ac37 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/adapters/RepeatedClickListener.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.adapters -import android.support.annotation.IntRange +import androidx.annotation.IntRange import android.view.View import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.IAdapter diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt index 3cf13df..15c3b41 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/AnimatorInterfaces.kt @@ -1,8 +1,8 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView import android.view.View import android.view.ViewPropertyAnimator +import androidx.recyclerview.widget.RecyclerView /** * Created by Allan Wang on 2017-07-11. diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/BaseItemAnimator.java b/adapter/src/main/kotlin/ca/allanwang/kau/animators/BaseItemAnimator.java index 06b8df6..4ead735 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/BaseItemAnimator.java +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/BaseItemAnimator.java @@ -26,10 +26,11 @@ import android.animation.Animator; import android.animation.AnimatorListenerAdapter; import android.animation.TimeInterpolator; import android.animation.ValueAnimator; -import android.support.annotation.NonNull; -import android.support.v4.view.ViewCompat; -import android.support.v7.widget.RecyclerView.ViewHolder; -import android.support.v7.widget.SimpleItemAnimator; +import androidx.annotation.NonNull; +import androidx.core.view.ViewCompat; +import androidx.recyclerview.widget.RecyclerView.ViewHolder; +import androidx.recyclerview.widget.SimpleItemAnimator; + import android.view.View; import android.view.ViewPropertyAnimator; import android.view.animation.Interpolator; @@ -38,11 +39,11 @@ import java.util.ArrayList; import java.util.List; /** - * This implementation of {@link android.support.v7.widget.RecyclerView.ItemAnimator} provides basic + * This implementation of {@link androidx.recyclerview.widget.RecyclerView.ItemAnimator} provides basic * animations on remove, add, and move events that happen to the items in * a RecyclerView. RecyclerView uses a DefaultItemAnimator by default. * - * @see android.support.v7.widget.RecyclerView#setItemAnimator(android.support.v7.widget.RecyclerView.ItemAnimator) + * @see androidx.recyclerview.widget.RecyclerView#setItemAnimator(androidx.recyclerview.widget.RecyclerView.ItemAnimator) */ public abstract class BaseItemAnimator extends SimpleItemAnimator { private static final boolean DEBUG = false; diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt index 9aeafde..f2b6353 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/DefaultAnimator.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView import android.view.ViewPropertyAnimator +import androidx.recyclerview.widget.RecyclerView /** * Created by Allan Wang on 2017-06-27. diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt index bf38cac..dec5f79 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/FadeScaleAnimator.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.view.ViewPropertyAnimator import ca.allanwang.kau.utils.scaleXY diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt index 7b9b732..a088273 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/KauAnimator.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.ViewPropertyAnimator import ca.allanwang.kau.utils.KAU_BOTTOM import ca.allanwang.kau.utils.KAU_RIGHT diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt index 5ecc937..ea0c123 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/NoAnimator.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.view.ViewPropertyAnimator diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt b/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt index f8f71a5..01ad1ff 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/animators/SlideAnimator.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.animators -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.view.ViewPropertyAnimator import ca.allanwang.kau.utils.KAU_BOTTOM diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt index ba969a2..784dd3c 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/CardIItem.kt @@ -2,13 +2,13 @@ package ca.allanwang.kau.iitems import android.graphics.Color import android.graphics.drawable.Drawable -import android.support.v7.widget.CardView -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.widget.Button import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView +import androidx.cardview.widget.CardView import ca.allanwang.kau.adapter.R import ca.allanwang.kau.adapters.ThemableIItem import ca.allanwang.kau.adapters.ThemableIItemDelegate diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt index 2116b34..098f017 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt @@ -1,9 +1,9 @@ package ca.allanwang.kau.iitems -import android.support.v7.widget.CardView -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.widget.TextView +import androidx.cardview.widget.CardView import ca.allanwang.kau.adapter.R import ca.allanwang.kau.adapters.ThemableIItem import ca.allanwang.kau.adapters.ThemableIItemDelegate diff --git a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt index 5174503..205d388 100644 --- a/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt +++ b/adapter/src/main/kotlin/ca/allanwang/kau/iitems/KauIItem.kt @@ -1,8 +1,8 @@ package ca.allanwang.kau.iitems import android.annotation.SuppressLint -import android.support.annotation.LayoutRes -import android.support.v7.widget.RecyclerView +import androidx.annotation.LayoutRes +import androidx.recyclerview.widget.RecyclerView import android.view.View import com.mikepenz.fastadapter.IClickable import com.mikepenz.fastadapter.IItem diff --git a/adapter/src/main/res/layout/kau_iitem_card.xml b/adapter/src/main/res/layout/kau_iitem_card.xml index 249f3b8..6bae0fe 100644 --- a/adapter/src/main/res/layout/kau_iitem_card.xml +++ b/adapter/src/main/res/layout/kau_iitem_card.xml @@ -3,7 +3,7 @@ <!-- Generic card with an imageview, title, description, and button --> -<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/kau_card_container" android:layout_width="match_parent" @@ -11,7 +11,7 @@ android:background="?android:selectableItemBackground" android:minHeight="?android:listPreferredItemHeight"> - <android.support.constraint.ConstraintLayout + <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/kau_padding_normal"> @@ -69,6 +69,6 @@ </LinearLayout> - </android.support.constraint.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> -</android.support.v7.widget.CardView> +</androidx.cardview.widget.CardView> diff --git a/adapter/src/main/res/layout/kau_iitem_header.xml b/adapter/src/main/res/layout/kau_iitem_header.xml index db809eb..b0b2ec8 100644 --- a/adapter/src/main/res/layout/kau_iitem_header.xml +++ b/adapter/src/main/res/layout/kau_iitem_header.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/kau_header_container" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -13,4 +13,4 @@ android:padding="@dimen/kau_padding_normal" android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> -</android.support.v7.widget.CardView>
\ No newline at end of file +</androidx.cardview.widget.CardView>
\ No newline at end of file diff --git a/android-lib.gradle b/android-lib.gradle index 7275347..e8a4c6d 100644 --- a/android-lib.gradle +++ b/android-lib.gradle @@ -31,7 +31,7 @@ android { versionCode androidGitVersion.code() consumerProguardFiles 'progress-proguard.txt' multiDexEnabled true - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { @@ -87,5 +87,6 @@ dependencies { androidTestImplementation kauDependency.kotlinTest androidTestImplementation kauDependency.espresso + androidTestImplementation kauDependency.testRules androidTestImplementation kauDependency.testRunner }
\ No newline at end of file diff --git a/buildSrc/README.md b/buildSrc/README.md index 60d2dfc..91a60ac 100644 --- a/buildSrc/README.md +++ b/buildSrc/README.md @@ -48,7 +48,7 @@ You are free to use the values through `kau.[tagName]`. As an example, AppCompat is imported in KAU using ```gradle -api "com.android.support:appcompat-v7:${kau.supportLibs}" +api "androidx.appcompat:appcompat:${kau.appcompat}" ``` # Plugins diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy index ec3d208..a27e503 100644 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy +++ b/buildSrc/src/main/groovy/ca/allanwang/kau/Dependencies.groovy @@ -7,6 +7,7 @@ class Dependencies { static def kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin}" static def kotlinTest = "org.jetbrains.kotlin:kotlin-test-junit:${Versions.kotlin}" static def junit = "junit:junit:${Versions.junit}" - static def espresso = "com.android.support.test.espresso:espresso-core:${Versions.espresso}" - static def testRunner = "com.android.support.test:runner:${Versions.testRunner}" + static def espresso = "androidx.test.espresso:espresso-core:${Versions.espresso}" + static def testRunner = "androidx.test.ext:junit:${Versions.testRunner}" + static def testRules = "androidx.test:rules:${Versions.testRules}" }
\ No newline at end of file diff --git a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy index 55fc646..637ae68 100644 --- a/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy +++ b/buildSrc/src/main/groovy/ca/allanwang/kau/Versions.groovy @@ -8,14 +8,26 @@ class Versions { // https://developer.android.com/studio/releases/build-tools static def buildTools = '28.0.3' - // https://developer.android.com/topic/libraries/support-library/revisions - static def supportLibs = '28.0.0' + // https://mvnrepository.com/artifact/androidx.appcompat/appcompat?repo=google + static def appcompat = '1.0.2' + + // https://mvnrepository.com/artifact/com.google.android.material/material + static def googleMaterial = '1.0.0' + + // https://mvnrepository.com/artifact/androidx.recyclerview/recyclerview + static def recyclerView = '1.0.0' + + // https://mvnrepository.com/artifact/androidx.cardview/cardview + static def cardView = '1.0.0' + + // https://mvnrepository.com/artifact/androidx.constraintlayout/constraintlayout + static def constraintLayout = '1.1.3' // https://kotlinlang.org/docs/reference/using-gradle.html - static def kotlin = '1.2.71' + static def kotlin = '1.3.11' // https://github.com/mikepenz/AboutLibraries/releases - static def aboutLibraries = '6.1.1' + static def aboutLibraries = '6.2.0' // https://github.com/Kotlin/anko/releases static def anko = '0.10.5' @@ -23,29 +35,35 @@ class Versions { // https://github.com/wasabeef/Blurry/releases static def blurry = '2.1.1' - // https://dl.google.com/dl/android/maven2/com/android/support/constraint/group-index.xml - static def constraintLayout = '1.1.3' - // https://github.com/mikepenz/FastAdapter#using-maven - static def fastAdapter = '3.2.9' + static def fastAdapter = '3.3.1' static def fastAdapterCommons = fastAdapter // https://github.com/bumptech/glide/releases static def glide = '4.8.0' // https://github.com/mikepenz/Android-Iconics#1-provide-the-gradle-dependency - static def iconics = '3.0.4' - static def iconicsGoogle = '3.0.1.2' - static def iconicsMaterial = '2.2.0.4' - static def iconicsCommunity = '2.0.46.1' + static def iconics = '3.1.0' + static def iconicsGoogle = '3.0.1.3' + static def iconicsMaterial = '2.2.0.5' + static def iconicsCommunity = '2.7.94.1' // https://github.com/afollestad/material-dialogs/releases static def materialDialog = '0.9.6.0' - static def espresso = '3.0.1' + // https://mvnrepository.com/artifact/androidx.test.espresso/espresso-core?repo=google + static def espresso = '3.1.1' + + // https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api static def junit = '4.12' - static def testRunner = '1.0.1' + + static def testRunner = '1.1.0' + + // https://mvnrepository.com/artifact/androidx.test/rules?repo=google + static def testRules = '1.1.1' + + // https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google static def gradlePlugin = '3.2.1' static def mavenPlugin = '2.1' static def playPublishPlugin = '1.2.2' diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt index 310fd53..bdd6eed 100644 --- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt +++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/CircleView.kt @@ -13,11 +13,11 @@ import android.graphics.drawable.ShapeDrawable import android.graphics.drawable.StateListDrawable import android.graphics.drawable.shapes.OvalShape import android.os.Build -import android.support.annotation.ColorInt -import android.support.annotation.ColorRes -import android.support.annotation.FloatRange -import android.support.v4.view.GravityCompat -import android.support.v4.view.ViewCompat +import androidx.annotation.ColorInt +import androidx.annotation.ColorRes +import androidx.annotation.FloatRange +import androidx.core.view.GravityCompat +import androidx.core.view.ViewCompat import android.util.AttributeSet import android.view.Gravity import android.widget.FrameLayout diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerDialog.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerDialog.kt index b264e58..6c4ad92 100644 --- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerDialog.kt +++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerDialog.kt @@ -2,8 +2,8 @@ package ca.allanwang.kau.colorpicker import android.content.Context import android.graphics.Color -import android.support.annotation.DimenRes -import android.support.annotation.StringRes +import androidx.annotation.DimenRes +import androidx.annotation.StringRes import ca.allanwang.kau.utils.INVALID_ID import ca.allanwang.kau.utils.string import com.afollestad.materialdialogs.MaterialDialog diff --git a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt index b9cea99..5174089 100644 --- a/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt +++ b/colorpicker/src/main/kotlin/ca/allanwang/kau/colorpicker/ColorPickerView.kt @@ -3,8 +3,8 @@ package ca.allanwang.kau.colorpicker import android.annotation.SuppressLint import android.content.Context import android.graphics.Color -import android.support.annotation.ColorInt -import android.support.v4.content.res.ResourcesCompat +import androidx.annotation.ColorInt +import androidx.core.content.res.ResourcesCompat import android.text.Editable import android.text.InputFilter import android.text.TextWatcher diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/activities/ElasticRecyclerActivity.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/activities/ElasticRecyclerActivity.kt index 3951970..5b0e97b 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/activities/ElasticRecyclerActivity.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/activities/ElasticRecyclerActivity.kt @@ -2,10 +2,10 @@ package ca.allanwang.kau.ui.activities import android.os.Build import android.os.Bundle -import android.support.annotation.RequiresApi -import android.support.v7.widget.RecyclerView -import android.support.v7.widget.Toolbar import android.transition.TransitionInflater +import androidx.annotation.RequiresApi +import androidx.appcompat.widget.Toolbar +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.internal.KauBaseActivity import ca.allanwang.kau.ui.R import ca.allanwang.kau.ui.widgets.ElasticDragDismissFrameLayout @@ -16,7 +16,7 @@ import kotlinx.android.synthetic.main.kau_elastic_recycler_activity.* * * A generic activity comprised of an ElasticDragDismissFrameLayout, CoordinatorLayout, Toolbar, RecyclerView, and Fab * [ca.allanwang.kau.ui.widgets.ElasticDragDismissFrameLayout] - * [android.support.v7.widget.RecyclerView] + * [androidx.recyclerview.widget.RecyclerView] * * The recyclerview defaults to a linearlayoutmanager, and the adapter is automatically bounded * @@ -39,6 +39,7 @@ abstract class ElasticRecyclerActivity : KauBaseActivity() { setContentView(R.layout.kau_elastic_recycler_activity) setSupportActionBar(kau_toolbar) if (!onCreate(savedInstanceState, configs)) return + kau_draggable.addListener(object : ElasticDragDismissFrameLayout.SystemChromeFader(this) { override fun onDragDismissed() { window.returnTransition = TransitionInflater.from(this@ElasticRecyclerActivity) diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/BoundedCardView.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/BoundedCardView.kt index 5fc3e06..25a05df 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/BoundedCardView.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/BoundedCardView.kt @@ -2,8 +2,8 @@ package ca.allanwang.kau.ui.views import android.content.Context import android.graphics.Rect -import android.support.v7.widget.CardView import android.util.AttributeSet +import androidx.cardview.widget.CardView import ca.allanwang.kau.ui.R import ca.allanwang.kau.utils.parentViewGroup diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt index 5db5eaa..5cb4329 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/views/MeasuredImageView.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.ui.views import android.content.Context -import android.support.v7.widget.AppCompatImageView +import androidx.appcompat.widget.AppCompatImageView import android.util.AttributeSet /** diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt index f357f79..b89373e 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/ElasticDragDismissFrameLayout.kt @@ -20,7 +20,7 @@ import android.app.Activity import android.content.Context import android.graphics.Color import android.os.Build -import android.support.annotation.RequiresApi +import androidx.annotation.RequiresApi import android.transition.TransitionInflater import android.util.AttributeSet import android.view.MotionEvent diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/InkPageIndicator.java b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/InkPageIndicator.java index a963556..13381aa 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/InkPageIndicator.java +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/InkPageIndicator.java @@ -27,14 +27,14 @@ import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.Path; import android.graphics.RectF; -import android.support.annotation.ColorInt; -import android.support.v4.view.ViewPager; +import androidx.annotation.ColorInt; import android.util.AttributeSet; import android.view.View; import android.view.animation.Interpolator; import java.util.Arrays; +import androidx.viewpager.widget.ViewPager; import ca.allanwang.kau.ui.R; import ca.allanwang.kau.utils.AnimHolder; import ca.allanwang.kau.utils.ColorUtilsKt; diff --git a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/TextSlider.kt b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/TextSlider.kt index bcd930f..a53ee9d 100644 --- a/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/TextSlider.kt +++ b/core-ui/src/main/kotlin/ca/allanwang/kau/ui/widgets/TextSlider.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.ui.widgets import android.content.Context import android.graphics.Color -import android.support.v4.widget.TextViewCompat +import androidx.core.widget.TextViewCompat import android.text.TextUtils import android.util.AttributeSet import android.view.Gravity diff --git a/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml b/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml index 9fbe447..5fc151c 100644 --- a/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml +++ b/core-ui/src/main/res-public/layout/kau_elastic_recycler_activity.xml @@ -7,7 +7,7 @@ app:dragDismissDistance="@dimen/kau_drag_dismiss_distance_large" app:dragDismissScale="0.95"> - <android.support.design.widget.CoordinatorLayout + <androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/kau_coordinator" android:layout_width="match_parent" android:layout_height="match_parent" @@ -15,27 +15,27 @@ android:background="?android:colorBackground" android:orientation="vertical"> - <android.support.design.widget.AppBarLayout + <com.google.android.material.appbar.AppBarLayout android:id="@+id/kau_appbar" android:layout_width="match_parent" android:layout_height="wrap_content"> - <android.support.v7.widget.Toolbar + <androidx.appcompat.widget.Toolbar android:id="@+id/kau_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> - </android.support.design.widget.AppBarLayout> + </com.google.android.material.appbar.AppBarLayout> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recycler" android:layout_width="match_parent" android:layout_height="match_parent" - app:layoutManager="android.support.v7.widget.LinearLayoutManager" + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> - <android.support.design.widget.FloatingActionButton + <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/kau_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -47,6 +47,6 @@ app:layout_anchor="@id/kau_recycler" app:layout_anchorGravity="bottom|right|end" /> - </android.support.design.widget.CoordinatorLayout> + </androidx.coordinatorlayout.widget.CoordinatorLayout> </ca.allanwang.kau.ui.widgets.ElasticDragDismissFrameLayout>
\ No newline at end of file diff --git a/core-ui/src/main/res-public/layout/kau_recycler_detached_background.xml b/core-ui/src/main/res-public/layout/kau_recycler_detached_background.xml index 7295d66..2273a20 100644 --- a/core-ui/src/main/res-public/layout/kau_recycler_detached_background.xml +++ b/core-ui/src/main/res-public/layout/kau_recycler_detached_background.xml @@ -15,13 +15,13 @@ <!--defaults to a LinearLayoutManager--> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recycler_detached" android:layout_width="match_parent" android:layout_height="wrap_content" android:clipToPadding="false" android:paddingBottom="@dimen/kau_spacing_normal" android:scrollbars="vertical" - app:layoutManager="android.support.v7.widget.LinearLayoutManager" /> + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> </FrameLayout> diff --git a/core-ui/src/main/res-public/layout/kau_recycler_textslider.xml b/core-ui/src/main/res-public/layout/kau_recycler_textslider.xml index eacd5be..d048627 100644 --- a/core-ui/src/main/res-public/layout/kau_recycler_textslider.xml +++ b/core-ui/src/main/res-public/layout/kau_recycler_textslider.xml @@ -1,11 +1,11 @@ <?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" android:id="@+id/kau_container" android:layout_width="match_parent" android:layout_height="match_parent"> - <android.support.v7.widget.Toolbar + <androidx.appcompat.widget.Toolbar android:id="@+id/kau_toolbar" android:layout_width="0dp" android:layout_height="?attr/actionBarSize" @@ -20,9 +20,9 @@ android:gravity="center" app:animation_type="slide_vertical" /> - </android.support.v7.widget.Toolbar> + </androidx.appcompat.widget.Toolbar> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recycler" android:layout_width="0dp" android:layout_height="0dp" @@ -31,4 +31,4 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/kau_toolbar" /> -</android.support.constraint.ConstraintLayout> +</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/core/build.gradle b/core/build.gradle index 046a734..a57ee6e 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -5,13 +5,11 @@ apply from: '../android-lib.gradle' dependencies { api kauDependency.kotlin - api "com.android.support:support-annotations:${kau.supportLibs}" - api "com.android.support:appcompat-v7:${kau.supportLibs}" - api "com.android.support:support-v13:${kau.supportLibs}" - api "com.android.support:design:${kau.supportLibs}" - api "com.android.support:recyclerview-v7:${kau.supportLibs}" - api "com.android.support:cardview-v7:${kau.supportLibs}" - api "com.android.support.constraint:constraint-layout:${kau.constraintLayout}" + api "androidx.appcompat:appcompat:${kau.appcompat}" + api "androidx.recyclerview:recyclerview:${kau.recyclerView}" + api "androidx.cardview:cardview:${kau.cardView}" + api "androidx.constraintlayout:constraintlayout:${kau.constraintLayout}" + api "com.google.android.material:material:${kau.googleMaterial}" api "com.mikepenz:iconics-core:${kau.iconics}@aar" api "com.mikepenz:google-material-typeface:${kau.iconicsGoogle}.original@aar" diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt index 2a9263a..52f344b 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/kpref/KPrefTest.kt @@ -1,9 +1,10 @@ package ca.allanwang.kau.kpref import android.annotation.SuppressLint -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -23,7 +24,7 @@ class KPrefTest { class TestPref : KPref() { init { - initialize(InstrumentationRegistry.getTargetContext(), "kpref_test_${System.currentTimeMillis()}") + initialize(ApplicationProvider.getApplicationContext<Context>(), "kpref_test_${System.currentTimeMillis()}") } var one by kpref("one", 1) diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt index 1dac92f..13a3c77 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/utils/KotterknifeTest.kt @@ -1,12 +1,12 @@ package ca.allanwang.kau.utils import android.content.Context -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 import android.view.View import android.widget.FrameLayout import android.widget.TextView +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import androidx.test.platform.app.InstrumentationRegistry import org.junit.Before import org.junit.Test import org.junit.runner.RunWith @@ -25,7 +25,7 @@ class KotterknifeTest { @Before fun init() { - context = InstrumentationRegistry.getContext() + context = InstrumentationRegistry.getInstrumentation().context } @Test diff --git a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt index f9ce24b..7a6d2e0 100644 --- a/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt +++ b/core/src/androidTest/kotlin/ca/allanwang/kau/xml/FaqTest.kt @@ -1,8 +1,10 @@ package ca.allanwang.kau.xml -import android.support.test.InstrumentationRegistry -import android.support.test.filters.MediumTest -import android.support.test.runner.AndroidJUnit4 +import android.content.Context +import androidx.test.core.app.ApplicationProvider +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.filters.MediumTest +import ca.allanwang.kau.test.R import org.junit.Test import org.junit.runner.RunWith import kotlin.test.assertEquals @@ -14,9 +16,12 @@ import kotlin.test.assertEquals @MediumTest class FaqTest { + val context: Context + get() = ApplicationProvider.getApplicationContext<Context>() + @Test fun simpleTest() { - InstrumentationRegistry.getTargetContext().kauParseFaq(R.xml.test_faq) { data -> + context.kauParseFaq(R.xml.test_faq) { data -> assertEquals(2, data.size, "FAQ size is incorrect") assertEquals("1. This is a question", data.first().question.toString(), "First question does not match") assertEquals("This is an answer", data.first().answer.toString(), "First answer does not match") @@ -27,7 +32,7 @@ class FaqTest { @Test fun withoutNumbering() { - InstrumentationRegistry.getTargetContext().kauParseFaq(R.xml.test_faq, false) { data -> + context.kauParseFaq(R.xml.test_faq, false) { data -> assertEquals(2, data.size, "FAQ size is incorrect") assertEquals("This is a question", data.first().question.toString(), "First question does not match") assertEquals("This is an answer", data.first().answer.toString(), "First answer does not match") diff --git a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt index dbdcf09..0184b9a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/email/EmailBuilder.kt @@ -6,7 +6,7 @@ import android.content.Intent import android.content.pm.PackageManager import android.net.Uri import android.os.Build -import android.support.annotation.StringRes +import androidx.annotation.StringRes import android.util.DisplayMetrics import ca.allanwang.kau.R import ca.allanwang.kau.logging.KL diff --git a/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt b/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt index 87d94ce..c71761d 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/internal/KauBaseActivity.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.internal -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import ca.allanwang.kau.permissions.kauOnRequestPermissionsResult /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt index 0a45b65..3d98633 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/kotlin/LazyContext.kt @@ -1,8 +1,8 @@ package ca.allanwang.kau.kotlin import android.content.Context -import android.support.annotation.AnimRes -import android.support.annotation.InterpolatorRes +import androidx.annotation.AnimRes +import androidx.annotation.InterpolatorRes import android.view.animation.Animation import android.view.animation.AnimationUtils import android.view.animation.Interpolator diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt index 36456ec..922dc09 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/PermissionManager.kt @@ -3,7 +3,7 @@ package ca.allanwang.kau.permissions import android.app.Activity import android.content.Context import android.content.pm.PackageManager -import android.support.v4.app.ActivityCompat +import androidx.core.app.ActivityCompat import ca.allanwang.kau.kotlin.lazyContext import ca.allanwang.kau.logging.KL import ca.allanwang.kau.utils.KauException diff --git a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt index 248e484..83cd2ed 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/permissions/Permissions.kt @@ -4,7 +4,7 @@ import android.Manifest import android.app.Activity import android.content.Context import android.os.Build -import android.support.annotation.RequiresApi +import androidx.annotation.RequiresApi /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt index a323e6c..4d7142c 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt @@ -4,7 +4,7 @@ import android.annotation.SuppressLint import android.app.Activity import android.content.Context import android.graphics.Canvas -import android.support.v4.view.ViewCompat +import androidx.core.view.ViewCompat import android.util.AttributeSet import android.view.MotionEvent import android.view.View diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java index 566e9e5..ac7fb7e 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java @@ -1,7 +1,7 @@ package ca.allanwang.kau.swipe; import android.content.Context; -import android.support.v4.view.ViewCompat; +import androidx.core.view.ViewCompat; import android.util.Log; import android.view.MotionEvent; import android.view.VelocityTracker; @@ -25,7 +25,7 @@ import static ca.allanwang.kau.swipe.SwipeBackHelperKt.SWIPE_EDGE_TOP; * of useful operations and state tracking for allowing a user to drag and reposition * views within their parent ViewGroup. * <p> - * This is an extension of {@link android.support.v4.widget.ViewDragHelper} + * This is an extension of {@link androidx.core.widget.ViewDragHelper} * Along with additional methods defined in {@link ViewDragHelperExtras} */ class ViewDragHelper implements ViewDragHelperExtras { diff --git a/core/src/main/kotlin/ca/allanwang/kau/ui/SimpleRippleDrawable.kt b/core/src/main/kotlin/ca/allanwang/kau/ui/SimpleRippleDrawable.kt index b92b222..4700162 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/ui/SimpleRippleDrawable.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/ui/SimpleRippleDrawable.kt @@ -4,8 +4,8 @@ import android.content.res.ColorStateList import android.graphics.drawable.ColorDrawable import android.graphics.drawable.RippleDrawable import android.os.Build -import android.support.annotation.ColorInt -import android.support.annotation.RequiresApi +import androidx.annotation.ColorInt +import androidx.annotation.RequiresApi import ca.allanwang.kau.utils.adjustAlpha /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt index ab0e59f..eab9536 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ActivityUtils.kt @@ -11,13 +11,13 @@ import android.content.Intent import android.graphics.Color import android.os.Build import android.os.Bundle -import android.support.annotation.ColorInt -import android.support.annotation.RequiresApi -import android.support.annotation.StringRes -import android.support.design.widget.Snackbar import android.view.Menu import android.view.View +import androidx.annotation.ColorInt +import androidx.annotation.RequiresApi +import androidx.annotation.StringRes import ca.allanwang.kau.R +import com.google.android.material.snackbar.Snackbar import com.mikepenz.iconics.typeface.IIcon import org.jetbrains.anko.contentView @@ -135,9 +135,13 @@ fun Context.setMenuIcons(menu: Menu, @ColorInt color: Int = Color.WHITE, vararg } } -inline fun Activity.hideKeyboard() = currentFocus.hideKeyboard() +inline fun Activity.hideKeyboard() { + currentFocus?.hideKeyboard() +} -inline fun Activity.showKeyboard() = currentFocus.showKeyboard() +inline fun Activity.showKeyboard() { + currentFocus?.showKeyboard() +} inline fun Activity.snackbar(text: String, duration: Int = Snackbar.LENGTH_LONG, noinline builder: Snackbar.() -> Unit = {}) = contentView!!.snackbar(text, duration, builder) diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimHolder.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimHolder.kt index 2767f04..b988085 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimHolder.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimHolder.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.utils import android.os.Build -import android.support.annotation.RequiresApi +import androidx.annotation.RequiresApi import ca.allanwang.kau.kotlin.lazyInterpolator /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt index a287cf2..d8e4681 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/AnimUtils.kt @@ -3,7 +3,7 @@ package ca.allanwang.kau.utils import android.animation.Animator import android.animation.AnimatorListenerAdapter import android.annotation.SuppressLint -import android.support.annotation.StringRes +import androidx.annotation.StringRes import android.view.View import android.view.ViewAnimationUtils import android.view.ViewPropertyAnimator diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt index 82cd577..d628214 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/BundleUtils.kt @@ -5,7 +5,7 @@ import android.app.Activity import android.app.ActivityOptions import android.content.Context import android.os.Bundle -import android.support.annotation.AnimRes +import androidx.annotation.AnimRes import android.util.Pair import android.view.View import ca.allanwang.kau.R diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt index 236f2ca..f010c6f 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ColorUtils.kt @@ -7,12 +7,12 @@ import android.graphics.Color import android.graphics.PorterDuff import android.graphics.drawable.Drawable import android.os.Build -import android.support.annotation.ColorInt -import android.support.annotation.FloatRange -import android.support.annotation.IntRange -import android.support.v4.graphics.drawable.DrawableCompat -import android.support.v7.widget.AppCompatEditText -import android.support.v7.widget.Toolbar +import androidx.annotation.ColorInt +import androidx.annotation.FloatRange +import androidx.annotation.IntRange +import androidx.core.graphics.drawable.DrawableCompat +import androidx.appcompat.widget.AppCompatEditText +import androidx.appcompat.widget.Toolbar import android.widget.* import com.afollestad.materialdialogs.R import java.util.* diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt index 1eeac1a..eb09093 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Const.kt @@ -1,6 +1,7 @@ package ca.allanwang.kau.utils -import android.support.v4.widget.ViewDragHelper +import androidx.customview.widget.ViewDragHelper + /** * Created by Allan Wang on 2017-06-08. diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt index 6568bf2..f6e9ac7 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ContextUtils.kt @@ -11,8 +11,8 @@ import android.content.pm.PackageManager import android.graphics.drawable.Drawable import android.net.Uri import android.os.Bundle -import android.support.annotation.* -import android.support.v4.content.ContextCompat +import androidx.annotation.* +import androidx.core.content.ContextCompat import android.util.TypedValue import android.view.View import android.view.animation.AnimationUtils diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/DrawableUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/DrawableUtils.kt index dae3bff..59e684a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/DrawableUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/DrawableUtils.kt @@ -2,8 +2,8 @@ package ca.allanwang.kau.utils import android.content.res.ColorStateList import android.graphics.drawable.Drawable -import android.support.annotation.ColorInt -import android.support.v4.graphics.drawable.DrawableCompat +import androidx.annotation.ColorInt +import androidx.core.graphics.drawable.DrawableCompat /** * Wrap the color into a state and tint the drawable diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt index acc71f2..f99b342 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/FragmentUtils.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.utils -import android.support.v4.app.Fragment +import androidx.fragment.app.Fragment import org.jetbrains.anko.bundleOf /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt index 51691af..66c56f8 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/IIconUtils.kt @@ -4,7 +4,7 @@ import android.content.Context import android.content.res.ColorStateList import android.graphics.Color import android.graphics.drawable.Drawable -import android.support.annotation.ColorInt +import androidx.annotation.ColorInt import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt index 8c7c039..3cbd93d 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Kotterknife.kt @@ -1,4 +1,4 @@ -@file:Suppress("UNCHECKED_CAST") +@file:Suppress("UNCHECKED_CAST", "DEPRECATION") package ca.allanwang.kau.utils @@ -8,146 +8,118 @@ package ca.allanwang.kau.utils * Courtesy of Jake Wharton * * https://github.com/JakeWharton/kotterknife/blob/master/src/main/kotlin/kotterknife/ButterKnife.kt + * + * Note that while this is useful for binding ids, there also exists other alternatives, such as + * `kotlin-android-extensions`. + * + * For fragments, make sure that the views are reset after the fragment lifecycle. */ import android.app.Activity import android.app.Dialog import android.app.DialogFragment import android.app.Fragment -import android.support.v7.widget.RecyclerView.ViewHolder import android.view.View +import androidx.recyclerview.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView.ViewHolder import java.util.* import kotlin.properties.ReadOnlyProperty import kotlin.reflect.KProperty -import android.support.v4.app.DialogFragment as SupportDialogFragment -import android.support.v4.app.Fragment as SupportFragment +import androidx.fragment.app.DialogFragment as SupportDialogFragment +import androidx.fragment.app.Fragment as SupportFragment -private const val DEPRECATION_MESSAGE = "Kotterknife will be removed in favour of the kotlin_android_extensions plugin" - -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindView(id: Int) : ReadOnlyProperty<View, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindView(id: Int) : ReadOnlyProperty<Activity, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindView(id: Int) : ReadOnlyProperty<Dialog, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindView(id: Int) : ReadOnlyProperty<DialogFragment, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindView(id: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, V> = required(id, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindView(id: Int) : ReadOnlyProperty<Fragment, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindView(id: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, V> = required(id, viewFinder) + : ReadOnlyProperty<SupportFragment, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) -fun <V : View> ViewHolder.bindView(id: Int) - : ReadOnlyProperty<ViewHolder, V> = required(id, viewFinder) +fun <V : View> RecyclerView.ViewHolder.bindView(id: Int) + : ReadOnlyProperty<RecyclerView.ViewHolder, V> = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindOptionalView(id: Int) : ReadOnlyProperty<View, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindOptionalView(id: Int) : ReadOnlyProperty<Activity, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindOptionalView(id: Int) : ReadOnlyProperty<Dialog, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindOptionalView(id: Int) : ReadOnlyProperty<DialogFragment, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindOptionalView(id: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, V?> = optional(id, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindOptionalView(id: Int) : ReadOnlyProperty<Fragment, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindOptionalView(id: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, V?> = optional(id, viewFinder) + : ReadOnlyProperty<SupportFragment, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) -fun <V : View> ViewHolder.bindOptionalView(id: Int) - : ReadOnlyProperty<ViewHolder, V?> = optional(id, viewFinder) +fun <V : View> RecyclerView.ViewHolder.bindOptionalView(id: Int) + : ReadOnlyProperty<RecyclerView.ViewHolder, V?> = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindViews(vararg ids: Int) : ReadOnlyProperty<View, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindViews(vararg ids: Int) : ReadOnlyProperty<Activity, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindViews(vararg ids: Int) : ReadOnlyProperty<Dialog, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindViews(vararg ids: Int) : ReadOnlyProperty<DialogFragment, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindViews(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = required(ids, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindViews(vararg ids: Int) : ReadOnlyProperty<Fragment, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindViews(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = required(ids, viewFinder) + : ReadOnlyProperty<SupportFragment, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindViews(vararg ids: Int) : ReadOnlyProperty<ViewHolder, List<V>> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<View, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<Activity, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<Dialog, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<DialogFragment, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindOptionalViews(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = optional(ids, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<Fragment, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindOptionalViews(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = optional(ids, viewFinder) + : ReadOnlyProperty<SupportFragment, List<V>> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty<ViewHolder, List<V>> = optional(ids, viewFinder) @@ -189,13 +161,13 @@ private fun <T, V : View> optional(ids: IntArray, finder: T.(Int) -> View?) = La private open class Lazy<in T, out V>(private val initializer: (T, KProperty<*>) -> V) : ReadOnlyProperty<T, V> { protected object EMPTY - protected var value: Any? = EMPTY +protected var value: Any? = EMPTY - override fun getValue(thisRef: T, property: KProperty<*>): V { +override fun getValue(thisRef: T, property: KProperty<*>): V { if (value == EMPTY) value = initializer(thisRef, property) - return value as V +return value as V } } @@ -209,133 +181,101 @@ private open class Lazy<in T, out V>(private val initializer: (T, KProperty<*>) * Credits to <a href="https://github.com/MichaelRocks">MichaelRocks</a> */ -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindViewResettable(id: Int) : ReadOnlyProperty<View, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindViewResettable(id: Int) : ReadOnlyProperty<Activity, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindViewResettable(id: Int) : ReadOnlyProperty<Dialog, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindViewResettable(id: Int) : ReadOnlyProperty<DialogFragment, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindViewResettable(id: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, V> = requiredResettable(id, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindViewResettable(id: Int) : ReadOnlyProperty<Fragment, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindViewResettable(id: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, V> = requiredResettable(id, viewFinder) + : ReadOnlyProperty<SupportFragment, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindViewResettable(id: Int) : ReadOnlyProperty<ViewHolder, V> = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<View, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<Activity, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<Dialog, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<DialogFragment, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindOptionalViewResettable(id: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, V?> = optionalResettable(id, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<Fragment, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindOptionalViewResettable(id: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, V?> = optionalResettable(id, viewFinder) + : ReadOnlyProperty<SupportFragment, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindOptionalViewResettable(id: Int) : ReadOnlyProperty<ViewHolder, V?> = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<View, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<Activity, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<Dialog, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<DialogFragment, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindViewsResettable(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = requiredResettable(ids, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<Fragment, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindViewsResettable(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = requiredResettable(ids, viewFinder) + : ReadOnlyProperty<SupportFragment, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty<ViewHolder, List<V>> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> View.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty<View, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Activity.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty<Activity, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Dialog.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty<Dialog, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> DialogFragment.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty<DialogFragment, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportDialogFragment.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.DialogFragment, List<V>> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty<SupportDialogFragment, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> Fragment.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty<Fragment, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> SupportFragment.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty<android.support.v4.app.Fragment, List<V>> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty<SupportFragment, List<V>> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun <V : View> ViewHolder.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty<ViewHolder, List<V>> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty<RecyclerView.ViewHolder, List<V>> = optionalResettable(ids, viewFinder) private fun <T, V : View> requiredResettable(id: Int, finder: T.(Int) -> View?) = LazyResettable { t: T, desc -> (t.finder(id) as V?)?.apply { } ?: viewNotFound(id, desc) @@ -358,12 +298,11 @@ private class LazyResettable<in T, out V>(initializer: (T, KProperty<*>) -> V) : return super.getValue(thisRef, property) } - fun reset() { +fun reset() { value = EMPTY } } -@Deprecated(DEPRECATION_MESSAGE) object Kotterknife { fun reset(target: Any) { KotterknifeRegistry.reset(target) @@ -373,7 +312,7 @@ object Kotterknife { private object KotterknifeRegistry { private val lazyMap = WeakHashMap<Any, MutableCollection<LazyResettable<*, *>>>() - fun register(target: Any, lazy: LazyResettable<*, *>) = lazyMap.getOrPut(target, { Collections.newSetFromMap(WeakHashMap()) }).add(lazy) +fun register(target: Any, lazy: LazyResettable<*, *>) = lazyMap.getOrPut(target, { Collections.newSetFromMap(WeakHashMap()) }).add(lazy) - fun reset(target: Any) = lazyMap[target]?.forEach(LazyResettable<*, *>::reset) +fun reset(target: Any) = lazyMap[target]?.forEach(LazyResettable<*, *>::reset) }
\ No newline at end of file diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt index 1eb0076..016f3d2 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/NotificationUtils.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.utils import android.content.Context -import android.support.v4.app.NotificationManagerCompat +import androidx.core.app.NotificationManagerCompat /** diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt index 3a34db5..1c336f9 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt @@ -1,8 +1,8 @@ package ca.allanwang.kau.utils import android.graphics.Rect -import android.support.v7.widget.RecyclerView import android.view.View +import androidx.recyclerview.widget.RecyclerView /** * Created by Allan Wang on 2017-07-11. diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt index ec206ee..1d12fd3 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/TransitionUtils.kt @@ -1,14 +1,14 @@ package ca.allanwang.kau.utils import android.os.Build -import android.support.annotation.RequiresApi -import android.support.annotation.TransitionRes -import android.support.transition.AutoTransition -import android.support.transition.TransitionInflater -import android.support.transition.TransitionManager +import androidx.annotation.RequiresApi +import androidx.annotation.TransitionRes +import androidx.transition.AutoTransition +import androidx.transition.TransitionInflater +import androidx.transition.TransitionManager import android.transition.Transition import android.view.ViewGroup -import android.support.transition.Transition as SupportTransition +import androidx.transition.Transition as SupportTransition /** * Created by Allan Wang on 2017-06-24. @@ -52,7 +52,7 @@ fun ViewGroup.transitionAuto(builder: AutoTransition.() -> Unit = {}) { } @KauUtils -fun ViewGroup.transitionDelayed(@TransitionRes id: Int, builder: android.support.transition.Transition.() -> Unit = {}) { +fun ViewGroup.transitionDelayed(@TransitionRes id: Int, builder: androidx.transition.Transition.() -> Unit = {}) { if (!buildIsLollipopAndUp) return val transition = TransitionInflater.from(context).inflateTransition(id) transition.builder() diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt index 46e29b2..c8d5d2a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/Utils.kt @@ -8,7 +8,7 @@ import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.Drawable import android.os.Handler import android.os.Looper -import android.support.annotation.IntRange +import androidx.annotation.IntRange import ca.allanwang.kau.R import java.math.RoundingMode import java.text.DecimalFormat diff --git a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt index 4e020bc..956df48 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/utils/ViewUtils.kt @@ -7,15 +7,10 @@ import android.annotation.SuppressLint import android.content.Context import android.graphics.Color import android.os.Build -import android.support.annotation.ColorInt -import android.support.annotation.ColorRes -import android.support.annotation.RequiresApi -import android.support.annotation.StringRes -import android.support.design.widget.FloatingActionButton -import android.support.design.widget.Snackbar -import android.support.design.widget.TextInputEditText -import android.support.v7.widget.LinearLayoutManager -import android.support.v7.widget.RecyclerView +import androidx.annotation.ColorInt +import androidx.annotation.ColorRes +import androidx.annotation.RequiresApi +import androidx.annotation.StringRes import android.view.LayoutInflater import android.view.MotionEvent import android.view.View @@ -23,7 +18,12 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.EditText import android.widget.ImageView +import androidx.recyclerview.widget.LinearLayoutManager +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.ui.createSimpleRippleDrawable +import com.google.android.material.floatingactionbutton.FloatingActionButton +import com.google.android.material.snackbar.Snackbar +import com.google.android.material.textfield.TextInputEditText import com.mikepenz.iconics.IconicsDrawable import com.mikepenz.iconics.typeface.IIcon @@ -291,7 +291,7 @@ fun FloatingActionButton.hideOnDownwardsScroll(recycler: RecyclerView) { recycler.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { - if (newState == android.support.v7.widget.RecyclerView.SCROLL_STATE_IDLE && !isShown) show() + if (newState == RecyclerView.SCROLL_STATE_IDLE && !isShown) show() } override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt index 28d51a4..3955a77 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/xml/Changelog.kt @@ -2,14 +2,14 @@ package ca.allanwang.kau.xml import android.content.Context import android.content.res.XmlResourceParser -import android.support.annotation.ColorInt -import android.support.annotation.LayoutRes -import android.support.annotation.XmlRes -import android.support.v7.widget.RecyclerView +import androidx.annotation.ColorInt +import androidx.annotation.LayoutRes +import androidx.annotation.XmlRes import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.TextView +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.R import ca.allanwang.kau.utils.materialDialog import ca.allanwang.kau.utils.use diff --git a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt index 7caf5d6..bbe9425 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.xml import android.content.Context import android.content.res.XmlResourceParser -import android.support.annotation.XmlRes +import androidx.annotation.XmlRes import android.text.Html import android.text.Spanned import ca.allanwang.kau.utils.use diff --git a/docs/Changelog.md b/docs/Changelog.md index a5f24f4..704e9c3 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -1,5 +1,8 @@ # Changelog +## v4.0.0-alpha01 +* Migrated to androidx. See migration for external dependency changes. + ## v3.8.0 * Update everything to Android Studio 3.1 * Fix new lint issues (see Migration for resource related methods) diff --git a/docs/Migration.md b/docs/Migration.md index ff89f87..8c5e016 100644 --- a/docs/Migration.md +++ b/docs/Migration.md @@ -2,6 +2,15 @@ Below are some highlights on major refactoring/breaking changes +# v4.0.0-alpha01 + +This is the first introduction of androidx. The goal is to just do a migration with minimal changes. +Nothing has been changed internally, but the dependencies are updated. +Notably, Android-Iconics [split their Community Icons](https://github.com/mikepenz/Android-Iconics/blob/develop/MIGRATION.md) into two enums. + +Kotterknife is also no longer deprecated. There are some use cases where `kotlin-android-extensions` isn't the best, such as when multiple layout files are used, or when ids are defined in the id.xml. +It is still recommended to use the extension where applicable. + # v3.8.0 Along with the update to support Android Studio 3.1, a lot of changes have occurred with other dependencies and with lint. diff --git a/gradle.properties b/gradle.properties index f1c49f3..1e0c1d3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=true +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt index b9681e9..132c27a 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefActivity.kt @@ -2,8 +2,8 @@ package ca.allanwang.kau.kpref.activity import android.annotation.SuppressLint import android.os.Bundle -import android.support.annotation.StringRes -import android.support.v7.widget.Toolbar +import androidx.annotation.StringRes +import androidx.appcompat.widget.Toolbar import android.view.View import ca.allanwang.kau.animators.KauAnimator import ca.allanwang.kau.animators.SlideAnimatorAdd diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt index 2cdeae2..4b50ee4 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/KPrefBinder.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.kpref.activity -import android.support.annotation.StringRes +import androidx.annotation.StringRes import ca.allanwang.kau.kpref.activity.items.* /** diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt index f391747..0a7922e 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefCheckbox.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.kpref.activity.items -import android.support.v7.widget.AppCompatCheckBox +import androidx.appcompat.widget.AppCompatCheckBox import android.widget.CheckBox import ca.allanwang.kau.kpref.activity.KClick import ca.allanwang.kau.kpref.activity.R diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt index 5081f50..aa60fcd 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemBase.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.kpref.activity.items -import android.support.annotation.CallSuper +import androidx.annotation.CallSuper import android.view.View import ca.allanwang.kau.kpref.activity.GlobalOptions import ca.allanwang.kau.kpref.activity.KClick diff --git a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt index fcc13ba..4e8ecbe 100644 --- a/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt +++ b/kpref-activity/src/main/kotlin/ca/allanwang/kau/kpref/activity/items/KPrefItemCore.kt @@ -1,11 +1,11 @@ package ca.allanwang.kau.kpref.activity.items import android.annotation.SuppressLint -import android.support.annotation.CallSuper -import android.support.annotation.IdRes -import android.support.annotation.LayoutRes -import android.support.annotation.StringRes -import android.support.v7.widget.RecyclerView +import androidx.annotation.CallSuper +import androidx.annotation.IdRes +import androidx.annotation.LayoutRes +import androidx.annotation.StringRes +import androidx.recyclerview.widget.RecyclerView import android.view.LayoutInflater import android.view.View import android.view.ViewGroup diff --git a/kpref-activity/src/main/res/layout/kau_pref_activity.xml b/kpref-activity/src/main/res/layout/kau_pref_activity.xml index 7651e5a..d6ea6e6 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_activity.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_activity.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" android:layout_width="match_parent" android:layout_height="match_parent"> @@ -13,7 +13,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - <android.support.v7.widget.Toolbar + <androidx.appcompat.widget.Toolbar android:id="@id/kau_toolbar" android:layout_width="0dp" android:layout_height="?attr/actionBarSize" @@ -32,7 +32,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/kau_toolbar" /> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recycler" android:layout_width="0dp" android:layout_height="0dp" @@ -41,4 +41,4 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/kau_toolbar" /> -</android.support.constraint.ConstraintLayout> +</androidx.constraintlayout.widget.ConstraintLayout> diff --git a/kpref-activity/src/main/res/layout/kau_pref_checkbox.xml b/kpref-activity/src/main/res/layout/kau_pref_checkbox.xml index 1fecb4d..6c52b52 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_checkbox.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_checkbox.xml @@ -1,4 +1,4 @@ -<android.support.v7.widget.AppCompatCheckBox xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.AppCompatCheckBox xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/kau_pref_inner_content" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/kpref-activity/src/main/res/layout/kau_pref_core.xml b/kpref-activity/src/main/res/layout/kau_pref_core.xml index 72f26d9..2571dd3 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_core.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_core.xml @@ -12,7 +12,7 @@ android:minHeight="?android:attr/listPreferredItemHeightSmall" android:orientation="horizontal"> - <android.support.constraint.ConstraintLayout + <androidx.constraintlayout.widget.ConstraintLayout android:id="@id/kau_pref_container" android:layout_width="match_parent" android:layout_height="wrap_content" @@ -22,7 +22,7 @@ <!--As per Android N, icons (24dp) are aligned to the left rather than centered--> - <android.support.v7.widget.AppCompatImageView + <androidx.appcompat.widget.AppCompatImageView android:id="@id/kau_pref_icon" android:layout_width="56dp" android:layout_height="56dp" @@ -37,7 +37,7 @@ tools:ignore="RtlSymmetry" tools:layout_editor_absoluteX="0dp" /> - <android.support.v7.widget.AppCompatTextView + <androidx.appcompat.widget.AppCompatTextView android:id="@id/kau_pref_title" android:layout_width="0dp" android:layout_height="wrap_content" @@ -52,7 +52,7 @@ app:layout_constraintTop_toTopOf="parent" tools:layout_editor_absoluteX="-175dp" /> - <android.support.v7.widget.AppCompatTextView + <androidx.appcompat.widget.AppCompatTextView android:id="@id/kau_pref_desc" android:layout_width="0dp" android:layout_height="wrap_content" @@ -80,7 +80,7 @@ app:layout_constraintTop_toBottomOf="@id/kau_pref_desc" tools:layout_editor_absoluteX="-175dp" /> - <android.support.constraint.Barrier + <androidx.constraintlayout.widget.Barrier android:id="@id/kau_pref_barrier" android:layout_width="0dp" android:layout_height="0dp" @@ -105,6 +105,6 @@ app:layout_constraintVertical_bias="0.5" tools:layout_editor_absoluteX="1dp" /> - </android.support.constraint.ConstraintLayout> + </androidx.constraintlayout.widget.ConstraintLayout> </LinearLayout>
\ No newline at end of file diff --git a/kpref-activity/src/main/res/layout/kau_pref_header.xml b/kpref-activity/src/main/res/layout/kau_pref_header.xml index d802a14..65504a3 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_header.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_header.xml @@ -1,4 +1,4 @@ -<android.support.v7.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/kau_pref_title" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/kpref-activity/src/main/res/layout/kau_pref_seekbar.xml b/kpref-activity/src/main/res/layout/kau_pref_seekbar.xml index 0b07e1c..5ff6351 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_seekbar.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_seekbar.xml @@ -1,4 +1,4 @@ -<android.support.v7.widget.AppCompatSeekBar xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.AppCompatSeekBar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/kau_pref_lower_content" android:layout_width="match_parent" android:paddingTop="@dimen/kau_padding_normal" diff --git a/kpref-activity/src/main/res/layout/kau_pref_seekbar_text.xml b/kpref-activity/src/main/res/layout/kau_pref_seekbar_text.xml index dc11d2a..5834820 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_seekbar_text.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_seekbar_text.xml @@ -1,6 +1,6 @@ <!--TextView that aligns to the bottom--> -<android.support.v7.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/kau_pref_inner_content" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/kpref-activity/src/main/res/layout/kau_pref_text.xml b/kpref-activity/src/main/res/layout/kau_pref_text.xml index 40fed2a..b873eaf 100644 --- a/kpref-activity/src/main/res/layout/kau_pref_text.xml +++ b/kpref-activity/src/main/res/layout/kau_pref_text.xml @@ -1,4 +1,4 @@ -<android.support.v7.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.AppCompatTextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@id/kau_pref_inner_content" android:layout_width="wrap_content" android:layout_height="wrap_content" diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt index c0b7e2d..db4d18b 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt @@ -1,7 +1,7 @@ package ca.allanwang.kau.mediapicker import android.graphics.drawable.Drawable -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import ca.allanwang.kau.iitems.KauIItem import com.bumptech.glide.load.DataSource diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt index 59202c0..29babe2 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt @@ -3,7 +3,7 @@ package ca.allanwang.kau.mediapicker import android.annotation.SuppressLint import android.app.Activity import android.graphics.drawable.Drawable -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import ca.allanwang.kau.iitems.KauIItem import ca.allanwang.kau.ui.views.MeasuredImageView diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt index 26736d4..9fc83f9 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt @@ -6,7 +6,7 @@ import android.net.Uri import android.os.Parcel import android.os.Parcelable import android.provider.MediaStore -import android.support.annotation.NonNull +import androidx.annotation.NonNull import java.io.File @@ -36,8 +36,8 @@ data class MediaModel( ) constructor(parcel: Parcel) : this( - parcel.readString(), - parcel.readString(), + parcel.readString()!!, + parcel.readString()!!, parcel.readLong(), parcel.readLong(), parcel.readString()) diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt index 37f2373..b915cc8 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt @@ -2,15 +2,15 @@ package ca.allanwang.kau.mediapicker import android.database.Cursor import android.os.Bundle -import android.support.design.widget.AppBarLayout -import android.support.v4.content.Loader -import android.support.v7.widget.LinearLayoutManager +import androidx.loader.content.Loader +import androidx.recyclerview.widget.LinearLayoutManager import ca.allanwang.kau.adapters.selectedItems import ca.allanwang.kau.adapters.selectionSize import ca.allanwang.kau.utils.hideOnDownwardsScroll import ca.allanwang.kau.utils.setIcon import ca.allanwang.kau.utils.toDrawable import ca.allanwang.kau.utils.toast +import com.google.android.material.appbar.AppBarLayout import com.mikepenz.google_material_typeface_library.GoogleMaterial import kotlinx.android.synthetic.main.kau_activity_image_picker.* diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt index 122838b..2700780 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.mediapicker import android.os.Build import android.os.Bundle -import android.support.annotation.RequiresApi +import androidx.annotation.RequiresApi import ca.allanwang.kau.utils.toast import kotlinx.android.synthetic.main.kau_activity_image_picker_overlay.* diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt index 6e38d14..1092158 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -13,11 +13,11 @@ import android.os.Bundle import android.provider.BaseColumns import android.provider.DocumentsContract import android.provider.MediaStore -import android.support.v4.app.LoaderManager -import android.support.v4.content.CursorLoader -import android.support.v4.content.Loader -import android.support.v7.widget.GridLayoutManager -import android.support.v7.widget.RecyclerView +import androidx.loader.app.LoaderManager +import androidx.loader.content.CursorLoader +import androidx.loader.content.Loader +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.RecyclerView import ca.allanwang.kau.adapters.fastAdapter import ca.allanwang.kau.animators.FadeScaleAnimatorAdd import ca.allanwang.kau.animators.KauAnimator @@ -274,7 +274,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>( f = File(tempPath) tempPath = null } else if (data?.data != null) { - f = File(data.data.path) + f = File(data.data!!.path) } else { KL.d { "Media camera no file found" } return @@ -291,8 +291,8 @@ abstract class MediaPickerCore<T : IItem<*, *>>( private fun onPickerResult(data: Intent?) { val items = mutableListOf<Uri>() if (data?.data != null) { - KL.v { "Media picker data uri: ${data.data.path}" } - items.add(data.data) + KL.v { "Media picker data uri: ${data.data!!.path}" } + items.add(data.data!!) } else if (data != null) { val clip = data.clipData if (clip != null) { diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaUtils.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaUtils.kt index f37be75..1976172 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaUtils.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaUtils.kt @@ -6,7 +6,7 @@ import android.content.Context import android.content.Intent import android.net.Uri import android.os.Environment -import android.support.v7.app.AppCompatActivity +import androidx.appcompat.app.AppCompatActivity import ca.allanwang.kau.utils.buildIsLollipopAndUp import java.io.File import java.io.IOException diff --git a/mediapicker/src/main/res/layout-v21/kau_activity_image_picker_overlay.xml b/mediapicker/src/main/res/layout-v21/kau_activity_image_picker_overlay.xml index a0ce301..d7447b0 100644 --- a/mediapicker/src/main/res/layout-v21/kau_activity_image_picker_overlay.xml +++ b/mediapicker/src/main/res/layout-v21/kau_activity_image_picker_overlay.xml @@ -7,7 +7,7 @@ app:dragDismissDistance="@dimen/kau_drag_dismiss_distance_large" app:dragDismissScale="0.95"> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" diff --git a/mediapicker/src/main/res/layout/kau_activity_image_picker.xml b/mediapicker/src/main/res/layout/kau_activity_image_picker.xml index 1b46097..c3458cf 100644 --- a/mediapicker/src/main/res/layout/kau_activity_image_picker.xml +++ b/mediapicker/src/main/res/layout/kau_activity_image_picker.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/kau_coordinator" android:layout_width="match_parent" @@ -7,13 +7,13 @@ android:background="?android:colorBackground" android:fitsSystemWindows="true"> - <android.support.design.widget.AppBarLayout + <com.google.android.material.appbar.AppBarLayout android:id="@+id/kau_appbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> - <android.support.v7.widget.Toolbar + <androidx.appcompat.widget.Toolbar android:id="@+id/kau_toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" @@ -31,17 +31,17 @@ android:paddingStart="@dimen/kau_padding_normal" android:text="@string/kau_0" /> - </android.support.v7.widget.Toolbar> + </androidx.appcompat.widget.Toolbar> - </android.support.design.widget.AppBarLayout> + </com.google.android.material.appbar.AppBarLayout> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@+id/kau_recyclerview" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> - <android.support.design.widget.FloatingActionButton + <com.google.android.material.floatingactionbutton.FloatingActionButton android:id="@+id/kau_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" @@ -53,4 +53,4 @@ app:layout_anchorGravity="bottom|right|end" /> -</android.support.design.widget.CoordinatorLayout>
\ No newline at end of file +</androidx.coordinatorlayout.widget.CoordinatorLayout>
\ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index d7199a3..e9e5a2e 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -27,7 +27,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 +101,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 +125,13 @@ 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 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..3b7f932 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,16 @@ 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 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.filters.MediumTest +import androidx.test.rule.ActivityTestRule import android.view.View +import androidx.test.ext.junit.runners.AndroidJUnit4 import ca.allanwang.kau.colorpicker.CircleView import org.hamcrest.Matchers.anything import org.junit.Rule @@ -22,6 +22,8 @@ import kotlin.test.fail /** * Created by Allan Wang on 22/02/2018. + * + * Tests related to the :colorpicker module */ @RunWith(AndroidJUnit4::class) @MediumTest @@ -43,7 +45,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)) 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..31dfcb3 --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt @@ -0,0 +1,112 @@ +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..2acdc4d --- /dev/null +++ b/sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt @@ -0,0 +1,22 @@ +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/MediaPicker.kt b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt index 42de62c..820d22f 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/MediaPicker.kt @@ -2,7 +2,7 @@ package ca.allanwang.kau.sample import android.content.Context import android.net.Uri -import android.support.v4.content.FileProvider +import androidx.core.content.FileProvider import ca.allanwang.kau.mediapicker.* import java.io.File 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..09401cd 100644 --- a/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt +++ b/sample/src/main/kotlin/ca/allanwang/kau/sample/PermissionCheckbox.kt @@ -1,6 +1,6 @@ package ca.allanwang.kau.sample -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.view.View import android.widget.CheckBox import android.widget.TextView 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..6c0fea1 100644 --- a/sample/src/main/res/xml/kau_changelog.xml +++ b/sample/src/main/res/xml/kau_changelog.xml @@ -6,6 +6,10 @@ <item text="" /> --> + <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 +17,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" /> diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt index 0ae856a..86ed83d 100644 --- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt +++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchItem.kt @@ -2,14 +2,14 @@ package ca.allanwang.kau.searchview import android.graphics.Typeface import android.graphics.drawable.Drawable -import android.support.constraint.ConstraintLayout -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.RecyclerView import android.text.Spannable import android.text.SpannableStringBuilder import android.text.style.StyleSpan import android.view.View import android.widget.ImageView import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import ca.allanwang.kau.iitems.KauIItem import ca.allanwang.kau.utils.* import com.mikepenz.google_material_typeface_library.GoogleMaterial diff --git a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt index d223ec4..fecf6c5 100644 --- a/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt +++ b/searchview/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt @@ -4,12 +4,12 @@ import android.app.Activity import android.content.Context import android.content.res.ColorStateList import android.graphics.Color -import android.support.annotation.ColorInt -import android.support.annotation.IdRes -import android.support.transition.ChangeBounds -import android.support.transition.TransitionManager -import android.support.transition.TransitionSet -import android.support.v7.widget.RecyclerView +import androidx.annotation.ColorInt +import androidx.annotation.IdRes +import androidx.transition.ChangeBounds +import androidx.transition.TransitionManager +import androidx.transition.TransitionSet +import androidx.recyclerview.widget.RecyclerView import android.text.Editable import android.text.TextWatcher import android.util.AttributeSet diff --git a/searchview/src/main/res/layout/kau_search_iitem.xml b/searchview/src/main/res/layout/kau_search_iitem.xml index 16df945..53e33ef 100644 --- a/searchview/src/main/res/layout/kau_search_iitem.xml +++ b/searchview/src/main/res/layout/kau_search_iitem.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" android:id="@id/kau_search_item_frame" android:layout_width="match_parent" @@ -58,4 +58,4 @@ app:layout_constraintStart_toEndOf="@id/kau_search_icon" app:layout_constraintTop_toBottomOf="@id/kau_search_title" /> -</android.support.constraint.ConstraintLayout>
\ No newline at end of file +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/searchview/src/main/res/layout/kau_search_view.xml b/searchview/src/main/res/layout/kau_search_view.xml index c975dad..cfcb2ed 100644 --- a/searchview/src/main/res/layout/kau_search_view.xml +++ b/searchview/src/main/res/layout/kau_search_view.xml @@ -43,7 +43,7 @@ android:focusable="true" android:scaleType="centerInside" /> - <android.support.v7.widget.AppCompatEditText + <androidx.appcompat.widget.AppCompatEditText android:id="@id/kau_search_edit_text" android:layout_width="0dp" android:layout_height="match_parent" @@ -98,7 +98,7 @@ android:layout_height="@dimen/kau_search_divider" android:background="?android:attr/listDivider" /> - <android.support.v7.widget.RecyclerView + <androidx.recyclerview.widget.RecyclerView android:id="@id/kau_search_recycler" android:layout_width="match_parent" android:layout_height="wrap_content" |