Apps

What’s new in WindowManager 1.1.0-beta01

[ad_1]


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 latest options and capabilities, that are prepared for testing and early adoption immediately!

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

Exercise embedding

androidx.window.embedding

Exercise embedding allows you to optimize your multi-activity apps for big screens. The 1.1.0-beta01 launch augments and refactors the APIs to supply better 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 possibly can inform the system your app has applied exercise embedding. Refactored SplitController to be extra targeted 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 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.
  • Consists of isActivityEmbedded() to switch the API in SplitController.

RuleController

  • Added class for operations associated to the EmbeddingRule class and subclasses.
  • Consists of 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 group 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 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 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() technique and changed with splitSupportStatus property to supply extra detailed details about why the break up function will not be out there.
  • The getInstance() technique now has a Context parameter.

Word: 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 verify 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 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 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 switch 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 format

androidx.window.format

The window format 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 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 conduct for the app early.

SplitInfo

  • Examine 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 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 models as a substitute 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 )

modifications to:

SplitPairRule.Builder(filters) // Optionally available if minWidthInDp argument is 600. .setMinWidthDp(minWidthInDp) // Optionally available 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 gadgets.

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 format route migrations for particulars.

setMaxAspectRatioInPortrait( EmbeddingAspectRatio.ALWAYS_ALLOW )

to point out splits on portrait gadgets.

 

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

Format route

Format route 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!


[ad_2]

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button