Skip to content

Commit

Permalink
Handle Ctrl-Shift-V from physical keyboard.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjansche committed Sep 9, 2016
1 parent 0829bc3 commit cbd9901
Showing 1 changed file with 9 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import android.inputmethodservice.KeyboardView;
import android.os.IBinder;
import android.text.InputType;
import android.text.method.MetaKeyKeyListener;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
Expand Down Expand Up @@ -84,7 +82,6 @@ public class MyanmarUnicodeKeyboard extends InputMethodService
private boolean mPredictionOn;
private boolean mCompletionOn;
private int mLastDisplayWidth;
private long mMetaState;

private Keyboard mBurmeseKeyboard;
private Keyboard mBurmeseShiftedKeyboard;
Expand Down Expand Up @@ -170,11 +167,6 @@ public void onStartInput(EditorInfo attribute, boolean restarting) {
mComposer.clear();
updateCandidates();

if (!restarting) {
// Clear shift states.
mMetaState = 0;
}

mPredictionOn = true;
mCompletionOn = false;
mCompletions = null;
Expand Down Expand Up @@ -295,9 +287,15 @@ public void onDisplayCompletions(CompletionInfo[] completions) {
* PROCESS_HARD_KEYS option.
*/
private boolean translateKeyDown(int keyCode, KeyEvent event) {
mMetaState = MetaKeyKeyListener.handleKeyDown(mMetaState, keyCode, event);
int c = event.getUnicodeChar(MetaKeyKeyListener.getMetaState(mMetaState));
mMetaState = MetaKeyKeyListener.adjustMetaAfterKeypress(mMetaState);
// Handle Ctrl-Shift-V
if (event.getKeyCode() == KeyEvent.KEYCODE_V
&& event.isCtrlPressed() // requires API level 11
&& event.isShiftPressed()) {
handlePasteFromZawgyi();
return true;
}

int c = event.getUnicodeChar();
InputConnection ic = getCurrentInputConnection();
if (c == 0 || ic == null) {
return false;
Expand Down Expand Up @@ -357,23 +355,6 @@ public boolean onKeyDown(int keyCode, KeyEvent event) {
return super.onKeyDown(keyCode, event);
}

/**
* Use this to monitor key events being delivered to the application.
* We get first crack at them, and can either resume them or let them
* continue to the app.
*/
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// If we want to do transformations on text being entered with a hard
// keyboard, we need to process the up events to update the meta key
// state we are tracking.
if (PROCESS_HARD_KEYS) {
mMetaState = MetaKeyKeyListener.handleKeyUp(mMetaState, keyCode, event);
}

return super.onKeyUp(keyCode, event);
}

/**
* Helper function to commit any text being composed in to the editor.
*/
Expand Down

0 comments on commit cbd9901

Please sign in to comment.