-Fixed some various coding standard issues from previous commit.

This commit is contained in:
Ironthighs
2016-07-21 19:24:38 -05:00
parent 3dfeea01da
commit 89b5bc9ee5
4 changed files with 32 additions and 19 deletions

View File

@ -11,8 +11,8 @@ android {
abortOnError false abortOnError false
//Uncomment disable lines for test builds... //Uncomment disable lines for test builds...
//disable 'MissingTranslation' disable 'MissingTranslation'
//disable 'ExtraTranslation' disable 'ExtraTranslation'
} }
defaultConfig { defaultConfig {

View File

@ -396,7 +396,7 @@ public final class EmulationActivity extends AppCompatActivity
case R.id.menu_emulation_configure_controls: case R.id.menu_emulation_configure_controls:
EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager().findFragmentById(R.id.frame_emulation_fragment); EmulationFragment emulationFragment = (EmulationFragment) getFragmentManager().findFragmentById(R.id.frame_emulation_fragment);
if(emulationFragment.isConfiguringControls()) if (emulationFragment.isConfiguringControls())
{ {
emulationFragment.stopConfiguringControls(); emulationFragment.stopConfiguringControls();
} }

View File

@ -102,11 +102,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
} }
@Override @Override
public void onViewCreated(View view, Bundle savedInstanceState) { public void onViewCreated(View view, Bundle savedInstanceState)
{
Button doneButton = (Button) view.findViewById(R.id.done_control_config); Button doneButton = (Button) view.findViewById(R.id.done_control_config);
doneButton.setOnClickListener(new View.OnClickListener() { doneButton.setOnClickListener(new View.OnClickListener()
{
@Override @Override
public void onClick(View v) { public void onClick(View v)
{
stopConfiguringControls(); stopConfiguringControls();
} }
}); });
@ -242,12 +245,14 @@ public final class EmulationFragment extends Fragment implements SurfaceHolder.C
mInputOverlay.setIsInEditMode(true); mInputOverlay.setIsInEditMode(true);
} }
public void stopConfiguringControls() { public void stopConfiguringControls()
{
getView().findViewById(R.id.done_control_config).setVisibility(View.GONE); getView().findViewById(R.id.done_control_config).setVisibility(View.GONE);
mInputOverlay.setIsInEditMode(false); mInputOverlay.setIsInEditMode(false);
} }
public boolean isConfiguringControls() { public boolean isConfiguringControls()
{
return mInputOverlay.isInEditMode(); return mInputOverlay.isInEditMode();
} }
} }

View File

@ -115,7 +115,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
@Override @Override
public boolean onTouch(View v, MotionEvent event) public boolean onTouch(View v, MotionEvent event)
{ {
if(isInEditMode()) { if (isInEditMode())
{
return onTouchWhileEditing(v, event); return onTouchWhileEditing(v, event);
} }
@ -124,20 +125,24 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
for (InputOverlayDrawableButton button : overlayButtons) for (InputOverlayDrawableButton button : overlayButtons)
{ {
// Determine the button state to apply based on the MotionEvent action flag. // Determine the button state to apply based on the MotionEvent action flag.
switch(event.getAction() & MotionEvent.ACTION_MASK) switch (event.getAction() & MotionEvent.ACTION_MASK)
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
// If a pointer enters the bounds of a button, press that button. // If a pointer enters the bounds of a button, press that button.
if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex)))
{
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.PRESSED); NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.PRESSED);
}
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
// If a pointer ends, release the button it was pressing. // If a pointer ends, release the button it was pressing.
if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex))) if (button.getBounds().contains((int)event.getX(pointerIndex), (int)event.getY(pointerIndex)))
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED); {
NativeLibrary.onGamePadEvent(NativeLibrary.TouchScreenDevice, button.getId(), ButtonState.RELEASED);
}
break; break;
} }
} }
@ -150,7 +155,9 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
float[] axises = joystick.getAxisValues(); float[] axises = joystick.getAxisValues();
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{
NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice, axisIDs[i], axises[i]); NativeLibrary.onGamePadMoveEvent(NativeLibrary.TouchScreenDevice, axisIDs[i], axises[i]);
}
} }
return true; return true;
@ -168,12 +175,12 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
for (InputOverlayDrawableButton button : overlayButtons) for (InputOverlayDrawableButton button : overlayButtons)
{ {
// Determine the button state to apply based on the MotionEvent action flag. // Determine the button state to apply based on the MotionEvent action flag.
switch(event.getAction() & MotionEvent.ACTION_MASK) switch (event.getAction() & MotionEvent.ACTION_MASK)
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
// If no button is being moved now, remember the currently touched button to move. // If no button is being moved now, remember the currently touched button to move.
if(mButtonBeingConfigured == null && button.getBounds().contains(fingerPositionX, fingerPositionY)) if (mButtonBeingConfigured == null && button.getBounds().contains(fingerPositionX, fingerPositionY))
{ {
mButtonBeingConfigured = button; mButtonBeingConfigured = button;
mButtonBeingConfigured.onConfigureTouch(v, event); mButtonBeingConfigured.onConfigureTouch(v, event);
@ -190,7 +197,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
if(mButtonBeingConfigured == button) if (mButtonBeingConfigured == button)
{ {
//Persist button position by saving new place. //Persist button position by saving new place.
saveControlPosition(mButtonBeingConfigured.getSharedPrefsId(), mButtonBeingConfigured.getBounds().left, mButtonBeingConfigured.getBounds().top); saveControlPosition(mButtonBeingConfigured.getSharedPrefsId(), mButtonBeingConfigured.getBounds().left, mButtonBeingConfigured.getBounds().top);
@ -203,18 +210,18 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
for (InputOverlayDrawableJoystick joystick : overlayJoysticks) for (InputOverlayDrawableJoystick joystick : overlayJoysticks)
{ {
switch(event.getAction()) switch (event.getAction())
{ {
case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_POINTER_DOWN:
if(mJoystickBeingConfigured == null && joystick.getBounds().contains(fingerPositionX, fingerPositionY)) if (mJoystickBeingConfigured == null && joystick.getBounds().contains(fingerPositionX, fingerPositionY))
{ {
mJoystickBeingConfigured = joystick; mJoystickBeingConfigured = joystick;
mJoystickBeingConfigured.onConfigureTouch(v, event); mJoystickBeingConfigured.onConfigureTouch(v, event);
} }
break; break;
case MotionEvent.ACTION_MOVE: case MotionEvent.ACTION_MOVE:
if(mJoystickBeingConfigured != null) if (mJoystickBeingConfigured != null)
{ {
mJoystickBeingConfigured.onConfigureTouch(v, event); mJoystickBeingConfigured.onConfigureTouch(v, event);
invalidate(); invalidate();
@ -222,7 +229,7 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
break; break;
case MotionEvent.ACTION_UP: case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_POINTER_UP: case MotionEvent.ACTION_POINTER_UP:
if(mJoystickBeingConfigured != null) if (mJoystickBeingConfigured != null)
{ {
saveControlPosition(mJoystickBeingConfigured.getSharedPrefsId(), mJoystickBeingConfigured.getBounds().left, mJoystickBeingConfigured.getBounds().right); saveControlPosition(mJoystickBeingConfigured.getSharedPrefsId(), mJoystickBeingConfigured.getBounds().left, mJoystickBeingConfigured.getBounds().right);
mJoystickBeingConfigured = null; mJoystickBeingConfigured = null;
@ -393,7 +400,8 @@ public final class InputOverlay extends SurfaceView implements OnTouchListener
mIsInEditMode = isInEditMode; mIsInEditMode = isInEditMode;
} }
public boolean isInEditMode() { public boolean isInEditMode()
{
return mIsInEditMode; return mIsInEditMode;
} }