diff --git a/OsmAnd/res/layout/help_activity.xml b/OsmAnd/res/layout/help_activity.xml new file mode 100644 index 0000000000..586defd3cc --- /dev/null +++ b/OsmAnd/res/layout/help_activity.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java index 1cefa05984..7a8ad985b4 100644 --- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java @@ -154,7 +154,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } }); - if (isOrientationPortrait()) { + if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { menu = ((FavoritesActivity) getActivity()).getClearToolbar(true).getMenu(); } else { ((FavoritesActivity) getActivity()).getClearToolbar(false); @@ -195,7 +195,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { final MenuItem item; item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j)); MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); - if (isOrientationPortrait()){ + if (ScreenOrientationHelper.isOrientationPortrait(getActivity())){ item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem menuItem) { @@ -211,11 +211,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } } - private boolean isOrientationPortrait() { - int orientation = ScreenOrientationHelper.getScreenOrientation(getActivity()); - return orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || - orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; - } public void doAction(int actionResId) { if (actionResId == R.string.local_index_mi_delete) { @@ -261,7 +256,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { private void enableSelectionMode(boolean selectionMode) { this.selectionMode = selectionMode; - if (isOrientationPortrait()) { + if (ScreenOrientationHelper.isOrientationPortrait(getActivity())) { ((FavoritesActivity)getActivity()).setToolbarVisibility(!selectionMode); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java index 8b3db418a2..0f6be0994b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/HelpActivity.java @@ -8,9 +8,12 @@ import java.io.InputStreamReader; import android.content.pm.ActivityInfo; import android.os.Build; import android.support.v4.view.MenuItemCompat; +import android.support.v7.widget.Toolbar; import android.view.*; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; +import net.osmand.plus.helpers.ScreenOrientationHelper; + import android.os.Bundle; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -35,7 +38,7 @@ public class HelpActivity extends OsmandActionBarActivity { getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW); } super.onCreate(savedInstanceState); - wv = new WebView(this); + String title = getString(R.string.help); String url = "index.html"; if(getIntent() != null) { @@ -49,7 +52,8 @@ public class HelpActivity extends OsmandActionBarActivity { } } getSupportActionBar().setTitle(title); - setContentView(wv); + setContentView(R.layout.help_activity); + wv = (WebView) findViewById(R.id.webView); wv.setFocusable(true); wv.setFocusableInTouchMode(true); wv.requestFocus(View.FOCUS_DOWN); @@ -101,18 +105,23 @@ public class HelpActivity extends OsmandActionBarActivity { @Override public boolean onCreateOptionsMenu(Menu menu) { + if (ScreenOrientationHelper.isOrientationPortrait(this)){ + menu = getClearToolbar(true).getMenu(); + } else { + getClearToolbar(false); + } createMenuItem(menu, HOME, R.string.home, R.drawable.ic_action_home_dark, R.drawable.ic_action_home_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM ); + MenuItemCompat.SHOW_AS_ACTION_ALWAYS); createMenuItem(menu, BACK, R.string.previous_button, - 0, 0, //R.drawable.ic_action_home_light, R.drawable.ic_action_home_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM ); + R.drawable.ic_action_undo_dark, R.drawable.ic_action_undo_dark, + MenuItemCompat.SHOW_AS_ACTION_ALWAYS ); createMenuItem(menu, FORWARD, R.string.next_button, - 0, 0, //R.drawable.ic_action_home_light, R.drawable.ic_action_home_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM ); + R.drawable.ic_action_redo_dark, R.drawable.ic_action_redo_dark, + MenuItemCompat.SHOW_AS_ACTION_ALWAYS ); createMenuItem(menu, CLOSE, R.string.close, - R.drawable.ic_action_ok_dark, R.drawable.ic_action_ok_dark, - MenuItemCompat.SHOW_AS_ACTION_IF_ROOM ); + R.drawable.ic_action_close_dark, R.drawable.ic_action_close_dark, + MenuItemCompat.SHOW_AS_ACTION_ALWAYS ); return super.onCreateOptionsMenu(menu); } @@ -162,4 +171,12 @@ public class HelpActivity extends OsmandActionBarActivity { public boolean isLightActionBar() { return ((OsmandApplication) getApplication()).getSettings().isLightActionBar(); } + + public Toolbar getClearToolbar(boolean visible) { + final Toolbar tb = (Toolbar) findViewById(R.id.bottomControls); + tb.setTitle(null); + tb.getMenu().clear(); + tb.setVisibility(visible? View.VISIBLE : View.GONE); + return tb; + } } diff --git a/OsmAnd/src/net/osmand/plus/helpers/ScreenOrientationHelper.java b/OsmAnd/src/net/osmand/plus/helpers/ScreenOrientationHelper.java index 012592edc6..8fe27a3acd 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/ScreenOrientationHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/ScreenOrientationHelper.java @@ -1,6 +1,7 @@ package net.osmand.plus.helpers; import android.app.Activity; +import android.content.Context; import android.content.pm.ActivityInfo; import android.util.DisplayMetrics; import android.util.Log; @@ -74,4 +75,10 @@ public class ScreenOrientationHelper { return orientation; } + + public static boolean isOrientationPortrait(Activity ctx) { + int orientation = ScreenOrientationHelper.getScreenOrientation(ctx); + return orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT || + orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; + } }