From b54b6a0cf2ad9dfdb1a373b2ba7c2cd3c8a0b0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20de=20Metz?= Date: Thu, 22 Nov 2018 19:58:55 +0100 Subject: [PATCH] Add 360 images mapillary filter. --- .../res/layout/fragment_mapillary_filters.xml | 49 ++++++++++++++++++- OsmAnd/res/values/strings.xml | 3 +- .../src/net/osmand/plus/OsmandSettings.java | 1 + .../mapillary/MapillaryFiltersFragment.java | 46 ++++++++++++----- .../plus/mapillary/MapillaryVectorLayer.java | 7 ++- 5 files changed, 91 insertions(+), 15 deletions(-) diff --git a/OsmAnd/res/layout/fragment_mapillary_filters.xml b/OsmAnd/res/layout/fragment_mapillary_filters.xml index a3baf12f4e..3535fec6be 100644 --- a/OsmAnd/res/layout/fragment_mapillary_filters.xml +++ b/OsmAnd/res/layout/fragment_mapillary_filters.xml @@ -376,6 +376,53 @@ android:background="?attr/dashboard_divider" /> + + + + + + + + + + + - \ No newline at end of file + diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index fcd0dae558..fb8b1046cb 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -373,7 +373,8 @@ Type username View only images added by Username - Filter images by submitter or by date. Only active in closeup zoom. + Filter images by submitter, by date or by type. Only active in closeup zoom. + Display only 360° images Radius ruler Permissions OsmAnd cannot import the file. Please check if OsmAnd has permission to read file from its location. diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 4bb77455e1..c63d2ca786 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -823,6 +823,7 @@ public class OsmandSettings { public final CommonPreference MAPILLARY_FILTER_USERNAME = new StringPreference("mapillary_filter_username", "").makeGlobal(); public final CommonPreference MAPILLARY_FILTER_FROM_DATE = new LongPreference("mapillary_filter_from_date", 0).makeGlobal(); public final CommonPreference MAPILLARY_FILTER_TO_DATE = new LongPreference("mapillary_filter_to_date", 0).makeGlobal(); + public final CommonPreference MAPILLARY_FILTER_PANO = new BooleanPreference("mapillary_filter_pano", false).makeGlobal(); public final CommonPreference USE_FAST_RECALCULATION = new BooleanPreference("use_fast_recalculation", true).makeGlobal().cache(); public final CommonPreference FORCE_PRIVATE_ACCESS_ROUTING_ASKED = new BooleanPreference("force_private_access_routing", false).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java index 2066537a31..c38ee0b279 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java @@ -115,7 +115,6 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { ((AppCompatImageView) view.findViewById(R.id.mapillary_filters_date_icon)).setImageDrawable(getIcon(R.drawable.ic_action_data, colorRes)); ((AppCompatImageView) view.findViewById(R.id.mapillary_filters_tile_cache_icon)).setImageDrawable(getIcon(R.drawable.ic_layer_top_dark, colorRes)); - final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) view.findViewById(R.id.auto_complete_text_view); textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, getMyApplication())); String selectedUsername = settings.MAPILLARY_FILTER_USERNAME.get(); @@ -150,13 +149,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { view.findViewById(R.id.warning_linear_layout).setVisibility(View.GONE); - if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || - settings.MAPILLARY_FILTER_TO_DATE.get() != 0 || - settings.MAPILLARY_FILTER_FROM_DATE.get() != 0) { - changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true); - } else { - changeButtonState((Button) view.findViewById(R.id.button_apply), .5f, false); - } + enableButtonApply(view); } @Override @@ -179,7 +172,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { from.set(Calendar.DAY_OF_MONTH, dayOfMonth); dateFromEt.setText(dateFormat.format(from.getTime())); settings.MAPILLARY_FILTER_FROM_DATE.set(from.getTimeInMillis()); - changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true); + enableButtonApply(view); mapActivity.getDashboard().refreshContent(true); } }; @@ -206,7 +199,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { to.set(Calendar.DAY_OF_MONTH, dayOfMonth); dateToEt.setText(dateFormat.format(to.getTime())); settings.MAPILLARY_FILTER_TO_DATE.set(to.getTimeInMillis()); - changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true); + enableButtonApply(view); mapActivity.getDashboard().refreshContent(true); } }; @@ -233,9 +226,28 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { } } + final View rowPano = view.findViewById(R.id.pano_row); + final CompoundButton pano = (CompoundButton) rowPano.findViewById(R.id.pano_row_toggle); + pano.setOnCheckedChangeListener(null); + pano.setChecked(settings.MAPILLARY_FILTER_PANO.get()); + pano.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + settings.MAPILLARY_FILTER_PANO.set(!settings.MAPILLARY_FILTER_PANO.get()); + enableButtonApply(view); + mapActivity.getDashboard().refreshContent(true); + } + }); + rowPano.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + pano.setChecked(!pano.isChecked()); + } + }); + final Button apply = (Button) view.findViewById(R.id.button_apply); - changeButtonState(apply, .5f, false); + disableButtonApply(view); apply.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -243,7 +255,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { String dateFrom = dateFromEt.getText().toString(); String dateTo = dateToEt.getText().toString(); - if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("")) { + if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("") || settings.MAPILLARY_FILTER_PANO.get()) { settings.USE_MAPILLARY_FILTER.set(true); } if (dateFrom.equals("")) { @@ -272,12 +284,14 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { textView.setText(""); dateFromEt.setText(""); dateToEt.setText(""); + pano.setChecked(false); settings.USE_MAPILLARY_FILTER.set(false); settings.MAPILLARY_FILTER_USER_KEY.set(""); settings.MAPILLARY_FILTER_USERNAME.set(""); settings.MAPILLARY_FILTER_FROM_DATE.set(0L); settings.MAPILLARY_FILTER_TO_DATE.set(0L); + settings.MAPILLARY_FILTER_PANO.set(false); plugin.updateLayers(mapActivity.getMapView(), mapActivity); hideKeyboard(); @@ -295,6 +309,14 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment { } } + private void enableButtonApply(View view) { + changeButtonState((Button) view.findViewById(R.id.button_apply), 1, true); + } + + private void disableButtonApply(View view) { + changeButtonState((Button) view.findViewById(R.id.button_apply), .5f, false); + } + private void changeButtonState(Button button, float alpha, boolean enabled) { button.setAlpha(alpha); button.setEnabled(enabled); diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java index abc928ba8b..5d90bbbf2c 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryVectorLayer.java @@ -202,6 +202,7 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont long capturedAt = ((Number) userData.get("captured_at")).longValue(); long from = settings.MAPILLARY_FILTER_FROM_DATE.get(); long to = settings.MAPILLARY_FILTER_TO_DATE.get(); + boolean pano = settings.MAPILLARY_FILTER_PANO.get(); if (!userKey.equals("")) { String key = (String) userData.get("userkey"); @@ -216,6 +217,10 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont } else if ((from != 0 && capturedAt < from) || (to != 0 && capturedAt > to)) { return true; } + + if (pano) { + return (long) userData.get("pano") == 0; + } return false; } @@ -386,4 +391,4 @@ class MapillaryVectorLayer extends MapTileLayer implements MapillaryLayer, ICont } return (int) (r * view.getScaleCoefficient()); } -} \ No newline at end of file +}