From a380adea1052d39f23c9c4d432a9380ce347d6c4 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Mon, 24 Dec 2018 00:27:25 -0500 Subject: 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 --- README.md | 2 +- .../ca/allanwang/kau/about/AboutActivityBase.kt | 4 +- .../ca/allanwang/kau/about/AboutPanelDelegate.kt | 2 +- .../ca/allanwang/kau/about/CollapsibleTextView.kt | 2 +- .../kotlin/ca/allanwang/kau/about/CutoutIItem.kt | 2 +- .../main/kotlin/ca/allanwang/kau/about/FaqIItem.kt | 2 +- .../kotlin/ca/allanwang/kau/about/LibraryIItem.kt | 4 +- .../res/layout/kau_about_section_libraries.xml | 6 +- .../src/main/res/layout/kau_about_section_main.xml | 8 +- about/src/main/res/layout/kau_activity_about.xml | 2 +- about/src/main/res/layout/kau_iitem_library.xml | 8 +- .../kau/adapters/FastItemThemedAdapter.kt | 2 +- .../kau/adapters/RepeatedClickListener.kt | 2 +- .../allanwang/kau/animators/AnimatorInterfaces.kt | 2 +- .../allanwang/kau/animators/BaseItemAnimator.java | 13 +- .../ca/allanwang/kau/animators/DefaultAnimator.kt | 2 +- .../allanwang/kau/animators/FadeScaleAnimator.kt | 2 +- .../ca/allanwang/kau/animators/KauAnimator.kt | 2 +- .../ca/allanwang/kau/animators/NoAnimator.kt | 2 +- .../ca/allanwang/kau/animators/SlideAnimator.kt | 2 +- .../kotlin/ca/allanwang/kau/iitems/CardIItem.kt | 4 +- .../kotlin/ca/allanwang/kau/iitems/HeaderIItem.kt | 4 +- .../kotlin/ca/allanwang/kau/iitems/KauIItem.kt | 4 +- adapter/src/main/res/layout/kau_iitem_card.xml | 8 +- adapter/src/main/res/layout/kau_iitem_header.xml | 4 +- android-lib.gradle | 3 +- buildSrc/README.md | 2 +- .../groovy/ca/allanwang/kau/Dependencies.groovy | 5 +- .../main/groovy/ca/allanwang/kau/Versions.groovy | 46 ++++--- .../ca/allanwang/kau/colorpicker/CircleView.kt | 10 +- .../allanwang/kau/colorpicker/ColorPickerDialog.kt | 4 +- .../allanwang/kau/colorpicker/ColorPickerView.kt | 4 +- .../kau/ui/activities/ElasticRecyclerActivity.kt | 9 +- .../ca/allanwang/kau/ui/views/BoundedCardView.kt | 2 +- .../ca/allanwang/kau/ui/views/MeasuredImageView.kt | 2 +- .../ui/widgets/ElasticDragDismissFrameLayout.kt | 2 +- .../allanwang/kau/ui/widgets/InkPageIndicator.java | 4 +- .../ca/allanwang/kau/ui/widgets/TextSlider.kt | 2 +- .../layout/kau_elastic_recycler_activity.xml | 16 +-- .../layout/kau_recycler_detached_background.xml | 4 +- .../res-public/layout/kau_recycler_textslider.xml | 10 +- core/build.gradle | 12 +- .../kotlin/ca/allanwang/kau/kpref/KPrefTest.kt | 9 +- .../ca/allanwang/kau/utils/KotterknifeTest.kt | 8 +- .../kotlin/ca/allanwang/kau/xml/FaqTest.kt | 15 ++- .../kotlin/ca/allanwang/kau/email/EmailBuilder.kt | 2 +- .../ca/allanwang/kau/internal/KauBaseActivity.kt | 2 +- .../kotlin/ca/allanwang/kau/kotlin/LazyContext.kt | 4 +- .../allanwang/kau/permissions/PermissionManager.kt | 2 +- .../ca/allanwang/kau/permissions/Permissions.kt | 2 +- .../ca/allanwang/kau/swipe/SwipeBackLayout.kt | 2 +- .../ca/allanwang/kau/swipe/ViewDragHelper.java | 4 +- .../ca/allanwang/kau/ui/SimpleRippleDrawable.kt | 4 +- .../kotlin/ca/allanwang/kau/utils/ActivityUtils.kt | 16 ++- .../kotlin/ca/allanwang/kau/utils/AnimHolder.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/AnimUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/BundleUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/ColorUtils.kt | 12 +- .../main/kotlin/ca/allanwang/kau/utils/Const.kt | 3 +- .../kotlin/ca/allanwang/kau/utils/ContextUtils.kt | 4 +- .../kotlin/ca/allanwang/kau/utils/DrawableUtils.kt | 4 +- .../kotlin/ca/allanwang/kau/utils/FragmentUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/IIconUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/Kotterknife.kt | 135 ++++++--------------- .../ca/allanwang/kau/utils/NotificationUtils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/RecyclerUtils.kt | 2 +- .../ca/allanwang/kau/utils/TransitionUtils.kt | 14 +-- .../main/kotlin/ca/allanwang/kau/utils/Utils.kt | 2 +- .../kotlin/ca/allanwang/kau/utils/ViewUtils.kt | 20 +-- .../main/kotlin/ca/allanwang/kau/xml/Changelog.kt | 8 +- core/src/main/kotlin/ca/allanwang/kau/xml/FAQ.kt | 2 +- docs/Changelog.md | 3 + docs/Migration.md | 9 ++ gradle.properties | 2 + .../allanwang/kau/kpref/activity/KPrefActivity.kt | 4 +- .../ca/allanwang/kau/kpref/activity/KPrefBinder.kt | 2 +- .../kau/kpref/activity/items/KPrefCheckbox.kt | 2 +- .../kau/kpref/activity/items/KPrefItemBase.kt | 2 +- .../kau/kpref/activity/items/KPrefItemCore.kt | 10 +- .../src/main/res/layout/kau_pref_activity.xml | 8 +- .../src/main/res/layout/kau_pref_checkbox.xml | 2 +- .../src/main/res/layout/kau_pref_core.xml | 12 +- .../src/main/res/layout/kau_pref_header.xml | 2 +- .../src/main/res/layout/kau_pref_seekbar.xml | 2 +- .../src/main/res/layout/kau_pref_seekbar_text.xml | 2 +- .../src/main/res/layout/kau_pref_text.xml | 2 +- .../ca/allanwang/kau/mediapicker/MediaItem.kt | 2 +- .../ca/allanwang/kau/mediapicker/MediaItemBasic.kt | 2 +- .../ca/allanwang/kau/mediapicker/MediaModel.kt | 6 +- .../kau/mediapicker/MediaPickerActivityBase.kt | 6 +- .../mediapicker/MediaPickerActivityOverlayBase.kt | 2 +- .../allanwang/kau/mediapicker/MediaPickerCore.kt | 16 +-- .../ca/allanwang/kau/mediapicker/MediaUtils.kt | 2 +- .../kau_activity_image_picker_overlay.xml | 2 +- .../main/res/layout/kau_activity_image_picker.xml | 16 +-- sample/build.gradle | 24 ++-- .../ca/allanwang/kau/sample/ColorPickerTest.kt | 24 ++-- .../ca/allanwang/kau/sample/KPrefViewTest.kt | 112 +++++++++++++++++ .../ca/allanwang/kau/sample/utils/EspressoUtils.kt | 22 ++++ sample/src/main/AndroidManifest.xml | 2 +- .../kotlin/ca/allanwang/kau/sample/MediaPicker.kt | 2 +- .../ca/allanwang/kau/sample/PermissionCheckbox.kt | 2 +- sample/src/main/res/layout/activity_swipe.xml | 6 +- sample/src/main/res/xml/kau_changelog.xml | 5 +- .../ca/allanwang/kau/searchview/SearchItem.kt | 4 +- .../ca/allanwang/kau/searchview/SearchView.kt | 12 +- .../src/main/res/layout/kau_search_iitem.xml | 4 +- searchview/src/main/res/layout/kau_search_view.xml | 4 +- 108 files changed, 496 insertions(+), 365 deletions(-) create mode 100644 sample/src/androidTest/kotlin/ca/allanwang/kau/sample/KPrefViewTest.kt create mode 100644 sample/src/androidTest/kotlin/ca/allanwang/kau/sample/utils/EspressoUtils.kt diff --git a/README.md b/README.md index 75df4db..4143ca8 100644 --- a/README.md +++ b/README.md @@ -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 @@ - - - + 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 @@ - - @@ -41,6 +41,6 @@ - + - + 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"> - 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 @@ - - - + - \ No newline at end of file + \ 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 @@ - - @@ -69,6 +69,6 @@ - + - + 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 @@ - - \ No newline at end of file + \ 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"> - - - - + - - - + \ 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 @@ - + app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" /> 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 @@ - - - + - - + 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(), "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() + @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. *

- * 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 View.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindView(id: Int) - : ReadOnlyProperty = required(id, viewFinder) + : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindView(id: Int) : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindView(id: Int) - : ReadOnlyProperty = required(id, viewFinder) + : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) -fun ViewHolder.bindView(id: Int) - : ReadOnlyProperty = required(id, viewFinder) +fun RecyclerView.ViewHolder.bindView(id: Int) + : ReadOnlyProperty = required(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindOptionalView(id: Int) - : ReadOnlyProperty = optional(id, viewFinder) + : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindOptionalView(id: Int) : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindOptionalView(id: Int) - : ReadOnlyProperty = optional(id, viewFinder) + : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) -fun ViewHolder.bindOptionalView(id: Int) - : ReadOnlyProperty = optional(id, viewFinder) +fun RecyclerView.ViewHolder.bindOptionalView(id: Int) + : ReadOnlyProperty = optional(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindViews(vararg ids: Int) - : ReadOnlyProperty> = required(ids, viewFinder) + : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindViews(vararg ids: Int) - : ReadOnlyProperty> = required(ids, viewFinder) + : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindViews(vararg ids: Int) : ReadOnlyProperty> = required(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindOptionalViews(vararg ids: Int) - : ReadOnlyProperty> = optional(ids, viewFinder) + : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindOptionalViews(vararg ids: Int) - : ReadOnlyProperty> = optional(ids, viewFinder) + : ReadOnlyProperty> = optional(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindOptionalViews(vararg ids: Int) : ReadOnlyProperty> = optional(ids, viewFinder) @@ -189,13 +161,13 @@ private fun optional(ids: IntArray, finder: T.(Int) -> View?) = La private open class Lazy(private val initializer: (T, KProperty<*>) -> V) : ReadOnlyProperty { 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(private val initializer: (T, KProperty<*>) * Credits to MichaelRocks */ -@Deprecated(DEPRECATION_MESSAGE) fun View.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindViewResettable(id: Int) - : ReadOnlyProperty = requiredResettable(id, viewFinder) + : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindViewResettable(id: Int) - : ReadOnlyProperty = requiredResettable(id, viewFinder) + : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindViewResettable(id: Int) : ReadOnlyProperty = requiredResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindOptionalViewResettable(id: Int) - : ReadOnlyProperty = optionalResettable(id, viewFinder) + : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindOptionalViewResettable(id: Int) - : ReadOnlyProperty = optionalResettable(id, viewFinder) + : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindOptionalViewResettable(id: Int) : ReadOnlyProperty = optionalResettable(id, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindViewsResettable(vararg ids: Int) - : ReadOnlyProperty> = requiredResettable(ids, viewFinder) + : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindViewsResettable(vararg ids: Int) - : ReadOnlyProperty> = requiredResettable(ids, viewFinder) + : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindViewsResettable(vararg ids: Int) : ReadOnlyProperty> = requiredResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun View.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Activity.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Dialog.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun DialogFragment.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportDialogFragment.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun Fragment.bindOptionalViewsResettable(vararg ids: Int) : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun SupportFragment.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty> = optionalResettable(ids, viewFinder) -@Deprecated(DEPRECATION_MESSAGE) fun ViewHolder.bindOptionalViewsResettable(vararg ids: Int) - : ReadOnlyProperty> = optionalResettable(ids, viewFinder) + : ReadOnlyProperty> = optionalResettable(ids, viewFinder) private fun 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(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>>() - 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 @@ - @@ -13,7 +13,7 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - - - + 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 @@ - - - - - - - + \ 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 @@ - ->( 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>( private fun onPickerResult(data: Intent?) { val items = mutableListOf() 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"> - - - - - + - + - - - \ No newline at end of file + \ 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 = ActivityTestRule(MainActivity::class.java) + + fun verifyCheck(checked: Boolean): Matcher { + return object : BoundedMatcher(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(R.id.kau_pref_inner_content).isChecked == checked + } + } + + inline fun ViewInteraction.checkInnerContent(desc: String, crossinline matcher: (T) -> Boolean): ViewInteraction { + val viewMatcher = object : BaseMatcher() { + 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(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("$tag should be ${if (checked) "checked" else "not checked"}") { + it.isChecked == checked + }.check { view, _ -> + ((view.alpha == 1f) == enabled) + } + + fun onCheckboxView(vararg matchers: Matcher) = + 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 index(index: Int, matcher: Matcher): Matcher = + object : BaseMatcher() { + + 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 first(matcher: Matcher): Matcher = 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" /> 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 @@ - - - \ No newline at end of file + \ 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 @@ --> + + + + @@ -13,7 +17,6 @@ - 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 @@ - - \ No newline at end of file + \ 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" /> - -