Window Manager

Window Manager helps application developers support new device form factors and provide a common API surface for different Window Manager features on both old and new platform versions. The initial release is aimed at the foldable devices, and future versions will extend to more display types and window features.
Latest Update Current Stable Release Next Release Candidate Beta Release Alpha Release
June 30, 2021 - - - 1.0.0-alpha09

Declaring dependencies

To add a dependency on Window Manager, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.

Add the dependencies for the artifacts you need in the build.gradle file for your app or module:

Groovy

dependencies {
    implementation "androidx.window:window:1.0.0-alpha09"

    // For RxJava2 integration
    implementation "androidx.window:window-rxjava2:1.0.0-alpha09"

    // For RxJava3 integration
    implementation "androidx.window:window-rxjava3:1.0.0-alpha09"

    // For testing
    implementation "androidx.window:window-testing:1.0.0-alpha09"
}

Kotlin

dependencies {
    implementation("androidx.window:window:1.0.0-alpha09")

    // For RxJava2 integration
    implementation("androidx.window:window-rxjava2:1.0.0-alpha09")

    // For RxJava3 integration
    implementation("androidx.window:window-rxjava3:1.0.0-alpha09")

    // For testing
    implementation("androidx.window:window-testing:1.0.0-alpha09")
}

Feedback

Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.

Create a new issue

See the Issue Tracker documentation for more information.

Version 1.0.0

Version 1.0.0-alpha09

June 30, 2021

androidx.window:window-*:1.0.0-alpha09 is released. Version 1.0.0-alpha09 contains these commits.

New Features

  • Change from integer constants to unbounded enums.
  • Add a test util to create test folding features.

API Changes

  • Add helper method to create test display features. (I3cf54)
    • Change from occlusionMode to occlusionType.

Bug Fixes

  • Emit initial value when adding multiple consumers of the data streams.

Version 1.0.0-alpha08

June 16, 2021

androidx.window:window-*:1.0.0-alpha08 is released. Version 1.0.0-alpha08 contains these commits.

New Features

  • Released a testing artifact to make it easier to test when using WindowInfoRepository. Use WindowInfoRepository to get information about DisplayFeatures and the WindowMetrics. (I57f66, Ida620)

Version 1.0.0-alpha07

June 2, 2021

androidx.window:window-*:1.0.0-alpha07 is released. Version 1.0.0-alpha07 contains these commits.

New Features

  • Migrate core window library to Kotlin. Will use coroutines and suspend functions to expose asynchronous data going forward.
  • Add WindowInfoRepo as the main interaction point for getting the WindowMetrics and the stream of WindowLayoutInfo.
  • New window-java artifact to expose Java friendly APIs to register and unregistered callbacks.
  • New window-rxjava2 and window-rxjava3 artifacts to expose RxJava adapted APIs.

API Changes

  • Add WindowServices to provide dependencies uniformly.
    • Add coroutine based api to consume window layout info. (Iab70f)
  • Migrate core window manager library to Kotlin. (Icca34)

Bug Fixes

  • Add new data class to represent feature bounds. (I6dcd1)

Version 1.0.0-alpha06

May 5, 2021

androidx.window:window:1.0.0-alpha06 is released. Version 1.0.0-alpha06 contains these commits.

New Features

  • We have started our migration to Kotlin and will finish in the next release.
  • DeviceState has been removed from the public API, please use FoldingFeature instead.
  • We have removed STATE_FLIPPED from the FoldingFeature states since it is not supported by any use-case at the moment.
  • We have also removed other deprecated APIs.

API Changes

  • Adding Kotlin as a dependency.
    • Migrate core library to Kotlin. (Idd995)
  • Removed DisplayFeature builder. (I61fa4)
  • Removed DeviceState from public api, use FoldingFeature instead. (Id6079)
  • Remove device state callback from extensions. (I5ea83)
  • Remove STATE_FLIPPED from FoldingFeature. (I9c4e1)
  • Remove deprecated registration methods. (Ib381b)

Version 1.0.0-alpha05

March 24, 2021

androidx.window:window:1.0.0-alpha05 is released. Version 1.0.0-alpha05 contains these commits.

New Features

We have added convenience methods to FoldingFeature so that apps can tell if the feature is separating, occluding, and determine the orientation of the hinge. We are also hiding the hinge type so that

We are removing the synchronous read methods from WindowManager. Synchronous read methods are error prone since there is an implicit race condition. Register listeners and callbacks to receive updates on the WindowLayoutInfo.

API Changes

  • Add convenience methods for working with FoldingFeatures (Ie733f)
  • Removes synchronous read methods from WindowManager (I96fd4)

Version 1.0.0-alpha04

March 10, 2021

androidx.window:window:1.0.0-alpha04 is released. Version 1.0.0-alpha04 contains these commits.

New Features

  • Fixes a bug where no WindowLayoutInfo is emitted if there isn’t an OEM implementation. Now we emit an empty WIndowLayoutInfo.
  • Fix a bug where state would not update properly if the hinge state changed while the app was backgrounded. Now the state should be consistent.
  • Update our proguard files to ignore warnings from runtime dependencies.

Bug Fixes

  • Emit an empty value when the OEM library is missing. (Ide935)

Version 1.0.0-alpha03

February 18, 2021

androidx.window:window:1.0.0-alpha03 is released. Version 1.0.0-alpha03 contains these commits.

New Features

  • Emit an empty value for WindowLayoutInfo when the OEM implementation is empty. This should make it easier to use the library on more devices. Since the APIs are asynchronous it is still recommended that apps write some defensive code and emit a default value after a timeout. We do not have any guarantees on OEM implementations and the initial value may be delayed.

Bug Fixes

  • Emit an empty value when the OEM library is missing. (Ide935)

Version 1.0.0-alpha02

January 27, 2021

androidx.window:window:1.0.0-alpha02 is released. Version 1.0.0-alpha02 contains these commits.

New Features

  • We have deprecated some APIs to help streamline the api and reduce mistakes. Some notable examples are removing the synchronous read operations from WindowManager and deprecating DeviceState. Synchronous read operations can lead to race conditions and have incorrect UI.

  • We have converted DisplayFeature to an interface that other features will implement going forward. Our first feature is FoldingFeature which is now the representation of a screen fold or a hinge. This also contains the state of the hinge replacing DeviceState.

  • WindowMetrics was introduced in Android 11 to provide developers with a simple way to query for metrics about a window, for example its position and size on screen and any system insets. We’ve backported the API in this release so that developers can leverage WindowMetrics and continue to support older Android versions. WindowMetrics can be obtained through the WindowManager#getCurrentWindowMetrics() and WindowManager#getMaximumWindowMetrics() APIs.

API Changes

  • Deprecate APIs that will be removed in the next alpha (Ib7cc4)
  • Updates ExtensionInterface to accept explicit Activity references. (I07ded)
  • Introduces the WindowMetrics API. (I3ccee)
  • Remove synchronous read methods from WindowManager (I69983)
  • Make ExtensionWindowBackend package protected. (Ied208)

Bug Fixes

  • Update ExtensionInterface APIs to accept visual contexts. (I8e827)

External Contribution

  • Merge DeviceState and WindowLayoutInfo so it is easier to access data. (Id34f4)

Version 1.0.0-alpha01

February 27, 2020

androidx.window:window:1.0.0-alpha01 and androidx.window:window-extensions:1.0.0-alpha01 are released. Version 1.0.0-alpha01 contains these commits. This is the first release of the Window Manager library.

New features

  • DisplayFeature: This new API identifies disruptions in the continuous flat screen surfaces such as hinges or folds
  • DeviceState: This new API provides the current posture of the phone from a list of defined postures (For example, CLOSED, OPENED, HALF_OPENED, etc.)