Filter out ACTION_UP events in onKey() listener.

Previously we invokes performeSave both for ACTION_DOWN and ACTION_UP,
thus it creates two documents.

Change-Id: I7fc2a62c34fc239c2bf3ca6c71122e360d589727
Fixes: 28179791
This commit is contained in:
Daichi Hirono
2016-04-14 14:40:47 +09:00
parent 15aac69c8f
commit b12733481b

View File

@@ -84,6 +84,13 @@ public class SaveFragment extends Fragment {
new View.OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
// Only handle key-down events. This is simpler, consistent with most other
// UIs, and enables the handling of repeated key events from holding down a
// key.
if (event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
}
if (keyCode == KeyEvent.KEYCODE_ENTER && mSave.isEnabled()) {
performSave();
return true;