Change travel item position in navigation drawer; show travel item only if db file exists

This commit is contained in:
alex 2018-03-27 17:28:29 +03:00
parent 8d6933ab06
commit abc796d823
2 changed files with 24 additions and 12 deletions

View file

@ -63,6 +63,7 @@ import net.osmand.plus.views.MapControlsLayer;
import net.osmand.plus.views.MapTileLayer;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.wikivoyage.WikivoyageExploreDialogFragment;
import net.osmand.plus.wikivoyage.data.WikivoyageDbHelper;
import net.osmand.router.GeneralRouter;
import org.apache.commons.logging.Log;
@ -765,6 +766,19 @@ public class MapActivityActions implements DialogProvider {
}).createItem());
}
if (WikivoyageDbHelper.isDbFileExists(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_travel, mapActivity)
.setIcon(R.drawable.ic_action_travel)
.setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
}
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity)
.setIcon(R.drawable.ic_action_ruler)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@ -775,17 +789,6 @@ public class MapActivityActions implements DialogProvider {
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_travel, mapActivity)
.setIcon(R.drawable.ic_action_track_16)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
.setIcon(R.drawable.ic_configure_screen_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {

View file

@ -7,6 +7,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.api.SQLiteAPI.SQLiteConnection;
import net.osmand.plus.api.SQLiteAPI.SQLiteCursor;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@ -82,7 +83,7 @@ public class WikivoyageDbHelper {
@Nullable
private SQLiteConnection openConnection() {
String path = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + DB_NAME).getAbsolutePath();
String path = getDbFile(application).getAbsolutePath();
return application.getSQLiteAPI().openByAbsolutePath(path, true);
}
@ -97,6 +98,14 @@ public class WikivoyageDbHelper {
return res;
}
public static boolean isDbFileExists(OsmandApplication app) {
return getDbFile(app).exists();
}
private static File getDbFile(OsmandApplication app) {
return app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR + DB_NAME);
}
public static class SearchResult {
private String searchTerm;