-
-
Notifications
You must be signed in to change notification settings - Fork 512
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 4 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 |
---|---|---|
|
@@ -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.
Why
null
here, instead of leaving default?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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Ok