-
-
Notifications
You must be signed in to change notification settings - Fork 514
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
fix(Android): fix build deprecations #2116
Changes from all commits
1c8db08
4c36950
f1b34fe
b47f95f
d6d68e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,8 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper { | |
|
||
override fun setToolbarShadowHidden(hidden: Boolean) { | ||
if (isToolbarShadowHidden != hidden) { | ||
appBarLayout?.targetElevation = if (hidden) 0f else PixelUtil.toPixelFromDIP(4f) | ||
appBarLayout?.elevation = if (hidden) 0f else PixelUtil.toPixelFromDIP(4f) | ||
appBarLayout?.stateListAnimator = null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without it the elevation is not set properly on initial render, I suppose the shadow is there by default so we have to reset it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
isToolbarShadowHidden = hidden | ||
} | ||
} | ||
|
@@ -125,7 +126,7 @@ class ScreenStackFragment : ScreenFragment, ScreenStackFragmentWrapper { | |
|
||
view?.addView(appBarLayout) | ||
if (isToolbarShadowHidden) { | ||
appBarLayout?.targetElevation = 0f | ||
appBarLayout?.elevation = 0f | ||
} | ||
toolbar?.let { appBarLayout?.addView(recycleView(it)) } | ||
setHasOptionsMenu(true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,14 @@ package com.swmansion.rnscreens | |
|
||
import android.content.Context | ||
import android.graphics.PorterDuff | ||
import android.graphics.PorterDuffColorFilter | ||
import android.os.Build | ||
import android.text.TextUtils | ||
import android.util.TypedValue | ||
import android.view.Gravity | ||
import android.view.View.OnClickListener | ||
import android.view.ViewGroup | ||
import android.view.WindowInsets | ||
import android.widget.ImageView | ||
import android.widget.TextView | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
@@ -82,7 +84,9 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) { | |
// we want to save the top inset before the status bar can be hidden, which would resolve in | ||
// inset being 0 | ||
if (headerTopInset == null) { | ||
headerTopInset = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) | ||
headerTopInset = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it is, but it should be converted to a number during build time so it does not matter according to this thread: https://stackoverflow.com/questions/21874227/why-do-android-os-build-version-codes-work-on-older-platforms There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, but where does the guarantee that this symbol is available in build time come from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We have this guarantee only since August 2023. I'm leaving link here for future git-blaming activities. https://developer.android.com/google/play/requirements/target-sdk?hl=pl There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually we don't have this guarantee, cause this link is about |
||
rootWindowInsets.getInsets(WindowInsets.Type.systemBars()).top | ||
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) | ||
rootWindowInsets.systemWindowInsetTop | ||
else | ||
// Hacky fallback for old android. Before Marshmallow, the status bar height was always 25 | ||
|
@@ -228,7 +232,7 @@ class ScreenStackHeaderConfig(context: Context) : ViewGroup(context) { | |
|
||
// color | ||
if (tintColor != 0) { | ||
toolbar.navigationIcon?.setColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP) | ||
toolbar.navigationIcon?.colorFilter = PorterDuffColorFilter(tintColor, PorterDuff.Mode.SRC_ATOP) | ||
} | ||
|
||
// subviews | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw the warning you pasted in PR description, but I checked in source code & this is not deprecated 🤷🏻♂️
It's fine I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually quite weird - according to the source code from Android Studio, GuardedRunnable with constructor with
ReactContext
parameter is deprecated though - I'm concerned why there's any difference here 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've found similar fix here: software-mansion/react-native-reanimated#1031
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why it is not deprecated right now is that since 0.73 this constructor has been de-deprecated 😄
I can see on 0.72 that
@Deprecated
is still there and has been removed since this commit.