diff --git a/Owl/app/build.gradle b/Owl/app/build.gradle index fb1c449..ce4064c 100644 --- a/Owl/app/build.gradle +++ b/Owl/app/build.gradle @@ -18,46 +18,50 @@ apply plugin: 'kotlin-kapt' apply plugin: 'androidx.navigation.safeargs.kotlin' android { - compileSdkVersion 29 + compileSdkVersion 30 defaultConfig { applicationId 'com.materialstudies.owl' minSdkVersion 23 - targetSdkVersion 29 + targetSdkVersion 30 versionCode 1 versionName '1.0' vectorDrawables.useSupportLibrary = true } + dataBinding { enabled true } + buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { jvmTarget = "1.8" } } dependencies { - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.fragment:fragment:1.2.0-beta02' - implementation 'androidx.constraintlayout:constraintlayout:1.1.3' - implementation 'androidx.core:core-ktx:1.1.0' - implementation 'com.google.android.material:material:1.1.0-beta01' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'androidx.appcompat:appcompat:1.2.0' + implementation 'androidx.fragment:fragment-ktx:1.2.5' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' + implementation 'androidx.core:core-ktx:1.5.0-alpha04' + implementation 'com.google.android.material:material:1.2.1' + implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation "androidx.navigation:navigation-runtime-ktx:$nav_version" implementation "androidx.navigation:navigation-fragment-ktx:$nav_version" implementation "androidx.navigation:navigation-ui-ktx:$nav_version" implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' - implementation 'com.github.bumptech.glide:glide:4.9.0' - annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' + implementation 'com.github.bumptech.glide:glide:4.11.0' + annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0' } diff --git a/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonsSheetFragment.kt b/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonsSheetFragment.kt index 4ee5f6e..28945f1 100644 --- a/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonsSheetFragment.kt +++ b/Owl/app/src/main/java/com/materialstudies/owl/ui/lessons/LessonsSheetFragment.kt @@ -27,6 +27,7 @@ import android.view.ViewGroup import androidx.activity.addCallback import androidx.annotation.ColorInt import androidx.annotation.Px +import androidx.core.view.WindowInsetsCompat.Type import androidx.core.view.doOnLayout import androidx.core.view.forEach import androidx.core.view.postDelayed @@ -148,7 +149,7 @@ class LessonsSheetFragment : Fragment() { } }) lessonsSheet.doOnApplyWindowInsets { _, insets, _, _ -> - behavior.peekHeight = peek + insets.systemWindowInsetBottom + behavior.peekHeight = peek + insets.getInsets(Type.navigationBars()).bottom } } collapsePlaylist.setOnClickListener { diff --git a/Owl/app/src/main/java/com/materialstudies/owl/util/BindingAdapters.kt b/Owl/app/src/main/java/com/materialstudies/owl/util/BindingAdapters.kt index 1af559b..270e4fc 100644 --- a/Owl/app/src/main/java/com/materialstudies/owl/util/BindingAdapters.kt +++ b/Owl/app/src/main/java/com/materialstudies/owl/util/BindingAdapters.kt @@ -19,8 +19,9 @@ package com.materialstudies.owl.util import android.graphics.drawable.Drawable import android.view.View import android.view.ViewGroup -import android.view.WindowInsets import android.widget.ImageView +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat import androidx.core.view.updateLayoutParams import androidx.databinding.BindingAdapter import com.bumptech.glide.Glide @@ -55,6 +56,9 @@ fun View.bindElevationOverlay(previousElevation: Float, elevation: Float) { @BindingAdapter("layoutFullscreen") fun View.bindLayoutFullscreen(previousFullscreen: Boolean, fullscreen: Boolean) { if (previousFullscreen != fullscreen && fullscreen) { + @Suppress("DEPRECATION") + // The new alternative is WindowCompat.setDecorFitsSystemWindows, but we can't + // always get access to the window from a view. systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_STABLE or View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION @@ -87,10 +91,11 @@ fun View.applySystemWindowInsetsPadding( } doOnApplyWindowInsets { view, insets, padding, _ -> - val left = if (applyLeft) insets.systemWindowInsetLeft else 0 - val top = if (applyTop) insets.systemWindowInsetTop else 0 - val right = if (applyRight) insets.systemWindowInsetRight else 0 - val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0 + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + val left = if (applyLeft) systemBars.left else 0 + val top = if (applyTop) systemBars.top else 0 + val right = if (applyRight) systemBars.right else 0 + val bottom = if (applyBottom) systemBars.bottom else 0 view.setPadding( padding.left + left, @@ -127,10 +132,11 @@ fun View.applySystemWindowInsetsMargin( } doOnApplyWindowInsets { view, insets, _, margin -> - val left = if (applyLeft) insets.systemWindowInsetLeft else 0 - val top = if (applyTop) insets.systemWindowInsetTop else 0 - val right = if (applyRight) insets.systemWindowInsetRight else 0 - val bottom = if (applyBottom) insets.systemWindowInsetBottom else 0 + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + val left = if (applyLeft) systemBars.left else 0 + val top = if (applyTop) systemBars.top else 0 + val right = if (applyRight) systemBars.right else 0 + val bottom = if (applyBottom) systemBars.bottom else 0 view.updateLayoutParams { leftMargin = margin.left + left @@ -142,14 +148,14 @@ fun View.applySystemWindowInsetsMargin( } fun View.doOnApplyWindowInsets( - block: (View, WindowInsets, InitialPadding, InitialMargin) -> Unit + block: (View, WindowInsetsCompat, InitialPadding, InitialMargin) -> Unit ) { // Create a snapshot of the view's padding & margin states val initialPadding = recordInitialPaddingForView(this) val initialMargin = recordInitialMarginForView(this) // Set an actual OnApplyWindowInsetsListener which proxies to the given // lambda, also passing in the original padding & margin states - setOnApplyWindowInsetsListener { v, insets -> + ViewCompat.setOnApplyWindowInsetsListener(this) { v, insets -> block(v, insets, initialPadding, initialMargin) // Always return the insets, so that children can also use them insets diff --git a/Owl/build.gradle b/Owl/build.gradle index 6d482e7..ca25b34 100644 --- a/Owl/build.gradle +++ b/Owl/build.gradle @@ -13,14 +13,14 @@ */ buildscript { - ext.kotlin_version = '1.3.50' - ext.nav_version = '2.2.0-beta01' + ext.kotlin_version = '1.4.10' + ext.nav_version = '2.3.1' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" } diff --git a/Owl/gradle.properties b/Owl/gradle.properties index 23339e0..83df5e3 100644 --- a/Owl/gradle.properties +++ b/Owl/gradle.properties @@ -15,7 +15,5 @@ org.gradle.jvmargs=-Xmx1536m # Android operating system, and which are packaged with your app's APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -android.enableJetifier=true # Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official diff --git a/Owl/gradle/wrapper/gradle-wrapper.properties b/Owl/gradle/wrapper/gradle-wrapper.properties index f04d6a2..c5f2522 100644 --- a/Owl/gradle/wrapper/gradle-wrapper.properties +++ b/Owl/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Mon Nov 02 08:45:57 GMT 2020 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip