@communi/keyboard-area-react-native 3.0.0 → 3.0.1
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.
|
@@ -2,10 +2,12 @@ package com.piscale.reactnative.keyboard
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.graphics.Rect
|
|
5
|
+
import android.os.Build
|
|
5
6
|
import android.view.Gravity
|
|
6
7
|
import android.view.View
|
|
7
8
|
import android.view.ViewTreeObserver
|
|
8
9
|
import android.view.WindowManager
|
|
10
|
+
import android.view.WindowInsets
|
|
9
11
|
import android.widget.PopupWindow
|
|
10
12
|
|
|
11
13
|
object KeyboardInfo {
|
|
@@ -29,6 +31,9 @@ object KeyboardInfo {
|
|
|
29
31
|
class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
30
32
|
|
|
31
33
|
private var heightMax = 0
|
|
34
|
+
private var windowWidthDp = 0
|
|
35
|
+
private var windowHeightDp = 0
|
|
36
|
+
private var dismissed = false
|
|
32
37
|
private var lastKeyboardHeight = -1
|
|
33
38
|
private val resizableView: View
|
|
34
39
|
private var keyboardListeners = ArrayList<KeyboardListener>()
|
|
@@ -40,6 +45,10 @@ class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
|
40
45
|
init {
|
|
41
46
|
contentView = View.inflate(activity, R.layout.keyboard_popup, null)
|
|
42
47
|
resizableView = contentView.findViewById(R.id.container)
|
|
48
|
+
resizableView.setOnApplyWindowInsetsListener { _, insets ->
|
|
49
|
+
computeKeyboardState()
|
|
50
|
+
insets
|
|
51
|
+
}
|
|
43
52
|
softInputMode = WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE or
|
|
44
53
|
WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE
|
|
45
54
|
inputMethodMode = PopupWindow.INPUT_METHOD_NEEDED
|
|
@@ -49,6 +58,7 @@ class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
|
49
58
|
|
|
50
59
|
val parentView = activity.window.decorView.rootView
|
|
51
60
|
parentView?.post {
|
|
61
|
+
if (dismissed) return@post
|
|
52
62
|
resizableView.viewTreeObserver.addOnGlobalLayoutListener(victim)
|
|
53
63
|
if (!isShowing && parentView.windowToken != null) {
|
|
54
64
|
showAtLocation(parentView, Gravity.NO_GRAVITY, 0, 0)
|
|
@@ -57,7 +67,9 @@ class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
|
57
67
|
}
|
|
58
68
|
|
|
59
69
|
override fun dismiss() {
|
|
70
|
+
dismissed = true
|
|
60
71
|
removeKeyboardListener()
|
|
72
|
+
resizableView.setOnApplyWindowInsetsListener(null)
|
|
61
73
|
resizableView.viewTreeObserver.removeOnGlobalLayoutListener(victim)
|
|
62
74
|
super.dismiss()
|
|
63
75
|
}
|
|
@@ -71,26 +83,42 @@ class KeyboardProvider(private val activity: Activity) : PopupWindow(activity) {
|
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
private fun computeKeyboardState() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
if (dismissed) return
|
|
87
|
+
val keyboardHeight: Int
|
|
88
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
89
|
+
val insets = activity.window.decorView.rootWindowInsets
|
|
90
|
+
if (insets == null) return // Wait for the first inset dispatch after attach.
|
|
91
|
+
// The old maximum visible frame becomes stale after rotation/folding.
|
|
92
|
+
// Use the current IME inset, excluding the system bar already in the host layout.
|
|
93
|
+
keyboardHeight = if (insets.isVisible(WindowInsets.Type.ime())) {
|
|
94
|
+
(insets.getInsets(WindowInsets.Type.ime()).bottom -
|
|
95
|
+
insets.getInsets(WindowInsets.Type.systemBars()).bottom).coerceAtLeast(0)
|
|
96
|
+
} else 0
|
|
97
|
+
} else {
|
|
98
|
+
val rect = Rect()
|
|
99
|
+
contentView.rootView.getWindowVisibleDisplayFrame(rect)
|
|
100
|
+
val configuration = activity.resources.configuration
|
|
101
|
+
if (windowWidthDp != configuration.screenWidthDp ||
|
|
102
|
+
windowHeightDp != configuration.screenHeightDp) {
|
|
103
|
+
heightMax = 0
|
|
104
|
+
windowWidthDp = configuration.screenWidthDp
|
|
105
|
+
windowHeightDp = configuration.screenHeightDp
|
|
106
|
+
}
|
|
107
|
+
heightMax = maxOf(heightMax, rect.bottom)
|
|
108
|
+
keyboardHeight = heightMax - rect.bottom
|
|
80
109
|
}
|
|
81
|
-
val keyboardHeight = heightMax - rect.bottom
|
|
82
110
|
KeyboardInfo.keyboardState =
|
|
83
111
|
if (keyboardHeight > 0) KeyboardInfo.STATE_OPENED else KeyboardInfo.STATE_CLOSED
|
|
84
112
|
if (keyboardHeight > 0) {
|
|
85
113
|
KeyboardInfo.keyboardHeight = keyboardHeight
|
|
86
114
|
}
|
|
87
115
|
if (keyboardHeight != lastKeyboardHeight) {
|
|
88
|
-
notifyKeyboardHeightChanged(keyboardHeight
|
|
116
|
+
notifyKeyboardHeightChanged(keyboardHeight)
|
|
89
117
|
}
|
|
90
118
|
lastKeyboardHeight = keyboardHeight
|
|
91
119
|
}
|
|
92
120
|
|
|
93
|
-
private fun notifyKeyboardHeightChanged(height: Int
|
|
121
|
+
private fun notifyKeyboardHeightChanged(height: Int) {
|
|
94
122
|
keyboardListeners.forEach {
|
|
95
123
|
it.onHeightChanged(height)
|
|
96
124
|
}
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';const
|
|
1
|
+
'use strict';const c=B;(function(K,W){const L=B,M=K();while(!![]){try{const S=-parseInt(L(0x86))/0x1*(parseInt(L(0xd5))/0x2)+-parseInt(L(0xc0))/0x3*(-parseInt(L(0xe2))/0x4)+-parseInt(L(0xb2))/0x5*(-parseInt(L(0xb9))/0x6)+-parseInt(L(0x82))/0x7+parseInt(L(0xcf))/0x8*(parseInt(L(0xd4))/0x9)+-parseInt(L(0x77))/0xa*(-parseInt(L(0x80))/0xb)+parseInt(L(0xd0))/0xc*(-parseInt(L(0xbf))/0xd);if(S===W)break;else M['push'](M['shift']());}catch(X){M['push'](M['shift']());}}}(a,0x955e5));function a(){const d=['AYS_H','selec','-\x20You','ISIBL','ardSi','addLi','push','ener','ke\x20su','isten','ORWAR','_MASK','PECIF','SOFT_','\x27pod\x20','andro','isIni','_IS_F','The\x20p','GED','SIZE','callb','_CHAN','zed','eaRea','5vGPAGY','he\x20pa','remov','IED','ilt\x20t','ckage','acks','6192684mrxlKI','putMo','_ADJU','linke','ardLi','re:\x20\x0a','3504202lzWwxc','54DQVkkl','IDDEN','E_ALW','u\x20are','p\x20aft','\x20run\x20','ST_RE','ardAr','\x0a-\x20Yo','\x20does','d.\x20Ma','INPUT','stall','HANGE','FIED','5264NDTCJh','84QrEAqO','d-are','filte','\x20Expo','14769roeHHi','2KWvjSN','\x20have','n\x27t\x20s','ackag','ndowS','\x20Go\x0a','start','\x20rebu','using','oardL','a-rea','ST_UN','Keybo','54228XmVDJu','E_HID','\x20not\x20','zeCha','nges','tive\x27','o\x20be\x20','tiali','ct-na','E_UNC','ing\x20t','5888230sKzYBX','AYS_V','ive','E_UNS','dList','forEa','stene','yboar','ST_PA','11sxFxcs','SPECI','900242bDSZpX','e\x20\x27ke','ST_NO','addKe','317444TcNyWC','er\x20in','oftIn','THING','_MODE','ctNat','get','D_NAV','ll\x27\x0a','eKeyb','E_VIS','eem\x20t','setWi','IGATI','IBLE','insta','he\x20ap','DEN','_STAT'];a=function(){return d;};return a();}import{PixelRatio as R,NativeModules as l,NativeEventEmitter as x,Platform as h}from'react-native';const O=c(0xab)+c(0xd8)+c(0x83)+c(0x7e)+c(0xd1)+c(0xdf)+c(0x74)+c(0x71)+c(0xc9)+c(0xd7)+c(0x91)+c(0x72)+c(0xbc)+c(0xca)+c(0xa1)+c(0xbe)+'\x0a'+h[c(0x9a)+'t']({'ios':c(0x9b)+c(0xd6)+c(0xc5)+c(0xa7)+c(0x95)+c(0x8e),'default':''})+(c(0x9b)+c(0xdc)+c(0xb6)+c(0x96)+c(0xc4)+c(0x87)+c(0xcc)+c(0x76)+c(0xb3)+c(0xb7)+c(0xc8)+c(0xc3)+c(0x6e)+c(0xdd)+c(0xd3)+c(0xda)),_=l[c(0xe1)+c(0xc7)+c(0xb1)+c(0x8b)+c(0x79)]?l[c(0xe1)+c(0xc7)+c(0xb1)+c(0x8b)+c(0x79)]:new Proxy({},{'get'(){throw new Error(O);}}),P={'SOFT_INPUT_ADJUST_NOTHING':_[c(0xa6)+c(0xcb)+c(0xbb)+c(0x84)+c(0x89)],'SOFT_INPUT_ADJUST_PAN':_[c(0xa6)+c(0xcb)+c(0xbb)+c(0x7f)+'N'],'SOFT_INPUT_ADJUST_RESIZE':_[c(0xa6)+c(0xcb)+c(0xbb)+c(0xc6)+c(0xad)],'SOFT_INPUT_ADJUST_UNSPECIFIED':_[c(0xa6)+c(0xcb)+c(0xbb)+c(0xe0)+c(0x81)+c(0xce)],'SOFT_INPUT_IS_FORWARD_NAVIGATION':_[c(0xa6)+c(0xcb)+c(0xaa)+c(0xa3)+c(0x8d)+c(0x93)+'ON'],'SOFT_INPUT_MASK_ADJUST':_[c(0xa6)+c(0xcb)+c(0xa4)+c(0xbb)+'ST'],'SOFT_INPUT_MASK_STATE':_[c(0xa6)+c(0xcb)+c(0xa4)+c(0x98)+'E'],'SOFT_INPUT_MODE_CHANGED':_[c(0xa6)+c(0xcb)+c(0x8a)+c(0xaf)+c(0xac)],'SOFT_INPUT_STATE_ALWAYS_HIDDEN':_[c(0xa6)+c(0xcb)+c(0x98)+c(0xc2)+c(0x99)+c(0xc1)],'SOFT_INPUT_STATE_ALWAYS_VISIBLE':_[c(0xa6)+c(0xcb)+c(0x98)+c(0xc2)+c(0x78)+c(0x9c)+'E'],'SOFT_INPUT_STATE_HIDDEN':_[c(0xa6)+c(0xcb)+c(0x98)+c(0x6d)+c(0x97)],'SOFT_INPUT_STATE_UNCHANGED':_[c(0xa6)+c(0xcb)+c(0x98)+c(0x75)+c(0xcd)+'D'],'SOFT_INPUT_STATE_UNSPECIFIED':_[c(0xa6)+c(0xcb)+c(0x98)+c(0x7a)+c(0xa5)+c(0xb5)],'SOFT_INPUT_STATE_VISIBLE':_[c(0xa6)+c(0xcb)+c(0x98)+c(0x90)+c(0x94)]},F=new x(_);function B(R,l){const F=a();return B=function(x,h){x=x-0x6d;let K=F[x];return K;},B(R,l);}export const KEYBOARD_SIZE_EVENT_NAME=c(0xe1)+c(0x9d)+c(0x6f)+c(0x70);export var SoftInputMode;(function(K){const C=c;K[C(0xa6)+C(0xcb)+C(0xbb)+C(0x84)+C(0x89)]=C(0xa6)+C(0xcb)+C(0xbb)+C(0x84)+C(0x89),K[C(0xa6)+C(0xcb)+C(0xbb)+C(0x7f)+'N']=C(0xa6)+C(0xcb)+C(0xbb)+C(0x7f)+'N',K[C(0xa6)+C(0xcb)+C(0xbb)+C(0xc6)+C(0xad)]=C(0xa6)+C(0xcb)+C(0xbb)+C(0xc6)+C(0xad),K[C(0xa6)+C(0xcb)+C(0xbb)+C(0xe0)+C(0x81)+C(0xce)]=C(0xa6)+C(0xcb)+C(0xbb)+C(0xe0)+C(0x81)+C(0xce),K[C(0xa6)+C(0xcb)+C(0xaa)+C(0xa3)+C(0x8d)+C(0x93)+'ON']=C(0xa6)+C(0xcb)+C(0xaa)+C(0xa3)+C(0x8d)+C(0x93)+'ON',K[C(0xa6)+C(0xcb)+C(0xa4)+C(0xbb)+'ST']=C(0xa6)+C(0xcb)+C(0xa4)+C(0xbb)+'ST',K[C(0xa6)+C(0xcb)+C(0xa4)+C(0x98)+'E']=C(0xa6)+C(0xcb)+C(0xa4)+C(0x98)+'E',K[C(0xa6)+C(0xcb)+C(0x8a)+C(0xaf)+C(0xac)]=C(0xa6)+C(0xcb)+C(0x8a)+C(0xaf)+C(0xac),K[C(0xa6)+C(0xcb)+C(0x98)+C(0xc2)+C(0x99)+C(0xc1)]=C(0xa6)+C(0xcb)+C(0x98)+C(0xc2)+C(0x99)+C(0xc1),K[C(0xa6)+C(0xcb)+C(0x98)+C(0xc2)+C(0x78)+C(0x9c)+'E']=C(0xa6)+C(0xcb)+C(0x98)+C(0xc2)+C(0x78)+C(0x9c)+'E',K[C(0xa6)+C(0xcb)+C(0x98)+C(0x6d)+C(0x97)]=C(0xa6)+C(0xcb)+C(0x98)+C(0x6d)+C(0x97),K[C(0xa6)+C(0xcb)+C(0x98)+C(0x75)+C(0xcd)+'D']=C(0xa6)+C(0xcb)+C(0x98)+C(0x75)+C(0xcd)+'D',K[C(0xa6)+C(0xcb)+C(0x98)+C(0x7a)+C(0xa5)+C(0xb5)]=C(0xa6)+C(0xcb)+C(0x98)+C(0x7a)+C(0xa5)+C(0xb5),K[C(0xa6)+C(0xcb)+C(0x98)+C(0x90)+C(0x94)]=C(0xa6)+C(0xcb)+C(0x98)+C(0x90)+C(0x94);}(SoftInputMode||(SoftInputMode={})));export class PSKeyboard{static [c(0xa9)+c(0x73)+c(0xb0)]=!0x1;static [c(0xae)+c(0xb8)]=[];static[c(0x92)+c(0xd9)+c(0x88)+c(0xba)+'de'](K){const V=c;if(h['OS']===V(0xa8)+'id')return _[V(0x92)+V(0xd9)+V(0x88)+V(0xba)+'de'](P[K]);}static[c(0x85)+c(0x7e)+c(0x7b)+c(0xa0)](K){const Z=c;_[Z(0xdb)+Z(0xe1)+Z(0xbd)+Z(0x7d)+'r'](),PSKeyboard[Z(0xae)+Z(0xb8)][Z(0x9f)](K);}static[c(0xb4)+c(0x8f)+c(0xde)+c(0xa2)+'er'](K){const w=c;PSKeyboard[w(0xae)+w(0xb8)]=PSKeyboard[w(0xae)+w(0xb8)][w(0xd2)+'r'](W=>W!==K);}}F[c(0x9e)+c(0x7d)+'r'](KEYBOARD_SIZE_EVENT_NAME,K=>{const H=c,W=h['OS']===H(0xa8)+'id'?K/R[H(0x8c)]():K;PSKeyboard[H(0xae)+H(0xb8)][H(0x7c)+'ch'](M=>{M(W);});});
|