@@ -62,7 +62,7 @@ const withIosAppDelegateBody = (config) => {
6262 tag : 'react-native-keyevent-body' ,
6363 src : config . modResults . contents ,
6464 newSrc : newSrc . join ( '\n' ) ,
65- anchor : `@implementation AppDelegate` ,
65+ anchor : `@implementation AppDelegate` , // /#import "AppDelegate\.h"/g,
6666 offset : 1 ,
6767 comment : '//' ,
6868 } ) ;
@@ -77,14 +77,14 @@ const withAndroidMainActivityImport = (config) => {
7777 // @ts -ignore
7878 const newConfig = ( 0 , config_plugins_1 . withMainActivity ) ( config , ( config ) => {
7979 const newSrc = [
80- 'import android.view.KeyEvent; ' ,
81- 'import com.github.kevinejohn.keyevent.KeyEventModule; ' ,
80+ 'import android.view.KeyEvent' ,
81+ 'import com.github.kevinejohn.keyevent.KeyEventModule' ,
8282 ] ;
8383 const newConfig = ( 0 , generateCode_1 . mergeContents ) ( {
8484 tag : 'react-native-keyevent-import' ,
8585 src : config . modResults . contents ,
8686 newSrc : newSrc . join ( '\n' ) ,
87- anchor : `; ` ,
87+ anchor : `import ` ,
8888 offset : 1 ,
8989 comment : '//' ,
9090 } ) ;
@@ -99,53 +99,49 @@ const withAndroidMainActivityBody = (config) => {
9999 // @ts -ignore
100100 const newConfig = ( 0 , config_plugins_1 . withMainActivity ) ( config , ( config ) => {
101101 const newSrc = [
102- '@Override' ,
103- 'public boolean onKeyDown(int keyCode, KeyEvent event) {' ,
104- '' ,
105- ' // // Uncomment this is key events should only trigger once when key is held down' ,
102+ 'override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {' ,
103+ ' // // Uncomment this if key events should only trigger once when key is held down' ,
106104 ' // if (event.getRepeatCount() == 0) {' ,
107- ' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event); ' ,
105+ ' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)' ,
108106 ' // }' ,
109107 '' ,
110108 ' // // This will trigger the key repeat if the key is held down' ,
111109 ' // // Comment this out if uncommenting the above' ,
112- ' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event); ' ,
110+ ' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)' ,
113111 '' ,
114112 ' // // Uncomment this if you want the default keyboard behavior' ,
115- ' // return super.onKeyDown(keyCode, event); ' ,
113+ ' // return super.onKeyDown(keyCode, event)' ,
116114 '' ,
117115 ' // // The default keyboard behaviour wll be overridden' ,
118116 ' // // This is similar to what e.preventDefault() does in a browser' ,
119117 ' // // comment this if uncommenting the above' ,
120- ' super.onKeyDown(keyCode, event); ' ,
121- ' return true; ' ,
118+ ' super.onKeyDown(keyCode, event)' ,
119+ ' return true' ,
122120 '}' ,
123121 '' ,
124- '@Override' ,
125- 'public boolean onKeyUp(int keyCode, KeyEvent event) {' ,
126- ' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);' ,
122+ 'override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {' ,
123+ ' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event)' ,
127124 '' ,
128125 ' // // Uncomment this if you want the default keyboard behavior' ,
129- ' // return super.onKeyUp(keyCode, event); ' ,
126+ ' // return super.onKeyUp(keyCode, event)' ,
130127 '' ,
131128 ' // // The default keyboard behaviour wll be overridden' ,
132129 ' // // This is similar to what e.preventDefault() does in a browser' ,
133130 ' // // comment this if uncommenting the above' ,
134- ' super.onKeyUp(keyCode, event); ' ,
135- ' return true; ' ,
131+ ' super.onKeyUp(keyCode, event)' ,
132+ ' return true' ,
136133 '}' ,
137134 '' ,
138- '@Override' ,
139- 'public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {' ,
140- ' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event);' ,
141- ' return super.onKeyMultiple(keyCode, repeatCount, event);' ,
135+ 'override fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent): Boolean {' ,
136+ ' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event)' ,
137+ ' return super.onKeyMultiple(keyCode, repeatCount, event)' ,
142138 '}' ,
143139 ] ;
144140 const newConfig = ( 0 , generateCode_1 . mergeContents ) ( {
145141 tag : 'react-native-keyevent-body' ,
146142 src : config . modResults . contents ,
147143 newSrc : newSrc . join ( '\n' ) ,
148- anchor : `public class MainActivity extends ReactActivity { ` ,
144+ anchor : `class MainActivity` ,
149145 offset : 1 ,
150146 comment : '//' ,
151147 } ) ;
0 commit comments