From 061f8796441015cbcd914819934c9df3e8f178dd Mon Sep 17 00:00:00 2001 From: Semper-Viventem Date: Fri, 27 Jul 2018 17:08:20 +0300 Subject: [PATCH 01/18] Use android x without support --- backdrop/build.gradle | 8 ++--- .../backdrop/BackdropBehavior.kt | 10 +++--- gradle.properties | 2 ++ sample/build.gradle | 35 +++++-------------- .../backdropview/extensions.kt | 18 +++------- .../backdropview/ui/MainActivity.kt | 6 ++-- .../backdropview/ui/common/BaseListAdapter.kt | 4 +-- .../backdropview/ui/common/Screen.kt | 3 +- .../backdropview/ui/gallery/GalleryAdapter.kt | 2 +- .../backdropview/ui/gallery/GalleryScreen.kt | 6 ++-- .../backdropview/ui/list/ListItemsAdapter.kt | 2 +- .../backdropview/ui/list/ListScreen.kt | 2 +- sample/src/main/res/layout/activity_main.xml | 8 ++--- sample/src/main/res/layout/item_gallery.xml | 4 +-- sample/src/main/res/layout/item_list.xml | 8 ++--- sample/src/main/res/layout/screen_gallery.xml | 6 ++-- sample/src/main/res/layout/screen_list.xml | 6 ++-- sample/src/main/res/layout/screen_text.xml | 8 ++--- sample/src/main/res/values/styles.xml | 2 +- 19 files changed, 58 insertions(+), 82 deletions(-) diff --git a/backdrop/build.gradle b/backdrop/build.gradle index 331b605..1200dcc 100644 --- a/backdrop/build.gradle +++ b/backdrop/build.gradle @@ -37,11 +37,11 @@ subprojects { android { - compileSdkVersion 27 + compileSdkVersion 'android-P' defaultConfig { minSdkVersion 21 - targetSdkVersion 27 + targetSdkVersion 28 } buildTypes { @@ -57,14 +57,14 @@ android { } ext { - supportVersion = '27.1.1' kotlin_version = '1.2.41' } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "com.android.support:appcompat-v7:$supportVersion" + // Android X + implementation "androidx.appcompat:appcompat:1.0.0-beta01" // Kotlin implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" diff --git a/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt b/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt index 406fff0..7fecd09 100644 --- a/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt +++ b/backdrop/src/main/kotlin/ru/semper_viventem/backdrop/BackdropBehavior.kt @@ -3,11 +3,11 @@ package ru.semper_viventem.backdrop import android.content.Context import android.os.Bundle import android.os.Parcelable -import android.support.annotation.IdRes -import android.support.design.widget.CoordinatorLayout -import android.support.v7.widget.Toolbar import android.util.AttributeSet import android.view.View +import androidx.annotation.IdRes +import androidx.appcompat.widget.Toolbar +import androidx.coordinatorlayout.widget.CoordinatorLayout class BackdropBehavior : CoordinatorLayout.Behavior { @@ -48,13 +48,13 @@ class BackdropBehavior : CoordinatorLayout.Behavior { constructor(context: Context, attrs: AttributeSet) : super(context, attrs) - override fun onSaveInstanceState(parent: CoordinatorLayout?, child: View?): Parcelable { + override fun onSaveInstanceState(parent: CoordinatorLayout, child: View): Parcelable { return Bundle().apply { putSerializable(ARG_DROP_STATE, dropState) } } - override fun onRestoreInstanceState(parent: CoordinatorLayout?, child: View?, state: Parcelable?) { + override fun onRestoreInstanceState(parent: CoordinatorLayout, child: View, state: Parcelable) { super.onRestoreInstanceState(parent, child, state) dropState = (state as? Bundle)?.getSerializable(ARG_DROP_STATE) as? DropState ?: DEFAULT_DROP_STATE diff --git a/gradle.properties b/gradle.properties index 743d692..8cb12f2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,6 +7,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m +android.useAndroidX = true +android.enableJetifier = false # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects diff --git a/sample/build.gradle b/sample/build.gradle index 378bbda..109bfac 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -14,7 +14,6 @@ android { targetSdkVersion 28 versionCode 1 versionName "1.0" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { @@ -28,39 +27,23 @@ android { } } -ext { - supportVersion = '28.0.0-alpha3' - retrofitVersion = '2.2.0' - conductorVersion = "2.1.4" - playServicesVersion = "15.0.0" -} - androidExtensions { experimental = true } dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - // Support - implementation "com.android.support:appcompat-v7:$supportVersion" - implementation "com.android.support:design:$supportVersion" - implementation "com.android.support:recyclerview-v7:$supportVersion" - implementation "com.android.support:cardview-v7:$supportVersion" - implementation 'com.android.support.constraint:constraint-layout:1.1.2' - // Material Components - // implementation "com.google.android.material:material:1.0.0-alpha1" + + // Android X + implementation "androidx.appcompat:appcompat:1.0.0-beta01" + implementation "androidx.constraintlayout:constraintlayout:1.1.2" + implementation "com.google.android.material:material:1.0.0-beta01" + // Kotlin implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - // Tests - testImplementation 'junit:junit:4.12' - androidTestImplementation 'com.android.support.test:runner:1.0.2' - androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - // Logging - implementation 'com.jakewharton.timber:timber:4.5.1' + // Images - implementation 'com.github.bumptech.glide:glide:4.6.1' - kapt 'com.github.bumptech.glide:compiler:4.7.1' - // Lists - implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1' + implementation 'com.squareup.picasso:picasso:2.71828' + implementation project(':backdrop') } diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/extensions.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/extensions.kt index 0ed258d..39b5833 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/extensions.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/extensions.kt @@ -1,16 +1,14 @@ package ru.semper_viventem.backdropview import android.content.Context -import android.support.annotation.LayoutRes -import android.support.design.widget.CoordinatorLayout -import android.support.design.widget.CoordinatorLayout.Behavior import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.ImageView -import com.bumptech.glide.Glide -import com.bumptech.glide.request.RequestOptions +import androidx.annotation.LayoutRes +import androidx.coordinatorlayout.widget.CoordinatorLayout +import com.squareup.picasso.Picasso fun ViewGroup.inflate(@LayoutRes layoutRes: Int, attachToRoot: Boolean = false): View { @@ -34,15 +32,9 @@ fun View.showKeyboard(show: Boolean) { } fun ImageView.load( - url: String?, - round: Boolean = false + url: String? ) { - Glide.with(context) + Picasso.get() .load(url) - .apply { - if (round) { - apply(RequestOptions.circleCropTransform()) - } - } .into(this) } \ No newline at end of file diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt index c771da2..be3bbc5 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/MainActivity.kt @@ -1,9 +1,9 @@ package ru.semper_viventem.backdropview.ui import android.os.Bundle -import android.support.annotation.IdRes -import android.support.v4.app.Fragment -import android.support.v7.app.AppCompatActivity +import androidx.annotation.IdRes +import androidx.appcompat.app.AppCompatActivity +import androidx.fragment.app.Fragment import kotlinx.android.synthetic.main.activity_main.* import ru.semper_viventem.backdrop.BackdropBehavior import ru.semper_viventem.backdropview.R diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/BaseListAdapter.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/BaseListAdapter.kt index 0f589cc..c16e9ae 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/BaseListAdapter.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/BaseListAdapter.kt @@ -1,7 +1,7 @@ package ru.semper_viventem.backdropview.ui.common -import android.support.v7.util.DiffUtil -import android.support.v7.widget.RecyclerView +import androidx.recyclerview.widget.DiffUtil +import androidx.recyclerview.widget.RecyclerView /** * Easy to use base adapter for lists with single item type. diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/Screen.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/Screen.kt index 5f7b67f..f1f5f13 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/Screen.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/common/Screen.kt @@ -1,11 +1,10 @@ package ru.semper_viventem.backdropview.ui.common -import android.content.Context import android.os.Bundle -import android.support.v4.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.Fragment abstract class Screen : Fragment { diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryAdapter.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryAdapter.kt index 78faf63..da0f23a 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryAdapter.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryAdapter.kt @@ -1,8 +1,8 @@ package ru.semper_viventem.backdropview.ui.gallery -import android.support.v7.widget.RecyclerView import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.item_gallery.view.* import ru.semper_viventem.backdropview.R import ru.semper_viventem.backdropview.inflate diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryScreen.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryScreen.kt index 067a1ab..650e099 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryScreen.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/gallery/GalleryScreen.kt @@ -1,9 +1,9 @@ package ru.semper_viventem.backdropview.ui.gallery -import android.support.v7.widget.DividerItemDecoration -import android.support.v7.widget.GridLayoutManager -import android.support.v7.widget.LinearSnapHelper import android.view.View +import androidx.recyclerview.widget.DividerItemDecoration +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.LinearSnapHelper import kotlinx.android.synthetic.main.screen_gallery.view.* import ru.semper_viventem.backdropview.R import ru.semper_viventem.backdropview.ui.common.Screen diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListItemsAdapter.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListItemsAdapter.kt index 53a4a66..76ac4dd 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListItemsAdapter.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListItemsAdapter.kt @@ -1,8 +1,8 @@ package ru.semper_viventem.backdropview.ui.list -import android.support.v7.widget.RecyclerView import android.view.View import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView import kotlinx.android.synthetic.main.item_list.view.* import ru.semper_viventem.backdropview.R import ru.semper_viventem.backdropview.inflate diff --git a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListScreen.kt b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListScreen.kt index b7c8d14..d32d968 100644 --- a/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListScreen.kt +++ b/sample/src/main/kotlin/ru/semper_viventem/backdropview/ui/list/ListScreen.kt @@ -1,7 +1,7 @@ package ru.semper_viventem.backdropview.ui.list -import android.support.v7.widget.LinearLayoutManager import android.view.View +import androidx.recyclerview.widget.LinearLayoutManager import kotlinx.android.synthetic.main.screen_list.view.* import ru.semper_viventem.backdropview.R import ru.semper_viventem.backdropview.ui.common.Screen diff --git a/sample/src/main/res/layout/activity_main.xml b/sample/src/main/res/layout/activity_main.xml index a5f0462..31b8a93 100644 --- a/sample/src/main/res/layout/activity_main.xml +++ b/sample/src/main/res/layout/activity_main.xml @@ -1,5 +1,5 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/item_gallery.xml b/sample/src/main/res/layout/item_gallery.xml index 415245a..8173d4a 100644 --- a/sample/src/main/res/layout/item_gallery.xml +++ b/sample/src/main/res/layout/item_gallery.xml @@ -1,5 +1,5 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/item_list.xml b/sample/src/main/res/layout/item_list.xml index 1fc1dbe..43d140e 100644 --- a/sample/src/main/res/layout/item_list.xml +++ b/sample/src/main/res/layout/item_list.xml @@ -1,5 +1,5 @@ - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/screen_gallery.xml b/sample/src/main/res/layout/screen_gallery.xml index 67bb476..5e51a09 100644 --- a/sample/src/main/res/layout/screen_gallery.xml +++ b/sample/src/main/res/layout/screen_gallery.xml @@ -1,5 +1,5 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/screen_list.xml b/sample/src/main/res/layout/screen_list.xml index 6bc2446..42352ab 100644 --- a/sample/src/main/res/layout/screen_list.xml +++ b/sample/src/main/res/layout/screen_list.xml @@ -1,5 +1,5 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/layout/screen_text.xml b/sample/src/main/res/layout/screen_text.xml index b7f47ed..56ac96f 100644 --- a/sample/src/main/res/layout/screen_text.xml +++ b/sample/src/main/res/layout/screen_text.xml @@ -1,5 +1,5 @@ - - - + - \ No newline at end of file + \ No newline at end of file diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml index 0eb88fe..bdfe33e 100644 --- a/sample/src/main/res/values/styles.xml +++ b/sample/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ -