From 6d18e50a3af9e6c1db8506027760b406dc98746a Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Thu, 5 Sep 2013 11:48:08 +0000 Subject: [PATCH] Removed start/stop and reload buttons from main menu --- res/menu/activity_main_actions.xml | 27 ------------------- res/menu/fragment_main_actions.xml | 12 +++++++++ .../router/activity/I2PActivityBase.java | 21 --------------- .../android/router/fragment/MainFragment.java | 7 +++++ 4 files changed, 19 insertions(+), 48 deletions(-) delete mode 100755 res/menu/activity_main_actions.xml create mode 100755 res/menu/fragment_main_actions.xml diff --git a/res/menu/activity_main_actions.xml b/res/menu/activity_main_actions.xml deleted file mode 100755 index 60e47760a..000000000 --- a/res/menu/activity_main_actions.xml +++ /dev/null @@ -1,27 +0,0 @@ -<menu xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:i2pandroid="http://schemas.android.com/apk/res-auto"> - <item android:title="@string/action_router_start" - android:id="@+id/menu_start" - android:icon="@drawable/ic_av_play" - i2pandroid:showAsAction="ifRoom" > - </item> - <item android:title="@string/action_router_stop" - android:id="@+id/menu_stop" - android:icon="@drawable/ic_av_stop" - i2pandroid:showAsAction="ifRoom" > - </item> - <item android:title="@string/action_reload" - android:id="@+id/menu_reload" - android:icon="@drawable/ic_navigation_refresh" - i2pandroid:showAsAction="ifRoom" > - </item> - <item android:title="@string/menu_settings" - android:id="@+id/menu_settings" - android:icon="@android:drawable/ic_menu_preferences" - i2pandroid:showAsAction="never" > - </item> - <item android:title="@string/menu_help" - android:id="@+id/menu_help" - i2pandroid:showAsAction="never" > - </item> -</menu> diff --git a/res/menu/fragment_main_actions.xml b/res/menu/fragment_main_actions.xml new file mode 100755 index 000000000..ab07512ef --- /dev/null +++ b/res/menu/fragment_main_actions.xml @@ -0,0 +1,12 @@ +<menu xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:i2pandroid="http://schemas.android.com/apk/res-auto"> + <item android:title="@string/menu_settings" + android:id="@+id/menu_settings" + android:icon="@android:drawable/ic_menu_preferences" + i2pandroid:showAsAction="never" > + </item> + <item android:title="@string/menu_help" + android:id="@+id/menu_help" + i2pandroid:showAsAction="never" > + </item> +</menu> diff --git a/src/net/i2p/android/router/activity/I2PActivityBase.java b/src/net/i2p/android/router/activity/I2PActivityBase.java index d5b9747bd..2614f59e4 100644 --- a/src/net/i2p/android/router/activity/I2PActivityBase.java +++ b/src/net/i2p/android/router/activity/I2PActivityBase.java @@ -16,7 +16,6 @@ import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.support.v7.app.ActionBar.Tab; import android.view.Menu; -import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; @@ -232,31 +231,11 @@ public abstract class I2PActivityBase extends ActionBarActivity implements super.onDestroy(); } - @Override - public boolean onCreateOptionsMenu(Menu menu) { - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.activity_main_actions, menu); - return true; - } - /** * Called whenever we call invalidateOptionsMenu() */ @Override public boolean onPrepareOptionsMenu(Menu menu) { - // add/hide items here - RouterService svc = _routerService; - boolean showStart = ((svc == null) || (!_isBound) || svc.canManualStart()) && - Util.isConnected(this); - MenuItem start = menu.findItem(R.id.menu_start); - start.setVisible(showStart); - start.setEnabled(showStart); - - boolean showStop = svc != null && _isBound && svc.canManualStop(); - MenuItem stop = menu.findItem(R.id.menu_stop); - stop.setVisible(showStop); - stop.setEnabled(showStop); - // If the nav drawer is open, hide action items related to the content view boolean drawerOpen = mDrawerLayout.isDrawerOpen(mDrawerList); onDrawerChange(drawerOpen); diff --git a/src/net/i2p/android/router/fragment/MainFragment.java b/src/net/i2p/android/router/fragment/MainFragment.java index 5ff43d499..6aa0c7216 100644 --- a/src/net/i2p/android/router/fragment/MainFragment.java +++ b/src/net/i2p/android/router/fragment/MainFragment.java @@ -4,6 +4,8 @@ import android.app.Activity; import android.os.Bundle; import android.os.Handler; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Button; @@ -197,6 +199,11 @@ public class MainFragment extends I2PFragmentBase { updateOneShot(); } + @Override + public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { + inflater.inflate(R.menu.fragment_main_actions, menu); + } + @Override public void onSaveInstanceState(Bundle outState) { if(_savedStatus != null) { -- GitLab