Saturday, October 14, 2023
HomeMobileWhat’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 steady 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’d like your suggestions so we are able to make WindowManager work finest for you. Add the 1.1.0-beta01 dependency to your app, comply with the migration steps beneath (should you’re already utilizing a earlier model of the library), and tell us what you suppose!

Exercise embedding

androidx.window.embedding

Exercise embedding lets you optimize your multi-activity apps for big screens. The 1.1.0-beta01 launch augments and refactors the APIs to supply larger versatility, functionality, and management in managing job window splits. We began with experimental APIs in 1.0.0 and are selling them in the end to steady in 1.1.0.

tl;dr

Added a manifest setting so you’ll be able to inform the system your app has applied exercise embedding. Refactored SplitController to be extra centered on cut up properties; extracted cut 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 items to display-independent pixels (dp). Enabled customization of cut up layouts. Added a tag to guidelines in order that builders can establish 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 interchange the API in SplitController.

RuleController

  • Added class for operations associated to the EmbeddingRule class and subclasses.
  • Contains the next APIs to interchange 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 group of guidelines.
    • clearRules() — Removes all registered guidelines.
    • parseRules() — Parses guidelines from XML rule definitions.

SplitAttributes

  • Added class to outline the cut up structure.

EmbeddingAspectRatio

  • Added class to outline enum-like conduct constants associated to show facet ratio. Helps you to specify when splits are enabled primarily based on the mother or father window’s facet ratio.

See SplitRule for properties that use the constants.

What’s modified

EmbeddingRule

  • Added tag area for identification of cut 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() technique and changed with splitSupportStatus property to supply extra detailed details about why the cut up function isn’t out there.
  • The getInstance() technique now has a Context parameter.

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

  • Added SplitAttributes calculator features to customise cut up layouts:
    • setSplitAttributesCalculator()
    • clearSplitAttributesCalculator()
    • isSplitAttributesCalculatorSupported() to test whether or not the SplitAttributesCalculator APIs are supported on the system.
  • Outlined SplitSupportStatus nested class to supply state constants for the splitSupportStatus property. Allows you to modify app conduct primarily based on whether or not exercise embedding splits are supported within the present app setting.

SplitRule

  • Added defaultSplitAttributes property which defines the default structure of a cut 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 a substitute 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 interchange end conduct constants.
  • Utilized the property modifications to the Builder nested class of SplitPairRule and SplitPlaceholderRule.

SplitInfo

  • Changed getSplitRatio() with getSplitAttributes() to supply further split-related data.

Window structure

androidx.window.structure

The window structure library allows 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 help in experimental.

WindowMetricsCalculator

  • Added non-activity UI context help.

Migration steps

Take the following step and improve your app from a earlier alpha model. And please tell us how we are able to 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 ready to true, the system can optimize cut up conduct for the app early.

SplitInfo

  • Test if the present cut 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 sorts. }

 

SplitController

  • SplitController.getInstance()

    SplitController.getInstance(Context)

  • SplitController.initialize(Context, @ResId int)

modifications to:

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

  • SplitController.getInstance().isActivityEmbedded(Exercise)

modifications to:

ActivityEmbeddingController.getInstance(Context) .isActivityEmbedded(Exercise)

  • SplitController.getInstance().registerRule(rule)

          modifications to:

RuleController.getInstance(Context).addRule(rule)

  • SplitController.getInstance().unregisterRule(rule)

modifications to:

RuleController.getInstance(Context).removeRule(rule)

  • SplitController.getInstance().clearRegisteredRules()

modifications to:

RuleController.getInstance(Context).clearRules()

  • SplitController.getInstance().getSplitRules()

modifications to:

    RuleController.getInstance(Context).getRules() 

SplitRule

  • Change minWidth to minWidthDp and minSmallestWidth to minSmallestWidthDp
  • minWidthDp and minSmallestWidthDp now use dp items as a substitute of pixels

Apps can use the next name:

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

or just divide minWithInPixels by displayMetrics#density.  

SplitPairRule.Builder

  • SplitPairRule.Builder( filters, minWidth, minSmallestWidth )

modifications 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 indicate 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 conduct migrations for particulars.

  • setLayoutDirection(layoutDirection) and setSplitRatio(ratio)

change to 

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

See structure course migrations for particulars.

setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )

to indicate splits on portrait units.

 

End conduct

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

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

Structure course

Structure course should be migrated to SplitAttributes.LayoutDirection:

  • ltr modifications to SplitAttributes.LayoutDirection.LEFT_TO_RIGHT
  • rtl modifications to SplitAttributes.LayoutDirection.RIGHT_TO_LEFT
  • locale modifications 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’

    . . .

}

 Comfortable coding!




Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments