Add help text
This commit is contained in:
parent
d823626d84
commit
50c74055d1
5 changed files with 139 additions and 7 deletions
3
OsmAnd/.gitignore
vendored
3
OsmAnd/.gitignore
vendored
|
@ -12,4 +12,5 @@ out/
|
|||
use/
|
||||
osmand.properties
|
||||
osmand.xml
|
||||
src/help
|
||||
assets/help/*.html
|
||||
assets/help/screens
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<category android:name="android.intent.category.MULTIWINDOW_LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name="net.osmand.plus.activities.HelpActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.MapActivity" android:label="@string/app_name" android:screenOrientation="unspecified"
|
||||
android:launchMode="singleTop">
|
||||
<intent-filter>
|
||||
|
@ -153,7 +154,7 @@
|
|||
<activity android:name="net.osmand.plus.sherpafy.TourViewActivity" android:exported="true" android:launchMode= "singleInstance"
|
||||
android:label="Sherpafy"/>
|
||||
<activity android:name="net.osmand.plus.activities.EditPOIFilterActivity"></activity>
|
||||
<activity android:name="net.osmand.plus.activities.search.GeoIntentActivity">
|
||||
<activity android:name="net.osmand.plus.activities.search.GeoIntentActivity" android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<data android:scheme="geo" />
|
||||
<data android:scheme="osmand.geo" />
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<include name="*.xml"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${src.absolute.dir}/help/">
|
||||
<copy todir="assets/help/">
|
||||
<fileset dir="../../help/" >
|
||||
<include name="*.html"/>
|
||||
<include name="screens/**/*.png"/>
|
||||
|
|
112
OsmAnd/src/net/osmand/plus/activities/HelpActivity.java
Normal file
112
OsmAnd/src/net/osmand/plus/activities/HelpActivity.java
Normal file
|
@ -0,0 +1,112 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import android.os.Bundle;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockActivity;
|
||||
|
||||
public class HelpActivity extends SherlockActivity {
|
||||
|
||||
public static final String URL = "url";
|
||||
public static final String TITLE = "title";
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getMyApplication().applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
//requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
final WebView wv = new WebView(this);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
String title = getString(R.string.help);
|
||||
String url = "index.html";
|
||||
if(getIntent() != null) {
|
||||
String tl = getIntent().getStringExtra(TITLE);
|
||||
if(tl != null) {
|
||||
title = tl;
|
||||
}
|
||||
String ul = getIntent().getStringExtra(URL);
|
||||
if(ul != null) {
|
||||
url = ul;
|
||||
}
|
||||
}
|
||||
getSupportActionBar().setTitle(title);
|
||||
setContentView(wv);
|
||||
wv.setFocusable(true);
|
||||
wv.setFocusableInTouchMode(true);
|
||||
wv.requestFocus(View.FOCUS_DOWN);
|
||||
wv.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
switch (event.getAction()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (!v.hasFocus()) {
|
||||
v.requestFocus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
wv.setWebViewClient(new WebViewClient() {
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
wv.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
public String readContent(String url) throws IOException {
|
||||
InputStream index = HelpActivity.class.getClassLoader().getResourceAsStream("help/" +url);
|
||||
BufferedReader read = new BufferedReader(new InputStreamReader(index));
|
||||
StringBuilder bld = new StringBuilder();
|
||||
String s;
|
||||
while((s = read.readLine()) != null) {
|
||||
bld.append(s);
|
||||
}
|
||||
read.close();
|
||||
return bld.toString();
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
|
||||
int itemId = item.getItemId();
|
||||
switch (itemId) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -57,6 +57,7 @@ public class MainMenuActivity extends Activity {
|
|||
|
||||
public static final int APP_EXIT_CODE = 4;
|
||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||
protected static final boolean TIPS_AND_TRICKS = false;
|
||||
|
||||
private ProgressDialog startProgressDialog;
|
||||
|
||||
|
@ -161,9 +162,16 @@ public class MainMenuActivity extends Activity {
|
|||
helpButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(activity);
|
||||
Dialog dlg = tactivity.getDialogToShowTips(false, true);
|
||||
dlg.show();
|
||||
if(TIPS_AND_TRICKS) {
|
||||
TipsAndTricksActivity tactivity = new TipsAndTricksActivity(activity);
|
||||
Dialog dlg = tactivity.getDialogToShowTips(false, true);
|
||||
dlg.show();
|
||||
} else {
|
||||
final Intent helpIntent = new Intent(activity, HelpActivity.class);
|
||||
activity.startActivity(helpIntent);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -287,10 +295,20 @@ public class MainMenuActivity extends Activity {
|
|||
pref.edit().putInt(TIPS_SHOW, ++i).commit();
|
||||
}
|
||||
if (i == 1 || i == 5 || appVersionChanged) {
|
||||
if(TIPS_AND_TRICKS) {
|
||||
TipsAndTricksActivity tipsActivity = new TipsAndTricksActivity(this);
|
||||
Dialog dlg = tipsActivity.getDialogToShowTips(!appVersionChanged, false);
|
||||
dlg.show();
|
||||
dialogShown = true;
|
||||
} else {
|
||||
if(appVersionChanged) {
|
||||
final Intent helpIntent = new Intent(activity, HelpActivity.class);
|
||||
helpIntent.putExtra(HelpActivity.TITLE, Version.getAppVersion(getMyApplication()));
|
||||
helpIntent.putExtra(HelpActivity.URL, "changes-1.8.html");
|
||||
activity.startActivity(helpIntent);
|
||||
dialogShown = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -306,7 +324,7 @@ public class MainMenuActivity extends Activity {
|
|||
checkVectorIndexesDownloaded();
|
||||
}
|
||||
}
|
||||
if(appCustomization.checkExceptionsOnStart()){
|
||||
if(appCustomization.checkExceptionsOnStart() && !dialogShown){
|
||||
checkPreviousRunsForExceptions(firstTime);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue