-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add generalized Lottie Feature Flags API #2512
Merged
Merged
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ada178e
create feature flag API and add Merge Paths flag
jbeta51 9dad956
ditch singleton model for flags
jbeta51 aad40b6
change LottieFeatureFlag flag tracker to Set
jbeta51 f503fbe
deprecate flag specific functions in favor of new generalized flag APIs
jbeta51 d37a660
add comments to deprecated functions
jbeta51 2fd82b1
build the composition layer after enabling a feature flag
jbeta51 db03fee
Merge remote-tracking branch 'upstream/master' into featureFlags
jbeta51 48ef0f0
move compose Painter and Animation to new flag funtions
jbeta51 78ab7be
fix compositions being build on no-change
jbeta51 b80ca84
clean FeatureFlag documentation
jbeta51 6e2a181
reduce scope of flag API components
jbeta51 0bdd1da
add comments to LottieAnimationView
jbeta51 e557c52
fix class missed in scope refactor
jbeta51 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
lottie/src/main/java/com/airbnb/lottie/LottieFeatureFlags.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.airbnb.lottie; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.os.Build; | ||
|
||
import com.airbnb.lottie.utils.Logger; | ||
|
||
import java.util.HashSet; | ||
|
||
public class LottieFeatureFlags { | ||
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. Let's move |
||
public enum FeatureFlag { | ||
/** | ||
* Merge paths currently don't work if the the operand shape is entirely contained within the | ||
* first shape. If you need to cut out one shape from another shape, use an even-odd fill type | ||
* instead of using merge paths. | ||
*/ | ||
MergePathsApi19(Build.VERSION_CODES.KITKAT); | ||
|
||
public final int minRequiredSdkVersion; | ||
|
||
FeatureFlag(int minRequiredSdkVersion) { | ||
this.minRequiredSdkVersion = minRequiredSdkVersion; | ||
} | ||
} | ||
|
||
private final HashSet<FeatureFlag> enabledFlags = new HashSet<>(); | ||
|
||
@SuppressLint("DefaultLocale") | ||
public void enableFlag(FeatureFlag flag, boolean enable) { | ||
if (enable) { | ||
if (Build.VERSION.SDK_INT < flag.minRequiredSdkVersion) { | ||
Logger.warning(String.format("%s is not supported pre SDK %d", flag.name(), flag.minRequiredSdkVersion)); | ||
return; | ||
} | ||
enabledFlags.add(flag); | ||
} else { | ||
enabledFlags.remove(flag); | ||
} | ||
} | ||
|
||
public boolean isFlagEnabled(FeatureFlag flag) { | ||
return enabledFlags.contains(flag); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you add docs here since this is a new public API?
I would make it extra explicit that people validate that opted in features look acceptable across all supported API levels.