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) {
if (!isGroupSynced(group.getId())) {
markersDbHelper.addGroup(group);
addHistoryMarkersToGroup(group);
addToGroupsList(group);
} else if (group.wptCategories != null) {
markersDbHelper.updateGroupCategories(group.getId(), group.getWptCategoriesString());
@ -317,6 +318,15 @@ public class MapMarkersHelper {
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) {
if (group != null) {
markersDbHelper.removeMarkersGroup(group.getId());

View file

@ -300,7 +300,8 @@ public class MapMarkersDbHelper {
if (db != null) {
try {
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 {
db.close();
}
@ -408,8 +409,8 @@ public class MapMarkersDbHelper {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
new String[]{String.valueOf(1), String.valueOf(0)});
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(1)});
if (query.moveToFirst()) {
do {
MapMarker marker = readItem(query);
@ -567,8 +568,8 @@ public class MapMarkersDbHelper {
SQLiteConnection db = openConnection(true);
if (db != null) {
try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ? " + "AND " + MARKERS_COL_DISABLED + " = ?",
new String[]{String.valueOf(0), String.valueOf(0)});
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(0)});
if (query.moveToFirst()) {
do {
markers.add(readItem(query));

View file

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