Added show wikivoyage pictures first time dialog
This commit is contained in:
commit
c871e8795d
10 changed files with 121 additions and 31 deletions
|
@ -52,6 +52,7 @@ public class IndexConstants {
|
||||||
public static final String GPX_INDEX_DIR = "tracks/";
|
public static final String GPX_INDEX_DIR = "tracks/";
|
||||||
public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/";
|
public static final String GPX_RECORDED_INDEX_DIR = GPX_INDEX_DIR + "rec/";
|
||||||
public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/";
|
public static final String GPX_IMPORT_DIR = GPX_INDEX_DIR + "import/";
|
||||||
|
|
||||||
public static final String TILES_INDEX_DIR= "tiles/";
|
public static final String TILES_INDEX_DIR= "tiles/";
|
||||||
public static final String LIVE_INDEX_DIR= "live/";
|
public static final String LIVE_INDEX_DIR= "live/";
|
||||||
public static final String TOURS_INDEX_DIR= "tours/";
|
public static final String TOURS_INDEX_DIR= "tours/";
|
||||||
|
@ -59,6 +60,7 @@ public class IndexConstants {
|
||||||
public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$
|
public static final String ROADS_INDEX_DIR = "roads/"; //$NON-NLS-1$
|
||||||
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$
|
public static final String WIKI_INDEX_DIR = "wiki/"; //$NON-NLS-1$
|
||||||
public static final String WIKIVOYAGE_INDEX_DIR = "travel/";
|
public static final String WIKIVOYAGE_INDEX_DIR = "travel/";
|
||||||
|
public static final String GPX_TRAVEL_DIR = GPX_INDEX_DIR + WIKIVOYAGE_INDEX_DIR;
|
||||||
public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$
|
public static final String AV_INDEX_DIR = "avnotes/"; //$NON-NLS-1$
|
||||||
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
|
public static final String FONT_INDEX_DIR = "fonts/"; //$NON-NLS-1$
|
||||||
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
public static final String VOICE_INDEX_DIR = "voice/"; //$NON-NLS-1$
|
||||||
|
|
|
@ -33,11 +33,10 @@ h1 {
|
||||||
font-size: 2em;
|
font-size: 2em;
|
||||||
color: #212121;
|
color: #212121;
|
||||||
font-family: serif;
|
font-family: serif;
|
||||||
font-weight: bold;
|
|
||||||
letter-spacing: 0.03em;
|
letter-spacing: 0.03em;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
padding-top: 5%;
|
padding-top: 5%;
|
||||||
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
|
@ -47,6 +46,7 @@ h2 {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
margin-top: 3%;
|
margin-top: 3%;
|
||||||
margin-bottom: 3%;
|
margin-bottom: 3%;
|
||||||
|
font-weight: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2.active:after {
|
h2.active:after {
|
||||||
|
@ -75,6 +75,7 @@ h3 {
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
|
font-weight: normal;
|
||||||
margin-top: 3%;
|
margin-top: 3%;
|
||||||
margin-bottom: 3%;
|
margin-bottom: 3%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_weight="0.5"
|
android:layout_weight="0.33"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
@ -105,13 +105,38 @@
|
||||||
tools:drawableLeft="@drawable/ic_action_list_header"
|
tools:drawableLeft="@drawable/ic_action_list_header"
|
||||||
tools:drawableTint="?attr/wikivoyage_active_color"
|
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||||
tools:ignore="UnusedAttribute" />
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
|
|
||||||
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
|
android:id="@+id/gpx_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="0.33"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:letterSpacing="@dimen/text_button_letter_spacing"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:paddingBottom="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||||
|
android:paddingRight="@dimen/bottom_sheet_content_padding_small"
|
||||||
|
android:paddingTop="@dimen/context_menu_padding_margin_tiny"
|
||||||
|
android:text="@string/points"
|
||||||
|
android:textColor="?attr/wikivoyage_active_color"
|
||||||
|
android:textSize="@dimen/default_desc_text_size"
|
||||||
|
osmand:typeface="@string/font_roboto_medium"
|
||||||
|
tools:drawableLeft="@drawable/ic_action_track_16"
|
||||||
|
tools:drawableTint="?attr/wikivoyage_active_color"
|
||||||
|
tools:ignore="UnusedAttribute" />
|
||||||
|
|
||||||
<net.osmand.plus.widgets.TextViewEx
|
<net.osmand.plus.widgets.TextViewEx
|
||||||
android:id="@+id/save_button"
|
android:id="@+id/save_button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center_vertical|end"
|
android:layout_gravity="center_vertical|end"
|
||||||
android:layout_weight="1"
|
android:layout_weight="0.34"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
android:drawablePadding="@dimen/bottom_sheet_content_padding_small"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
|
|
|
@ -7,7 +7,6 @@ import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.support.annotation.ColorInt;
|
import android.support.annotation.ColorInt;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.LocationPoint;
|
import net.osmand.data.LocationPoint;
|
||||||
|
@ -812,7 +811,7 @@ public class GPXUtilities {
|
||||||
return points.isEmpty();
|
return points.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getPointsSize() {
|
public int getPointsSize() {
|
||||||
return points.size();
|
return points.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1210,8 +1209,13 @@ public class GPXUtilities {
|
||||||
public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) {
|
public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) {
|
||||||
Writer output = null;
|
Writer output = null;
|
||||||
try {
|
try {
|
||||||
|
fout.getParentFile().mkdirs();
|
||||||
output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$
|
output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$
|
||||||
return writeGpx(output, file, ctx);
|
String msg = writeGpx(output, file, ctx);
|
||||||
|
if(Algorithms.isEmpty(file.path)) {
|
||||||
|
file.path = fout.getAbsolutePath();
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Error saving gpx", e); //$NON-NLS-1$
|
log.error("Error saving gpx", e); //$NON-NLS-1$
|
||||||
return ctx.getString(R.string.error_occurred_saving_gpx);
|
return ctx.getString(R.string.error_occurred_saving_gpx);
|
||||||
|
@ -1286,8 +1290,10 @@ public class GPXUtilities {
|
||||||
}
|
}
|
||||||
|
|
||||||
serializer.endTag(null, "gpx"); //$NON-NLS-1$
|
serializer.endTag(null, "gpx"); //$NON-NLS-1$
|
||||||
serializer.flush();
|
|
||||||
serializer.endDocument();
|
serializer.endDocument();
|
||||||
|
serializer.flush();
|
||||||
|
|
||||||
|
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
log.error("Error saving gpx", e); //$NON-NLS-1$
|
log.error("Error saving gpx", e); //$NON-NLS-1$
|
||||||
return ctx.getString(R.string.error_occurred_saving_gpx);
|
return ctx.getString(R.string.error_occurred_saving_gpx);
|
||||||
|
@ -1396,10 +1402,10 @@ public class GPXUtilities {
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (IOException e) {
|
||||||
GPXFile res = new GPXFile();
|
GPXFile res = new GPXFile();
|
||||||
res.path = f.getAbsolutePath();
|
res.path = f.getAbsolutePath();
|
||||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
log.error("Error reading gpx " + res.path, e); //$NON-NLS-1$
|
||||||
res.warning = ctx.getString(R.string.error_reading_gpx);
|
res.warning = ctx.getString(R.string.error_reading_gpx);
|
||||||
return res;
|
return res;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -72,11 +72,13 @@ public class TrackActivity extends TabActivity {
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
file = null;
|
if (intent.hasExtra(TRACK_FILE_NAME)) {
|
||||||
|
file = new File(intent.getStringExtra(TRACK_FILE_NAME));
|
||||||
|
}
|
||||||
|
|
||||||
ActionBar actionBar = getSupportActionBar();
|
ActionBar actionBar = getSupportActionBar();
|
||||||
if (actionBar != null) {
|
if (actionBar != null) {
|
||||||
if (intent.hasExtra(TRACK_FILE_NAME)) {
|
if(file != null) {
|
||||||
file = new File(intent.getStringExtra(TRACK_FILE_NAME));
|
|
||||||
String fn = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
|
String fn = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
|
||||||
actionBar.setTitle(fn);
|
actionBar.setTitle(fn);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -449,14 +449,18 @@ public class TrackPointFragment extends OsmandExpandableListFragment {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!MenuItemCompat.isActionViewExpanded(mi)) {
|
if (!MenuItemCompat.isActionViewExpanded(mi)) {
|
||||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
|
||||||
final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(getGpxDataItem().getFile());
|
|
||||||
final boolean synced = markersHelper.isGroupSynced(markersGr.getId());
|
|
||||||
|
|
||||||
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
||||||
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
R.drawable.ic_action_gshare_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||||
createMenuItem(menu, SELECT_MAP_MARKERS_ID, synced ? R.string.remove_from_map_markers : R.string.shared_string_add_to_map_markers, R.drawable.ic_action_flag_dark,
|
if (getGpx().path != null) {
|
||||||
R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||||
|
final MapMarkersGroup markersGr = markersHelper.getOrCreateGroup(new File(getGpx().path));
|
||||||
|
final boolean synced = markersHelper.isGroupSynced(markersGr.getId());
|
||||||
|
createMenuItem(menu, SELECT_MAP_MARKERS_ID, synced ? R.string.remove_from_map_markers
|
||||||
|
: R.string.shared_string_add_to_map_markers, R.drawable.ic_action_flag_dark,
|
||||||
|
R.drawable.ic_action_flag_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||||
|
}
|
||||||
createMenuItem(menu, SELECT_FAVORITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_fav_dark,
|
createMenuItem(menu, SELECT_FAVORITES_ID, R.string.shared_string_add_to_favorites, R.drawable.ic_action_fav_dark,
|
||||||
R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
R.drawable.ic_action_fav_dark, MenuItemCompat.SHOW_AS_ACTION_NEVER);
|
||||||
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
createMenuItem(menu, DELETE_ID, R.string.shared_string_delete, R.drawable.ic_action_delete_dark,
|
||||||
|
|
|
@ -21,19 +21,21 @@ import android.view.ViewGroup;
|
||||||
import android.webkit.WebSettings;
|
import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
import net.osmand.plus.GPXUtilities;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
import net.osmand.plus.OsmandSettings.WikivoyageShowImages;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.plus.activities.TrackActivity;
|
||||||
|
import net.osmand.plus.myplaces.TrackPointFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageBaseDialogFragment;
|
||||||
|
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
import net.osmand.plus.wikivoyage.WikivoyageShowPicturesDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
import net.osmand.plus.wikivoyage.WikivoyageWebViewClient;
|
||||||
|
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
import net.osmand.plus.wikivoyage.data.WikivoyageArticle;
|
||||||
|
import net.osmand.plus.wikivoyage.data.WikivoyageDbHelper;
|
||||||
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
import net.osmand.plus.wikivoyage.data.WikivoyageLocalDataHelper;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
@ -98,10 +100,12 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
private String selectedLang;
|
private String selectedLang;
|
||||||
private WikivoyageArticle article;
|
private WikivoyageArticle article;
|
||||||
|
|
||||||
|
private TextView trackButton;
|
||||||
private TextView selectedLangTv;
|
private TextView selectedLangTv;
|
||||||
private TextView saveBtn;
|
private TextView saveBtn;
|
||||||
private WebView contentWebView;
|
private WebView contentWebView;
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
@SuppressLint("SetJavaScriptEnabled")
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,6 +161,33 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
fragment.show(fm, WikivoyageArticleContentsFragment.TAG);
|
fragment.show(fm, WikivoyageArticleContentsFragment.TAG);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
trackButton = (TextView) mainView.findViewById(R.id.gpx_button);
|
||||||
|
trackButton.setCompoundDrawablesWithIntrinsicBounds(
|
||||||
|
getActiveIcon(R.drawable.ic_action_track_16), null, null, null
|
||||||
|
);
|
||||||
|
trackButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
FragmentManager fm = getFragmentManager();
|
||||||
|
if (article == null || fm == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final GPXFile gpx = article.getGpxFile();
|
||||||
|
WikivoyageDbHelper dbHelper = getMyApplication().getWikivoyageDbHelper();
|
||||||
|
File file = getMyApplication().getAppPath(IndexConstants.GPX_TRAVEL_DIR + dbHelper.getGPXName(article));
|
||||||
|
|
||||||
|
GPXUtilities.writeGpxFile(file, gpx, getMyApplication());
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString(WikivoyageArticleContentsFragment.CONTENTS_JSON_KEY, article.getContentsJson());
|
||||||
|
Intent newIntent = new Intent(getActivity(), getMyApplication().getAppCustomization().getTrackActivity());
|
||||||
|
newIntent.putExtra(TrackActivity.TRACK_FILE_NAME, gpx.path);
|
||||||
|
// newIntent.putExtra(TrackActivity.OPEN_POINTS_TAB, true);
|
||||||
|
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
|
startActivity(newIntent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
saveBtn = (TextView) mainView.findViewById(R.id.save_button);
|
saveBtn = (TextView) mainView.findViewById(R.id.save_button);
|
||||||
|
|
||||||
|
@ -295,6 +326,9 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen
|
||||||
if (article == null) {
|
if (article == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(article.getGpxFile() != null) {
|
||||||
|
trackButton.setText(trackButton.getText() + " (" + article.getGpxFile().getPointsSize() +")");
|
||||||
|
}
|
||||||
|
|
||||||
WikivoyageLocalDataHelper ldh = getMyApplication().getWikivoyageDbHelper().getLocalDataHelper();
|
WikivoyageLocalDataHelper ldh = getMyApplication().getWikivoyageDbHelper().getLocalDataHelper();
|
||||||
ldh.addToHistory(article);
|
ldh.addToHistory(article);
|
||||||
|
|
|
@ -2,18 +2,21 @@ package net.osmand.plus.wikivoyage.data;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
import net.osmand.Collator;
|
import net.osmand.Collator;
|
||||||
import net.osmand.CollatorStringMatcher;
|
import net.osmand.CollatorStringMatcher;
|
||||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.OsmAndCollator;
|
import net.osmand.OsmAndCollator;
|
||||||
|
import net.osmand.PlatformUtil;
|
||||||
|
import net.osmand.plus.GPXUtilities;
|
||||||
|
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
|
||||||
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -22,10 +25,14 @@ import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import gnu.trove.map.hash.TLongObjectHashMap;
|
import gnu.trove.map.hash.TLongObjectHashMap;
|
||||||
|
|
||||||
public class WikivoyageDbHelper {
|
public class WikivoyageDbHelper {
|
||||||
|
|
||||||
|
private static final Log LOG = PlatformUtil.getLog(WikivoyageDbHelper.class);
|
||||||
|
|
||||||
private static final String ARTICLES_TABLE_NAME = "wikivoyage_articles";
|
private static final String ARTICLES_TABLE_NAME = "wikivoyage_articles";
|
||||||
private static final String ARTICLES_COL_ID = "article_id";
|
private static final String ARTICLES_COL_ID = "article_id";
|
||||||
private static final String ARTICLES_COL_TITLE = "title";
|
private static final String ARTICLES_COL_TITLE = "title";
|
||||||
|
@ -293,19 +300,24 @@ public class WikivoyageDbHelper {
|
||||||
try {
|
try {
|
||||||
res.content = Algorithms.gzipToString(cursor.getBlob(2));
|
res.content = Algorithms.gzipToString(cursor.getBlob(2));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
LOG.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
res.isPartOf = cursor.getString(3);
|
res.isPartOf = cursor.getString(3);
|
||||||
res.lat = cursor.getDouble(4);
|
res.lat = cursor.getDouble(4);
|
||||||
res.lon = cursor.getDouble(5);
|
res.lon = cursor.getDouble(5);
|
||||||
res.imageTitle = cursor.getString(6);
|
res.imageTitle = cursor.getString(6);
|
||||||
byte[] gpxFileBlob = cursor.getBlob(7);
|
|
||||||
res.cityId = cursor.getLong(8);
|
res.cityId = cursor.getLong(8);
|
||||||
res.originalId = cursor.getLong(9);
|
res.originalId = cursor.getLong(9);
|
||||||
res.lang = cursor.getString(10);
|
res.lang = cursor.getString(10);
|
||||||
res.contentsJson = cursor.getString(11);
|
res.contentsJson = cursor.getString(11);
|
||||||
res.aggregatedPartOf = cursor.getString(12);
|
res.aggregatedPartOf = cursor.getString(12);
|
||||||
|
try {
|
||||||
|
String gpxContent = Algorithms.gzipToString(cursor.getBlob(7));
|
||||||
|
res.gpxFile = GPXUtilities.loadGPXFile(application, new ByteArrayInputStream(gpxContent.getBytes("UTF-8")));
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,4 +328,8 @@ public class WikivoyageDbHelper {
|
||||||
String nm = tb.getName();
|
String nm = tb.getName();
|
||||||
return nm.substring(0, nm.indexOf('.')).replace('_', ' ');
|
return nm.substring(0, nm.indexOf('.')).replace('_', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getGPXName(WikivoyageArticle article) {
|
||||||
|
return article.getTitle().replace('/', '_').replace('\'', '_').replace('\"', '_') + ".gpx";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,7 +239,6 @@ public class WikivoyageLocalDataHelper {
|
||||||
conn.execSQL(BOOKMARKS_TABLE_CREATE);
|
conn.execSQL(BOOKMARKS_TABLE_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
private void onUpgrade(SQLiteConnection conn, int oldVersion, int newVersion) {
|
private void onUpgrade(SQLiteConnection conn, int oldVersion, int newVersion) {
|
||||||
if (oldVersion < 2) {
|
if (oldVersion < 2) {
|
||||||
conn.execSQL(BOOKMARKS_TABLE_CREATE);
|
conn.execSQL(BOOKMARKS_TABLE_CREATE);
|
||||||
|
@ -247,9 +246,11 @@ public class WikivoyageLocalDataHelper {
|
||||||
if (oldVersion < 3) {
|
if (oldVersion < 3) {
|
||||||
conn.execSQL("ALTER TABLE " + HISTORY_TABLE_NAME + " ADD " + HISTORY_COL_TRAVEL_BOOK + " TEXT");
|
conn.execSQL("ALTER TABLE " + HISTORY_TABLE_NAME + " ADD " + HISTORY_COL_TRAVEL_BOOK + " TEXT");
|
||||||
conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_TRAVEL_BOOK + " TEXT");
|
conn.execSQL("ALTER TABLE " + BOOKMARKS_TABLE_NAME + " ADD " + BOOKMARKS_COL_TRAVEL_BOOK + " TEXT");
|
||||||
Object[] args = new Object[]{context.getWikivoyageDbHelper().getSelectedTravelBook().getName()};
|
if(context.getWikivoyageDbHelper().getSelectedTravelBook() != null) {
|
||||||
conn.execSQL("UPDATE " + HISTORY_TABLE_NAME + " SET " + HISTORY_COL_TRAVEL_BOOK + " = ?", args);
|
Object[] args = new Object[]{context.getWikivoyageDbHelper().getSelectedTravelBook().getName()};
|
||||||
conn.execSQL("UPDATE " + BOOKMARKS_TABLE_NAME + " SET " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?", args);
|
conn.execSQL("UPDATE " + HISTORY_TABLE_NAME + " SET " + HISTORY_COL_TRAVEL_BOOK + " = ?", args);
|
||||||
|
conn.execSQL("UPDATE " + BOOKMARKS_TABLE_NAME + " SET " + BOOKMARKS_COL_TRAVEL_BOOK + " = ?", args);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class SavedArticlesTabFragment extends BaseOsmAndFragment implements WikivoyageLocalDataHelper.Listener {
|
public class SavedArticlesTabFragment extends BaseOsmAndFragment implements WikivoyageLocalDataHelper.Listener {
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(SavedArticlesTabFragment.class);
|
protected static final Log LOG = PlatformUtil.getLog(SavedArticlesTabFragment.class);
|
||||||
|
|
||||||
private WikivoyageLocalDataHelper dataHelper;
|
private WikivoyageLocalDataHelper dataHelper;
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ public class SavedArticlesTabFragment extends BaseOsmAndFragment implements Wiki
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
final OsmandApplication app = getMyApplication();
|
final OsmandApplication app = getMyApplication();
|
||||||
dataHelper = app.getWikivoyageDbHelper().getLocalDataHelper();
|
dataHelper = app.getWikivoyageDbHelper().getLocalDataHelper();
|
||||||
LOG.debug("Data helper null:" + (dataHelper != null));
|
|
||||||
|
|
||||||
final View mainView = inflater.inflate(R.layout.fragment_saved_articles_tab, container, false);
|
final View mainView = inflater.inflate(R.layout.fragment_saved_articles_tab, container, false);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue