diff --git a/build.gradle b/build.gradle index 9d178c4..ece3ddf 100644 --- a/build.gradle +++ b/build.gradle @@ -3,20 +3,20 @@ buildscript { ext.versions = [ 'compile_sdk' : 29, 'min_sdk' : 21, - 'android_gradle_plugin' : '3.4.1', - 'kotlin' : '1.3.41', + 'android_gradle_plugin' : '3.5.0', + 'kotlin' : '1.3.50', 'maven_publish_plugin' : '0.8.0', - 'coroutines' : '1.2.2', - 'appcompat' : '1.0.2', - 'androidx_core' : '1.0.2', + 'coroutines' : '1.3.1', + 'appcompat' : '1.1.0', + 'androidx_core' : '1.1.0', 'drawerlayout' : '1.0.0', 'material' : '1.0.0', - 'lifecycle' : '2.0.0', + 'lifecycle' : '2.1.0', 'leakcanary' : '1.6.3', - 'leakcanary2' : '2.0-beta-2', + 'leakcanary2' : '2.0-beta-3', 'moshi' : '1.8.0', - 'okhttp' : '4.0.0', - 'retrofit' : '2.6.0', + 'okhttp' : '4.2.0', + 'retrofit' : '2.6.1', 'retrofit_coroutines' : '0.9.2', 'picasso' : '2.71828', 'process_phoenix' : '2.0.0', diff --git a/debugdrawer-leakcanary/build.gradle b/debugdrawer-leakcanary/build.gradle index 4a072cb..0bbd675 100644 --- a/debugdrawer-leakcanary/build.gradle +++ b/debugdrawer-leakcanary/build.gradle @@ -13,13 +13,18 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { implementation project(':debugdrawer') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "com.squareup.leakcanary:leakcanary-android:${versions.leakcanary}" } } diff --git a/debugdrawer-leakcanary2/build.gradle b/debugdrawer-leakcanary2/build.gradle index 8cbd98c..1154c87 100644 --- a/debugdrawer-leakcanary2/build.gradle +++ b/debugdrawer-leakcanary2/build.gradle @@ -13,13 +13,18 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { implementation project(':debugdrawer') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "com.squareup.leakcanary:leakcanary-android:${versions.leakcanary2}" } } diff --git a/debugdrawer-okhttp-logger/build.gradle b/debugdrawer-okhttp-logger/build.gradle index 0958c46..67101c5 100644 --- a/debugdrawer-okhttp-logger/build.gradle +++ b/debugdrawer-okhttp-logger/build.gradle @@ -13,13 +13,18 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { implementation project(':debugdrawer') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "com.squareup.okhttp3:okhttp:${versions.okhttp}" implementation "com.squareup.okhttp3:logging-interceptor:${versions.okhttp}" implementation "com.jakewharton.timber:timber:${versions.timber}" diff --git a/debugdrawer-retrofit/build.gradle b/debugdrawer-retrofit/build.gradle index 0e4b438..5336358 100644 --- a/debugdrawer-retrofit/build.gradle +++ b/debugdrawer-retrofit/build.gradle @@ -13,13 +13,18 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { implementation project(':debugdrawer') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "com.squareup.retrofit2:retrofit-mock:${versions.retrofit}" implementation "com.jakewharton:process-phoenix:${versions.process_phoenix}" } diff --git a/debugdrawer-timber/build.gradle b/debugdrawer-timber/build.gradle index 29d07b7..e159e52 100644 --- a/debugdrawer-timber/build.gradle +++ b/debugdrawer-timber/build.gradle @@ -13,13 +13,18 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { implementation project(':debugdrawer') - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "com.jakewharton.timber:timber:${versions.timber}" implementation "androidx.core:core:${versions.androidx_core}" } diff --git a/debugdrawer/build.gradle b/debugdrawer/build.gradle index 03b76e1..2fc3888 100644 --- a/debugdrawer/build.gradle +++ b/debugdrawer/build.gradle @@ -13,12 +13,17 @@ android { main.java.srcDirs += 'src/main/kotlin' } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + libraryVariants.all { it.generateBuildConfig.enabled = false } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "androidx.drawerlayout:drawerlayout:${versions.drawerlayout}" } } diff --git a/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/DebugDrawer.kt b/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/DebugDrawer.kt index acce970..fd855ec 100644 --- a/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/DebugDrawer.kt +++ b/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/DebugDrawer.kt @@ -4,12 +4,15 @@ import android.app.Activity import android.app.Application.ActivityLifecycleCallbacks import android.content.res.Resources import android.graphics.Color +import android.graphics.Rect +import android.os.Build import android.os.Bundle import android.util.SparseArray import android.view.ContextThemeWrapper import android.view.Gravity.END import android.view.LayoutInflater import android.view.View +import android.view.View.LAYOUT_DIRECTION_RTL import android.view.View.OnApplyWindowInsetsListener import android.view.ViewGroup import android.view.ViewGroup.LayoutParams.MATCH_PARENT @@ -151,6 +154,25 @@ object DebugDrawer { val insetListener = InsetListener(drawerContentScrollView, drawerContent) container.setOnApplyWindowInsetsListener(insetListener) + // Exclude gestures on the top 200dp on the end-side of the DrawerLayout. This allows the + // drawer to be revealed even with gesture navigation enabled. + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + drawerLayout.doOnLayout { view -> + val rect = Rect(0, 0, 0, view.dpToPx(200)) + val isRtl = view.resources.configuration.layoutDirection == LAYOUT_DIRECTION_RTL + + if (isRtl) { + rect.left = 0 + rect.right = view.dpToPx(32) + } else { + rect.left = view.width - view.dpToPx(32) + rect.right = view.width + } + + view.systemGestureExclusionRects = listOf(rect) + } + } + // Add the DrawerLayout to the activity, register lifecycle callbacks to inform modules of // attach/detach events, and return the main container the activity can use to push and pop // screen views. diff --git a/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/Utils.kt b/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/Utils.kt index 38f3cf2..300b08c 100644 --- a/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/Utils.kt +++ b/debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/Utils.kt @@ -12,6 +12,29 @@ internal fun View.dpToPx(dp: Int): Int = resources.dpToPx(dp) internal fun ViewGroup.inflate(layoutRes: Int, attach: Boolean = false) = LayoutInflater.from(context).inflate(layoutRes, this, false) +internal inline fun View.doOnLayout(crossinline action: (view: View) -> Unit) { + if (isLaidOut && !isLayoutRequested) { + action(this) + } else { + addOnLayoutChangeListener(object : View.OnLayoutChangeListener { + override fun onLayoutChange( + view: View, + left: Int, + top: Int, + right: Int, + bottom: Int, + oldLeft: Int, + oldTop: Int, + oldRight: Int, + oldBottom: Int + ) { + view.removeOnLayoutChangeListener(this) + action(view) + } + }) + } +} + internal fun SparseArray.toSet(): Set { val set = LinkedHashSet(this.size()) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 43bb256..a32d5bc 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu May 23 21:00:47 AEST 2019 +#Thu Sep 12 14:59:55 AEST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/sample-app/build.gradle b/sample-app/build.gradle index 5a6eecb..2595809 100644 --- a/sample-app/build.gradle +++ b/sample-app/build.gradle @@ -24,10 +24,15 @@ android { debug.java.srcDirs += 'src/debug/kotlin' release.java.srcDirs += 'src/release/kotlin' } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.coroutines}" debugImplementation project(':debugdrawer') debugImplementation project(':debugdrawer-leakcanary2') @@ -38,7 +43,7 @@ dependencies { implementation "androidx.drawerlayout:drawerlayout:${versions.drawerlayout}" implementation "com.google.android.material:material:${versions.material}" implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:${versions.lifecycle}" - implementation "androidx.lifecycle:lifecycle-livedata:${versions.lifecycle}" + implementation "androidx.lifecycle:lifecycle-livedata-ktx:${versions.lifecycle}" implementation "androidx.lifecycle:lifecycle-extensions:${versions.lifecycle}" debugImplementation "com.squareup.leakcanary:leakcanary-android:${versions.leakcanary2}" implementation "com.squareup.moshi:moshi:${versions.moshi}" diff --git a/sample-app/src/main/kotlin/au/com/gridstone/debugdrawer/sampleapp/MainActivity.kt b/sample-app/src/main/kotlin/au/com/gridstone/debugdrawer/sampleapp/MainActivity.kt index ec38606..ad55de8 100644 --- a/sample-app/src/main/kotlin/au/com/gridstone/debugdrawer/sampleapp/MainActivity.kt +++ b/sample-app/src/main/kotlin/au/com/gridstone/debugdrawer/sampleapp/MainActivity.kt @@ -10,8 +10,9 @@ import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.widget.Toolbar import androidx.core.view.GravityCompat import androidx.drawerlayout.widget.DrawerLayout -import androidx.lifecycle.Observer import androidx.lifecycle.ViewModelProviders +import androidx.lifecycle.get +import androidx.lifecycle.observe import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import au.com.gridstone.debugdrawer.sampleapp.AppConfiguration.getRootViewContainerFor @@ -40,10 +41,10 @@ class MainActivity : AppCompatActivity() { recycler.layoutManager = LinearLayoutManager(this) val viewAnimator: ViewAnimator = findViewById(R.id.games_viewAnimator) - val viewModel: GamesViewModel = ViewModelProviders.of(this).get(GamesViewModel::class.java) + val viewModel: GamesViewModel = ViewModelProviders.of(this).get() // Observe ViewModel state and change UI accordingly. - viewModel.states.observe(this, Observer { state -> + viewModel.states.observe(this) { state -> when (state) { State.Idle, State.Loading -> viewAnimator.displayedChild = 0 @@ -58,7 +59,7 @@ class MainActivity : AppCompatActivity() { viewAnimator.displayedChild = 2 } } - }) + } // Put refresh button in toolbar menu and have it refresh the games list. toolbar.inflateMenu(R.menu.home) diff --git a/simple-sample-app/build.gradle b/simple-sample-app/build.gradle index f263724..d9ed987 100644 --- a/simple-sample-app/build.gradle +++ b/simple-sample-app/build.gradle @@ -24,9 +24,14 @@ android { debug.java.srcDirs += 'src/debug/kotlin' release.java.srcDirs += 'src/release/kotlin' } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } } dependencies { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin}" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}" debugImplementation project(':debugdrawer') }