Skip to content

Commit

Permalink
Merge pull request #10 from mitchhentges/three-finger-update
Browse files Browse the repository at this point in the history
Apply mock on three-finger-tap
  • Loading branch information
Mitchell Hentges committed Dec 2, 2015
2 parents 1f9bba9 + cdf5c34 commit a4b85e4
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 4 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# Position Mock [![Build Status](https://travis-ci.org/mitchhentges/position-mock.svg?branch=master)](https://travis-ci.org/mitchhentges/position-mock)

Mocks a static location on the Android platform.
Built using Gradle, because it's the default Android build tool supported by Android Studio

## How to use

1. Use standard Google Maps motions to drag map around until black dot in centre corresponds to location that you'd
like to "mock to"
2. Either hit the `APPLY` button or do a three-finger-tap to apply the mocked location
3. Once the title bar flashes green, the position has been mocked

## Building

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.GroundOverlayOptions;

/**
* Created by Mitch
Expand Down Expand Up @@ -91,8 +93,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.apply:
titleBarAnimator.animateTitleBar();
map.applyTarget(currentLocation);
applyMockLocation();
return true;
default:
return super.onOptionsItemSelected(item);
Expand All @@ -103,4 +104,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
public void onMapReady(GoogleMap googleMap) {
map.setGoogleMap(googleMap);
}

public void applyMockLocation() {
titleBarAnimator.animateTitleBar();
map.applyTarget(currentLocation);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package ca.mitchhentges.positionmock;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.google.android.gms.maps.MapFragment;

/**
* @author cacti
* @since 12/2/2015
*/
public class TouchableMapFragment extends MapFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);

TouchableWrapper touchableWrapper = new TouchableWrapper((PositionMockActivity) getActivity());
touchableWrapper.addView(view);

return touchableWrapper;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package ca.mitchhentges.positionmock;

import android.view.MotionEvent;
import android.widget.FrameLayout;

/**
* @author cacti
* @since 12/2/2015
*/
public class TouchableWrapper extends FrameLayout {

private final PositionMockActivity activity;

public TouchableWrapper(PositionMockActivity activity) {
super(activity);
this.activity = activity;
}

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
int action = event.getAction();
if ((action & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_POINTER_DOWN
&& event.getPointerCount() == 3) {
activity.applyMockLocation();
}
return super.onInterceptTouchEvent(event);
}
}
2 changes: 1 addition & 1 deletion app/src/main/res/layout/map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<fragment android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment" />
android:name="ca.mitchhentges.positionmock.TouchableMapFragment" />
<View
android:layout_width="5dp"
android:layout_height="5dp"
Expand Down

0 comments on commit a4b85e4

Please sign in to comment.