Skip to content

Commit

Permalink
front: Exposed some of the Key/Axis providers' functionality.
Browse files Browse the repository at this point in the history
Will be used in of the upcoming commits.
  • Loading branch information
littleguy77 committed Jan 21, 2013
1 parent 3ecabf8 commit 2d1423c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,25 @@ public class AxisProvider extends AbstractProvider

/**
* Instantiates a new axis provider.
*
* @param view The view receiving MotionEvent data.
*/
@TargetApi( 12 )
public AxisProvider( View view )
public AxisProvider()
{
// By default, provide data from all possible axes
mInputCodes = new int[DEFAULT_NUM_INPUTS];
for( int i = 0; i < mInputCodes.length; i++ )
mInputCodes[i] = -( i + 1 );
}

/**
* Instantiates a new axis provider.
*
* @param view The view receiving MotionEvent data.
*/
@TargetApi( 12 )
public AxisProvider( View view )
{
this();

// Connect the input source
view.setOnGenericMotionListener( new GenericMotionListener() );
Expand All @@ -69,6 +78,11 @@ public void setInputCodeFilter( int[] inputCodeFilter )
mInputCodes = inputCodeFilter.clone();
}

public boolean onGenericMotion( MotionEvent event )
{
return new GenericMotionListener().onGenericMotion( null, event );
}

/**
* Just an indirection class that eliminates some logcat chatter about benign errors. If we make
* the parent class implement View.OnGenericMotionListener, then we get logcat error messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,26 @@ public enum ImeFormula
/**
* Instantiates a new key provider.
*
* @param view The view receiving KeyEvent data.
* @param formula The decoding formula to be used.
* @param ignoredCodes List of key codes that should be ignored.
*/
public KeyProvider( View view, ImeFormula formula, List<Integer> ignoredCodes )
public KeyProvider( ImeFormula formula, List<Integer> ignoredCodes )
{
// Assign the fields
mImeFormula = formula;
mIgnoredCodes = ignoredCodes;
}

/**
* Instantiates a new key provider.
*
* @param view The view receiving KeyEvent data.
* @param formula The decoding formula to be used.
* @param ignoredCodes List of key codes that should be ignored.
*/
public KeyProvider( View view, ImeFormula formula, List<Integer> ignoredCodes )
{
this( formula, ignoredCodes );

// Connect the input source
view.setOnKeyListener( this );
Expand All @@ -83,9 +94,7 @@ public KeyProvider( View view, ImeFormula formula, List<Integer> ignoredCodes )
*/
public KeyProvider( Builder builder, ImeFormula formula, List<Integer> ignoredCodes )
{
// Assign the fields
mImeFormula = formula;
mIgnoredCodes = ignoredCodes;
this( formula, ignoredCodes );

// Connect the input source
builder.setOnKeyListener( this );
Expand Down Expand Up @@ -121,7 +130,7 @@ public boolean onKey( DialogInterface dialog, int keyCode, KeyEvent event )
* @param event the event
* @return True if the listener has consumed the event, false otherwise.
*/
private boolean onKey( int keyCode, KeyEvent event )
public boolean onKey( int keyCode, KeyEvent event )
{
// Ignore specified key codes
if( mIgnoredCodes != null && mIgnoredCodes.contains( keyCode ) )
Expand Down

0 comments on commit 2d1423c

Please sign in to comment.