Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump deps and add support for gesture nav #35

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer-leakcanary/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer-leakcanary2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer-okhttp-logger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer-retrofit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer-timber/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
Expand Down
7 changes: 6 additions & 1 deletion debugdrawer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
23 changes: 23 additions & 0 deletions debugdrawer/src/main/kotlin/au/com/gridstone/debugdrawer/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T> SparseArray<T>.toSet(): Set<T> {
val set = LinkedHashSet<T>(this.size())

Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
9 changes: 7 additions & 2 deletions sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion simple-sample-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}