Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
#1856 - Moving ActionBar actions to Navigation Drawer
Browse files Browse the repository at this point in the history
  • Loading branch information
bleege committed Aug 7, 2015
1 parent 440ae9d commit a8462aa
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
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;
Expand Down Expand Up @@ -230,6 +228,7 @@ public void onLowMemory() {
// Other events
//

/*
// Adds items to the action bar menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
Expand All @@ -243,6 +242,7 @@ public boolean onCreateOptionsMenu(Menu menu) {
}
return super.onCreateOptionsMenu(menu);
}
*/

// Called when pressing action bar items
@Override
Expand All @@ -251,36 +251,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
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);
}
Expand All @@ -293,6 +263,39 @@ private void setupDrawerContent(NavigationView navigationView) {
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;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
@@ -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>

0 comments on commit a8462aa

Please sign in to comment.