diff --git a/OsmAnd/assets/article_style.css b/OsmAnd/assets/article_style.css new file mode 100644 index 0000000000..aadaf5e91f --- /dev/null +++ b/OsmAnd/assets/article_style.css @@ -0,0 +1,53 @@ +body { + display: block; + margin: 5%; +} + +h2 { + font-size: 2em; + letter-spacing: 0.05em; + color: #727272; + font-family: serif; +} + +h3 { + font-size: 2em; + font-family: sans-serif; + padding-top: 5%; +} + +p, li { + font-family: sans-serif; + font-size: 1em; + line-height: 1em; +} + +img { + width: 100%; +} + +a { + color: #237bff; + text-decoration-color: #a3c8ff; +} + +.external-free { + background-color: #f44336; + color: white; + padding: 14px 25px; + text-align: center; + text-decoration: none; + display: inline-block; +} + + +.thumb-tright, .thumbinner { + width: 100%; +} + +.thumbcaption { + width: 100%; + font-size: 1em; + color: #727272; + font-style: italic; +} diff --git a/OsmAnd/res/drawable-hdpi/ic_action_explore_part1.png b/OsmAnd/res/drawable-hdpi/ic_action_explore_part1.png new file mode 100644 index 0000000000..20a3c83130 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_explore_part1.png differ diff --git a/OsmAnd/res/drawable-hdpi/ic_action_explore_part2.png b/OsmAnd/res/drawable-hdpi/ic_action_explore_part2.png new file mode 100644 index 0000000000..f1289dd212 Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_explore_part2.png differ diff --git a/OsmAnd/res/drawable-hdpi/ic_action_placeholder_city.png b/OsmAnd/res/drawable-hdpi/ic_action_placeholder_city.png new file mode 100644 index 0000000000..ce205864ea Binary files /dev/null and b/OsmAnd/res/drawable-hdpi/ic_action_placeholder_city.png differ diff --git a/OsmAnd/res/drawable-hdpi/ic_action_search_dark.png b/OsmAnd/res/drawable-hdpi/ic_action_search_dark.png index 3e131808a8..2881893508 100644 Binary files a/OsmAnd/res/drawable-hdpi/ic_action_search_dark.png and b/OsmAnd/res/drawable-hdpi/ic_action_search_dark.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_explore_part1.png b/OsmAnd/res/drawable-mdpi/ic_action_explore_part1.png new file mode 100644 index 0000000000..c623bcee85 Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_explore_part1.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_explore_part2.png b/OsmAnd/res/drawable-mdpi/ic_action_explore_part2.png new file mode 100644 index 0000000000..2097883b9f Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_explore_part2.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_placeholder_city.png b/OsmAnd/res/drawable-mdpi/ic_action_placeholder_city.png new file mode 100644 index 0000000000..bcabdb0a88 Binary files /dev/null and b/OsmAnd/res/drawable-mdpi/ic_action_placeholder_city.png differ diff --git a/OsmAnd/res/drawable-mdpi/ic_action_search_dark.png b/OsmAnd/res/drawable-mdpi/ic_action_search_dark.png index 6d37f2ca3a..0dda6bece7 100644 Binary files a/OsmAnd/res/drawable-mdpi/ic_action_search_dark.png and b/OsmAnd/res/drawable-mdpi/ic_action_search_dark.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_explore_part1.png b/OsmAnd/res/drawable-xhdpi/ic_action_explore_part1.png new file mode 100644 index 0000000000..9954b8a027 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_explore_part1.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_explore_part2.png b/OsmAnd/res/drawable-xhdpi/ic_action_explore_part2.png new file mode 100644 index 0000000000..9b22d6bd68 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_explore_part2.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_placeholder_city.png b/OsmAnd/res/drawable-xhdpi/ic_action_placeholder_city.png new file mode 100644 index 0000000000..4eef5e26c2 Binary files /dev/null and b/OsmAnd/res/drawable-xhdpi/ic_action_placeholder_city.png differ diff --git a/OsmAnd/res/drawable-xhdpi/ic_action_search_dark.png b/OsmAnd/res/drawable-xhdpi/ic_action_search_dark.png index 60536de3bb..21e854525d 100644 Binary files a/OsmAnd/res/drawable-xhdpi/ic_action_search_dark.png and b/OsmAnd/res/drawable-xhdpi/ic_action_search_dark.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part1.png b/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part1.png new file mode 100644 index 0000000000..18c1a0429c Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part1.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part2.png b/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part2.png new file mode 100644 index 0000000000..d2936893c6 Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_explore_part2.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_placeholder_city.png b/OsmAnd/res/drawable-xxhdpi/ic_action_placeholder_city.png new file mode 100644 index 0000000000..0b2eed5734 Binary files /dev/null and b/OsmAnd/res/drawable-xxhdpi/ic_action_placeholder_city.png differ diff --git a/OsmAnd/res/drawable-xxhdpi/ic_action_search_dark.png b/OsmAnd/res/drawable-xxhdpi/ic_action_search_dark.png index 52f8a7de31..ec76e4d72c 100644 Binary files a/OsmAnd/res/drawable-xxhdpi/ic_action_search_dark.png and b/OsmAnd/res/drawable-xxhdpi/ic_action_search_dark.png differ diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 95afd05a63..adfa47e719 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -721,6 +721,7 @@ public class OsmandSettings { public final CommonPreference COORDS_INPUT_USE_RIGHT_SIDE = new BooleanPreference("coords_input_use_right_side", true).makeGlobal(); public final CommonPreference COORDS_INPUT_FORMAT = new IntPreference("coords_input_format", CoordinateInputFormats.DD_MM_MMM); + public final CommonPreference COORDS_INPUT_USE_OSMAND_KEYBOARD = new BooleanPreference("coords_input_use_osmand_keyboard", true).makeGlobal(); public final CommonPreference USE_MAPILLARY_FILTER = new BooleanPreference("use_mapillary_filters", false).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_USER_KEY = new StringPreference("mapillary_filter_user_key", "").makeGlobal(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java index 4cc678cfe2..3c2056336e 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputBottomSheetDialogFragment.java @@ -20,39 +20,23 @@ import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.mapmarkers.CoordinateInputFormats.CoordinateInputFormatDef; -import static net.osmand.plus.mapmarkers.CoordinateInputDialogFragment.USE_OSMAND_KEYBOARD; - public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public final static String TAG = "CoordinateInputBottomSheetDialogFragment"; private CoordinateInputFormatChangeListener listener; - private boolean useOsmandKeyboard; - public void setListener(CoordinateInputFormatChangeListener listener) { this.listener = listener; } - @Override - public void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - if (savedInstanceState == null) { - Bundle args = getArguments(); - if (args != null) { - useOsmandKeyboard = args.getBoolean(USE_OSMAND_KEYBOARD); - } - } else { - useOsmandKeyboard = savedInstanceState.getBoolean(USE_OSMAND_KEYBOARD); - } - } - @Override public void createMenuItems(Bundle savedInstanceState) { final Context context = getContext(); final OsmandSettings settings = getMyApplication().getSettings(); items.add(new TitleItem(getString(R.string.shared_string_options))); + boolean useOsmandKeyboard = settings.COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); BaseBottomSheetItem useSystemKeyboardItem = new BottomSheetItemWithCompoundButton.Builder() .setChecked(!useOsmandKeyboard) @@ -63,7 +47,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia @Override public void onClick(View v) { if (listener != null) { - listener.onKeyboardChanged(!useOsmandKeyboard); + listener.onKeyboardChanged(); } dismiss(); } @@ -134,12 +118,6 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia } } - @Override - public void onSaveInstanceState(Bundle outState) { - outState.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); - super.onSaveInstanceState(outState); - } - @Override protected int getDismissButtonTextId() { return R.string.shared_string_close; @@ -152,7 +130,7 @@ public class CoordinateInputBottomSheetDialogFragment extends MenuBottomSheetDia interface CoordinateInputFormatChangeListener { - void onKeyboardChanged(boolean useOsmandKeyboard); + void onKeyboardChanged(); void onHandChanged(); diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 593a874bfd..020e762248 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -54,6 +54,7 @@ import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.OsmAndLocationProvider.OsmAndCompassListener; import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.base.MapViewTrackingUtilities; @@ -76,8 +77,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm public static final String TAG = "CoordinateInputDialogFragment"; - public static final String USE_OSMAND_KEYBOARD = "use_osmand_keyboard"; - private final List mapMarkers = new ArrayList<>(); private OnMapMarkersSavedListener listener; @@ -89,7 +88,6 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm private boolean lightTheme; private boolean orientationPortrait; - private boolean useOsmandKeyboard = true; private boolean north = true; private boolean east = true; @@ -170,12 +168,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm mainView.findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - Bundle args = new Bundle(); - args.putBoolean(USE_OSMAND_KEYBOARD, useOsmandKeyboard); - CoordinateInputBottomSheetDialogFragment fragment = new CoordinateInputBottomSheetDialogFragment(); fragment.setUsedOnMap(false); - fragment.setArguments(args); fragment.setListener(createCoordinateInputFormatChangeListener()); fragment.show(getChildFragmentManager(), CoordinateInputBottomSheetDialogFragment.TAG); } @@ -253,8 +247,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm pointNameKeyboardBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if (useOsmandKeyboard) { - changeKeyboard(false); + if (isOsmandKeyboardOn()) { + changeKeyboard(); } } }); @@ -294,7 +288,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if (useOsmandKeyboard) { + if (isOsmandKeyboardOn()) { View focusedView = getDialog().getCurrentFocus(); if (focusedView != null && focusedView instanceof EditText) { EditText focusedEditText = (EditText) focusedView; @@ -340,7 +334,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm R.id.keyboard_item_next_field, R.id.keyboard_item_backspace); - if (!useOsmandKeyboard && isOsmandKeyboardCurrentlyVisible()) { + if (!isOsmandKeyboardOn() && isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(false); } @@ -349,8 +343,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm @Override public void onClick(View view) { boolean isCurrentlyVisible = isOsmandKeyboardCurrentlyVisible(); - if (!isCurrentlyVisible && !useOsmandKeyboard) { - changeKeyboard(true); + if (!isCurrentlyVisible && !isOsmandKeyboardOn()) { + changeKeyboard(); } else { changeOsmandKeyboardVisibility(!isCurrentlyVisible); } @@ -589,7 +583,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnTouchListener inputEditTextOnTouchListener = new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { - if (useOsmandKeyboard) { + if (isOsmandKeyboardOn()) { if (!isOsmandKeyboardCurrentlyVisible()) { changeOsmandKeyboardVisibility(true); } @@ -615,7 +609,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm View.OnLongClickListener inputEditTextOnLongClickListener = new View.OnLongClickListener() { @Override public boolean onLongClick(final View view) { - if (useOsmandKeyboard) { + if (isOsmandKeyboardOn()) { final EditText inputEditText = (EditText) view; PopupMenu popupMenu = new PopupMenu(getContext(), inputEditText); Menu menu = popupMenu.getMenu(); @@ -738,8 +732,18 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return sb.toString(); } - private void changeKeyboard(boolean useOsmandKeyboard) { - this.useOsmandKeyboard = useOsmandKeyboard; + private boolean isOsmandKeyboardOn() { + return getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD.get(); + } + + private void changeOsmandKeyboardSetting() { + OsmandSettings.OsmandPreference pref = getMyApplication().getSettings().COORDS_INPUT_USE_OSMAND_KEYBOARD; + pref.set(!pref.get()); + } + + private void changeKeyboard() { + changeOsmandKeyboardSetting(); + boolean useOsmandKeyboard = isOsmandKeyboardOn(); changeOsmandKeyboardVisibility(useOsmandKeyboard); final View focusedView = getDialog().getCurrentFocus(); if (focusedView != null) { @@ -761,8 +765,8 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm return new CoordinateInputFormatChangeListener() { @Override - public void onKeyboardChanged(boolean useOsmandKeyboard) { - changeKeyboard(useOsmandKeyboard); + public void onKeyboardChanged() { + changeKeyboard(); } @Override diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java index 5eff13de75..820ccb5df1 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/WikivoyageArticleDialogFragment.java @@ -20,10 +20,13 @@ import android.webkit.WebView; import android.widget.TextView; import net.osmand.AndroidUtils; +import net.osmand.IndexConstants; import net.osmand.plus.R; import net.osmand.plus.wikivoyage.data.WikivoyageArticle; import net.osmand.plus.wikivoyage.data.WikivoyageSearchResult; +import java.io.File; + public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragment { public static final String TAG = "WikivoyageArticleDialogFragment"; @@ -31,6 +34,14 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen private static final String SEARCH_RESULT_KEY = "search_result_key"; private static final String SELECTED_LANG_KEY = "selected_lang_key"; + private static final String HEADER_INNER = "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "
\n"; + private static final String FOOTER_INNER = "
"; + private WikivoyageSearchResult searchResult; private String selectedLang; @@ -143,9 +154,20 @@ public class WikivoyageArticleDialogFragment extends WikivoyageBaseDialogFragmen return; } - contentWebView.loadData(article.getContent(), "text/html", "UTF-8"); + String content = HEADER_INNER + article.getContent() + FOOTER_INNER; + contentWebView.loadDataWithBaseURL(getBaseUrl(), content, "text/html", "UTF-8", null); } + @NonNull + private String getBaseUrl() { + File wikivoyageDir = getMyApplication().getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR); + if (new File(wikivoyageDir, "article_style.css").exists()) { + return "file://" + wikivoyageDir.getAbsolutePath() + "/"; + } + return "file:///android_asset/"; + } + + @NonNull private Drawable getSelectedLangIcon() { Drawable normal = getContentIcon(R.drawable.ic_action_map_language); if (Build.VERSION.SDK_INT >= 21) { diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java index 7e143d8515..cf48103596 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/WikivoyageDbHelper.java @@ -82,21 +82,21 @@ public class WikivoyageDbHelper { SQLiteConnection conn = openConnection(); if (conn != null) { try { - String dbQuery = SEARCH_TABLE_SELECT + " WHERE " + SEARCH_COL_SEARCH_TERM + " LIKE ?"; + String dbQuery = SEARCH_TABLE_SELECT + " WHERE " + SEARCH_COL_CITY_ID + + " IN (SELECT " + SEARCH_COL_CITY_ID + " FROM " + SEARCH_TABLE_NAME + + " WHERE " + SEARCH_COL_SEARCH_TERM + " LIKE ?)"; SQLiteCursor cursor = conn.rawQuery(dbQuery, new String[]{searchQuery + "%"}); if (cursor.moveToFirst()) { do { res.add(readSearchResult(cursor)); } while (cursor.moveToNext()); } - cursor.close(); } finally { conn.close(); } } List list = new ArrayList<>(groupSearchResultsByCityId(res)); - Collections.sort(list, new Comparator() { @Override public int compare(WikivoyageSearchResult o1, WikivoyageSearchResult o2) {