03 April 2023
The 1.1.0-beta01 release of Jetpack WindowManager continues the library’s steady progress toward stable release of version 1.1.0. The beta adds an assortment of new features and capabilities, which are ready for testing and early adoption today!
We need your feedback so we can make WindowManager work best for you. Add the 1.1.0-beta01 dependency to your app, follow the migration steps below (if you’re already using a previous version of the library), and let us know what you think!
androidx.window.embedding
Activity embedding enables you to optimize your multi-activity apps for large screens. The 1.1.0-beta01 release augments and refactors the APIs to provide greater versatility, capability, and control in managing task window splits. We started with experimental APIs in 1.0.0 and are promoting them ultimately to stable in 1.1.0.
Added a manifest setting so you can inform the system your app has implemented activity embedding. Refactored SplitController to be more focused on split properties; extracted split rule APIs to RuleController and activity embedding APIs to ActivityEmbeddingController. Added the SplitAttributes class to describe embedding splits. Added the EmbeddingAspectRatio class to set a minimum ratio for applying activity embedding rules. Changed pixels units to display-independent pixels (dp). Enabled customization of split layouts. Added a tag to rules so that developers can identify and manage specific rules.
PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED
ActivityEmbeddingController
Activity
or ActivityStack
classes.isActivityEmbedded()
to replace the API in SplitController
.RuleController
SplitAttributes
EmbeddingAspectRatio
See SplitRule for properties that use the constants.
EmbeddingRule
SplitController
()
Note: The getInstance() methods of ActivityEmbeddingController and RuleController also have a Context parameter.
splitSupportStatus
property. Enables you to modify app behavior based on whether activity embedding splits are supported in the current app environment.SplitRule
SplitInfo
androidx.window.layout
The window layout library lets you determine features of app display windows. With the 1.1.0-beta01 release, you can now work in contexts other than just activities.WindowInfoTracker
WindowMetricsCalculator
Take the next step and upgrade your app from a previous alpha version. And please let us know how we can further facilitate the upgrade process.
PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED
< property android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED" android:value="true" />
When the property is set to true, the system can optimize split behavior for the app early.
SplitInfo
SplitInfo.splitAttributes.splitType is SplitAttributes.SplitType.ExpandContainersSplitType
if (SplitInfo.splitAttributes.splitType is SplitAttributes.SplitType.RatioSplitType) { val ratio = splitInfo.splitAttributes.splitType.ratio } else { // Ratio is meaningless for other types. }
SplitController
changes to
SplitController.getInstance(Context)
changes to:
RuleController.getInstance(Context) .setRules(RuleController.parse(Context, @ResId int))
changes to:
ActivityEmbeddingController.getInstance(Context) .isActivityEmbedded(Activity)
RuleController.getInstance(Context).addRule(rule)
changes to:
RuleController.getInstance(Context).removeRule(rule)
changes to:
RuleController.getInstance(Context).clearRules()
changes to:
RuleController.getInstance(Context).getRules()
SplitRule
Apps can use the following call:
TypedValue.applyDimension( COMPLEX_UNIT_DIP, minWidthInPixels, resources.displayMetrics )or simply divide minWithInPixels by displayMetrics#density.
SplitPairRule.Builder
changes to:
SplitPairRule.Builder(filters) // Optional if minWidthInDp argument is 600. .setMinWidthDp(minWidthInDp) // Optional if minSmallestWidthInDp argument is 600. .setMinSmallestWidthDp(minSmallestWidthInDp)
change to:
setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .build() )
See SplitRule migrations for details.
setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )
to show splits on portrait devices.
SplitPlaceholder.Builder
See SplitPairRule.Builder migrations for details.
FinishBehavior
enum-like constants.See finish behavior migrations for details.
change to
setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .build() )See layout direction migrations for details.
setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )to show splits on portrait devices.
Finish behavior constants must be migrated to FinishBehavior
enum-like class constants:
- FINISH_NEVER changes to FinishBehavior.NEVER
- FINISH_ALWAYS changes to FinishBehavior.ALWAYS
- FINISH_ADJACENT changes to FinishBehavior.ADJACENT
Layout direction must be migrated to SplitAttributes.LayoutDirection:
- ltr changes to SplitAttributes.LayoutDirection.LEFT_TO_RIGHT
- rtl changes to SplitAttributes.LayoutDirection.RIGHT_TO_LEFT
- locale changes to SplitAttributes.LayoutDirection.LOCALE
- splitRatio migrates to SplitAttributes.SplitType.ratio(splitRatio)
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
}
}
dependencies {
implementation 'androidx.window:window:1.1.0-beta01'
. . .
}