Skip to content

Commit e29ff69

Browse files
committed
feat: upgrade androidx.window to 1.4.0
Ref numbersprotocol/capture-cam#3340 BREAKING CHANGE: Replace deprecated WindowManager with WindowMetricsCalculator - Update androidx.window dependency from 1.0.0-alpha09 to 1.4.0 - Migrate from androidx.window.WindowManager to androidx.window.layout.WindowMetricsCalculator - Replace windowManager.getCurrentWindowMetrics() with windowMetricsCalculator.computeCurrentWindowMetrics( requireActivity()) - Fix Google Play Console warning about outdated SDK version - Improve compatibility with latest Android API levels
1 parent 7ff4c63 commit e29ff69

File tree

5 files changed

+23
-10
lines changed

5 files changed

+23
-10
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog
22

3+
## [0.0.20] - 2025-09-01
4+
5+
### Changed
6+
7+
- **BREAKING**: Migrated from deprecated `androidx.window.WindowManager` to `androidx.window.layout.WindowMetricsCalculator`
8+
- Updated androidx.window dependency from `1.0.0-alpha09` to `1.4.0` to resolve Google Play Store deprecation warning
9+
- Replaced `windowManager.getCurrentWindowMetrics()` with `windowMetricsCalculator.computeCurrentWindowMetrics(requireActivity())`
10+
11+
### Fixed
12+
13+
- Fixed Google Play Console warning: "Your app uses an outdated SDK version of androidx.window:window"
14+
- Resolved compatibility issues with Android API levels by using stable androidx.window APIs
15+
316
## [0.0.19] - 2025-03-14
417

518
### Changed

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ dependencies {
9292
implementation "androidx.camera:camera-view:$camerax_version"
9393

9494
//WindowManager
95-
implementation 'androidx.window:window:1.0.0-alpha09'
95+
implementation 'androidx.window:window:1.4.0'
9696

9797
// Unit Testing
9898
testImplementation "junit:junit:$junitVersion"

android/src/main/java/io/numbersprotocol/capturelite/plugins/previewcamera/PreviewCameraFragment.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import androidx.core.app.ActivityCompat
2323
import androidx.core.content.ContextCompat
2424
import androidx.fragment.app.Fragment
2525
import androidx.localbroadcastmanager.content.LocalBroadcastManager
26-
import androidx.window.WindowManager
26+
import androidx.window.layout.WindowMetricsCalculator
2727
import com.getcapacitor.JSObject
2828
import com.getcapacitor.PluginCall
2929
import io.numbersprotocol.capturelite.plugins.previewcamera.databinding.FragmentPreviewCameraBinding
@@ -72,7 +72,7 @@ class PreviewCameraFragment : Fragment() {
7272

7373
private var camera: Camera? = null
7474
private var cameraProvider: ProcessCameraProvider? = null
75-
private lateinit var windowManager: WindowManager
75+
private lateinit var windowMetricsCalculator: WindowMetricsCalculator
7676

7777
private var currentDisplayOrientation = 0;
7878

@@ -182,8 +182,8 @@ class PreviewCameraFragment : Fragment() {
182182
// Every time the orientation of device changes, update rotation for use cases
183183
// displayManager.registerDisplayListener(displayListener, null)
184184

185-
//Initialize WindowManager to retrieve display metrics
186-
windowManager = WindowManager(view.context)
185+
//Initialize WindowMetricsCalculator to retrieve display metrics
186+
windowMetricsCalculator = WindowMetricsCalculator.getOrCreate()
187187

188188
// Determine the output directory
189189

@@ -473,7 +473,7 @@ class PreviewCameraFragment : Fragment() {
473473

474474
fun focus(x: Float, y: Float) {
475475
// Get screen metrics used to setup camera for full screen resolution
476-
val metrics = windowManager.getCurrentWindowMetrics().bounds
476+
val metrics = windowMetricsCalculator.computeCurrentWindowMetrics(requireActivity()).bounds
477477
val factory: MeteringPointFactory = SurfaceOrientedMeteringPointFactory(
478478
metrics.width().toFloat(), metrics.height().toFloat()
479479
)
@@ -497,7 +497,7 @@ class PreviewCameraFragment : Fragment() {
497497
fun bindCameraUseCases(customScreenOrientation: Int = Surface.ROTATION_0) {
498498

499499
// Get screen metrics used to setup camera for full screen resolution
500-
val metrics = windowManager.getCurrentWindowMetrics().bounds
500+
val metrics = windowMetricsCalculator.computeCurrentWindowMetrics(requireActivity()).bounds
501501

502502
Log.d(TAG, "Screen metrics: ${metrics.width()} x ${metrics.height()}")
503503

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@numbersprotocol/preview-camera",
3-
"version": "0.0.19",
3+
"version": "0.0.20",
44
"description": "Preview Camera Plugin for iOS, Android",
55
"main": "dist/plugin.cjs.js",
66
"module": "dist/esm/index.js",

0 commit comments

Comments
 (0)