Refactor favorite group

This commit is contained in:
Dima-1 2020-01-08 11:59:39 +02:00
parent ad7ec16aeb
commit 9a4f043a64
19 changed files with 114 additions and 129 deletions

View file

@ -856,7 +856,7 @@ public class OsmandAidlApi {
FavouritesDbHelper favoritesHelper = app.getFavorites();
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
for (FavouritesDbHelper.FavoriteGroup g : groups) {
if (g.name.equals(name)) {
if (g.getName().equals(name)) {
return false;
}
}
@ -872,7 +872,7 @@ public class OsmandAidlApi {
FavouritesDbHelper favoritesHelper = app.getFavorites();
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
for (FavouritesDbHelper.FavoriteGroup g : groups) {
if (g.name.equals(name)) {
if (g.getName().equals(name)) {
favoritesHelper.deleteGroup(g);
return true;
}
@ -884,7 +884,7 @@ public class OsmandAidlApi {
FavouritesDbHelper favoritesHelper = app.getFavorites();
List<FavouritesDbHelper.FavoriteGroup> groups = favoritesHelper.getFavoriteGroups();
for (FavouritesDbHelper.FavoriteGroup g : groups) {
if (g.name.equals(prevGroupName)) {
if (g.getName().equals(prevGroupName)) {
int color = 0;
if (!Algorithms.isEmpty(colorTag)) {
color = ColorDialogs.getColorByTag(colorTag);

View file

@ -67,10 +67,10 @@ public class FavouritesDbHelper {
public static class FavoriteGroup {
public static final String PERSONAL_CATEGORY = "personal";
protected String name;
protected boolean visible = true;
protected int color;
protected List<FavouritePoint> points = new ArrayList<>();
private String name;
private boolean visible = true;
private int color;
private List<FavouritePoint> points = new ArrayList<>();
public boolean isPersonal() {
return isPersonal(name);
@ -109,10 +109,10 @@ public class FavouritesDbHelper {
}
public String convertDisplayNameToGroupIdName(Context context, String name) {
if(name.equals(context.getString(R.string.personal_category_name))) {
if (name.equals(context.getString(R.string.personal_category_name))) {
return PERSONAL_CATEGORY;
}
if(name.equals(context.getString(R.string.shared_string_favorites))) {
if (name.equals(context.getString(R.string.shared_string_favorites))) {
return "";
}
return name;
@ -162,9 +162,9 @@ public class FavouritesDbHelper {
public FavouritePoint getSpecialPoint(FavouritePoint.SpecialPointType pointType) {
for (FavouritePoint fp : cachedFavoritePoints) {
if (fp.getSpecialPointType() == pointType) {
return fp;
}
return fp;
}
}
return null;
}
@ -194,7 +194,7 @@ public class FavouritesDbHelper {
private void runSyncWithMarkers(FavoriteGroup favGroup) {
MapMarkersHelper helper = context.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
if(group != null) {
if (group != null) {
helper.runSynchronization(group);
}
}
@ -202,7 +202,7 @@ public class FavouritesDbHelper {
private boolean removeFromMarkers(FavoriteGroup favGroup) {
MapMarkersHelper helper = context.getMapMarkersHelper();
MapMarkersGroup group = helper.getMarkersGroup(favGroup);
if(group != null) {
if (group != null) {
helper.removeMarkersGroup(group);
return true;
}
@ -305,8 +305,8 @@ public class FavouritesDbHelper {
public void lookupAddressAllSpecialPoints() {
if (!context.isApplicationInitializing()) {
for(FavouritePoint p : getFavouritePoints()) {
if(p.getSpecialPointType() != null) {
for (FavouritePoint p : getFavouritePoints()) {
if (p.getSpecialPointType() != null) {
lookupAddress(p);
}
}
@ -321,21 +321,21 @@ public class FavouritesDbHelper {
cancelAddressRequest(p);
request = new AddressLookupRequest(new LatLon(latitude, longitude),
new GeocodingLookupService.OnAddressLookupResult() {
@Override
public void geocodingDone(String address) {
addressRequestMap.remove(p);
editAddressDescription(p, address);
context.runInUIThread(new Runnable() {
@Override
public void run() {
for (FavoritesListener listener : listeners) {
listener.onFavoriteDataUpdated(p);
}
}
});
public void geocodingDone(String address) {
addressRequestMap.remove(p);
editAddressDescription(p, address);
context.runInUIThread(new Runnable() {
@Override
public void run() {
for (FavoritesListener listener : listeners) {
listener.onFavoriteDataUpdated(p);
}
}
});
}
}, null);
}
}, null);
addressRequestMap.put(p, request);
context.getGeocodingLookupService().lookupAddress(request);
}
@ -495,7 +495,7 @@ public class FavouritesDbHelper {
private void backup(File backupFile, File externalFile) {
try {
File f = new File(backupFile.getParentFile(), backupFile.getName());
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream( new FileOutputStream(f));
BZip2CompressorOutputStream out = new BZip2CompressorOutputStream(new FileOutputStream(f));
FileInputStream fis = new FileInputStream(externalFile);
Algorithms.streamCopy(fis, out);
fis.close();

View file

@ -535,7 +535,7 @@ public class MapMarkersHelper {
}
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) {
@ -543,7 +543,7 @@ public class MapMarkersHelper {
}
private String getMarkerGroupId(FavoriteGroup group) {
return group.name;
return group.getName();
}
@NonNull
@ -1161,13 +1161,13 @@ public class MapMarkersHelper {
if (favGroup == null) {
return;
}
group.visible = favGroup.visible;
group.visible = favGroup.isVisible();
if (!group.isVisible() || group.isDisabled()) {
removeGroupActiveMarkers(group, true);
return;
}
for (FavouritePoint fp : favGroup.points) {
for (FavouritePoint fp : favGroup.getPoints()) {
addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null);
}

View file

@ -18,7 +18,6 @@ import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@ -61,7 +60,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
if (group == null) {
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()
.setIcon(getContentIcon(R.drawable.ic_action_edit_dark))
@ -76,7 +75,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
b.setTitle(R.string.favorite_category_name);
final EditText nameEditText = new EditText(activity);
nameEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
nameEditText.setText(group.name);
nameEditText.setText(group.getName());
LinearLayout container = new LinearLayout(activity);
int sidePadding = AndroidUtils.dpToPx(activity, 24f);
int topPadding = AndroidUtils.dpToPx(activity, 4f);
@ -88,10 +87,10 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
@Override
public void onClick(DialogInterface dialog, int which) {
String name = nameEditText.getText().toString();
boolean nameChanged = !Algorithms.objectEquals(group.name, name);
boolean nameChanged = !Algorithms.objectEquals(group.getName(), name);
if (nameChanged) {
app.getFavorites()
.editFavouriteGroup(group, name, group.color, group.visible);
.editFavouriteGroup(group, name, group.getColor(), group.isVisible());
updateParentFragment();
}
dismiss();
@ -135,9 +134,9 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Integer color = colorAdapter.getItem(position);
if (color != null) {
if (color != group.color) {
if (color != group.getColor()) {
app.getFavorites()
.editFavouriteGroup(group, group.name, color, group.visible);
.editFavouriteGroup(group, group.getName(), color, group.isVisible());
updateParentFragment();
}
}
@ -153,16 +152,16 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
items.add(changeColorItem);
BaseBottomSheetItem showOnMapItem = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(group.visible)
.setChecked(group.isVisible())
.setIcon(getContentIcon(R.drawable.ic_map))
.setTitle(getString(R.string.shared_string_show_on_map))
.setLayoutId(R.layout.bottom_sheet_item_with_switch)
.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean visible = !group.visible;
boolean visible = !group.isVisible();
app.getFavorites()
.editFavouriteGroup(group, group.name, group.color, visible);
.editFavouriteGroup(group, group.getName(), group.getColor(), visible);
updateParentFragment();
dismiss();
}
@ -170,7 +169,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
.create();
items.add(showOnMapItem);
if (group.points.size() > 0) {
if (group.getPoints().size() > 0) {
items.add(new DividerHalfItem(getContext()));
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
@ -240,7 +239,7 @@ public class EditFavoriteGroupDialogFragment extends MenuBottomSheetDialogFragme
}
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) {
colorImageView.setImageDrawable(getContentIcon(R.drawable.ic_action_circle));
} else {

View file

@ -328,14 +328,14 @@ public class FavoritesSearchFragment extends DialogFragment {
Set<?> flt = filter;
for (FavoriteGroup key : gs) {
if (flt == null || flt.contains(key)) {
for (FavouritePoint p : key.points) {
for (FavouritePoint p : key.getPoints()) {
if (p.isVisible()) {
points.add(p);
}
}
} else {
ArrayList<FavouritePoint> list = new ArrayList<>();
for (FavouritePoint p : key.points) {
for (FavouritePoint p : key.getPoints()) {
if (p.isVisible() && flt.contains(p)) {
list.add(p);
}
@ -517,15 +517,15 @@ public class FavoritesSearchFragment extends DialogFragment {
String cs = constraint.toString().toLowerCase();
for (FavoriteGroup g : helper.getFavoriteGroups()) {
String gName;
if (Algorithms.isEmpty(g.name)) {
if (Algorithms.isEmpty(g.getName())) {
gName = favorites;
} else {
gName = g.name.toLowerCase();
gName = g.getName().toLowerCase();
}
if (g.visible && gName.contains(cs)) {
if (g.isVisible() && gName.contains(cs)) {
filter.add(g);
} else {
for (FavouritePoint fp : g.points) {
for (FavouritePoint fp : g.getPoints()) {
if (fp.isVisible() && fp.getName().toLowerCase().contains(cs)) {
filter.add(fp);
}

View file

@ -209,14 +209,14 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
listView.setOnGroupCollapseListener(new ExpandableListView.OnGroupCollapseListener() {
@Override
public void onGroupCollapse(int groupPosition) {
String groupName = favouritesAdapter.getGroup(groupPosition).name;
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
getGroupExpandedPreference(groupName).set(false);
}
});
listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
String groupName = favouritesAdapter.getGroup(groupPosition).name;
String groupName = favouritesAdapter.getGroup(groupPosition).getName();
getGroupExpandedPreference(groupName).set(true);
}
});
@ -232,7 +232,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
int selection = listView.getHeaderViewsCount();
for (int i = 0; i < groupPos; i++) {
selection++; // because of group header
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).name).get()) {
if (getGroupExpandedPreference(favouritesAdapter.getGroup(i).getName()).get()) {
selection += favouritesAdapter.getChildrenCount(i);
}
}
@ -314,16 +314,16 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
FavoriteGroup group = favouritesAdapter.getGroup(groupPosition);
ch.setChecked(!ch.isChecked());
if (ch.isChecked()) {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
if (set != null) {
set.add(model);
} else {
set = new LinkedHashSet<>();
set.add(model);
favoritesSelected.put(group.name, set);
favoritesSelected.put(group.getName(), set);
}
} else {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
if (set != null) {
set.remove(model);
}
@ -451,7 +451,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
List<PointDescription> names = new ArrayList<>();
for (Map.Entry<String, Set<FavouritePoint>> entry : favoritesSelected.entrySet()) {
FavoriteGroup favGr = helper.getGroup(entry.getKey());
if (entry.getValue().size() == favGr.points.size()) {
if (entry.getValue().size() == favGr.getPoints().size()) {
markersHelper.addOrEnableGroup(favGr);
} else {
for (FavouritePoint fp : entry.getValue()) {
@ -539,8 +539,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
StringBuilder html = new StringBuilder();
html.append("<h1>My Favorites</h1>");
for (FavoriteGroup group : groups) {
html.append("<h3>" + group.name + "</h3>");
for (FavouritePoint fp : group.points) {
html.append("<h3>" + group.getName() + "</h3>");
for (FavouritePoint fp : group.getPoints()) {
String url = "geo:" + ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "?m=" + fp.getName();
html.append("<p>" + fp.getName() + " - " + "<a href=\"" + url + "\">geo:"
+ ((float) fp.getLatitude()) + "," + ((float) fp.getLongitude()) + "</a><br>");
@ -589,7 +589,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
@Override
protected Void doInBackground(Void... params) {
if (group != null) {
helper.saveFile(group.points, dst);
helper.saveFile(group.getPoints(), dst);
}
return null;
}
@ -681,7 +681,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
private void initListExpandedState() {
for (int i = 0; i < favouritesAdapter.getGroupCount(); i++) {
String groupName = favouritesAdapter.getGroup(i).name;
String groupName = favouritesAdapter.getGroup(i).getName();
if (getGroupExpandedPreference(groupName).get()) {
listView.expandGroup(i);
} else {
@ -755,10 +755,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
boolean empty = true;
if (flt == null || flt.contains(key)) {
empty = false;
favoriteGroups.put(key, new ArrayList<>(key.points));
favoriteGroups.put(key, new ArrayList<>(key.getPoints()));
} else {
ArrayList<FavouritePoint> list = new ArrayList<>();
for (FavouritePoint p : key.points) {
for (FavouritePoint p : key.getPoints()) {
if (flt.contains(p)) {
list.add(p);
empty = false;
@ -767,7 +767,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
favoriteGroups.put(key, list);
}
if (!empty) {
if (key.visible) {
if (key.isVisible()) {
groups.add(key);
} else {
disablesGroups.add(key);
@ -831,11 +831,11 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
OsmandApplication app = getMyApplication();
boolean light = app.getSettings().isLightContent();
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 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);
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()) {
setCategoryIcon(app, app.getUIUtilities().getPaintedIcon(
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
@ -850,7 +850,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
} else {
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) {
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() {
@Override
public void onClick(View v) {
List<FavouritePoint> fvs = model.points;
List<FavouritePoint> fvs = model.getPoints();
if (ch.isChecked()) {
groupsToDelete.add(model);
if (fvs != null) {
Set<FavouritePoint> set = favoritesSelected.get(model.name);
Set<FavouritePoint> set = favoritesSelected.get(model.getName());
if (set != null) {
set.addAll(model.points);
set.addAll(model.getPoints());
} else {
set = new LinkedHashSet<>(model.points);
favoritesSelected.put(model.name, set);
set = new LinkedHashSet<>(model.getPoints());
favoritesSelected.put(model.getName(), set);
}
}
} else {
groupsToDelete.remove(model);
favoritesSelected.remove(model.name);
favoritesSelected.remove(model.getName());
}
favouritesAdapter.notifyDataSetInvalidated();
updateSelectionMode(actionMode);
@ -895,7 +895,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
ch.setOnClickListener(new View.OnClickListener() {
@Override
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);
if (selectionMode) {
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);
ch.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (ch.isChecked()) {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
if (set != null) {
set.add(model);
} else {
set = new LinkedHashSet<>();
set.add(model);
favoritesSelected.put(group.name, set);
favoritesSelected.put(group.getName(), set);
}
} else {
Set<FavouritePoint> set = favoritesSelected.get(group.name);
Set<FavouritePoint> set = favoritesSelected.get(group.getName());
if (set != null) {
groupsToDelete.remove(group);
getGroupPosition(group.name);
getGroupPosition(group.getName());
set.remove(model);
favouritesAdapter.notifyDataSetInvalidated();
}
@ -1026,7 +1026,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
public int getGroupPosition(String groupName) {
for (int i = 0; i < getGroupCount(); i++) {
FavoriteGroup group = getGroup(i);
if (group.name.equals(groupName)) {
if (group.getName().equals(groupName)) {
return i;
}
}
@ -1050,10 +1050,10 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment implemen
Set<Object> filter = new HashSet<>();
String cs = constraint.toString().toLowerCase();
for (FavoriteGroup g : helper.getFavoriteGroups()) {
if (g.name.toLowerCase().contains(cs)) {
if (g.getName().toLowerCase().contains(cs)) {
filter.add(g);
} else {
for (FavouritePoint fp : g.points) {
for (FavouritePoint fp : g.getPoints()) {
if (fp.getName().toLowerCase().contains(cs)) {
filter.add(fp);
}

View file

@ -49,7 +49,7 @@ public class FavoriteImageDrawable extends Drawable {
this.withShadow = withShadow;
this.synced = synced;
Resources res = ctx.getResources();
int overlayIconId = point.getOverlayIconId();
int overlayIconId = point != null ? point.getOverlayIconId() : 0;
if (overlayIconId != 0) {
personalPointBitmap = UiUtilities.tintDrawable(ResourcesCompat.getDrawable(res, overlayIconId, null),
ContextCompat.getColor(ctx, R.color.icon_color_default_light));

View file

@ -123,7 +123,7 @@ public class FavoriteDialogs {
List<FavoriteGroup> gs = helper.getFavoriteGroups();
final String[] list = new String[gs.size()];
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));

View file

@ -90,11 +90,11 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
private void buildGroupFavouritesView(View view) {
FavoriteGroup favoriteGroup = app.getFavorites().getGroup(fav);
List<FavouritePoint> groupFavourites = favoriteGroup.points;
List<FavouritePoint> groupFavourites = favoriteGroup.getPoints();
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;
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);
buildRow(view, app.getUIUtilities().getPaintedIcon(R.drawable.ic_action_folder, color), null, name, 0, null,
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) {
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++) {
final FavouritePoint point = points.get(i);
boolean selected = selectedPoint != null && selectedPoint.equals(point);
@ -187,7 +187,7 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FavoritesActivity.openFavoritesGroup(context, group.name);
FavoritesActivity.openFavoritesGroup(context, group.getName());
}
});
view.addView(button);

View file

@ -186,8 +186,8 @@ public class EditCategoryDialogFragment extends DialogFragment {
Bundle bundle = new Bundle();
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_NAME, group.name);
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.color);
bundle.putString(KEY_CTX_EDIT_CAT_NAME, group.getName());
bundle.putString(KEY_CTX_EDIT_CAT_COLOR, "" + group.getColor());
fragment.setArguments(bundle);
return fragment;
}

View file

@ -149,7 +149,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
if (helper != null) {
FavoriteGroup group = helper.getGroup(name);
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;
FavoriteGroup group = getGroup();
if (group != null) {
color = group.color;
color = group.getColor();
}
if (color == 0) {
color = defaultColor;

View file

@ -87,7 +87,7 @@ public class SelectCategoryDialogFragment extends DialogFragment {
} else {
List<FavouritesDbHelper.FavoriteGroup> gs = helper.getFavoriteGroups();
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 file

@ -52,8 +52,8 @@ public class AddFavouritesGroupBottomSheetDialogFragment extends AddGroupBottomS
@Override
protected void onItemClick(int position) {
FavoriteGroup group = favouritesDbHelper.getFavoriteGroups().get(position - 1);
if (!group.visible) {
favouritesDbHelper.editFavouriteGroup(group, group.name, group.color, true);
if (!group.isVisible()) {
favouritesDbHelper.editFavouriteGroup(group, group.getName(), group.getColor(), true);
}
getMyApplication().getMapMarkersHelper().addOrEnableGroup(group);
dismiss();

View file

@ -3,13 +3,8 @@ package net.osmand.plus.mapmarkers.adapters;
import android.content.Context;
import android.graphics.Color;
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.UiUtilities;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import java.util.List;
@ -32,9 +27,9 @@ public class FavouritesGroupsAdapter extends GroupsAdapter {
} else if (holder instanceof MapMarkersGroupViewHolder) {
FavoriteGroup favoriteGroup = getItem(position);
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.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()));
}
}

View file

@ -150,21 +150,12 @@ public class FavoriteAction extends QuickAction {
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);
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));
getParams().put(KEY_CATEGORY_NAME, group.getName());
getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.getColor()));
} else {

View file

@ -409,10 +409,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
hide();
} else if (word.getType() == ObjectType.FAVORITE_GROUP) {
FavouritesDbHelper.FavoriteGroup group = (FavouritesDbHelper.FavoriteGroup) word.getResult().object;
if (group.points.size() > 1) {
if (group.getPoints().size() > 1) {
double left = 0, right = 0;
double top = 0, bottom = 0;
for (FavouritePoint p : group.points) {
for (FavouritePoint p : group.getPoints()) {
if (left == 0) {
left = p.getLongitude();
right = p.getLongitude();
@ -429,8 +429,8 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
hideToolbar();
MapActivity.launchMapActivityMoveToTop(getActivity());
hide();
} else if (group.points.size() == 1) {
FavouritePoint p = group.points.get(0);
} else if (group.getPoints().size() == 1) {
FavouritePoint p = group.getPoints().get(0);
app.getSettings().setMapLocationToShow(p.getLatitude(), p.getLongitude(), word.getResult().preferredZoom);
hideToolbar();
MapActivity.launchMapActivityMoveToTop(getActivity());

View file

@ -235,16 +235,16 @@ public class QuickSearchHelper implements ResourceListener {
String baseGroupName = app.getString(R.string.shared_string_favorites);
List<FavoriteGroup> groups = app.getFavorites().getFavoriteGroups();
for (FavoriteGroup group : groups) {
if (group.visible) {
if (group.isVisible()) {
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.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
sr.objectType = ObjectType.FAVORITE_GROUP;
sr.preferredZoom = 17;
if (phrase.getNameStringMatcher().matches(sr.localeName)) {
if (group.points.size() < 5) {
for (FavouritePoint point : group.points) {
if (group.getPoints().size() < 5) {
for (FavouritePoint point : group.getPoints()) {
SearchResult srp = new SearchResult(phrase);
srp.localeName = point.getName();
srp.object = point;
@ -302,7 +302,7 @@ public class QuickSearchHelper implements ResourceListener {
sr.preferredZoom = 17;
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)) {
FavoriteGroup group = (FavoriteGroup) phrase.getLastSelectedWord().getResult().object;
if (group != null && !point.getCategory().equals(group.name)) {
if (group != null && !point.getCategory().equals(group.getName())) {
continue;
}
}

View file

@ -358,7 +358,7 @@ public class QuickSearchListItem {
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false, fav);
case FAVORITE_GROUP:
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);
case REGION:
return getIcon(app, R.drawable.ic_world_globe_dark);

View file

@ -121,7 +121,7 @@ public class FavouritesLayer extends OsmandMapLayer implements ContextMenuLayer.
for (FavoriteGroup group : favorites.getFavoriteGroups()) {
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
boolean synced = mapMarkersHelper.getMarkersGroup(group) != null;
for (FavouritePoint o : group.points) {
for (FavouritePoint o : group.getPoints()) {
double lat = o.getLatitude();
double lon = o.getLongitude();
if (o.isVisible() && o != contextMenuLayer.getMoveableObject()