First clicker and HelpFragment UI fix. Import of new help.

This commit is contained in:
GaidamakUA 2015-10-30 17:16:16 +02:00
parent b52810cbdf
commit ad0e5717f9
7 changed files with 182 additions and 27 deletions

View file

@ -207,6 +207,10 @@ task collectHelpContentsAssets(type: Sync) {
from "assets/"
into "assets/help"
include "style.css"
from "../../help/website/feature_articles"
into "assets/feature_articles"
include "*.html"
}
task collectRoutingResources(type: Sync) {

View file

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/shared_string_help"
app:navigationIcon="@drawable/abc_ic_ab_back_mtrl_am_alpha"
app:theme="?attr/toolbar_theme"
android:background="?attr/pstsTabBackground"/>
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>

View file

@ -6,11 +6,12 @@
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/shared_string_help"
app:navigationIcon="@drawable/abc_ic_ab_back_mtrl_am_alpha"
app:theme="?attr/toolbar_theme"/>
android:background="?attr/pstsTabBackground"/>
<ExpandableListView
android:id="@android:id/list"

View file

@ -0,0 +1,106 @@
package net.osmand.plus.dialogs.helpscreen;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import org.apache.commons.logging.Log;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class HelpArticleDialogFragment extends DialogFragment {
private static final Log LOG = PlatformUtil.getLog(HelpArticleDialogFragment.class);
public static final String FILE_NAME = "url";
private WebView webView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
boolean isLightTheme = (getOsmandApplication())
.getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
int themeId = isLightTheme ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme;
setStyle(STYLE_NO_FRAME, themeId);
}
@NonNull
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_help_article, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
String fileContents = getAssetAsString(getArguments().getString(FILE_NAME), getActivity());
webView = (WebView) view.findViewById(R.id.webView);
if (savedInstanceState != null) {
webView.restoreState(savedInstanceState);
} else {
webView.loadDataWithBaseURL("http://osmand.net", fileContents, null, "utf-8", null);
}
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
webView.saveState(outState);
}
private OsmandApplication getOsmandApplication() {
return (OsmandApplication) getActivity().getApplication();
}
public static HelpArticleDialogFragment createInstance(String fileName) {
Bundle args = new Bundle();
args.putString(FILE_NAME, fileName);
final HelpArticleDialogFragment helpArticleDialogFragment = new HelpArticleDialogFragment();
helpArticleDialogFragment.setArguments(args);
return helpArticleDialogFragment;
}
public String getAssetAsString(String filename, Context context) {
StringBuilder buf = new StringBuilder();
InputStream is;
BufferedReader in = null;
try {
is = context.getAssets().open(filename);
in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
String str;
while ((str = in.readLine()) != null) {
buf.append(str);
}
} catch (IOException e) {
LOG.error(null, e);
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
LOG.error(null, e);
}
}
}
return buf.toString();
}
}

View file

@ -6,6 +6,7 @@ import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.DialogFragment;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
@ -45,6 +46,14 @@ public class HelpScreenDialogFragment extends DialogFragment implements Expandab
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_help_screen, container, false);
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
MenuCategory.BEGIN_WITH_OSMAND.initItems(createBeginWithOsmandItems());
MenuCategory.FEATURES.initItems(createFeaturesItems());
MenuCategory.PLUGINS.initItems(createPluginsItems());
@ -67,8 +76,11 @@ public class HelpScreenDialogFragment extends DialogFragment implements Expandab
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
int childPosition, long id) {
LOG.debug("Chield=" + categories[groupPosition].getItem(childPosition) + "; clicker="
+ categories[groupPosition].getItem(childPosition).getOnClickListener());
if (categories[groupPosition] != MenuCategory.HELP_US_TO_IMPROVE &&
categories[groupPosition].getItem(childPosition).getOnClickListener() != null) {
LOG.debug("nice");
categories[groupPosition].getItem(childPosition).getOnClickListener().onClick(v);
}
return false;
@ -98,7 +110,6 @@ public class HelpScreenDialogFragment extends DialogFragment implements Expandab
@Override
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
LOG.debug("categories[groupPosition]=" + categories[groupPosition]);
if(categories[groupPosition] == MenuCategory.HELP_US_TO_IMPROVE) {
convertView = LayoutInflater.from(parent.getContext()).inflate(
R.layout.help_to_improve_item, parent, false);
@ -274,11 +285,19 @@ public class HelpScreenDialogFragment extends DialogFragment implements Expandab
return arrayList;
}
private static List<MyMenuItem> createPluginsItems() {
private List<MyMenuItem> createPluginsItems() {
ArrayList<MyMenuItem> arrayList = new ArrayList<>();
MyMenuItem.Builder builder = new MyMenuItem.Builder()
.setTitle(R.string.shared_string_online_maps)
.setIcon(R.drawable.ic_world_globe_dark);
.setIcon(R.drawable.ic_world_globe_dark)
.setListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
HelpArticleDialogFragment.createInstance(
"feature_articles/online-maps-plugin.html")
.show(getActivity().getSupportFragmentManager(), null);
}
});
arrayList.add(builder.create());
builder.reset()
.setTitle(R.string.contour_lines_and_hillshade_maps_item)

View file

@ -85,8 +85,9 @@ public class MyMenuItem {
return this;
}
public void setListener(OnClickListener listener) {
public Builder setListener(OnClickListener listener) {
this.listener = listener;
return this;
}
public Builder reset() {

View file

@ -1,9 +1,22 @@
package net.osmand.plus.views;
import gnu.trove.list.array.TIntArrayList;
import java.util.ArrayList;
import java.util.List;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import net.londatiga.android.ActionItem;
import net.londatiga.android.QuickAction;
@ -24,23 +37,11 @@ import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.controls.MapRouteInfoControl;
import net.osmand.plus.views.controls.MapRoutePreferencesControl;
import net.osmand.plus.views.corenative.NativeCoreContext;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.PointF;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.List;
import gnu.trove.list.array.TIntArrayList;
public class MapControlsLayer extends OsmandMapLayer {
@ -853,7 +854,8 @@ public class MapControlsLayer extends OsmandMapLayer {
f = false;
nightMode = night;
if (bgDark != 0 && bgLight != 0) {
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight));
iv.setBackgroundDrawable(ctx.getResources().getDrawable(night ? bgDark : bgLight,
mapActivity.getTheme()));
}
Drawable d = null;
if(resDarkId != 0 && nightMode) {