Add buttons to help

This commit is contained in:
Victor Shcherb 2014-07-13 23:04:19 +02:00
parent 0d5ad994c2
commit 4f6a4a0dcd
3 changed files with 69 additions and 13 deletions

View file

@ -9,6 +9,8 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
<string name="forward">Forward</string>
<string name="home">Home</string>
<string name="live_monitoring_m_descr">Send tracking to a specified web service if GPX recording is enabled.</string>
<string name="live_monitoring_m">Online tracking (GPX required)</string>
<string name="live_monitoring_start">Start online tracking</string>

View file

@ -7,6 +7,7 @@ import java.io.InputStreamReader;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
@ -14,18 +15,28 @@ import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.MenuItem.OnMenuItemClickListener;
public class HelpActivity extends SherlockActivity {
private static final String FILE_ANDROID_ASSET_HELP = "file:///android_asset/help/";
public static final String URL = "url";
public static final String TITLE = "title";
private static final int HOME = 1;
private static final int BACK = 2;
private static final int FORWARD = 3;
private static final int CLOSE = 4;
private WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
getMyApplication().applyTheme(this);
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
final WebView wv = new WebView(this);
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
wv = new WebView(this);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
String title = getString(R.string.help);
String url = "index.html";
@ -70,16 +81,8 @@ public class HelpActivity extends SherlockActivity {
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
// @Override
// public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
// }
// public boolean shouldOverrideUrlLoading(WebView view, String url){
// return false; // then it is not handled by default action
// }
});
wv.loadUrl("file:///android_asset/help/" + url);
wv.loadUrl(FILE_ANDROID_ASSET_HELP + url);
}
public String readContent(String url) throws IOException {
@ -97,6 +100,23 @@ public class HelpActivity extends SherlockActivity {
private OsmandApplication getMyApplication() {
return (OsmandApplication) getApplication();
}
@Override
public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
createMenuItem(menu, HOME, R.string.home,
R.drawable.ic_action_home_light, R.drawable.ic_action_home_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM );
createMenuItem(menu, BACK, R.string.back,
0, 0, //R.drawable.ic_action_home_light, R.drawable.ic_action_home_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM );
createMenuItem(menu, FORWARD, R.string.forward,
0, 0, //R.drawable.ic_action_home_light, R.drawable.ic_action_home_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM );
createMenuItem(menu, CLOSE, R.string.close,
R.drawable.ic_action_ok_light, R.drawable.ic_action_ok_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM );
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
@ -105,8 +125,42 @@ public class HelpActivity extends SherlockActivity {
case android.R.id.home:
finish();
return true;
case HOME:
wv.loadUrl(FILE_ANDROID_ASSET_HELP + "index.html");
return true;
case BACK:
if(wv.canGoBack()) {
wv.goBack();
}
return true;
case FORWARD:
if(wv.canGoForward()) {
wv.goForward();
}
return true;
case CLOSE:
finish();
return true;
}
return false;
}
public MenuItem createMenuItem(Menu m, int id, int titleRes, int iconLight, int iconDark, int menuItemType) {
int r = isLightActionBar() ? iconLight : iconDark;
MenuItem menuItem = m.add(0, id, 0, titleRes);
if (r != 0) {
menuItem.setIcon(r);
}
menuItem.setShowAsActionFlags(menuItemType).setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(com.actionbarsherlock.view.MenuItem item) {
return onOptionsItemSelected(item);
}
});
return menuItem;
}
public boolean isLightActionBar() {
return ((OsmandApplication) getApplication()).getSettings().isLightActionBar();
}
}

View file

@ -852,13 +852,13 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, SHARE_SESSION, R.string.osmo_share_session,
R.drawable.ic_action_gshare_light, R.drawable.ic_action_gshare_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
MenuItem.SHOW_AS_ACTION_IF_ROOM);
createMenuItem(menu, CREATE_GROUP, R.string.osmo_create_group,
0, 0,/*R.drawable.ic_action_marker_light,*/
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
createMenuItem(menu, SETTINGS_ID, R.string.settings,
R.drawable.ic_action_settings_light, R.drawable.ic_action_settings_dark,
MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
MenuItem.SHOW_AS_ACTION_IF_ROOM);
return super.onCreateOptionsMenu(menu);
}