diff --git a/OsmAnd/res/layout/fragment_mapillary_filters.xml b/OsmAnd/res/layout/fragment_mapillary_filters.xml
index 841fadae4d..d121a43e1e 100644
--- a/OsmAnd/res/layout/fragment_mapillary_filters.xml
+++ b/OsmAnd/res/layout/fragment_mapillary_filters.xml
@@ -6,6 +6,7 @@
android:orientation="vertical">
@@ -110,10 +111,11 @@
android:minHeight="60dp">
+ tools:src="@drawable/ic_action_user" />
+ tools:src="@drawable/ic_action_data" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/list_item_buttons.xml b/OsmAnd/res/layout/list_item_buttons.xml
deleted file mode 100644
index 9ac9d244c1..0000000000
--- a/OsmAnd/res/layout/list_item_buttons.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/OsmAnd/res/layout/list_item_date_from_and_to.xml b/OsmAnd/res/layout/list_item_date_from_and_to.xml
deleted file mode 100644
index 147bd4d6fc..0000000000
--- a/OsmAnd/res/layout/list_item_date_from_and_to.xml
+++ /dev/null
@@ -1,61 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/res/layout/list_item_icon_with_title_and_descr.xml b/OsmAnd/res/layout/list_item_icon_with_title_and_descr.xml
deleted file mode 100644
index 589a622220..0000000000
--- a/OsmAnd/res/layout/list_item_icon_with_title_and_descr.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
index 9ed9ec3024..fae8f03a3b 100644
--- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
+++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java
@@ -1,7 +1,6 @@
package net.osmand.plus;
import android.app.Activity;
-import android.app.DatePickerDialog;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
@@ -11,18 +10,12 @@ import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.AppCompatImageView;
-import android.text.Editable;
-import android.text.TextWatcher;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
-import android.widget.DatePicker;
-import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.SeekBar;
@@ -30,20 +23,13 @@ import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.activities.HelpActivity;
-import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.dialogs.HelpArticleDialogFragment;
-import net.osmand.plus.views.controls.DelayAutoCompleteTextView;
-import net.osmand.plus.mapillary.MapillaryAutoCompleteAdapter;
import org.apache.commons.logging.Log;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -55,15 +41,6 @@ public class ContextMenuAdapter {
private int DEFAULT_LAYOUT_ID = R.layout.list_menu_item_native;
List items = new ArrayList<>();
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
- private MapActivity mapActivity;
-
- public ContextMenuAdapter() {
-
- }
-
- public ContextMenuAdapter(MapActivity mapActivity) {
- this.mapActivity = mapActivity;
- }
public int length() {
return items.size();
@@ -352,167 +329,6 @@ public class ContextMenuAdapter {
}
}
- final View autoCompleteTextView = convertView.findViewById(R.id.auto_complete_text_view);
- if (autoCompleteTextView != null) {
- final DelayAutoCompleteTextView textView = (DelayAutoCompleteTextView) autoCompleteTextView;
- textView.setAdapter(new MapillaryAutoCompleteAdapter(getContext(), R.layout.auto_complete_suggestion, app));
-
- String selectedUsername = app.getSettings().MAPILLARY_FILTER_USERNAME.get();
- if (!selectedUsername.equals("") && app.getSettings().USE_MAPILLARY_FILTER.get()) {
- textView.setText(selectedUsername);
- textView.setSelection(selectedUsername.length());
- }
-
- textView.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
-
- }
-
- @Override
- public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
- ((View)textView.getParent()).findViewById(R.id.warning_linear_layout).setVisibility(View.GONE);
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
-
- }
- });
-
- ImageView imageView = (ImageView) ((View) textView.getParent()).findViewById(R.id.warning_image_view);
- imageView.setImageDrawable(mIconsCache.getPaintedIcon(R.drawable.ic_small_warning,
- app.getResources().getColor(R.color.color_warning)));
- }
-
- final View dateFromEditText = convertView.findViewById(R.id.date_from_edit_text);
- if (dateFromEditText != null) {
- final EditText dateFrom = (EditText) dateFromEditText;
- final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
- final OsmandSettings settings = app.getSettings();
-
- final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- Calendar from = Calendar.getInstance();
- from.set(Calendar.YEAR, year);
- from.set(Calendar.MONTH, monthOfYear);
- from.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- dateFrom.setText(dateFormat.format(from.getTime()));
- settings.MAPILLARY_FILTER_FROM_DATE.set(from.getTimeInMillis());
- }
- };
-
- dateFrom.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Calendar now = Calendar.getInstance();
- new DatePickerDialog(mapActivity, date,
- now.get(Calendar.YEAR),
- now.get(Calendar.MONTH),
- now.get(Calendar.DAY_OF_MONTH)).show();
- }
- });
-
- if (settings.USE_MAPILLARY_FILTER.get()) {
- long from = settings.MAPILLARY_FILTER_FROM_DATE.get();
- if (from != 0) {
- dateFrom.setText(dateFormat.format(new Date(from)));
- }
- }
- dateFrom.setCompoundDrawablesWithIntrinsicBounds(null, null,
- mIconsCache.getThemedIcon(R.drawable.ic_action_arrow_drop_down), null);
- }
-
- final View dateToEditText = convertView.findViewById(R.id.date_to_edit_text);
- if (dateToEditText != null) {
- final EditText dateTo = (EditText) dateToEditText;
- final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
- final OsmandSettings settings = app.getSettings();
-
- final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
- @Override
- public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
- Calendar to = Calendar.getInstance();
- to.set(Calendar.YEAR, year);
- to.set(Calendar.MONTH, monthOfYear);
- to.set(Calendar.DAY_OF_MONTH, dayOfMonth);
- dateTo.setText(dateFormat.format(to.getTime()));
- settings.MAPILLARY_FILTER_TO_DATE.set(to.getTimeInMillis());
- }
- };
-
- dateTo.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- Calendar now = Calendar.getInstance();
- new DatePickerDialog(mapActivity, date,
- now.get(Calendar.YEAR),
- now.get(Calendar.MONTH),
- now.get(Calendar.DAY_OF_MONTH)).show();
- }
- });
-
- if (settings.USE_MAPILLARY_FILTER.get()) {
- long to = settings.MAPILLARY_FILTER_TO_DATE.get();
- if (to != 0) {
- dateTo.setText(dateFormat.format(new Date(to)));
- }
- }
- dateTo.setCompoundDrawablesWithIntrinsicBounds(null, null,
- mIconsCache.getThemedIcon(R.drawable.ic_action_arrow_drop_down), null);
- }
-
- final View applyBtn = convertView.findViewById(R.id.button_apply);
- if (applyBtn != null) {
- final Button apply = (Button) applyBtn;
- apply.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- View list = (View) view.getParent().getParent().getParent();
- String username = ((AutoCompleteTextView) list.findViewById(R.id.auto_complete_text_view)).getText().toString();
- String dateFrom = ((EditText) list.findViewById(R.id.date_from_edit_text)).getText().toString();
- String dateTo = ((EditText) list.findViewById(R.id.date_to_edit_text)).getText().toString();
- OsmandSettings settings = app.getSettings();
-
- if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("")) {
- settings.USE_MAPILLARY_FILTER.set(true);
- }
- if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) {
- list.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
- }
- if (dateFrom.equals("")) {
- settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
- }
- if (dateTo.equals("")) {
- settings.MAPILLARY_FILTER_TO_DATE.set(0L);
- }
- }
- });
- }
-
- final View clearBtn = convertView.findViewById(R.id.button_clear);
- if (clearBtn != null) {
- final Button clear = (Button) clearBtn;
- clear.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- View list = (View) view.getParent().getParent().getParent();
- OsmandSettings settings = app.getSettings();
-
- ((AutoCompleteTextView) list.findViewById(R.id.auto_complete_text_view)).setText("");
- ((EditText) list.findViewById(R.id.date_from_edit_text)).setText("");
- ((EditText) list.findViewById(R.id.date_to_edit_text)).setText("");
-
- 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);
- }
- });
- }
-
if (item.isCategory()) {
convertView.setFocusable(false);
convertView.setClickable(false);
diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
index 0347b7dd9f..8aee8f4e1a 100644
--- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
+++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
@@ -1050,7 +1050,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
public void refreshContent(boolean force) {
- if (visibleType == DashboardType.WAYPOINTS
+ if (visibleType == DashboardType.MAPILLARY) {
+ Fragment mapillaryFragment = mapActivity.getSupportFragmentManager().findFragmentByTag(MapillaryFiltersFragment.TAG);
+ mapActivity.getSupportFragmentManager().beginTransaction()
+ .detach(mapillaryFragment)
+ .attach(mapillaryFragment)
+ .commit();
+ } else if (visibleType == DashboardType.WAYPOINTS
|| visibleType == DashboardType.MAP_MARKERS
|| visibleType == DashboardType.MAP_MARKERS_SELECTION
|| visibleType == DashboardType.CONFIGURE_SCREEN
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
index c736fbb503..14869050df 100644
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
+++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryFiltersFragment.java
@@ -1,14 +1,35 @@
package net.osmand.plus.mapillary;
+import android.app.DatePickerDialog;
+import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
+import android.support.v7.widget.AppCompatImageView;
+import android.support.v7.widget.AppCompatTextView;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CompoundButton;
+import android.widget.DatePicker;
+import android.widget.EditText;
+import android.widget.ImageView;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
+import net.osmand.plus.views.controls.DelayAutoCompleteTextView;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
public class MapillaryFiltersFragment extends BaseOsmAndFragment {
@@ -20,13 +41,191 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_mapillary_filters, container, false);
+ final MapActivity mapActivity = (MapActivity) getActivity();
+ final OsmandSettings settings = getSettings();
+ final MapillaryPlugin plugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
- boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ final boolean nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
+ final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.ctx_menu_info_view_bg_dark : R.color.ctx_menu_info_view_bg_light);
+ final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
+ final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null);
view.setBackgroundColor(backgroundColor);
+
+
+ final View toggleRow = view.findViewById(R.id.toggle_row);
+ toggleRow.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ showOrHideMapillaryLayers(settings, plugin, mapActivity);
+ }
+ });
+ final boolean selected = settings.SHOW_MAPILLARY.get();
+ final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
+ int toggleIconColorId;
+ int toggleIconId;
+ if (selected) {
+ toggleIconId = R.drawable.ic_action_view;
+ toggleIconColorId = nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light;
+ } else {
+ toggleIconId = R.drawable.ic_action_hide;
+ toggleIconColorId = nightMode ? 0 : R.color.icon_color;
+ }
+ ((AppCompatTextView) toggleRow.findViewById(R.id.toggle_row_title)).setText(toggleActionStringId);
+ final Drawable drawable = getIcon(toggleIconId, toggleIconColorId);
+ ((AppCompatImageView) toggleRow.findViewById(R.id.toggle_row_icon)).setImageDrawable(drawable);
+ final CompoundButton toggle = (CompoundButton) toggleRow.findViewById(R.id.toggle_row_toggle);
+ toggle.setChecked(selected);
+ toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
+ showOrHideMapillaryLayers(settings, plugin, mapActivity);
+ }
+ });
+
+
+ final int colorRes = nightMode ? R.color.color_white : R.color.icon_color;
+ ((AppCompatImageView) view.findViewById(R.id.mapillary_filters_user_icon)).setImageDrawable(getIcon(R.drawable.ic_action_user, colorRes));
+ ((AppCompatImageView) view.findViewById(R.id.mapillary_filters_date_icon)).setImageDrawable(getIcon(R.drawable.ic_action_data, 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();
+ if (!selectedUsername.equals("") && settings.USE_MAPILLARY_FILTER.get()) {
+ textView.setText(selectedUsername);
+ textView.setSelection(selectedUsername.length());
+ }
+ textView.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
+ view.findViewById(R.id.warning_linear_layout).setVisibility(View.GONE);
+ }
+
+ @Override
+ public void afterTextChanged(Editable editable) {
+
+ }
+ });
+ ImageView imageView = (ImageView) view.findViewById(R.id.warning_image_view);
+ imageView.setImageDrawable(getPaintedContentIcon(R.drawable.ic_small_warning,
+ getResources().getColor(R.color.color_warning)));
+
+
+ final EditText dateFromEt = (EditText) view.findViewById(R.id.date_from_edit_text);
+ final DatePickerDialog.OnDateSetListener dateFromDialog = new DatePickerDialog.OnDateSetListener() {
+ @Override
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ Calendar from = Calendar.getInstance();
+ from.set(Calendar.YEAR, year);
+ from.set(Calendar.MONTH, monthOfYear);
+ from.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ dateFromEt.setText(dateFormat.format(from.getTime()));
+ settings.MAPILLARY_FILTER_FROM_DATE.set(from.getTimeInMillis());
+ }
+ };
+ dateFromEt.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Calendar now = Calendar.getInstance();
+ new DatePickerDialog(mapActivity, dateFromDialog,
+ now.get(Calendar.YEAR),
+ now.get(Calendar.MONTH),
+ now.get(Calendar.DAY_OF_MONTH)).show();
+ }
+ });
+ dateFromEt.setCompoundDrawablesWithIntrinsicBounds(null, null, getContentIcon(R.drawable.ic_action_arrow_drop_down), null);
+
+
+ final EditText dateToEt = (EditText) view.findViewById(R.id.date_to_edit_text);
+ final DatePickerDialog.OnDateSetListener dateToDialog = new DatePickerDialog.OnDateSetListener() {
+ @Override
+ public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
+ Calendar to = Calendar.getInstance();
+ to.set(Calendar.YEAR, year);
+ to.set(Calendar.MONTH, monthOfYear);
+ to.set(Calendar.DAY_OF_MONTH, dayOfMonth);
+ dateToEt.setText(dateFormat.format(to.getTime()));
+ settings.MAPILLARY_FILTER_TO_DATE.set(to.getTimeInMillis());
+ }
+ };
+ dateToEt.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ Calendar now = Calendar.getInstance();
+ new DatePickerDialog(mapActivity, dateToDialog,
+ now.get(Calendar.YEAR),
+ now.get(Calendar.MONTH),
+ now.get(Calendar.DAY_OF_MONTH)).show();
+ }
+ });
+ dateToEt.setCompoundDrawablesWithIntrinsicBounds(null, null, getContentIcon(R.drawable.ic_action_arrow_drop_down), null);
+
+ if (settings.USE_MAPILLARY_FILTER.get()) {
+ long to = settings.MAPILLARY_FILTER_TO_DATE.get();
+ if (to != 0) {
+ dateToEt.setText(dateFormat.format(new Date(to)));
+ }
+ long from = settings.MAPILLARY_FILTER_FROM_DATE.get();
+ if (from != 0) {
+ dateFromEt.setText(dateFormat.format(new Date(from)));
+ }
+ }
+
+
+ final Button apply = (Button) view.findViewById(R.id.button_apply);
+ apply.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String username = textView.getText().toString();
+ String dateFrom = dateFromEt.getText().toString();
+ String dateTo = dateToEt.getText().toString();
+
+ if (!settings.MAPILLARY_FILTER_USERNAME.get().equals("") || !dateFrom.equals("") || !dateTo.equals("")) {
+ settings.USE_MAPILLARY_FILTER.set(true);
+ }
+ if (!username.equals("") && settings.MAPILLARY_FILTER_USERNAME.get().equals("")) {
+ view.findViewById(R.id.warning_linear_layout).setVisibility(View.VISIBLE);
+ }
+ if (dateFrom.equals("")) {
+ settings.MAPILLARY_FILTER_FROM_DATE.set(0L);
+ }
+ if (dateTo.equals("")) {
+ settings.MAPILLARY_FILTER_TO_DATE.set(0L);
+ }
+ }
+ });
+
+
+ final Button clear = (Button) view.findViewById(R.id.button_clear);
+ clear.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ textView.setText("");
+ dateFromEt.setText("");
+ dateToEt.setText("");
+
+ 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);
+ }
+ });
+
return view;
}
+
+ private void showOrHideMapillaryLayers(OsmandSettings settings, MapillaryPlugin plugin, MapActivity mapActivity) {
+ settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
+ plugin.updateLayers(mapActivity.getMapView(), mapActivity);
+ mapActivity.getDashboard().refreshContent(true);
+ }
}
diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java
deleted file mode 100644
index 93115af094..0000000000
--- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryMenu.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package net.osmand.plus.mapillary;
-
-import android.widget.ArrayAdapter;
-
-import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuItem;
-import net.osmand.plus.OsmandApplication;
-import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.OsmandSettings;
-import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
-
-public class MapillaryMenu {
-
- public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
- ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity);
- adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
- createLayersItems(adapter, mapActivity);
- return adapter;
- }
-
- private static void createLayersItems(final ContextMenuAdapter contextMenuAdapter, final MapActivity mapActivity) {
- final OsmandApplication app = mapActivity.getMyApplication();
- final OsmandSettings settings = app.getSettings();
- final MapillaryPlugin plugin = OsmandPlugin.getPlugin(MapillaryPlugin.class);
- if (plugin == null) {
- return;
- }
-
- final boolean selected = settings.SHOW_MAPILLARY.get();
- final int toggleActionStringId = selected ? R.string.shared_string_enabled : R.string.shared_string_disabled;
-
- ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
- @Override
- public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int position, boolean isChecked) {
- if (itemId == toggleActionStringId) {
- settings.SHOW_MAPILLARY.set(!settings.SHOW_MAPILLARY.get());
- plugin.updateLayers(mapActivity.getMapView(), mapActivity);
- mapActivity.getDashboard().refreshContent(true);
- }
- return false;
- }
- };
-
- boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
- int toggleIconColorId;
- int toggleIconId;
- if (selected) {
- toggleIconId = R.drawable.ic_action_view;
- toggleIconColorId = nightMode ? R.color.color_dialog_buttons_dark : R.color.color_dialog_buttons_light;
- } else {
- toggleIconId = R.drawable.ic_action_hide;
- toggleIconColorId = nightMode ? 0 : R.color.icon_color;
- }
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(toggleActionStringId, mapActivity)
- .setIcon(toggleIconId)
- .setColor(toggleIconColorId)
- .setListener(l)
- .setSelected(selected)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.search_poi_filter, mapActivity)
- .setDescription(app.getString(R.string.mapillary_menu_filter_description))
- .setCategory(true)
- .setLayout(R.layout.list_group_title_with_descr)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.mapillary_menu_title_username, mapActivity)
- .setDescription(app.getString(R.string.mapillary_menu_descr_username))
- .setIcon(R.drawable.ic_action_user)
- .setClickable(false)
- .setLayout(R.layout.list_item_icon_with_title_and_descr)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setLayout(R.layout.list_item_auto_complete_text_view)
- .setClickable(false)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.mapillary_menu_title_dates, mapActivity)
- .setDescription(app.getString(R.string.mapillary_menu_descr_dates))
- .setIcon(R.drawable.ic_action_data)
- .setClickable(false)
- .setLayout(R.layout.list_item_icon_with_title_and_descr)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setLayout(R.layout.list_item_date_from_and_to)
- .setClickable(false)
- .createItem());
-
- contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
- .setLayout(R.layout.list_item_buttons)
- .setClickable(false)
- .createItem());
- }
-}