-
Notifications
You must be signed in to change notification settings - Fork 2
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
GT-2455 provide a Scarlet.Builder extension method to force the default platform #2173
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.tinder.scarlet.internal.utils; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
class RuntimePlatformInternals { | ||
Check warning on line 5 in gto-support-scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.java Codecov / codecov/patchgto-support-scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.java#L5
|
||
/** @noinspection KotlinInternalInJava*/ | ||
@NonNull | ||
@SuppressWarnings("MethodName") | ||
static RuntimePlatform Default() { | ||
return new RuntimePlatform.Default(); | ||
Check warning on line 10 in gto-support-scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.java Codecov / codecov/patchgto-support-scarlet/src/main/java/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.java#L10
|
||
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.
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.tinder.scarlet | ||
|
||
import org.ccci.gto.android.common.util.getDeclaredFieldOrNull | ||
import org.ccci.gto.android.common.util.getOrNull | ||
|
||
private val platformField = getDeclaredFieldOrNull<Scarlet.Builder>("platform") | ||
|
||
internal var Scarlet.Builder.platform: Any? | ||
get() = platformField?.getOrNull(this) | ||
set(value) { | ||
platformField?.set(this, requireNotNull(value)) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.tinder.scarlet.internal.utils | ||
|
||
internal fun defaultPlatform() = RuntimePlatformInternals.Default() | ||
Check warning on line 3 in gto-support-scarlet/src/main/kotlin/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.kt Codecov / codecov/patchgto-support-scarlet/src/main/kotlin/com/tinder/scarlet/internal/utils/RuntimePlatformInternals.kt#L3
|
||
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 wrap the package-private java |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.ccci.gto.android.common.scarlet | ||
|
||
import com.tinder.scarlet.Scarlet | ||
import com.tinder.scarlet.internal.utils.defaultPlatform | ||
import com.tinder.scarlet.platform | ||
|
||
/** | ||
* Scarlet improperly detects desugared Android apps as the Java 8 runtime. | ||
* This method will force the default platform for Scarlet to be used. | ||
* | ||
* See: | ||
* https://github.com/Tinder/Scarlet/issues/235 | ||
* https://issuetracker.google.com/issues/342419066 | ||
*/ | ||
fun Scarlet.Builder.forceDefaultPlatform() = apply { platform = defaultPlatform() } | ||
Check warning on line 15 in gto-support-scarlet/src/main/kotlin/org/ccci/gto/android/common/scarlet/ScarletBuilder.kt Codecov / codecov/patchgto-support-scarlet/src/main/kotlin/org/ccci/gto/android/common/scarlet/ScarletBuilder.kt#L15
|
||
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. This is the only new thing exposed on the public API of this module |
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.
This is a package private Java class to hide it from the public API for library consumers