HomeAndroidWhat’s new in WindowManager 1.1.0-beta01

What’s new in WindowManager 1.1.0-beta01



Posted by Jon Eckenrode, Technical Author, Software program Engineering
blog header featuring Android logos

The 1.1.0-beta01 launch of Jetpack WindowManager continues the library’s regular progress towards secure launch of model 1.1.0. The beta provides an assortment of recent options and capabilities, that are prepared for testing and early adoption at the moment!

We want your suggestions so we will make WindowManager work finest for you. Add the 1.1.0-beta01 dependency to your app, comply with the migration steps beneath (for those who’re already utilizing a earlier model of the library), and tell us what you assume!

Exercise embedding

androidx.window.embedding

Exercise embedding allows you to optimize your multi-activity apps for giant screens. The 1.1.0-beta01 launch augments and refactors the APIs to offer higher versatility, functionality, and management in managing activity window splits. We began with experimental APIs in 1.0.0 and are selling them finally to secure in 1.1.0.

tl;dr

Added a manifest setting so you possibly can inform the system your app has carried out exercise embedding. Refactored SplitController to be extra centered on break up properties; extracted break up rule APIs to RuleController and exercise embedding APIs to ActivityEmbeddingController. Added the SplitAttributes class to explain embedding splits. Added the EmbeddingAspectRatio class to set a minimal ratio for making use of exercise embedding guidelines. Modified pixels models to display-independent pixels (dp). Enabled customization of break up layouts. Added a tag to guidelines in order that builders can determine and handle particular guidelines.

What’s new

PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED

  • Added as a boolean property of the <software> tag within the app manifest.

ActivityEmbeddingController

  • Added class for operations associated to the Exercise or ActivityStack courses.
  • Contains isActivityEmbedded() to switch the API in SplitController.

RuleController

  • Added class for operations associated to the EmbeddingRule class and subclasses.
  • Contains the next APIs to switch APIs in SplitController:
    • addRule() — Provides a rule or updates the rule that has the identical tag.
    • removeRule() — Removes a rule from the gathering of registered guidelines.
    • setRules() — Establishes a set of guidelines.
    • clearRules() — Removes all registered guidelines.
    • parseRules() — Parses guidelines from XML rule definitions.

SplitAttributes

  • Added class to outline the break up format.

EmbeddingAspectRatio

  • Added class to outline enum-like habits constants associated to show side ratio. Allows you to specify when splits are enabled based mostly on the dad or mum window’s side ratio.

See SplitRule for properties that use the constants.

What’s modified

EmbeddingRule

  • Added tag subject for identification of break up guidelines.

SplitController

  • Refactored APIs to the next modules:
    • ActivityEmbeddingController
      • Moved isActivityEmbedded() to ActivityEmbeddingController.
    • RuleController
      • Eliminated the next APIs and changed their performance with RuleController APIs:
        • clearRegisteredRules()
        • getSplitRules()
        • initialize()
        • registerRule()
        • unregisterRule()
  • Deprecated isSplitSupported() methodology and changed with splitSupportStatus property to offer extra detailed details about why the break up function will not be obtainable.
  • The getInstance() methodology now has a Context parameter.

Be aware: The getInstance() strategies of ActivityEmbeddingController and RuleController even have a Context parameter.

  • Added SplitAttributes calculator features to customise break up layouts:
    • setSplitAttributesCalculator()
    • clearSplitAttributesCalculator()
    • isSplitAttributesCalculatorSupported() to examine whether or not the SplitAttributesCalculator APIs are supported on the system.
  • Outlined SplitSupportStatus nested class to offer state constants for the splitSupportStatus property. Lets you modify app habits based mostly on whether or not exercise embedding splits are supported within the present app atmosphere.

SplitRule

  • Added defaultSplitAttributes property which defines the default format of a break up; replaces splitRatio and layoutDirection.
  • Added translation of the XML properties splitRatio and splitLayoutDirection to defaultSplitAttributes.
  • Modified minimal dimension definitions to make use of density-independent pixels (dp) as an alternative of pixels.
    • Modified minWidth to minWidthDp with default worth 600dp.
    • Modified minSmallestWidth to minSmallestWidthDp with default worth 600dp.
    • Added minHeightDp property with default worth 600dp.
  • Added maxAspectRatioInHorizontal with default worth ALWAYS_ALLOW.
  • Added maxAspectRatioInPortrait with default worth 1.4.
  • Outlined FinishBehavior nested class to switch end habits constants.
  • Utilized the property adjustments to the Builder nested class of SplitPairRule and SplitPlaceholderRule.

SplitInfo

  • Changed getSplitRatio() with getSplitAttributes() to offer further split-related info.

Window format

androidx.window.format

The window format library helps you to decide options of app show home windows. With the 1.1.0-beta01 launch, now you can work in contexts different than simply actions.

What’s modified

WindowInfoTracker

  • Added non-activity UI context assist in experimental.

WindowMetricsCalculator

  • Added non-activity UI context assist.

Migration steps

Take the following step and improve your app from a earlier alpha model. And please tell us how we will additional facilitate the improve course of.

PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED

  • To allow exercise embedding, apps should add the property to the <software> tag within the app manifest: 

< property android:title=”android.window.PROPERTY_ACTIVITY_EMBEDDING_SPLITS_ENABLED” android:worth=”true” />

When the property is about to true, the system can optimize break up habits for the app early.

SplitInfo

  • Test if the present break up is stacked:

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 different varieties. }

 

SplitController

  • SplitController.getInstance()

    SplitController.getInstance(Context)

  • SplitController.initialize(Context, @ResId int)

adjustments to:

RuleController.getInstance(Context) .setRules(RuleController.parse(Context, @ResId int)) 

  • SplitController.getInstance().isActivityEmbedded(Exercise)

adjustments to:

ActivityEmbeddingController.getInstance(Context) .isActivityEmbedded(Exercise)

  • SplitController.getInstance().registerRule(rule)

          adjustments to:

RuleController.getInstance(Context).addRule(rule)

  • SplitController.getInstance().unregisterRule(rule)

adjustments to:

RuleController.getInstance(Context).removeRule(rule)

  • SplitController.getInstance().clearRegisteredRules()

adjustments to:

RuleController.getInstance(Context).clearRules()

  • SplitController.getInstance().getSplitRules()

adjustments to:

    RuleController.getInstance(Context).getRules() 

SplitRule

  • Change minWidth to minWidthDp and minSmallestWidth to minSmallestWidthDp
  • minWidthDp and minSmallestWidthDp now use dp models as an alternative of pixels

Apps can use the next name:

TypedValue.applyDimension( COMPLEX_UNIT_DIP, minWidthInPixels, assets.displayMetrics )

or just divide minWithInPixels by displayMetrics#density.  

SplitPairRule.Builder

  • SplitPairRule.Builder( filters, minWidth, minSmallestWidth )

adjustments to:

SplitPairRule.Builder(filters) // Non-compulsory if minWidthInDp argument is 600. .setMinWidthDp(minWidthInDp) // Non-compulsory if minSmallestWidthInDp argument is 600. .setMinSmallestWidthDp(minSmallestWidthInDp)

  • setLayoutDirection(layoutDirection) and setSplitRatio(ratio)

change to:

setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .construct() )

  • setFinishPrimaryWithSecondary and setFinishSecondaryWithPrimary take the FinishBehavior enum-like constants.

See SplitRule migrations for particulars.

setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )

to point out splits on portrait units.

SplitPlaceholder.Builder

  • Has solely filters and placeholderIntent parameters; different properties transfer to setters.

See SplitPairRule.Builder migrations for particulars.  

  • setFinishPrimaryWithPlaceholder takes the FinishBehavior enum-like constants.

See end habits migrations for particulars.

  • setLayoutDirection(layoutDirection) and setSplitRatio(ratio)

change to 

setDefaultSplitAttributes(SplitAttributes.Builder() .setLayoutDirection(layoutDirection) .setSplitType(SplitAttributes.SplitType.ratio(ratio)) .construct() )

See format course migrations for particulars.

setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )

to point out splits on portrait units.

 

End habits

End habits constants should be migrated to FinishBehavior enum-like class constants:

  • FINISH_NEVER adjustments to FinishBehavior.NEVER
  • FINISH_ALWAYS adjustments to FinishBehavior.ALWAYS
  • FINISH_ADJACENT adjustments to FinishBehavior.ADJACENT

Format course

Format course should be migrated to SplitAttributes.LayoutDirection:

  • ltr adjustments to SplitAttributes.LayoutDirection.LEFT_TO_RIGHT
  • rtl adjustments to SplitAttributes.LayoutDirection.RIGHT_TO_LEFT
  • locale adjustments to SplitAttributes.LayoutDirection.LOCALE
  • splitRatio migrates to SplitAttributes.SplitType.ratio(splitRatio)

Get began 

To get began with WindowManager, add the Google Maven repository to your app’s settings.gradle or project-level construct.gradle file: 

dependencyResolutionManagement {

    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)

    repositories {

        google()

    }

}

 Then add the 1.1.0-beta01 dependency to your app’s module-level construct.gradle file: 

dependencies {

    implementation ‘androidx.window:window:1.1.0-beta01’

    . . .

}

 Completely happy coding!


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments