Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/SampleExtensionImpl.java +6 −16 Original line number Diff line number Diff line Loading @@ -69,21 +69,15 @@ class SampleExtensionImpl extends StubExtension { new ResourceConfigDisplayFeatureProducer(context) )); mDevicePostureProducer.addDataChangedCallback(this::onDevicePostureChanged); mDevicePostureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged); mDisplayFeatureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged); } private void onDevicePostureChanged() { updateDeviceState(new ExtensionDeviceState(getDevicePosture())); // Trigger a change in display features as the posture will be used in place of the feature // state if the state is left unset by the producer. onDisplayFeaturesChanged(); } private int getDevicePosture() { private int getFeatureState(DisplayFeature feature) { Integer featureState = feature.getState(); Optional<Integer> posture = mDevicePostureProducer.getData(); return posture.orElse(ExtensionDeviceState.POSTURE_UNKNOWN); int fallbackPosture = posture.orElse(ExtensionFoldingFeature.STATE_FLAT); return featureState == null ? fallbackPosture : featureState; } private void onDisplayFeaturesChanged() { Loading Loading @@ -115,17 +109,14 @@ class SampleExtensionImpl extends StubExtension { Optional<List<DisplayFeature>> storedFeatures = mDisplayFeatureProducer.getData(); if (storedFeatures.isPresent()) { int posture = getDevicePosture(); for (DisplayFeature baseFeature : storedFeatures.get()) { Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(activity, featureRect); Integer featureState = baseFeature.getState(); features.add(new ExtensionFoldingFeature(featureRect, baseFeature.getType(), featureState == null ? posture : featureState)); getFeatureState(baseFeature))); } } return features; Loading @@ -141,7 +132,6 @@ class SampleExtensionImpl extends StubExtension { mSettingsDisplayFeatureProducer.unregisterObserversIfNeeded(); } onDevicePostureChanged(); onDisplayFeaturesChanged(); } } libs/WindowManager/Jetpack/src/androidx/window/extensions/StubExtension.java +1 −15 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ abstract class StubExtension implements ExtensionInterface { private ExtensionCallback mExtensionCallback; private final Set<Activity> mWindowLayoutChangeListenerActivities = new HashSet<>(); private boolean mDeviceStateChangeListenerRegistered; StubExtension() { } Loading @@ -53,18 +52,6 @@ abstract class StubExtension implements ExtensionInterface { this.onListenersChanged(); } @Override public void onDeviceStateListenersChanged(boolean isEmpty) { this.mDeviceStateChangeListenerRegistered = !isEmpty; this.onListenersChanged(); } void updateDeviceState(ExtensionDeviceState newState) { if (this.mExtensionCallback != null) { mExtensionCallback.onDeviceStateChanged(newState); } } void updateWindowLayout(@NonNull Activity activity, @NonNull ExtensionWindowLayoutInfo newLayout) { if (this.mExtensionCallback != null) { Loading @@ -78,8 +65,7 @@ abstract class StubExtension implements ExtensionInterface { } protected boolean hasListeners() { return !mWindowLayoutChangeListenerActivities.isEmpty() || mDeviceStateChangeListenerRegistered; return !mWindowLayoutChangeListenerActivities.isEmpty(); } protected abstract void onListenersChanged(); Loading libs/WindowManager/Jetpack/window-extensions-release.aar −1.53 KiB (7.43 KiB) File changed.No diff preview for this file type. View original file View changed file libs/WindowManager/Jetpack/window-sidecar-release.aar +987 B (5.23 KiB) File changed.No diff preview for this file type. View original file View changed file Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/SampleExtensionImpl.java +6 −16 Original line number Diff line number Diff line Loading @@ -69,21 +69,15 @@ class SampleExtensionImpl extends StubExtension { new ResourceConfigDisplayFeatureProducer(context) )); mDevicePostureProducer.addDataChangedCallback(this::onDevicePostureChanged); mDevicePostureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged); mDisplayFeatureProducer.addDataChangedCallback(this::onDisplayFeaturesChanged); } private void onDevicePostureChanged() { updateDeviceState(new ExtensionDeviceState(getDevicePosture())); // Trigger a change in display features as the posture will be used in place of the feature // state if the state is left unset by the producer. onDisplayFeaturesChanged(); } private int getDevicePosture() { private int getFeatureState(DisplayFeature feature) { Integer featureState = feature.getState(); Optional<Integer> posture = mDevicePostureProducer.getData(); return posture.orElse(ExtensionDeviceState.POSTURE_UNKNOWN); int fallbackPosture = posture.orElse(ExtensionFoldingFeature.STATE_FLAT); return featureState == null ? fallbackPosture : featureState; } private void onDisplayFeaturesChanged() { Loading Loading @@ -115,17 +109,14 @@ class SampleExtensionImpl extends StubExtension { Optional<List<DisplayFeature>> storedFeatures = mDisplayFeatureProducer.getData(); if (storedFeatures.isPresent()) { int posture = getDevicePosture(); for (DisplayFeature baseFeature : storedFeatures.get()) { Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(activity, featureRect); Integer featureState = baseFeature.getState(); features.add(new ExtensionFoldingFeature(featureRect, baseFeature.getType(), featureState == null ? posture : featureState)); getFeatureState(baseFeature))); } } return features; Loading @@ -141,7 +132,6 @@ class SampleExtensionImpl extends StubExtension { mSettingsDisplayFeatureProducer.unregisterObserversIfNeeded(); } onDevicePostureChanged(); onDisplayFeaturesChanged(); } }
libs/WindowManager/Jetpack/src/androidx/window/extensions/StubExtension.java +1 −15 Original line number Diff line number Diff line Loading @@ -31,7 +31,6 @@ abstract class StubExtension implements ExtensionInterface { private ExtensionCallback mExtensionCallback; private final Set<Activity> mWindowLayoutChangeListenerActivities = new HashSet<>(); private boolean mDeviceStateChangeListenerRegistered; StubExtension() { } Loading @@ -53,18 +52,6 @@ abstract class StubExtension implements ExtensionInterface { this.onListenersChanged(); } @Override public void onDeviceStateListenersChanged(boolean isEmpty) { this.mDeviceStateChangeListenerRegistered = !isEmpty; this.onListenersChanged(); } void updateDeviceState(ExtensionDeviceState newState) { if (this.mExtensionCallback != null) { mExtensionCallback.onDeviceStateChanged(newState); } } void updateWindowLayout(@NonNull Activity activity, @NonNull ExtensionWindowLayoutInfo newLayout) { if (this.mExtensionCallback != null) { Loading @@ -78,8 +65,7 @@ abstract class StubExtension implements ExtensionInterface { } protected boolean hasListeners() { return !mWindowLayoutChangeListenerActivities.isEmpty() || mDeviceStateChangeListenerRegistered; return !mWindowLayoutChangeListenerActivities.isEmpty(); } protected abstract void onListenersChanged(); Loading
libs/WindowManager/Jetpack/window-extensions-release.aar −1.53 KiB (7.43 KiB) File changed.No diff preview for this file type. View original file View changed file
libs/WindowManager/Jetpack/window-sidecar-release.aar +987 B (5.23 KiB) File changed.No diff preview for this file type. View original file View changed file