Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2018-03-22 12:47:42 +01:00
commit 026f55d4eb
3 changed files with 19 additions and 5 deletions

View file

@ -310,6 +310,7 @@ public class MapMarkersHelper {
public void syncWithMarkers(@NonNull MapMarkersGroup group) { public void syncWithMarkers(@NonNull MapMarkersGroup group) {
if (!isGroupSynced(group.getId())) { if (!isGroupSynced(group.getId())) {
markersDbHelper.addGroup(group); markersDbHelper.addGroup(group);
addHistoryMarkersToGroup(group);
addToGroupsList(group); addToGroupsList(group);
} else if (group.wptCategories != null) { } else if (group.wptCategories != null) {
markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString()); markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString());
@ -317,6 +318,15 @@ public class MapMarkersHelper {
runSynchronization(group); runSynchronization(group);
} }
private void addHistoryMarkersToGroup(@NonNull MapMarkersGroup group) {
List<MapMarker> historyMarkers = new ArrayList<>(mapMarkersHistory);
for (MapMarker m : historyMarkers) {
if (m.groupKey != null && group.getId() != null && m.groupKey.equals(group.getId())) {
group.getMarkers().add(m);
}
}
}
public void removeMarkersGroup(MapMarkersGroup group) { public void removeMarkersGroup(MapMarkersGroup group) {
if (group != null) { if (group != null) {
markersDbHelper.removeMarkersGroup(group.getId()); markersDbHelper.removeMarkersGroup(group.getId());

View file

@ -300,7 +300,8 @@ public class MapMarkersDbHelper {
if (db != null) { if (db != null) {
try { try {
db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[]{1}); db.execSQL("DELETE FROM " + GROUPS_TABLE_NAME + " WHERE " + GROUPS_COL_DISABLED + " = ? ", new Object[]{1});
db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME + " WHERE " + MARKERS_COL_DISABLED + " = ? ", new Object[]{1}); db.execSQL("DELETE FROM " + MARKERS_TABLE_NAME
+ " WHERE " + MARKERS_COL_DISABLED + " = ? AND " + MARKERS_COL_ACTIVE + " = ?", new Object[]{1, 1});
} finally { } finally {
db.close(); db.close();
} }
@ -408,8 +409,8 @@ public class MapMarkersDbHelper {
SQLiteConnection db = openConnection(true); SQLiteConnection db = openConnection(true);
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?", SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(1), String.valueOf(0)}); new String[]{String.valueOf(1)});
if (query.moveToFirst()) { if (query.moveToFirst()) {
do { do {
MapMarker marker = readItem(query); MapMarker marker = readItem(query);
@ -567,8 +568,8 @@ public class MapMarkersDbHelper {
SQLiteConnection db = openConnection(true); SQLiteConnection db = openConnection(true);
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?", SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(0), String.valueOf(0)}); new String[]{String.valueOf(0)});
if (query.moveToFirst()) { if (query.moveToFirst()) {
do { do {
markers.add(readItem(query)); markers.add(readItem(query));

View file

@ -51,6 +51,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] selectAllItem = new BottomSheetItemWithCompoundButton[1];
selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() selectAllItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(true)
.setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size()) .setDescription(getString(R.string.shared_string_total) + ": " + gpxFile.getPoints().size())
.setIcon(getContentIcon(R.drawable.ic_action_group_select_all)) .setIcon(getContentIcon(R.drawable.ic_action_group_select_all))
.setTitle(getString(R.string.shared_string_select_all)) .setTitle(getString(R.string.shared_string_select_all))
@ -75,6 +76,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
for (String category : pointsByCategories.keySet()) { for (String category : pointsByCategories.keySet()) {
final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] categoryItem = new BottomSheetItemWithCompoundButton[1];
categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() categoryItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setChecked(true)
.setOnCheckedChangeListener(new OnCheckedChangeListener() { .setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -100,6 +102,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee
.create(); .create();
items.add(categoryItem[0]); items.add(categoryItem[0]);
categoryItems.add(categoryItem[0]); categoryItems.add(categoryItem[0]);
selectedCategories.add(category);
} }
} }