Skip to content

Commit e4fa57d

Browse files
authored
Merge pull request material-components#60 from chrisbanes/cb/owl-update
Update Owl
2 parents ce2a756 + c05955c commit e4fa57d

File tree

6 files changed

+38
-28
lines changed

6 files changed

+38
-28
lines changed

Owl/app/build.gradle

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,50 @@ apply plugin: 'kotlin-kapt'
1818
apply plugin: 'androidx.navigation.safeargs.kotlin'
1919

2020
android {
21-
compileSdkVersion 29
21+
compileSdkVersion 30
2222
defaultConfig {
2323
applicationId 'com.materialstudies.owl'
2424
minSdkVersion 23
25-
targetSdkVersion 29
25+
targetSdkVersion 30
2626
versionCode 1
2727
versionName '1.0'
2828
vectorDrawables.useSupportLibrary = true
2929
}
30+
3031
dataBinding {
3132
enabled true
3233
}
34+
3335
buildTypes {
3436
release {
3537
minifyEnabled false
3638
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
3739
}
3840
}
41+
3942
compileOptions {
4043
sourceCompatibility JavaVersion.VERSION_1_8
4144
targetCompatibility JavaVersion.VERSION_1_8
4245
}
46+
4347
kotlinOptions {
4448
jvmTarget = "1.8"
4549
}
4650
}
4751

4852
dependencies {
49-
implementation 'androidx.appcompat:appcompat:1.1.0'
50-
implementation 'androidx.fragment:fragment:1.2.0-beta02'
51-
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
52-
implementation 'androidx.core:core-ktx:1.1.0'
53-
implementation 'com.google.android.material:material:1.1.0-beta01'
54-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
53+
implementation 'androidx.appcompat:appcompat:1.2.0'
54+
implementation 'androidx.fragment:fragment-ktx:1.2.5'
55+
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
56+
implementation 'androidx.core:core-ktx:1.5.0-alpha04'
57+
implementation 'com.google.android.material:material:1.2.1'
58+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
5559

5660
implementation "androidx.navigation:navigation-runtime-ktx:$nav_version"
5761
implementation "androidx.navigation:navigation-fragment-ktx:$nav_version"
5862
implementation "androidx.navigation:navigation-ui-ktx:$nav_version"
5963
implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0'
6064

61-
implementation 'com.github.bumptech.glide:glide:4.9.0'
62-
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
65+
implementation 'com.github.bumptech.glide:glide:4.11.0'
66+
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
6367
}

Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonsSheetFragment.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import android.view.ViewGroup
2727
import androidx.activity.addCallback
2828
import androidx.annotation.ColorInt
2929
import androidx.annotation.Px
30+
import androidx.core.view.WindowInsetsCompat.Type
3031
import androidx.core.view.doOnLayout
3132
import androidx.core.view.forEach
3233
import androidx.core.view.postDelayed
@@ -148,7 +149,7 @@ class LessonsSheetFragment : Fragment() {
148149
}
149150
})
150151
lessonsSheet.doOnApplyWindowInsets { _, insets, _, _ ->
151-
behavior.peekHeight = peek + insets.systemWindowInsetBottom
152+
behavior.peekHeight = peek + insets.getInsets(Type.navigationBars()).bottom
152153
}
153154
}
154155
collapsePlaylist.setOnClickListener {

Owl/app/src/main/java/com/materialstudies/owl/util/BindingAdapters.kt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ package com.materialstudies.owl.util
1919
import android.graphics.drawable.Drawable
2020
import android.view.View
2121
import android.view.ViewGroup
22-
import android.view.WindowInsets
2322
import android.widget.ImageView
23+
import androidx.core.view.ViewCompat
24+
import androidx.core.view.WindowInsetsCompat
2425
import androidx.core.view.updateLayoutParams
2526
import androidx.databinding.BindingAdapter
2627
import com.bumptech.glide.Glide
@@ -55,6 +56,9 @@ fun View.bindElevationOverlay(previousElevation: Float, elevation: Float) {
5556
@BindingAdapter("layoutFullscreen")
5657
fun View.bindLayoutFullscreen(previousFullscreen: Boolean, fullscreen: Boolean) {
5758
if (previousFullscreen != fullscreen && fullscreen) {
59+
@Suppress("DEPRECATION")
60+
// The new alternative is WindowCompat.setDecorFitsSystemWindows, but we can't
61+
// always get access to the window from a view.
5862
systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or
5963
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or
6064
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
@@ -87,10 +91,11 @@ fun View.applySystemWindowInsetsPadding(
8791
}
8892

8993
doOnApplyWindowInsets { view, insets, padding, _ ->
90-
val left = if (applyLeft) insets.systemWindowInsetLeft else 0
91-
val top = if (applyTop) insets.systemWindowInsetTop else 0
92-
val right = if (applyRight) insets.systemWindowInsetRight else 0
93-
val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0
94+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
95+
val left = if (applyLeft) systemBars.left else 0
96+
val top = if (applyTop) systemBars.top else 0
97+
val right = if (applyRight) systemBars.right else 0
98+
val bottom = if (applyBottom) systemBars.bottom else 0
9499

95100
view.setPadding(
96101
padding.left + left,
@@ -127,10 +132,11 @@ fun View.applySystemWindowInsetsMargin(
127132
}
128133

129134
doOnApplyWindowInsets { view, insets, _, margin ->
130-
val left = if (applyLeft) insets.systemWindowInsetLeft else 0
131-
val top = if (applyTop) insets.systemWindowInsetTop else 0
132-
val right = if (applyRight) insets.systemWindowInsetRight else 0
133-
val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0
135+
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
136+
val left = if (applyLeft) systemBars.left else 0
137+
val top = if (applyTop) systemBars.top else 0
138+
val right = if (applyRight) systemBars.right else 0
139+
val bottom = if (applyBottom) systemBars.bottom else 0
134140

135141
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
136142
leftMargin = margin.left + left
@@ -142,14 +148,14 @@ fun View.applySystemWindowInsetsMargin(
142148
}
143149

144150
fun View.doOnApplyWindowInsets(
145-
block: (View, WindowInsets, InitialPadding, InitialMargin) -> Unit
151+
block: (View, WindowInsetsCompat, InitialPadding, InitialMargin) -> Unit
146152
) {
147153
// Create a snapshot of the view's padding & margin states
148154
val initialPadding = recordInitialPaddingForView(this)
149155
val initialMargin = recordInitialMarginForView(this)
150156
// Set an actual OnApplyWindowInsetsListener which proxies to the given
151157
// lambda, also passing in the original padding & margin states
152-
setOnApplyWindowInsetsListener { v, insets ->
158+
ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets ->
153159
block(v, insets, initialPadding, initialMargin)
154160
// Always return the insets, so that children can also use them
155161
insets

Owl/build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
*/
1414

1515
buildscript {
16-
ext.kotlin_version = '1.3.50'
17-
ext.nav_version = '2.2.0-beta01'
16+
ext.kotlin_version = '1.4.10'
17+
ext.nav_version = '2.3.1'
1818
repositories {
1919
google()
2020
jcenter()
2121
}
2222
dependencies {
23-
classpath 'com.android.tools.build:gradle:3.5.0'
23+
classpath 'com.android.tools.build:gradle:4.1.0'
2424
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
2525
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
2626
}

Owl/gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@ org.gradle.jvmargs=-Xmx1536m
1515
# Android operating system, and which are packaged with your app's APK
1616
# https://developer.android.com/topic/libraries/support-library/androidx-rn
1717
android.useAndroidX=true
18-
# Automatically convert third-party libraries to use AndroidX
19-
android.enableJetifier=true
2018
# Kotlin code style for this project: "official" or "obsolete":
2119
kotlin.code.style=official
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
#Mon Nov 02 08:45:57 GMT 2020
12
distributionBase=GRADLE_USER_HOME
23
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip

0 commit comments

Comments
 (0)