diff options
author | Brad Leege <bleege@gmail.com> | 2015-08-07 14:50:18 -0500 |
---|---|---|
committer | Brad Leege <bleege@gmail.com> | 2015-08-07 14:50:18 -0500 |
commit | a8462aa5f7868651436e82d86f9652a50639c794 (patch) | |
tree | 0be4a3df0c1763f61d07dfc2bee03b3c9432be84 /android | |
parent | 440ae9df9da2d42c056bb0aa69d80b7ff7a90d9b (diff) | |
download | qtlocation-mapboxgl-a8462aa5f7868651436e82d86f9652a50639c794.tar.gz |
#1856 - Moving ActionBar actions to Navigation Drawer
Diffstat (limited to 'android')
3 files changed, 43 insertions, 40 deletions
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java index 646285ceb1..ada2fc45b2 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxgl/testapp/MainActivity.java @@ -11,8 +11,6 @@ import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.GestureDetector; -import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; import android.view.View; @@ -230,6 +228,7 @@ public class MainActivity extends AppCompatActivity { // Other events // +/* // Adds items to the action bar menu @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -243,6 +242,7 @@ public class MainActivity extends AppCompatActivity { } return super.onCreateOptionsMenu(menu); } +*/ // Called when pressing action bar items @Override @@ -251,36 +251,6 @@ public class MainActivity extends AppCompatActivity { case android.R.id.home: mDrawerLayout.openDrawer(GravityCompat.START); return true; - - case R.id.action_gps: - // Toggle GPS position updates - toggleGps(!mapView.isMyLocationEnabled()); - updateMap(); - return true; - - case R.id.action_debug: - // Toggle debug mode - mapView.toggleDebug(); - - // Show the FPS counter - if (mapView.isDebugActive()) { - mFpsTextView.setVisibility(View.VISIBLE); - mFpsTextView.setText(getResources().getString(R.string.label_fps)); - } else { - mFpsTextView.setVisibility(View.INVISIBLE); - } - return true; - - case R.id.action_markers: - // Toggle markers - toggleMarkers(!mIsMarkersOn); - return true; - - case R.id.action_compass: - // Toggle compass - mapView.setCompassEnabled(!mapView.isCompassEnabled()); - return true; - default: return super.onOptionsItemSelected(item); } @@ -293,6 +263,39 @@ public class MainActivity extends AppCompatActivity { public boolean onNavigationItemSelected(MenuItem menuItem) { menuItem.setChecked(true); mDrawerLayout.closeDrawers(); + + // Respond To Selection + switch (menuItem.getItemId()) { + case R.id.action_gps: + // Toggle GPS position updates + toggleGps(!mapView.isMyLocationEnabled()); + updateMap(); + break; + + case R.id.action_debug: + // Toggle debug mode + mapView.toggleDebug(); + + // Show the FPS counter + if (mapView.isDebugActive()) { + mFpsTextView.setVisibility(View.VISIBLE); + mFpsTextView.setText(getResources().getString(R.string.label_fps)); + } else { + mFpsTextView.setVisibility(View.INVISIBLE); + } + break; + + case R.id.action_markers: + // Toggle markers + toggleMarkers(!mIsMarkersOn); + break; + + case R.id.action_compass: + // Toggle compass + mapView.setCompassEnabled(!mapView.isCompassEnabled()); + break; + } + return true; } }); diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml index 03ab056515..4a12117161 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml @@ -10,5 +10,13 @@ android:icon="@android:drawable/ic_menu_myplaces" android:title="@string/action_point_annotations" /> + <item android:id="@+id/action_gps" + android:icon="@drawable/ic_action_location_searching" + android:title="@string/action_gps" + /> + <item android:id="@+id/action_compass" + android:icon="@drawable/ic_explore_white_24dp" + android:title="@string/action_compass" + /> </menu> diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml index 8981b7a95a..014fa25d67 100644 --- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml +++ b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_main.xml @@ -1,11 +1,3 @@ <?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> - <item android:id="@+id/action_gps" - android:icon="@drawable/ic_action_location_searching" - android:title="@string/action_gps" - app:showAsAction="ifRoom" /> - <item android:id="@+id/action_compass" - android:icon="@drawable/ic_explore_white_24dp" - android:title="@string/action_compass" - app:showAsAction="ifRoom"/> </menu> |