Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions build/withReactNativeKeyevent.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const withIosAppDelegateBody = (config) => {
tag: 'react-native-keyevent-body',
src: config.modResults.contents,
newSrc: newSrc.join('\n'),
anchor: `@implementation AppDelegate`,
anchor: `@implementation AppDelegate`, // /#import "AppDelegate\.h"/g,
offset: 1,
comment: '//',
});
Expand All @@ -77,14 +77,14 @@ const withAndroidMainActivityImport = (config) => {
// @ts-ignore
const newConfig = (0, config_plugins_1.withMainActivity)(config, (config) => {
const newSrc = [
'import android.view.KeyEvent;',
'import com.github.kevinejohn.keyevent.KeyEventModule;',
'import android.view.KeyEvent',
'import com.github.kevinejohn.keyevent.KeyEventModule',
];
const newConfig = (0, generateCode_1.mergeContents)({
tag: 'react-native-keyevent-import',
src: config.modResults.contents,
newSrc: newSrc.join('\n'),
anchor: `;`,
anchor: `import`,
offset: 1,
comment: '//',
});
Expand All @@ -99,53 +99,49 @@ const withAndroidMainActivityBody = (config) => {
// @ts-ignore
const newConfig = (0, config_plugins_1.withMainActivity)(config, (config) => {
const newSrc = [
'@Override',
'public boolean onKeyDown(int keyCode, KeyEvent event) {',
'',
' // // Uncomment this is key events should only trigger once when key is held down',
'override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {',
' // // Uncomment this if key events should only trigger once when key is held down',
' // if (event.getRepeatCount() == 0) {',
' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);',
' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)',
' // }',
'',
' // // This will trigger the key repeat if the key is held down',
' // // Comment this out if uncommenting the above',
' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);',
' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)',
'',
' // // Uncomment this if you want the default keyboard behavior',
' // return super.onKeyDown(keyCode, event);',
' // return super.onKeyDown(keyCode, event)',
'',
' // // The default keyboard behaviour wll be overridden',
' // // This is similar to what e.preventDefault() does in a browser',
' // // comment this if uncommenting the above',
' super.onKeyDown(keyCode, event);',
' return true;',
' super.onKeyDown(keyCode, event)',
' return true',
'}',
'',
'@Override',
'public boolean onKeyUp(int keyCode, KeyEvent event) {',
' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);',
'override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {',
' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event)',
'',
' // // Uncomment this if you want the default keyboard behavior',
' // return super.onKeyUp(keyCode, event);',
' // return super.onKeyUp(keyCode, event)',
'',
' // // The default keyboard behaviour wll be overridden',
' // // This is similar to what e.preventDefault() does in a browser',
' // // comment this if uncommenting the above',
' super.onKeyUp(keyCode, event);',
' return true;',
' super.onKeyUp(keyCode, event)',
' return true',
'}',
'',
'@Override',
'public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {',
' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event);',
' return super.onKeyMultiple(keyCode, repeatCount, event);',
'override fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent): Boolean {',
' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event)',
' return super.onKeyMultiple(keyCode, repeatCount, event)',
'}',
];
const newConfig = (0, generateCode_1.mergeContents)({
tag: 'react-native-keyevent-body',
src: config.modResults.contents,
newSrc: newSrc.join('\n'),
anchor: `public class MainActivity extends ReactActivity {`,
anchor: `class MainActivity`,
offset: 1,
comment: '//',
});
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
],
"author": "Scott Pritchard",
"devDependencies": {
"expo-module-scripts": "^3.1.0"
"expo-module-scripts": "^3.4.1"
},
"peerDependencies": {
"expo": "^49.0.0"
"expo": "^50.0.0"
},
"dependencies": {
"@expo/config-plugins": "^7.2.5"
"@expo/config-plugins": "^7.8.4"
}
}
46 changes: 21 additions & 25 deletions src/withReactNativeKeyevent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ const withAndroidMainActivityImport: ConfigPlugin = (config) => {
// @ts-ignore
const newConfig = withMainActivity(config, (config) => {
const newSrc = [
'import android.view.KeyEvent;',
'import com.github.kevinejohn.keyevent.KeyEventModule;',
'import android.view.KeyEvent',
'import com.github.kevinejohn.keyevent.KeyEventModule',
];
const newConfig = mergeContents({
tag: 'react-native-keyevent-import',
src: config.modResults.contents,
newSrc: newSrc.join('\n'),
anchor: `;`,
anchor: `import`,
offset: 1,
comment: '//',
});
Expand All @@ -99,53 +99,49 @@ const withAndroidMainActivityBody: ConfigPlugin = (config) => {
// @ts-ignore
const newConfig = withMainActivity(config, (config) => {
const newSrc = [
'@Override',
'public boolean onKeyDown(int keyCode, KeyEvent event) {',
'',
' // // Uncomment this is key events should only trigger once when key is held down',
'override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {',
' // // Uncomment this if key events should only trigger once when key is held down',
' // if (event.getRepeatCount() == 0) {',
' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);',
' // KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)',
' // }',
'',
' // // This will trigger the key repeat if the key is held down',
' // // Comment this out if uncommenting the above',
' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event);',
' KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)',
'',
' // // Uncomment this if you want the default keyboard behavior',
' // return super.onKeyDown(keyCode, event);',
' // return super.onKeyDown(keyCode, event)',
'',
' // // The default keyboard behaviour wll be overridden',
' // // This is similar to what e.preventDefault() does in a browser',
' // // comment this if uncommenting the above',
' super.onKeyDown(keyCode, event);',
' return true;',
'}',
' super.onKeyDown(keyCode, event)',
' return true',
'}',
'',
'@Override',
'public boolean onKeyUp(int keyCode, KeyEvent event) {',
' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event);',
'override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {',
' KeyEventModule.getInstance().onKeyUpEvent(keyCode, event)',
'',
' // // Uncomment this if you want the default keyboard behavior',
' // return super.onKeyUp(keyCode, event);',
' // // Uncomment this if you want the default keyboard behavior',
' // return super.onKeyUp(keyCode, event)',
'',
' // // The default keyboard behaviour wll be overridden',
' // // This is similar to what e.preventDefault() does in a browser',
' // // comment this if uncommenting the above',
' super.onKeyUp(keyCode, event);',
' return true;',
' super.onKeyUp(keyCode, event)',
' return true',
'}',
'',
'@Override',
'public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {',
' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event);',
' return super.onKeyMultiple(keyCode, repeatCount, event);',
'override fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent): Boolean {',
' KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event)',
' return super.onKeyMultiple(keyCode, repeatCount, event)',
'}',
];
const newConfig = mergeContents({
tag: 'react-native-keyevent-body',
src: config.modResults.contents,
newSrc: newSrc.join('\n'),
anchor: `public class MainActivity extends ReactActivity {`,
anchor: `class MainActivity`,
offset: 1,
comment: '//',
});
Expand Down
Loading