Skip to content
This repository was archived by the owner on Nov 21, 2024. It is now read-only.
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
24 changes: 14 additions & 10 deletions Owl/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<ViewGroup.MarginLayoutParams> {
leftMargin = margin.left + left
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions Owl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
2 changes: 0 additions & 2 deletions Owl/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion Owl/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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