Refactor favorite group
This commit is contained in:
parent
ad7ec16aeb
commit
9a4f043a64
19 changed files with 114 additions and 129 deletions
|
@ -856,7 +856,7 @@ public class OsmandAidlApi {
|
||||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||||
if (g.name.equals(name)) {
|
if (g.getName().equals(name)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -872,7 +872,7 @@ public class OsmandAidlApi {
|
||||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||||
if (g.name.equals(name)) {
|
if (g.getName().equals(name)) {
|
||||||
favoritesHelper.deleteGroup(g);
|
favoritesHelper.deleteGroup(g);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -884,7 +884,7 @@ public class OsmandAidlApi {
|
||||||
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
FavouritesDbHelper favoritesHelper = app.getFavorites();
|
||||||
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
|
||||||
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
for (FavouritesDbHelper.FavoriteGroup g : groups) {
|
||||||
if (g.name.equals(prevGroupName)) {
|
if (g.getName().equals(prevGroupName)) {
|
||||||
int color = 0;
|
int color = 0;
|
||||||
if (!Algorithms.isEmpty(colorTag)) {
|
if (!Algorithms.isEmpty(colorTag)) {
|
||||||
color = ColorDialogs.getColorByTag(colorTag);
|
color = ColorDialogs.getColorByTag(colorTag);
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class FavouritesDbHelper {
|
||||||
|
|
||||||
public static class FavoriteGroup {
|
public static class FavoriteGroup {
|
||||||
public static final String PERSONAL_CATEGORY = "personal";
|
public static final String PERSONAL_CATEGORY = "personal";
|
||||||
protected String name;
|
private String name;
|
||||||
protected boolean visible = true;
|
private boolean visible = true;
|
||||||
protected int color;
|
private int color;
|
||||||
protected List<FavouritePoint> points = new ArrayList<>();
|
private List<FavouritePoint> points = new ArrayList<>();
|
||||||
|
|
||||||
public boolean isPersonal() {
|
public boolean isPersonal() {
|
||||||
return isPersonal(name);
|
return isPersonal(name);
|
||||||
|
|
|
@ -535,7 +535,7 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapMarkersGroup createFavMarkerGroup(FavoriteGroup favGroup) {
|
private MapMarkersGroup createFavMarkerGroup(FavoriteGroup favGroup) {
|
||||||
return new MapMarkersGroup(favGroup.name, favGroup.name, MapMarkersGroup.FAVORITES_TYPE);
|
return new MapMarkersGroup(favGroup.getName(), favGroup.getName(), MapMarkersGroup.FAVORITES_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMarkerGroupId(File gpx) {
|
private String getMarkerGroupId(File gpx) {
|
||||||
|
@ -543,7 +543,7 @@ public class MapMarkersHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getMarkerGroupId(FavoriteGroup group) {
|
private String getMarkerGroupId(FavoriteGroup group) {
|
||||||
return group.name;
|
return group.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -1161,13 +1161,13 @@ public class MapMarkersHelper {
|
||||||
if (favGroup == null) {
|
if (favGroup == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
group.visible = favGroup.visible;
|
group.visible = favGroup.isVisible();
|
||||||
if (!group.isVisible() || group.isDisabled()) {
|
if (!group.isVisible() || group.isDisabled()) {
|
||||||
removeGroupActiveMarkers(group, true);
|
removeGroupActiveMarkers(group, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (FavouritePoint fp : favGroup.points) {
|
for (FavouritePoint fp : favGroup.getPoints()) {
|
||||||
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null);
|
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import android.view.ViewGroup.LayoutParams;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
@ -61,7 +60,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
if (group == null) {
|
if (group == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
items.add(new TitleItem(Algorithms.isEmpty(group.name) ? app.getString(R.string.shared_string_favorites) : group.name));
|
items.add(new TitleItem(Algorithms.isEmpty(group.getName()) ? app.getString(R.string.shared_string_favorites) : group.getName()));
|
||||||
|
|
||||||
BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder()
|
BaseBottomSheetItem editNameItem = new SimpleBottomSheetItem.Builder()
|
||||||
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
|
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
|
||||||
|
@ -76,7 +75,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
b.setTitle(R.string.favorite_category_name);
|
b.setTitle(R.string.favorite_category_name);
|
||||||
final EditText nameEditText = new EditText(activity);
|
final EditText nameEditText = new EditText(activity);
|
||||||
nameEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
nameEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
|
||||||
nameEditText.setText(group.name);
|
nameEditText.setText(group.getName());
|
||||||
LinearLayout container = new LinearLayout(activity);
|
LinearLayout container = new LinearLayout(activity);
|
||||||
int sidePadding = AndroidUtils.dpToPx(activity, 24f);
|
int sidePadding = AndroidUtils.dpToPx(activity, 24f);
|
||||||
int topPadding = AndroidUtils.dpToPx(activity, 4f);
|
int topPadding = AndroidUtils.dpToPx(activity, 4f);
|
||||||
|
@ -88,10 +87,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String name = nameEditText.getText().toString();
|
String name = nameEditText.getText().toString();
|
||||||
boolean nameChanged = !Algorithms.objectEquals(group.name, name);
|
boolean nameChanged = !Algorithms.objectEquals(group.getName(), name);
|
||||||
if (nameChanged) {
|
if (nameChanged) {
|
||||||
app.getFavorites()
|
app.getFavorites()
|
||||||
.editFavouriteGroup(group, name, group.color, group.visible);
|
.editFavouriteGroup(group, name, group.getColor(), group.isVisible());
|
||||||
updateParentFragment();
|
updateParentFragment();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -135,9 +134,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||||
Integer color = colorAdapter.getItem(position);
|
Integer color = colorAdapter.getItem(position);
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
if (color != group.color) {
|
if (color != group.getColor()) {
|
||||||
app.getFavorites()
|
app.getFavorites()
|
||||||
.editFavouriteGroup(group, group.name, color, group.visible);
|
.editFavouriteGroup(group, group.getName(), color, group.isVisible());
|
||||||
updateParentFragment();
|
updateParentFragment();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,16 +152,16 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
items.add(changeColorItem);
|
items.add(changeColorItem);
|
||||||
|
|
||||||
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder()
|
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder()
|
||||||
.setChecked(group.visible)
|
.setChecked(group.isVisible())
|
||||||
.setIcon(getContentIcon(R.drawable.ic_map))
|
.setIcon(getContentIcon(R.drawable.ic_map))
|
||||||
.setTitle(getString(R.string.shared_string_show_on_map))
|
.setTitle(getString(R.string.shared_string_show_on_map))
|
||||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
|
||||||
.setOnClickListener(new View.OnClickListener() {
|
.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean visible = !group.visible;
|
boolean visible = !group.isVisible();
|
||||||
app.getFavorites()
|
app.getFavorites()
|
||||||
.editFavouriteGroup(group, group.name, group.color, visible);
|
.editFavouriteGroup(group, group.getName(), group.getColor(), visible);
|
||||||
updateParentFragment();
|
updateParentFragment();
|
||||||
dismiss();
|
dismiss();
|
||||||
}
|
}
|
||||||
|
@ -170,7 +169,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
.create();
|
.create();
|
||||||
items.add(showOnMapItem);
|
items.add(showOnMapItem);
|
||||||
|
|
||||||
if (group.points.size() > 0) {
|
if (group.getPoints().size() > 0) {
|
||||||
items.add(new DividerHalfItem(getContext()));
|
items.add(new DividerHalfItem(getContext()));
|
||||||
|
|
||||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||||
|
@ -240,7 +239,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateColorView(ImageView colorImageView) {
|
private void updateColorView(ImageView colorImageView) {
|
||||||
int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color;
|
int color = group.getColor() == 0 ? getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
|
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -328,14 +328,14 @@ public class FavoritesSearchFragment extends DialogFragment {
|
||||||
Set<?> flt = filter;
|
Set<?> flt = filter;
|
||||||
for (FavoriteGroup key : gs) {
|
for (FavoriteGroup key : gs) {
|
||||||
if (flt == null || flt.contains(key)) {
|
if (flt == null || flt.contains(key)) {
|
||||||
for (FavouritePoint p : key.points) {
|
for (FavouritePoint p : key.getPoints()) {
|
||||||
if (p.isVisible()) {
|
if (p.isVisible()) {
|
||||||
points.add(p);
|
points.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ArrayList<FavouritePoint> list = new ArrayList<>();
|
ArrayList<FavouritePoint> list = new ArrayList<>();
|
||||||
for (FavouritePoint p : key.points) {
|
for (FavouritePoint p : key.getPoints()) {
|
||||||
if (p.isVisible() && flt.contains(p)) {
|
if (p.isVisible() && flt.contains(p)) {
|
||||||
list.add(p);
|
list.add(p);
|
||||||
}
|
}
|
||||||
|
@ -517,15 +517,15 @@ public class FavoritesSearchFragment extends DialogFragment {
|
||||||
String cs = constraint.toString().toLowerCase();
|
String cs = constraint.toString().toLowerCase();
|
||||||
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
||||||
String gName;
|
String gName;
|
||||||
if (Algorithms.isEmpty(g.name)) {
|
if (Algorithms.isEmpty(g.getName())) {
|
||||||
gName = favorites;
|
gName = favorites;
|
||||||
} else {
|
} else {
|
||||||
gName = g.name.toLowerCase();
|
gName = g.getName().toLowerCase();
|
||||||
}
|
}
|
||||||
if (g.visible && gName.contains(cs)) {
|
if (g.isVisible() && gName.contains(cs)) {
|
||||||
filter.add(g);
|
filter.add(g);
|
||||||
} else {
|
} else {
|
||||||
for (FavouritePoint fp : g.points) {
|
for (FavouritePoint fp : g.getPoints()) {
|
||||||
if (fp.isVisible() && fp.getName().toLowerCase().contains(cs)) {
|
if (fp.isVisible() && fp.getName().toLowerCase().contains(cs)) {
|
||||||
filter.add(fp);
|
filter.add(fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,14 +209,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
listView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
|
listView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGroupCollapse(int groupPosition) {
|
public void onGroupCollapse(int groupPosition) {
|
||||||
String groupName = favouritesAdapter.getGroup(groupPosition).name;
|
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
|
||||||
getGroupExpandedPreference(groupName).set(false);
|
getGroupExpandedPreference(groupName).set(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
|
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onGroupExpand(int groupPosition) {
|
public void onGroupExpand(int groupPosition) {
|
||||||
String groupName = favouritesAdapter.getGroup(groupPosition).name;
|
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
|
||||||
getGroupExpandedPreference(groupName).set(true);
|
getGroupExpandedPreference(groupName).set(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -232,7 +232,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
int selection = listView.getHeaderViewsCount();
|
int selection = listView.getHeaderViewsCount();
|
||||||
for (int i = 0; i < groupPos; i++) {
|
for (int i = 0; i < groupPos; i++) {
|
||||||
selection++; // because of group header
|
selection++; // because of group header
|
||||||
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).name).get()) {
|
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).getName()).get()) {
|
||||||
selection += favouritesAdapter.getChildrenCount(i);
|
selection += favouritesAdapter.getChildrenCount(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -314,16 +314,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
|
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
|
||||||
ch.setChecked(!ch.isChecked());
|
ch.setChecked(!ch.isChecked());
|
||||||
if (ch.isChecked()) {
|
if (ch.isChecked()) {
|
||||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
set.add(model);
|
set.add(model);
|
||||||
} else {
|
} else {
|
||||||
set = new LinkedHashSet<>();
|
set = new LinkedHashSet<>();
|
||||||
set.add(model);
|
set.add(model);
|
||||||
favoritesSelected.put(group.name, set);
|
favoritesSelected.put(group.getName(), set);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
set.remove(model);
|
set.remove(model);
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
List<PointDescription> names = new ArrayList<>();
|
List<PointDescription> names = new ArrayList<>();
|
||||||
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
|
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
|
||||||
FavoriteGroup favGr = helper.getGroup(entry.getKey());
|
FavoriteGroup favGr = helper.getGroup(entry.getKey());
|
||||||
if (entry.getValue().size() == favGr.points.size()) {
|
if (entry.getValue().size() == favGr.getPoints().size()) {
|
||||||
markersHelper.addOrEnableGroup(favGr);
|
markersHelper.addOrEnableGroup(favGr);
|
||||||
} else {
|
} else {
|
||||||
for (FavouritePoint fp : entry.getValue()) {
|
for (FavouritePoint fp : entry.getValue()) {
|
||||||
|
@ -539,8 +539,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
StringBuilder html = new StringBuilder();
|
StringBuilder html = new StringBuilder();
|
||||||
html.append("<h1>My Favorites</h1>");
|
html.append("<h1>My Favorites</h1>");
|
||||||
for (FavoriteGroup group : groups) {
|
for (FavoriteGroup group : groups) {
|
||||||
html.append("<h3>" + group.name + "</h3>");
|
html.append("<h3>" + group.getName() + "</h3>");
|
||||||
for (FavouritePoint fp : group.points) {
|
for (FavouritePoint fp : group.getPoints()) {
|
||||||
String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
|
String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
|
||||||
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:"
|
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:"
|
||||||
+ ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
|
+ ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
|
||||||
|
@ -589,7 +589,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
helper.saveFile(group.points, dst);
|
helper.saveFile(group.getPoints(), dst);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
|
|
||||||
private void initListExpandedState() {
|
private void initListExpandedState() {
|
||||||
for (int i = 0; i < favouritesAdapter.getGroupCount(); i++) {
|
for (int i = 0; i < favouritesAdapter.getGroupCount(); i++) {
|
||||||
String groupName = favouritesAdapter.getGroup(i).name;
|
String groupName = favouritesAdapter.getGroup(i).getName();
|
||||||
if (getGroupExpandedPreference(groupName).get()) {
|
if (getGroupExpandedPreference(groupName).get()) {
|
||||||
listView.expandGroup(i);
|
listView.expandGroup(i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -755,10 +755,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
boolean empty = true;
|
boolean empty = true;
|
||||||
if (flt == null || flt.contains(key)) {
|
if (flt == null || flt.contains(key)) {
|
||||||
empty = false;
|
empty = false;
|
||||||
favoriteGroups.put(key, new ArrayList<>(key.points));
|
favoriteGroups.put(key, new ArrayList<>(key.getPoints()));
|
||||||
} else {
|
} else {
|
||||||
ArrayList<FavouritePoint> list = new ArrayList<>();
|
ArrayList<FavouritePoint> list = new ArrayList<>();
|
||||||
for (FavouritePoint p : key.points) {
|
for (FavouritePoint p : key.getPoints()) {
|
||||||
if (flt.contains(p)) {
|
if (flt.contains(p)) {
|
||||||
list.add(p);
|
list.add(p);
|
||||||
empty = false;
|
empty = false;
|
||||||
|
@ -767,7 +767,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
favoriteGroups.put(key, list);
|
favoriteGroups.put(key, list);
|
||||||
}
|
}
|
||||||
if (!empty) {
|
if (!empty) {
|
||||||
if (key.visible) {
|
if (key.isVisible()) {
|
||||||
groups.add(key);
|
groups.add(key);
|
||||||
} else {
|
} else {
|
||||||
disablesGroups.add(key);
|
disablesGroups.add(key);
|
||||||
|
@ -831,11 +831,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
boolean light = app.getSettings().isLightContent();
|
boolean light = app.getSettings().isLightContent();
|
||||||
final FavoriteGroup model = getGroup(groupPosition);
|
final FavoriteGroup model = getGroup(groupPosition);
|
||||||
boolean visible = model.visible;
|
boolean visible = model.isVisible();
|
||||||
int enabledColor = light ? R.color.text_color_primary_light : R.color.text_color_primary_dark;
|
int enabledColor = light ? R.color.text_color_primary_light : R.color.text_color_primary_dark;
|
||||||
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
||||||
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
|
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
|
||||||
int color = model.color == 0 || model.color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.color;
|
int color = model.getColor() == 0 || model.getColor() == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.getColor();
|
||||||
if (!model.isPersonal()) {
|
if (!model.isPersonal()) {
|
||||||
setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
|
setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
|
||||||
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
|
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
|
||||||
|
@ -850,7 +850,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
} else {
|
} else {
|
||||||
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
label.setTypeface(Typeface.DEFAULT, Typeface.ITALIC);
|
||||||
}
|
}
|
||||||
label.setText(model.name.length() == 0 ? getString(R.string.shared_string_favorites) : model.getDisplayName(app));
|
label.setText(model.getName().length() == 0 ? getString(R.string.shared_string_favorites) : model.getDisplayName(app));
|
||||||
|
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||||
|
@ -860,21 +860,21 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
ch.setOnClickListener(new View.OnClickListener() {
|
ch.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
List<FavouritePoint> fvs = model.points;
|
List<FavouritePoint> fvs = model.getPoints();
|
||||||
if (ch.isChecked()) {
|
if (ch.isChecked()) {
|
||||||
groupsToDelete.add(model);
|
groupsToDelete.add(model);
|
||||||
if (fvs != null) {
|
if (fvs != null) {
|
||||||
Set<FavouritePoint> set = favoritesSelected.get(model.name);
|
Set<FavouritePoint> set = favoritesSelected.get(model.getName());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
set.addAll(model.points);
|
set.addAll(model.getPoints());
|
||||||
} else {
|
} else {
|
||||||
set = new LinkedHashSet<>(model.points);
|
set = new LinkedHashSet<>(model.getPoints());
|
||||||
favoritesSelected.put(model.name, set);
|
favoritesSelected.put(model.getName(), set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
groupsToDelete.remove(model);
|
groupsToDelete.remove(model);
|
||||||
favoritesSelected.remove(model.name);
|
favoritesSelected.remove(model.getName());
|
||||||
}
|
}
|
||||||
favouritesAdapter.notifyDataSetInvalidated();
|
favouritesAdapter.notifyDataSetInvalidated();
|
||||||
updateSelectionMode(actionMode);
|
updateSelectionMode(actionMode);
|
||||||
|
@ -895,7 +895,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
ch.setOnClickListener(new View.OnClickListener() {
|
ch.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
EditFavoriteGroupDialogFragment.showInstance(getChildFragmentManager(), model.name);
|
EditFavoriteGroupDialogFragment.showInstance(getChildFragmentManager(), model.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -977,26 +977,26 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
ch.setVisibility(View.VISIBLE);
|
ch.setVisibility(View.VISIBLE);
|
||||||
ch.setChecked(favoritesSelected.get(group.name) != null && favoritesSelected.get(group.name).contains(model));
|
ch.setChecked(favoritesSelected.get(group.getName()) != null && favoritesSelected.get(group.getName()).contains(model));
|
||||||
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
|
row.findViewById(R.id.favourite_icon).setVisibility(View.GONE);
|
||||||
ch.setOnClickListener(new View.OnClickListener() {
|
ch.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if (ch.isChecked()) {
|
if (ch.isChecked()) {
|
||||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
set.add(model);
|
set.add(model);
|
||||||
} else {
|
} else {
|
||||||
set = new LinkedHashSet<>();
|
set = new LinkedHashSet<>();
|
||||||
set.add(model);
|
set.add(model);
|
||||||
favoritesSelected.put(group.name, set);
|
favoritesSelected.put(group.getName(), set);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Set<FavouritePoint> set = favoritesSelected.get(group.name);
|
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
|
||||||
if (set != null) {
|
if (set != null) {
|
||||||
groupsToDelete.remove(group);
|
groupsToDelete.remove(group);
|
||||||
getGroupPosition(group.name);
|
getGroupPosition(group.getName());
|
||||||
set.remove(model);
|
set.remove(model);
|
||||||
favouritesAdapter.notifyDataSetInvalidated();
|
favouritesAdapter.notifyDataSetInvalidated();
|
||||||
}
|
}
|
||||||
|
@ -1026,7 +1026,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
public int getGroupPosition(String groupName) {
|
public int getGroupPosition(String groupName) {
|
||||||
for (int i = 0; i < getGroupCount(); i++) {
|
for (int i = 0; i < getGroupCount(); i++) {
|
||||||
FavoriteGroup group = getGroup(i);
|
FavoriteGroup group = getGroup(i);
|
||||||
if (group.name.equals(groupName)) {
|
if (group.getName().equals(groupName)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1050,10 +1050,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
|
||||||
Set<Object> filter = new HashSet<>();
|
Set<Object> filter = new HashSet<>();
|
||||||
String cs = constraint.toString().toLowerCase();
|
String cs = constraint.toString().toLowerCase();
|
||||||
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
for (FavoriteGroup g : helper.getFavoriteGroups()) {
|
||||||
if (g.name.toLowerCase().contains(cs)) {
|
if (g.getName().toLowerCase().contains(cs)) {
|
||||||
filter.add(g);
|
filter.add(g);
|
||||||
} else {
|
} else {
|
||||||
for (FavouritePoint fp : g.points) {
|
for (FavouritePoint fp : g.getPoints()) {
|
||||||
if (fp.getName().toLowerCase().contains(cs)) {
|
if (fp.getName().toLowerCase().contains(cs)) {
|
||||||
filter.add(fp);
|
filter.add(fp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class FavoriteImageDrawable extends Drawable {
|
||||||
this.withShadow = withShadow;
|
this.withShadow = withShadow;
|
||||||
this.synced = synced;
|
this.synced = synced;
|
||||||
Resources res = ctx.getResources();
|
Resources res = ctx.getResources();
|
||||||
int overlayIconId = point.getOverlayIconId();
|
int overlayIconId = point != null ? point.getOverlayIconId() : 0;
|
||||||
if (overlayIconId != 0) {
|
if (overlayIconId != 0) {
|
||||||
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, overlayIconId, null),
|
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, overlayIconId, null),
|
||||||
ContextCompat.getColor(ctx, R.color.icon_color_default_light));
|
ContextCompat.getColor(ctx, R.color.icon_color_default_light));
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class FavoriteDialogs {
|
||||||
List<FavoriteGroup> gs = helper.getFavoriteGroups();
|
List<FavoriteGroup> gs = helper.getFavoriteGroups();
|
||||||
final String[] list = new String[gs.size()];
|
final String[] list = new String[gs.size()];
|
||||||
for (int i = 0; i < list.length; i++) {
|
for (int i = 0; i < list.length; i++) {
|
||||||
list[i] = gs.get(i).name;
|
list[i] = gs.get(i).getName();
|
||||||
}
|
}
|
||||||
cat.setAdapter(new ArrayAdapter<String>(activity, R.layout.list_textview, list));
|
cat.setAdapter(new ArrayAdapter<String>(activity, R.layout.list_textview, list));
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,11 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||||
|
|
||||||
private void buildGroupFavouritesView(View view) {
|
private void buildGroupFavouritesView(View view) {
|
||||||
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
|
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
|
||||||
List<FavouritePoint> groupFavourites = favoriteGroup.points;
|
List<FavouritePoint> groupFavourites = favoriteGroup.getPoints();
|
||||||
if (groupFavourites.size() > 0) {
|
if (groupFavourites.size() > 0) {
|
||||||
int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
|
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? view.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
|
||||||
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
int disabledColor = light ? R.color.text_color_secondary_light : R.color.text_color_secondary_dark;
|
||||||
color = favoriteGroup.visible ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
|
color = favoriteGroup.isVisible() ? (color | 0xff000000) : view.getResources().getColor(disabledColor);
|
||||||
String name = view.getContext().getString(R.string.context_menu_points_of_group);
|
String name = view.getContext().getString(R.string.context_menu_points_of_group);
|
||||||
buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
|
buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
|
||||||
true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
|
true, getCollapsableFavouritesView(view.getContext(), true, favoriteGroup, fav),
|
||||||
|
@ -160,7 +160,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||||
private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
|
private CollapsableView getCollapsableFavouritesView(final Context context, boolean collapsed, @NonNull final FavoriteGroup group, FavouritePoint selectedPoint) {
|
||||||
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
|
LinearLayout view = (LinearLayout) buildCollapsableContentView(context, collapsed, true);
|
||||||
|
|
||||||
List<FavouritePoint> points = group.points;
|
List<FavouritePoint> points = group.getPoints();
|
||||||
for (int i = 0; i < points.size() && i < 10; i++) {
|
for (int i = 0; i < points.size() && i < 10; i++) {
|
||||||
final FavouritePoint point = points.get(i);
|
final FavouritePoint point = points.get(i);
|
||||||
boolean selected = selectedPoint != null && selectedPoint.equals(point);
|
boolean selected = selectedPoint != null && selectedPoint.equals(point);
|
||||||
|
@ -187,7 +187,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
FavoritesActivity.openFavoritesGroup(context, group.name);
|
FavoritesActivity.openFavoritesGroup(context, group.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.addView(button);
|
view.addView(button);
|
||||||
|
|
|
@ -186,8 +186,8 @@ public class EditCategoryDialogFragment extends DialogFragment {
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putString(KEY_CTX_EDIT_CAT_EDITOR_TAG, editorTag);
|
bundle.putString(KEY_CTX_EDIT_CAT_EDITOR_TAG, editorTag);
|
||||||
bundle.putString(KEY_CTX_EDIT_CAT_NEW, Boolean.valueOf(false).toString());
|
bundle.putString(KEY_CTX_EDIT_CAT_NEW, Boolean.valueOf(false).toString());
|
||||||
bundle.putString(KEY_CTX_EDIT_CAT_NAME, group.name);
|
bundle.putString(KEY_CTX_EDIT_CAT_NAME, group.getName());
|
||||||
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.color);
|
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.getColor());
|
||||||
fragment.setArguments(bundle);
|
fragment.setArguments(bundle);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
||||||
if (helper != null) {
|
if (helper != null) {
|
||||||
FavoriteGroup group = helper.getGroup(name);
|
FavoriteGroup group = helper.getGroup(name);
|
||||||
this.group = group;
|
this.group = group;
|
||||||
super.setCategory(name, group.color);
|
super.setCategory(name, group.getColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
||||||
int color = 0;
|
int color = 0;
|
||||||
FavoriteGroup group = getGroup();
|
FavoriteGroup group = getGroup();
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
color = group.color;
|
color = group.getColor();
|
||||||
}
|
}
|
||||||
if (color == 0) {
|
if (color == 0) {
|
||||||
color = defaultColor;
|
color = defaultColor;
|
||||||
|
|
|
@ -87,7 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
|
||||||
} else {
|
} else {
|
||||||
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
|
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
|
||||||
for (final FavouritesDbHelper.FavoriteGroup category : gs) {
|
for (final FavouritesDbHelper.FavoriteGroup category : gs) {
|
||||||
addCategory(activity, ll, category.getDisplayName(getContext()), category.color);
|
addCategory(activity, ll, category.getDisplayName(getContext()), category.getColor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
View itemView = activity.getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null);
|
View itemView = activity.getLayoutInflater().inflate(R.layout.favorite_category_dialog_item, null);
|
||||||
|
|
|
@ -52,8 +52,8 @@ public class AddFavouritesGroupBottomSheetDialogFragment extends AddGroupBottomS
|
||||||
@Override
|
@Override
|
||||||
protected void onItemClick(int position) {
|
protected void onItemClick(int position) {
|
||||||
FavoriteGroup group = favouritesDbHelper.getFavoriteGroups().get(position - 1);
|
FavoriteGroup group = favouritesDbHelper.getFavoriteGroups().get(position - 1);
|
||||||
if (!group.visible) {
|
if (!group.isVisible()) {
|
||||||
favouritesDbHelper.editFavouriteGroup(group, group.name, group.color, true);
|
favouritesDbHelper.editFavouriteGroup(group, group.getName(), group.getColor(), true);
|
||||||
}
|
}
|
||||||
getMyApplication().getMapMarkersHelper().addOrEnableGroup(group);
|
getMyApplication().getMapMarkersHelper().addOrEnableGroup(group);
|
||||||
dismiss();
|
dismiss();
|
||||||
|
|
|
@ -3,13 +3,8 @@ package net.osmand.plus.mapmarkers.adapters;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.support.v7.widget.RecyclerView;
|
import android.support.v7.widget.RecyclerView;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
|
||||||
import net.osmand.plus.UiUtilities;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -32,9 +27,9 @@ public class FavouritesGroupsAdapter extends GroupsAdapter {
|
||||||
} else if (holder instanceof MapMarkersGroupViewHolder) {
|
} else if (holder instanceof MapMarkersGroupViewHolder) {
|
||||||
FavoriteGroup favoriteGroup = getItem(position);
|
FavoriteGroup favoriteGroup = getItem(position);
|
||||||
MapMarkersGroupViewHolder markersGroupViewHolder = (MapMarkersGroupViewHolder) holder;
|
MapMarkersGroupViewHolder markersGroupViewHolder = (MapMarkersGroupViewHolder) holder;
|
||||||
int color = favoriteGroup.color == 0 || favoriteGroup.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.color;
|
int color = favoriteGroup.getColor() == 0 || favoriteGroup.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : favoriteGroup.getColor();
|
||||||
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getPaintedIcon(R.drawable.ic_action_folder, color | 0xff000000));
|
markersGroupViewHolder.icon.setImageDrawable(iconsCache.getPaintedIcon(R.drawable.ic_action_folder, color | 0xff000000));
|
||||||
markersGroupViewHolder.name.setText(favoriteGroup.name.length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.name);
|
markersGroupViewHolder.name.setText(favoriteGroup.getName().length() == 0 ? app.getString(R.string.shared_string_favorites) : favoriteGroup.getName());
|
||||||
markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.getPoints().size()));
|
markersGroupViewHolder.numberCount.setText(String.valueOf(favoriteGroup.getPoints().size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -150,21 +150,12 @@ public class FavoriteAction extends QuickAction {
|
||||||
|
|
||||||
FavouritesDbHelper.FavoriteGroup group = helper.getFavoriteGroups().get(0);
|
FavouritesDbHelper.FavoriteGroup group = helper.getFavoriteGroups().get(0);
|
||||||
|
|
||||||
if (group.name.isEmpty() && group.color == 0) {
|
int color = group.getColor() == 0 ? activity.getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||||
|
categoryEdit.setText(group.getDisplayName(activity));
|
||||||
|
categoryImage.setColorFilter(color);
|
||||||
|
|
||||||
group.name = activity.getString(R.string.shared_string_favorites);
|
getParams().put(KEY_CATEGORY_NAME, group.getName());
|
||||||
|
getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.getColor()));
|
||||||
categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
|
|
||||||
categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
categoryEdit.setText(group.name);
|
|
||||||
categoryImage.setColorFilter(group.color);
|
|
||||||
}
|
|
||||||
|
|
||||||
getParams().put(KEY_CATEGORY_NAME, group.name);
|
|
||||||
getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.color));
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
|
@ -409,10 +409,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
hide();
|
hide();
|
||||||
} else if (word.getType() == ObjectType.FAVORITE_GROUP) {
|
} else if (word.getType() == ObjectType.FAVORITE_GROUP) {
|
||||||
FavouritesDbHelper.FavoriteGroup group = (FavouritesDbHelper.FavoriteGroup) word.getResult().object;
|
FavouritesDbHelper.FavoriteGroup group = (FavouritesDbHelper.FavoriteGroup) word.getResult().object;
|
||||||
if (group.points.size() > 1) {
|
if (group.getPoints().size() > 1) {
|
||||||
double left = 0, right = 0;
|
double left = 0, right = 0;
|
||||||
double top = 0, bottom = 0;
|
double top = 0, bottom = 0;
|
||||||
for (FavouritePoint p : group.points) {
|
for (FavouritePoint p : group.getPoints()) {
|
||||||
if (left == 0) {
|
if (left == 0) {
|
||||||
left = p.getLongitude();
|
left = p.getLongitude();
|
||||||
right = p.getLongitude();
|
right = p.getLongitude();
|
||||||
|
@ -429,8 +429,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
||||||
hideToolbar();
|
hideToolbar();
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
hide();
|
hide();
|
||||||
} else if (group.points.size() == 1) {
|
} else if (group.getPoints().size() == 1) {
|
||||||
FavouritePoint p = group.points.get(0);
|
FavouritePoint p = group.getPoints().get(0);
|
||||||
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
|
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
|
||||||
hideToolbar();
|
hideToolbar();
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||||
|
|
|
@ -235,16 +235,16 @@ public class QuickSearchHelper implements ResourceListener {
|
||||||
String baseGroupName = app.getString(R.string.shared_string_favorites);
|
String baseGroupName = app.getString(R.string.shared_string_favorites);
|
||||||
List<FavoriteGroup> groups = app.getFavorites().getFavoriteGroups();
|
List<FavoriteGroup> groups = app.getFavorites().getFavoriteGroups();
|
||||||
for (FavoriteGroup group : groups) {
|
for (FavoriteGroup group : groups) {
|
||||||
if (group.visible) {
|
if (group.isVisible()) {
|
||||||
SearchResult sr = new SearchResult(phrase);
|
SearchResult sr = new SearchResult(phrase);
|
||||||
sr.localeName = Algorithms.isEmpty(group.name) ? baseGroupName : group.name;
|
sr.localeName = Algorithms.isEmpty(group.getName()) ? baseGroupName : group.getName();
|
||||||
sr.object = group;
|
sr.object = group;
|
||||||
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
|
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
|
||||||
sr.objectType = ObjectType.FAVORITE_GROUP;
|
sr.objectType = ObjectType.FAVORITE_GROUP;
|
||||||
sr.preferredZoom = 17;
|
sr.preferredZoom = 17;
|
||||||
if (phrase.getNameStringMatcher().matches(sr.localeName)) {
|
if (phrase.getNameStringMatcher().matches(sr.localeName)) {
|
||||||
if (group.points.size() < 5) {
|
if (group.getPoints().size() < 5) {
|
||||||
for (FavouritePoint point : group.points) {
|
for (FavouritePoint point : group.getPoints()) {
|
||||||
SearchResult srp = new SearchResult(phrase);
|
SearchResult srp = new SearchResult(phrase);
|
||||||
srp.localeName = point.getName();
|
srp.localeName = point.getName();
|
||||||
srp.object = point;
|
srp.object = point;
|
||||||
|
@ -302,7 +302,7 @@ public class QuickSearchHelper implements ResourceListener {
|
||||||
sr.preferredZoom = 17;
|
sr.preferredZoom = 17;
|
||||||
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)) {
|
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)) {
|
||||||
FavoriteGroup group = (FavoriteGroup) phrase.getLastSelectedWord().getResult().object;
|
FavoriteGroup group = (FavoriteGroup) phrase.getLastSelectedWord().getResult().object;
|
||||||
if (group != null && !point.getCategory().equals(group.name)) {
|
if (group != null && !point.getCategory().equals(group.getName())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -358,7 +358,7 @@ public class QuickSearchListItem {
|
||||||
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false, fav);
|
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false, fav);
|
||||||
case FAVORITE_GROUP:
|
case FAVORITE_GROUP:
|
||||||
FavoriteGroup group = (FavoriteGroup) searchResult.object;
|
FavoriteGroup group = (FavoriteGroup) searchResult.object;
|
||||||
int color = group.color == 0 || group.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.color;
|
int color = group.getColor() == 0 || group.getColor() == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.getColor();
|
||||||
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
|
return app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
|
||||||
case REGION:
|
case REGION:
|
||||||
return getIcon(app, R.drawable.ic_world_globe_dark);
|
return getIcon(app, R.drawable.ic_world_globe_dark);
|
||||||
|
|
|
@ -121,7 +121,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
|
||||||
for (FavoriteGroup group : favorites.getFavoriteGroups()) {
|
for (FavoriteGroup group : favorites.getFavoriteGroups()) {
|
||||||
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
|
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
|
||||||
boolean synced = mapMarkersHelper.getMarkersGroup(group) != null;
|
boolean synced = mapMarkersHelper.getMarkersGroup(group) != null;
|
||||||
for (FavouritePoint o : group.points) {
|
for (FavouritePoint o : group.getPoints()) {
|
||||||
double lat = o.getLatitude();
|
double lat = o.getLatitude();
|
||||||
double lon = o.getLongitude();
|
double lon = o.getLongitude();
|
||||||
if (o.isVisible() && o != contextMenuLayer.getMoveableObject()
|
if (o.isVisible() && o != contextMenuLayer.getMoveableObject()
|
||||||
|
|
Loading…
Reference in a new issue