Added bottom control for help activity when portrait

This commit is contained in:
Denis 2015-02-04 14:56:02 +02:00
parent bbe400b6f6
commit 5506c7b571
4 changed files with 53 additions and 17 deletions

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
<net.osmand.plus.activities.search.toolbar.SplitToolbar
android:orientation="horizontal"
android:id="@+id/bottomControls"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>

View file

@ -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);
}
}

View file

@ -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;
}
}

View file

@ -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;
}
}