mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
key codes instead of key names
This commit is contained in:
parent
6cf327a064
commit
06db42f28c
6 changed files with 68 additions and 255 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<keymap>
|
<keymap>
|
||||||
<binding key="<VolumeDown>" action="volumeKeyScrollForward"/>
|
<binding key="4" action="cancelMenu"/>
|
||||||
<binding key="<VolumeUp>" action="volumeKeyScrollBackward"/>
|
<binding key="23" action="processHyperlink"/>
|
||||||
<binding key="<Back>" action="cancelMenu"/>
|
<binding key="24" action="volumeKeyScrollBackward"/>
|
||||||
<binding key="<Enter>" action="processHyperlink"/>
|
<binding key="25" action="volumeKeyScrollForward"/>
|
||||||
<binding key="<PadCenter>" action="processHyperlink"/>
|
<binding key="66" action="processHyperlink"/>
|
||||||
</keymap>
|
</keymap>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.geometerplus.android.fbreader.preferences;
|
package org.geometerplus.android.fbreader.preferences;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.view.KeyEvent;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.core.application.ZLKeyBindings;
|
import org.geometerplus.zlibrary.core.application.ZLKeyBindings;
|
||||||
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
|
import org.geometerplus.zlibrary.core.options.ZLIntegerOption;
|
||||||
|
@ -407,14 +408,14 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU };
|
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU };
|
||||||
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, cancelMenuScreen.Resource, "backKeyAction",
|
this, cancelMenuScreen.Resource, "backKeyAction",
|
||||||
bindings.getOption("<Back>", false), backKeyActions
|
bindings.getOption(KeyEvent.KEYCODE_BACK, false), backKeyActions
|
||||||
));
|
));
|
||||||
final String[] backKeyLongPressActions =
|
final String[] backKeyLongPressActions =
|
||||||
//{ ActionCode.EXIT, ActionCode.GO_BACK, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
//{ ActionCode.EXIT, ActionCode.GO_BACK, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
||||||
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
{ ActionCode.EXIT, ActionCode.SHOW_CANCEL_MENU, FBReaderApp.NoAction };
|
||||||
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
cancelMenuScreen.addPreference(new ZLStringChoicePreference(
|
||||||
this, cancelMenuScreen.Resource, "backKeyLongPressAction",
|
this, cancelMenuScreen.Resource, "backKeyLongPressAction",
|
||||||
bindings.getOption("<Back>", true), backKeyLongPressActions
|
bindings.getOption(KeyEvent.KEYCODE_BACK, true), backKeyLongPressActions
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,12 +146,12 @@ public abstract class ZLApplication {
|
||||||
//may be protected
|
//may be protected
|
||||||
abstract public ZLKeyBindings keyBindings();
|
abstract public ZLKeyBindings keyBindings();
|
||||||
|
|
||||||
public final boolean hasActionForKey(String key, boolean longPress) {
|
public final boolean hasActionForKey(int key, boolean longPress) {
|
||||||
final String actionId = keyBindings().getBinding(key, longPress);
|
final String actionId = keyBindings().getBinding(key, longPress);
|
||||||
return actionId != null && !NoAction.equals(actionId);
|
return actionId != null && !NoAction.equals(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean doActionByKey(String key, boolean longPress) {
|
public final boolean doActionByKey(int key, boolean longPress) {
|
||||||
final String actionId = keyBindings().getBinding(key, longPress);
|
final String actionId = keyBindings().getBinding(key, longPress);
|
||||||
if (actionId != null) {
|
if (actionId != null) {
|
||||||
final ZLAction action = myIdToActionMap.get(actionId);
|
final ZLAction action = myIdToActionMap.get(actionId);
|
||||||
|
|
|
@ -33,23 +33,35 @@ public final class ZLKeyBindings {
|
||||||
|
|
||||||
private final String myName;
|
private final String myName;
|
||||||
private final ZLStringListOption myKeysOption;
|
private final ZLStringListOption myKeysOption;
|
||||||
private final TreeMap<String,ZLStringOption> myActionMap = new TreeMap<String,ZLStringOption>();
|
private final TreeMap<Integer,ZLStringOption> myActionMap = new TreeMap<Integer,ZLStringOption>();
|
||||||
private final TreeMap<String,ZLStringOption> myLongPressActionMap = new TreeMap<String,ZLStringOption>();
|
private final TreeMap<Integer,ZLStringOption> myLongPressActionMap = new TreeMap<Integer,ZLStringOption>();
|
||||||
|
|
||||||
public ZLKeyBindings(String name) {
|
public ZLKeyBindings(String name) {
|
||||||
myName = name;
|
myName = name;
|
||||||
final List<String> keys = new LinkedList<String>();
|
final List<String> keys = new LinkedList<String>();
|
||||||
new Reader(keys).readBindings();
|
new Reader(keys).readBindings();
|
||||||
|
Collections.sort(keys);
|
||||||
myKeysOption = new ZLStringListOption(name, "KeyList", keys);
|
myKeysOption = new ZLStringListOption(name, "KeyList", keys);
|
||||||
|
// this code is here for migration from old versions;
|
||||||
|
// should be removed in FBReader 2.0
|
||||||
|
ZLStringOption oldBackKeyOption = new ZLStringOption(name + ":" + ACTION, "<Back>", "");
|
||||||
|
if (oldBackKeyOption.getValue() != null) {
|
||||||
|
new ZLStringOption(name + ":" + ACTION, "4", oldBackKeyOption.getValue());
|
||||||
|
}
|
||||||
|
oldBackKeyOption = new ZLStringOption(name + ":" + LONG_PRESS_ACTION, "<Back>", "");
|
||||||
|
if (oldBackKeyOption.getValue() != null) {
|
||||||
|
new ZLStringOption(name + ":" + LONG_PRESS_ACTION, "4", oldBackKeyOption.getValue());
|
||||||
|
}
|
||||||
|
// end of migration code
|
||||||
}
|
}
|
||||||
|
|
||||||
private ZLStringOption createOption(String key, boolean longPress, String defaultValue) {
|
private ZLStringOption createOption(int key, boolean longPress, String defaultValue) {
|
||||||
final String group = myName + ":" + (longPress ? LONG_PRESS_ACTION : ACTION);
|
final String group = myName + ":" + (longPress ? LONG_PRESS_ACTION : ACTION);
|
||||||
return new ZLStringOption(group, key, defaultValue);
|
return new ZLStringOption(group, String.valueOf(key), defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ZLStringOption getOption(String key, boolean longPress) {
|
public ZLStringOption getOption(int key, boolean longPress) {
|
||||||
final TreeMap<String,ZLStringOption> map = longPress ? myLongPressActionMap : myActionMap;
|
final TreeMap<Integer,ZLStringOption> map = longPress ? myLongPressActionMap : myActionMap;
|
||||||
ZLStringOption option = map.get(key);
|
ZLStringOption option = map.get(key);
|
||||||
if (option == null) {
|
if (option == null) {
|
||||||
option = createOption(key, longPress, ZLApplication.NoAction);
|
option = createOption(key, longPress, ZLApplication.NoAction);
|
||||||
|
@ -58,17 +70,19 @@ public final class ZLKeyBindings {
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindKey(String key, boolean longPress, String actionId) {
|
public void bindKey(int key, boolean longPress, String actionId) {
|
||||||
|
final String stringKey = String.valueOf(key);
|
||||||
List<String> keys = myKeysOption.getValue();
|
List<String> keys = myKeysOption.getValue();
|
||||||
if (!keys.contains(key)) {
|
if (!keys.contains(stringKey)) {
|
||||||
keys = new ArrayList<String>(keys);
|
keys = new ArrayList<String>(keys);
|
||||||
keys.add(key);
|
keys.add(stringKey);
|
||||||
|
Collections.sort(keys);
|
||||||
myKeysOption.setValue(keys);
|
myKeysOption.setValue(keys);
|
||||||
}
|
}
|
||||||
getOption(key, longPress).setValue(actionId);
|
getOption(key, longPress).setValue(actionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBinding(String key, boolean longPress) {
|
public String getBinding(int key, boolean longPress) {
|
||||||
return getOption(key, longPress).getValue();
|
return getOption(key, longPress).getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +101,15 @@ public final class ZLKeyBindings {
|
||||||
@Override
|
@Override
|
||||||
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
public boolean startElementHandler(String tag, ZLStringMap attributes) {
|
||||||
if ("binding".equals(tag)) {
|
if ("binding".equals(tag)) {
|
||||||
final String key = attributes.getValue("key");
|
final String stringKey = attributes.getValue("key");
|
||||||
final String actionId = attributes.getValue("action");
|
final String actionId = attributes.getValue("action");
|
||||||
if (key != null && actionId != null) {
|
if (stringKey != null && actionId != null) {
|
||||||
myKeyList.add(key);
|
try {
|
||||||
myActionMap.put(key, createOption(key, false, actionId));
|
final int key = Integer.parseInt(stringKey);
|
||||||
|
myKeyList.add(stringKey);
|
||||||
|
myActionMap.put(key, createOption(key, false, actionId));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,193 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (C) 2007-2011 Geometer Plus <contact@geometerplus.com>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
||||||
* 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geometerplus.zlibrary.ui.android.util;
|
|
||||||
|
|
||||||
import android.view.KeyEvent;
|
|
||||||
|
|
||||||
public final class ZLAndroidKeyUtil {
|
|
||||||
public static String getKeyNameByCode(int code) {
|
|
||||||
switch (code) {
|
|
||||||
case KeyEvent.KEYCODE_0:
|
|
||||||
return "<0>";
|
|
||||||
case KeyEvent.KEYCODE_1:
|
|
||||||
return "<1>";
|
|
||||||
case KeyEvent.KEYCODE_2:
|
|
||||||
return "<2>";
|
|
||||||
case KeyEvent.KEYCODE_3:
|
|
||||||
return "<3>";
|
|
||||||
case KeyEvent.KEYCODE_4:
|
|
||||||
return "<4>";
|
|
||||||
case KeyEvent.KEYCODE_5:
|
|
||||||
return "<5>";
|
|
||||||
case KeyEvent.KEYCODE_6:
|
|
||||||
return "<6>";
|
|
||||||
case KeyEvent.KEYCODE_7:
|
|
||||||
return "<7>";
|
|
||||||
case KeyEvent.KEYCODE_8:
|
|
||||||
return "<8>";
|
|
||||||
case KeyEvent.KEYCODE_9:
|
|
||||||
return "<9>";
|
|
||||||
case KeyEvent.KEYCODE_A:
|
|
||||||
return "<A>";
|
|
||||||
case KeyEvent.KEYCODE_B:
|
|
||||||
return "<B>";
|
|
||||||
case KeyEvent.KEYCODE_C:
|
|
||||||
return "<C>";
|
|
||||||
case KeyEvent.KEYCODE_D:
|
|
||||||
return "<D>";
|
|
||||||
case KeyEvent.KEYCODE_E:
|
|
||||||
return "<E>";
|
|
||||||
case KeyEvent.KEYCODE_F:
|
|
||||||
return "<F>";
|
|
||||||
case KeyEvent.KEYCODE_G:
|
|
||||||
return "<G>";
|
|
||||||
case KeyEvent.KEYCODE_H:
|
|
||||||
return "<H>";
|
|
||||||
case KeyEvent.KEYCODE_I:
|
|
||||||
return "<I>";
|
|
||||||
case KeyEvent.KEYCODE_J:
|
|
||||||
return "<J>";
|
|
||||||
case KeyEvent.KEYCODE_K:
|
|
||||||
return "<K>";
|
|
||||||
case KeyEvent.KEYCODE_L:
|
|
||||||
return "<L>";
|
|
||||||
case KeyEvent.KEYCODE_M:
|
|
||||||
return "<M>";
|
|
||||||
case KeyEvent.KEYCODE_N:
|
|
||||||
return "<N>";
|
|
||||||
case KeyEvent.KEYCODE_O:
|
|
||||||
return "<O>";
|
|
||||||
case KeyEvent.KEYCODE_P:
|
|
||||||
return "<P>";
|
|
||||||
case KeyEvent.KEYCODE_Q:
|
|
||||||
return "<Q>";
|
|
||||||
case KeyEvent.KEYCODE_R:
|
|
||||||
return "<R>";
|
|
||||||
case KeyEvent.KEYCODE_S:
|
|
||||||
return "<S>";
|
|
||||||
case KeyEvent.KEYCODE_T:
|
|
||||||
return "<T>";
|
|
||||||
case KeyEvent.KEYCODE_U:
|
|
||||||
return "<U>";
|
|
||||||
case KeyEvent.KEYCODE_V:
|
|
||||||
return "<V>";
|
|
||||||
case KeyEvent.KEYCODE_W:
|
|
||||||
return "<W>";
|
|
||||||
case KeyEvent.KEYCODE_X:
|
|
||||||
return "<X>";
|
|
||||||
case KeyEvent.KEYCODE_Y:
|
|
||||||
return "<Y>";
|
|
||||||
case KeyEvent.KEYCODE_Z:
|
|
||||||
return "<Z>";
|
|
||||||
case KeyEvent.KEYCODE_APOSTROPHE:
|
|
||||||
return "<'>";
|
|
||||||
case KeyEvent.KEYCODE_AT:
|
|
||||||
return "<@>";
|
|
||||||
case KeyEvent.KEYCODE_BACK:
|
|
||||||
return "<Back>";
|
|
||||||
case KeyEvent.KEYCODE_BACKSLASH:
|
|
||||||
return "<\\>";
|
|
||||||
case KeyEvent.KEYCODE_CALL:
|
|
||||||
return "<Call>";
|
|
||||||
case KeyEvent.KEYCODE_CAMERA:
|
|
||||||
return "<Camera>";
|
|
||||||
case KeyEvent.KEYCODE_CLEAR:
|
|
||||||
return "<Clear>";
|
|
||||||
case KeyEvent.KEYCODE_COMMA:
|
|
||||||
return "<,>";
|
|
||||||
case KeyEvent.KEYCODE_DEL:
|
|
||||||
return "<Del>";
|
|
||||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
|
||||||
return "<PadCenter>";
|
|
||||||
case KeyEvent.KEYCODE_DPAD_DOWN:
|
|
||||||
return "<PadDown>";
|
|
||||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
|
||||||
return "<PadLeft>";
|
|
||||||
case KeyEvent.KEYCODE_DPAD_RIGHT:
|
|
||||||
return "<PadRight>";
|
|
||||||
case KeyEvent.KEYCODE_DPAD_UP:
|
|
||||||
return "<PadUp>";
|
|
||||||
case KeyEvent.KEYCODE_ENDCALL:
|
|
||||||
return "<EndCall>";
|
|
||||||
case KeyEvent.KEYCODE_ENTER:
|
|
||||||
return "<Enter>";
|
|
||||||
case KeyEvent.KEYCODE_ENVELOPE:
|
|
||||||
return "<Envelope>";
|
|
||||||
case KeyEvent.KEYCODE_EQUALS:
|
|
||||||
return "<=>";
|
|
||||||
case KeyEvent.KEYCODE_EXPLORER:
|
|
||||||
return "<Explorer>";
|
|
||||||
case KeyEvent.KEYCODE_FOCUS:
|
|
||||||
return "<??? 0>";
|
|
||||||
case KeyEvent.KEYCODE_GRAVE:
|
|
||||||
return "<??? 1>";
|
|
||||||
case KeyEvent.KEYCODE_HEADSETHOOK:
|
|
||||||
return "<??? 2>";
|
|
||||||
case KeyEvent.KEYCODE_HOME:
|
|
||||||
return "<Home>";
|
|
||||||
case KeyEvent.KEYCODE_LEFT_BRACKET:
|
|
||||||
return "<(>";
|
|
||||||
case KeyEvent.KEYCODE_MENU:
|
|
||||||
return "<Menu>";
|
|
||||||
case KeyEvent.KEYCODE_MINUS:
|
|
||||||
return "<->";
|
|
||||||
case KeyEvent.KEYCODE_NOTIFICATION:
|
|
||||||
return "<??? 3>";
|
|
||||||
case KeyEvent.KEYCODE_NUM:
|
|
||||||
return "<Num>";
|
|
||||||
case KeyEvent.KEYCODE_PERIOD:
|
|
||||||
return "<??? 4>";
|
|
||||||
case KeyEvent.KEYCODE_PLUS:
|
|
||||||
return "<+>";
|
|
||||||
case KeyEvent.KEYCODE_POUND:
|
|
||||||
return "<??? 5>";
|
|
||||||
case KeyEvent.KEYCODE_POWER:
|
|
||||||
return "<Power>";
|
|
||||||
case KeyEvent.KEYCODE_RIGHT_BRACKET:
|
|
||||||
return "<)>";
|
|
||||||
case KeyEvent.KEYCODE_SEMICOLON:
|
|
||||||
return "<;>";
|
|
||||||
case KeyEvent.KEYCODE_SLASH:
|
|
||||||
return "</>";
|
|
||||||
case KeyEvent.KEYCODE_SOFT_LEFT:
|
|
||||||
return "<??? 6>";
|
|
||||||
case KeyEvent.KEYCODE_SOFT_RIGHT:
|
|
||||||
return "<??? 7>";
|
|
||||||
case KeyEvent.KEYCODE_SPACE:
|
|
||||||
return "<Space>";
|
|
||||||
case KeyEvent.KEYCODE_STAR:
|
|
||||||
return "<*>";
|
|
||||||
case KeyEvent.KEYCODE_SYM:
|
|
||||||
return "<Sym>";
|
|
||||||
case KeyEvent.KEYCODE_TAB:
|
|
||||||
return "<Tab>";
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
|
||||||
return "<VolumeDown>";
|
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
|
||||||
return "<VolumeUp>";
|
|
||||||
case KeyEvent.KEYCODE_UNKNOWN:
|
|
||||||
default:
|
|
||||||
return "<Unknown>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ZLAndroidKeyUtil() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,7 +29,6 @@ import org.geometerplus.zlibrary.core.view.ZLViewWidget;
|
||||||
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
import org.geometerplus.zlibrary.core.application.ZLApplication;
|
||||||
|
|
||||||
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;
|
import org.geometerplus.zlibrary.ui.android.library.ZLAndroidActivity;
|
||||||
import org.geometerplus.zlibrary.ui.android.util.ZLAndroidKeyUtil;
|
|
||||||
|
|
||||||
public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongClickListener {
|
public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongClickListener {
|
||||||
private final Paint myPaint = new Paint();
|
private final Paint myPaint = new Paint();
|
||||||
|
@ -387,35 +386,33 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
|
||||||
return view.onFingerLongPress(myPressedX, myPressedY);
|
return view.onFingerLongPress(myPressedX, myPressedY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String myKeyUnderTracking;
|
private int myKeyUnderTracking = -1;
|
||||||
private long myTrackingStartTime;
|
private long myTrackingStartTime;
|
||||||
|
|
||||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||||
final ZLApplication application = ZLApplication.Instance();
|
final ZLApplication application = ZLApplication.Instance();
|
||||||
|
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
default:
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
if (application.hasActionForKey(keyCode, true) ||
|
||||||
case KeyEvent.KEYCODE_BACK:
|
application.hasActionForKey(keyCode, false)) {
|
||||||
case KeyEvent.KEYCODE_ENTER:
|
if (myKeyUnderTracking != -1) {
|
||||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
if (myKeyUnderTracking == keyCode) {
|
||||||
{
|
return true;
|
||||||
final String keyName = ZLAndroidKeyUtil.getKeyNameByCode(keyCode);
|
} else {
|
||||||
if (myKeyUnderTracking != null) {
|
myKeyUnderTracking = -1;
|
||||||
if (myKeyUnderTracking.equals(keyName)) {
|
}
|
||||||
|
}
|
||||||
|
if (application.hasActionForKey(keyCode, true)) {
|
||||||
|
myKeyUnderTracking = keyCode;
|
||||||
|
myTrackingStartTime = System.currentTimeMillis();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
myKeyUnderTracking = null;
|
return application.doActionByKey(keyCode, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (application.hasActionForKey(keyName, true)) {
|
|
||||||
myKeyUnderTracking = keyName;
|
|
||||||
myTrackingStartTime = System.currentTimeMillis();
|
|
||||||
return true;
|
|
||||||
} else {
|
} else {
|
||||||
return application.doActionByKey(keyName, false);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
case KeyEvent.KEYCODE_DPAD_LEFT:
|
case KeyEvent.KEYCODE_DPAD_LEFT:
|
||||||
application.getCurrentView().onTrackballRotated(-1, 0);
|
application.getCurrentView().onTrackballRotated(-1, 0);
|
||||||
return true;
|
return true;
|
||||||
|
@ -428,30 +425,20 @@ public class ZLAndroidWidget extends View implements ZLViewWidget, View.OnLongCl
|
||||||
case KeyEvent.KEYCODE_DPAD_UP:
|
case KeyEvent.KEYCODE_DPAD_UP:
|
||||||
application.getCurrentView().onTrackballRotated(0, -1);
|
application.getCurrentView().onTrackballRotated(0, -1);
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||||
switch (keyCode) {
|
if (myKeyUnderTracking != -1) {
|
||||||
case KeyEvent.KEYCODE_VOLUME_DOWN:
|
if (myKeyUnderTracking == keyCode) {
|
||||||
case KeyEvent.KEYCODE_VOLUME_UP:
|
final boolean longPress = System.currentTimeMillis() >
|
||||||
case KeyEvent.KEYCODE_BACK:
|
myTrackingStartTime + ViewConfiguration.getLongPressTimeout();
|
||||||
case KeyEvent.KEYCODE_ENTER:
|
ZLApplication.Instance().doActionByKey(keyCode, longPress);
|
||||||
case KeyEvent.KEYCODE_DPAD_CENTER:
|
}
|
||||||
if (myKeyUnderTracking != null) {
|
myKeyUnderTracking = -1;
|
||||||
final String keyName = ZLAndroidKeyUtil.getKeyNameByCode(keyCode);
|
return true;
|
||||||
if (myKeyUnderTracking.equals(keyName)) {
|
} else {
|
||||||
final boolean longPress = System.currentTimeMillis() >
|
return false;
|
||||||
myTrackingStartTime + ViewConfiguration.getLongPressTimeout();
|
|
||||||
ZLApplication.Instance().doActionByKey(keyName, longPress);
|
|
||||||
}
|
|
||||||
myKeyUnderTracking = null;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue