react-native-keyboard-controller 1.18.5 → 1.18.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  package com.reactnativekeyboardcontroller.extensions
2
2
 
3
+ import android.annotation.SuppressLint
3
4
  import android.graphics.Rect
4
5
  import android.os.Build
5
6
  import android.view.View
6
- import androidx.annotation.RequiresApi
7
7
  import com.reactnativekeyboardcontroller.log.Logger
8
8
 
9
9
  /**
@@ -11,6 +11,7 @@ import com.reactnativekeyboardcontroller.log.Logger
11
11
  * to ensure that insets are always received.
12
12
  * @see https://stackoverflow.com/a/61909205/9272042
13
13
  */
14
+ @SuppressLint("ObsoleteSdkInt")
14
15
  fun View.requestApplyInsetsWhenAttached() {
15
16
  // https://chris.banes.dev/2019/04/12/insets-listeners-to-layouts/
16
17
  if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT && isAttachedToWindow) {
@@ -38,14 +39,16 @@ private val tmpIntArr = IntArray(2)
38
39
  /**
39
40
  * Function which updates the given [rect] with this view's position and bounds in its window.
40
41
  */
41
- @RequiresApi(Build.VERSION_CODES.KITKAT)
42
+ @SuppressLint("ObsoleteSdkInt")
42
43
  fun View.copyBoundsInWindow(rect: Rect) {
43
- if (isAttachedToWindow) {
44
- rect.set(0, 0, width, height)
45
- getLocationInWindow(tmpIntArr)
46
- rect.offset(tmpIntArr[0], tmpIntArr[1])
47
- } else {
48
- Logger.w("View.copyBoundsInWindow", "Can not copy bounds as view is not attached to window")
44
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
45
+ if (isAttachedToWindow) {
46
+ rect.set(0, 0, width, height)
47
+ getLocationInWindow(tmpIntArr)
48
+ rect.offset(tmpIntArr[0], tmpIntArr[1])
49
+ } else {
50
+ Logger.w("View.copyBoundsInWindow", "Can not copy bounds as view is not attached to window")
51
+ }
49
52
  }
50
53
  }
51
54
 
@@ -2,9 +2,9 @@ package com.reactnativekeyboardcontroller.modules.statusbar
2
2
 
3
3
  import android.animation.ArgbEvaluator
4
4
  import android.animation.ValueAnimator
5
+ import android.annotation.SuppressLint
5
6
  import android.app.Activity
6
7
  import android.os.Build
7
- import androidx.annotation.RequiresApi
8
8
  import androidx.core.view.WindowInsetsCompat
9
9
  import androidx.core.view.WindowInsetsControllerCompat
10
10
  import com.facebook.react.bridge.ReactApplicationContext
@@ -37,37 +37,39 @@ class StatusBarManagerCompatModuleImpl(
37
37
  }
38
38
  }
39
39
 
40
- @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
40
+ @SuppressLint("ObsoleteSdkInt")
41
41
  fun setColor(
42
42
  color: Int,
43
43
  animated: Boolean,
44
44
  ) {
45
- if (!isEnabled()) {
46
- return original.setColor(color.toDouble(), animated)
47
- }
48
-
49
- val activity = mReactContext.currentActivity
50
- if (activity == null) {
51
- Logger.w(
52
- TAG,
53
- "StatusBarManagerCompatModule: Ignored status bar change, current activity is null.",
54
- )
55
- return
56
- }
45
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
46
+ if (!isEnabled()) {
47
+ return original.setColor(color.toDouble(), animated)
48
+ }
57
49
 
58
- UiThreadUtil.runOnUiThread {
59
- val window = activity.window
50
+ val activity = mReactContext.currentActivity
51
+ if (activity == null) {
52
+ Logger.w(
53
+ TAG,
54
+ "StatusBarManagerCompatModule: Ignored status bar change, current activity is null.",
55
+ )
56
+ return
57
+ }
60
58
 
61
- if (animated) {
62
- val curColor: Int = window.statusBarColor
63
- val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), curColor, color)
64
- colorAnimation.addUpdateListener { animator ->
65
- window.statusBarColor = animator.animatedValue as Int
59
+ UiThreadUtil.runOnUiThread {
60
+ val window = activity.window
61
+
62
+ if (animated) {
63
+ val curColor: Int = window.statusBarColor
64
+ val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), curColor, color)
65
+ colorAnimation.addUpdateListener { animator ->
66
+ window.statusBarColor = animator.animatedValue as Int
67
+ }
68
+ colorAnimation.setDuration(DEFAULT_ANIMATION_TIME).startDelay = 0
69
+ colorAnimation.start()
70
+ } else {
71
+ window.statusBarColor = color
66
72
  }
67
- colorAnimation.setDuration(DEFAULT_ANIMATION_TIME).startDelay = 0
68
- colorAnimation.start()
69
- } else {
70
- window.statusBarColor = color
71
73
  }
72
74
  }
73
75
  }
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
4
4
  import android.content.res.Configuration
5
5
  import android.os.Handler
6
6
  import android.os.Looper
7
+ import android.view.WindowManager
7
8
  import android.widget.FrameLayout
8
9
  import androidx.core.view.ViewCompat
9
10
  import androidx.core.view.WindowCompat
@@ -153,6 +154,8 @@ class EdgeToEdgeReactViewGroup(
153
154
  !isEdgeToEdge,
154
155
  )
155
156
  }
157
+ // unclear legacy flag if it was set earlier
158
+ reactContext.currentActivity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
156
159
  }
157
160
  }
158
161
 
@@ -6,7 +6,6 @@ import android.os.Build
6
6
  import android.view.MotionEvent
7
7
  import android.view.VelocityTracker
8
8
  import android.view.ViewConfiguration
9
- import androidx.annotation.RequiresApi
10
9
  import androidx.core.view.ViewCompat
11
10
  import androidx.core.view.WindowInsetsCompat
12
11
  import com.facebook.react.uimanager.ThemedReactContext
@@ -50,7 +49,6 @@ class KeyboardGestureAreaReactViewGroup(
50
49
 
51
50
  private var velocityTracker: VelocityTracker? = null
52
51
 
53
- @RequiresApi(Build.VERSION_CODES.R)
54
52
  override fun dispatchTouchEvent(event: MotionEvent?): Boolean {
55
53
  if (velocityTracker == null) {
56
54
  // Obtain a VelocityTracker if we don't have one yet
@@ -86,7 +84,6 @@ class KeyboardGestureAreaReactViewGroup(
86
84
  // endregion
87
85
 
88
86
  // region Handlers
89
- @RequiresApi(Build.VERSION_CODES.KITKAT)
90
87
  private fun onActionDown(event: MotionEvent) {
91
88
  velocityTracker?.addMovement(event)
92
89
 
@@ -97,7 +94,6 @@ class KeyboardGestureAreaReactViewGroup(
97
94
  lastWindowY = bounds.top
98
95
  }
99
96
 
100
- @RequiresApi(Build.VERSION_CODES.R)
101
97
  private fun onActionMove(event: MotionEvent) {
102
98
  // Since the view is likely to be translated/moved as the WindowInsetsAnimation
103
99
  // progresses, we need to make sure we account for that change in our touch
@@ -230,11 +226,14 @@ class KeyboardGestureAreaReactViewGroup(
230
226
  else -> false
231
227
  }
232
228
 
233
- @RequiresApi(Build.VERSION_CODES.R)
234
229
  private fun getWindowHeight(): Int {
235
- val metrics = reactContext.currentActivity?.windowManager?.currentWindowMetrics
230
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
231
+ val metrics = reactContext.currentActivity?.windowManager?.currentWindowMetrics
236
232
 
237
- return metrics?.bounds?.height() ?: 0
233
+ return metrics?.bounds?.height() ?: 0
234
+ }
235
+
236
+ return 0
238
237
  }
239
238
 
240
239
  companion object {
@@ -1,7 +1,5 @@
1
1
  package com.reactnativekeyboardcontroller
2
2
 
3
- import android.os.Build
4
- import androidx.annotation.RequiresApi
5
3
  import com.facebook.react.bridge.ReactApplicationContext
6
4
  import com.facebook.react.bridge.ReactContextBaseJavaModule
7
5
  import com.facebook.react.bridge.ReactMethod
@@ -22,7 +20,6 @@ class StatusBarManagerCompatModule(
22
20
  }
23
21
 
24
22
  @ReactMethod
25
- @RequiresApi(Build.VERSION_CODES.LOLLIPOP)
26
23
  private fun setColor(
27
24
  color: Int,
28
25
  animated: Boolean,
package/jest/index.js CHANGED
@@ -42,6 +42,21 @@ const state = {
42
42
  isVisible: false,
43
43
  };
44
44
 
45
+ const DefaultKeyboardToolbarTheme = {
46
+ light: {
47
+ primary: "#2c2c2c",
48
+ disabled: "#B0BEC5",
49
+ background: "#f3f3f4",
50
+ ripple: "#bcbcbcbc",
51
+ },
52
+ dark: {
53
+ primary: "#fafafa",
54
+ disabled: "#707070",
55
+ background: "#2C2C2E",
56
+ ripple: "#F8F8F888",
57
+ },
58
+ };
59
+
45
60
  const mock = {
46
61
  // hooks
47
62
  /// keyboard
@@ -105,6 +120,8 @@ const mock = {
105
120
  KeyboardAvoidingView: View,
106
121
  KeyboardAwareScrollView: ScrollView,
107
122
  KeyboardToolbar: View,
123
+ // themes
124
+ DefaultKeyboardToolbarTheme,
108
125
  };
109
126
 
110
127
  module.exports = mock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-keyboard-controller",
3
- "version": "1.18.5",
3
+ "version": "1.18.6",
4
4
  "description": "Keyboard manager which works in identical way on both iOS and Android",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",