mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
[Android] Remove the explicit key event listener from InputConfigFragment. The AlertDialog class has a key listener built into it.
Also documented the methods/interfaces in MotionAlertDialog.
This commit is contained in:
parent
e12c66b6cf
commit
670b028492
@ -99,9 +99,9 @@ public final class InputConfigFragment extends PreferenceFragment
|
||||
final MotionAlertDialog dialog = new MotionAlertDialog(m_activity);
|
||||
|
||||
// Set the key listener
|
||||
dialog.setOnKeyEventListener(new MotionAlertDialog.OnKeyEventListener()
|
||||
dialog.setOnKeyListener(new AlertDialog.OnKeyListener()
|
||||
{
|
||||
public boolean onKey(KeyEvent event)
|
||||
public boolean onKey(DialogInterface dlg, int keyCode, KeyEvent event)
|
||||
{
|
||||
Log.d("InputConfigFragment", "Received key event: " + event.getAction());
|
||||
switch (event.getAction())
|
||||
@ -211,38 +211,42 @@ public final class InputConfigFragment extends PreferenceFragment
|
||||
*/
|
||||
protected static final class MotionAlertDialog extends AlertDialog
|
||||
{
|
||||
private OnKeyEventListener keyListener;
|
||||
private OnMotionEventListener motionListener;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ctx context to use this dialog in.
|
||||
*/
|
||||
public MotionAlertDialog(Context ctx)
|
||||
{
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public interface OnKeyEventListener
|
||||
{
|
||||
boolean onKey(KeyEvent event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface which defines a callback method for general
|
||||
* motion events. This allows motion event code to be set
|
||||
* in the event anonymous classes of this dialog are used.
|
||||
*/
|
||||
public interface OnMotionEventListener
|
||||
{
|
||||
boolean onMotion(MotionEvent event);
|
||||
}
|
||||
|
||||
public void setOnKeyEventListener(OnKeyEventListener listener)
|
||||
{
|
||||
this.keyListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the motion listener.
|
||||
*
|
||||
* @param listener The motion listener to set.
|
||||
*/
|
||||
public void setOnMotionEventListener(OnMotionEventListener listener)
|
||||
{
|
||||
this.motionListener = listener;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event)
|
||||
{
|
||||
if (keyListener.onKey(event))
|
||||
if (this.onKeyDown(event.getKeyCode(), event))
|
||||
return true;
|
||||
|
||||
return super.dispatchKeyEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user