
Posted by John Ekenrod, Technical Writer, Software Engineering
The 1.1.0-beta01 release of Jetpack WindowManager continues the library’s ongoing progress towards the 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!
activity embedding
androidx.window.embedding
Activity embedding enables you to optimize your multi-activity apps for larger screens. The 1.1.0-beta01 release enhances and refactors the API to provide more versatility, capability, and control in managing working window partitions. We started with experimental APIs in 1.0.0 and are eventually promoting them to stable in 1.1.0.
tl;dr; Doctor
Added a manifest setting so you can inform the system that your app has implemented activity embedding. refactored split controller to focus more on divested properties; Split Rule API Removed rule controller and to the Activity Embedding API Activity Embedding Controller, added split attributes class to describe the embedding partition. added embeddingaspect ratio The class for setting the minimum ratio for the activity embedding rule to apply. Pixel units were changed to display-independent pixels (dp). Capable customization of split layout. Added a tag to rules so that developers can identify and manage specific rules.
What’s new
PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED
- Added as boolean property of <आवेदन> Tag in app manifest.
ActivityEmbeddingController
- Added class for works related to
Activity
OrActivityStack
classes.
- Involved
isActivityEmbedded()
to change the APISplitController
,
RuleController
- Added class for works related to embedding rules class and subclass.
- This includes the following APIs to replace the APIs split controller,
- addrule() — Adds a rule or updates a rule with the same tag.
- remove rule() — Removes a rule from the collection of registered rules.
- set rules() – Establishes a set of rules.
- clear rule () – Deletes all registered rules.
- parseRules() — Parses rules from XML rule definitions.
SplitAttributes
- Added class to define split layout.
EmbeddingAspectRatio
- Added class to define enum-like behavior constants related to display aspect ratio. Allows you to specify when splitting is enabled based on the aspect ratio of the parent window.
Look split rule For properties that use constants.
what has changed
EmbeddingRule
- Added tag field to identify split rules.
SplitController
- Refactor API for the following modules:
- Activity Embedding Controller
- Have been taken isActivityEmbedded() To Activity Embedding Controller,
- rule controller
- The following APIs have been deprecated and their functionality has been replaced with the RuleController API:
- clear registered rule()
- getSplitRules()
- start over ()
- register rule()
- unregisterRule
()
- demoted isSplitSupported() method and replaced with splitSupportStatus properties to provide more detailed information on why the partition attribute is not available.
- get Instance() method is now a Context parameter.
Comment: get Instance() methods of Activity Embedding Controller And rule controller there is also one Context parameter.
- couple split attributes Calculator functions for customizing partition layout:
- setSplitAttributesCalculator,
- ClearSplitAttributesCalculator,
- isSplitAttributesCalculatorSupported() to check whether SplitAttributes Calculator APIs are supported on the device.
- defined splitsupportstatus nested classes to provide state constants for
splitSupportStatus
Property. Enables you to modify app behavior based on whether activity embedding splits are supported in the current app environment.
SplitRule
- couple defaultSplitAttributes property that defines the default layout of the partition; in place of split ratio And layout direction,
-
Added translation of the XML attribute splitRatio and splitlayout direction To defaultSplitAttributes,
-
Changed minimum dimension definitions to use density-independent pixels (dp) instead of pixels.
- Changed minWidth To minWidthDp With default value 600dp.
- Changed minSmallestWidth To minSmallestWidthDp With default value 600dp.
- couple minHeightDp Property with default value 600dp.
- couple maxAspectRatioHorizontal with default value always allow,
- couple maxAspectRatioInPortrait With default value 1.4.
- defined terminated behavior Nested class to replace expired behavior constants.
- applied property changes in the creator nested classes split pair rule And splitplaceholder rule,
SplitInfo
- Replaced getSplitRatio() Together getSplitAttributes() To provide additional segmentation information.
window layout
androidx.window.layout
The Window Layout library lets you determine the characteristics of the app display window. With release 1.1.0-beta01, you can now work in contexts other than just Activities.
what has changed
WindowInfoTracker
- Added non-activity UI context support in experimental.
WindowMetricsCalculator
- Added non-activity UI context support.
stages of migration
Take the next step and upgrade your app from a previous alpha version. And please let us know how we can make the upgrade process even easier.
PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED
- To enable activity embedding, add the app to the app manifest <एप्लिकेशन> The attribute has to be added to the tag:
<संपत्ति android:name="android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED" android:value="true" />
When the property is set to true, the system can quickly customize split behavior for the app.
SplitInfo
- Check if the current partition is heaped:
SplitInfo.SplitAttributes.Split is of type SplitAttributes.
if (SplitInfo.splitAttributes.splitType is SplitAttributes.SplitType.RatioSplitType) { val ratio = splitInfo.splitAttributes.splitType.ratio } else { // ratio is meaningless for other types. ,
SplitController
- splitController.getInstance()
SplitController.GetInstance(context)
- splitController.initialize(context, @ResId int)
Change in:
RuleController.getInstance(context).setRules(RuleController.parse(context, @ResId int))
- splitController.getInstance().isActivityEmbedded(activity)
Change in:
activityEmbeddingController.getInstance(context).isActivityEmbedded(activity)
- SplitController.getInstance().registerRule(rule)
Change in:
Rule controller.getInstance(context).addRule(rule)
- SplitController.getInstance().unregisterRule(rule)
Change in:
Rules controller.getInstance(context).removeRule(rules)
- splitController.getInstance().clearRegisteredRules()
Change in:
Rules controller.getInstance(context).clearRules()
- SplitController.getInstance().getSplitRules()
Change in:
Rules controller.getInstance(context).getRules()
SplitRule
- Change minWidth To minWidthDp And minSmallestWidth To minSmallestWidthDp
- minWidthDp And minSmallestWidthDp now use dp unit instead of pixels
Apps can use the following calls:
TypedValue.applyDimension( COMPLEX_UNIT_DIP, minWidthInPixels, Resources.displayMetrics )
or just split minWithInPixels By DisplayMetrics#Density,
SplitPairRule.Builder
- SplitPairRule.builder(filter, minWidth, minSmallestWidth)
Change in:
SplitPairRule.Builder(filters) // Optional if minWidthInDp argument is 600. .setMinWidthDp(minWidthInDp) // Optional if the minSmallestWidthInDp argument is 600.
- setLayoutDirection(layoutDirection) and setSplitterRatio(ratio)
convert to:
setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .build() )
- setfinish primary with secondary And setfinish secondary with primary Take terminated behavior Enum-like constant.
Look split rule Migration for details.
setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )
To show splits on portrait devices.
SplitPlaceholder.Builder
- is only filter And placeholderIntent parameter; Other properties go to the settlers.
Look splitpairrule.builder Migration for details.
- setFinishPrimaryWithPlaceholder Takes
See full behavior migration for details.
- set layout direction (layout direction) And setsplit ratio (ratio)
turn into
setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .build() )
See Layout direction migration for details.
setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )
To show splits on portrait devices.
end behavior
deprecated behavior constants should be migrated FinishBehavior
Enum-like class constants:
- FINISH_never change in end the behavior. never
- FINISH_EVERY change in end the behavior. Always
- FINISH_ADJACENT change in termination behavior. imminent
layout direction
Layout direction should be migrated SplitAttributes. layout direction,
- l tr change in splitAttributes.layoutDirection.LEFT_TO_RIGHT
- rtl change in splitAttributes.layoutDirection.RIGHT_TO_LEFT
- Location change in splitAttributes.LayoutDirection.LOCALE
- split ratio migrates to SplitAttributes. split type. ratio (split ratio)
get started
To get started with WindowManager, add the Google Maven repository to your app settings.gradle or project level build.gradle file:
Dependency Resolution Management {
repositoryMode.set(repositoryMode.FAIL_ON_PROJECT_REPOS)
inventory {
Google()
,
,
Then add the 1.1.0-beta01 dependency to your app’s module-level build.gradle file:
dependency {
implementation ‘androidx.window:window:1.1.0-beta01’
, , ,
,
Happy Coding!