diff --git a/OsmAnd/src/net/osmand/plus/GPXDatabase.java b/OsmAnd/src/net/osmand/plus/GPXDatabase.java index d81cbfca91..808bfd4cfc 100644 --- a/OsmAnd/src/net/osmand/plus/GPXDatabase.java +++ b/OsmAnd/src/net/osmand/plus/GPXDatabase.java @@ -13,7 +13,7 @@ import java.util.List; public class GPXDatabase { private static final String DB_NAME = "gpx_database"; - private static final int DB_VERSION = 4; + private static final int DB_VERSION = 5; private static final String GPX_TABLE_NAME = "gpxTable"; private static final String GPX_COL_NAME = "fileName"; private static final String GPX_COL_DIR = "fileDir"; @@ -183,11 +183,43 @@ public class GPXDatabase { db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_TYPE + " int"); db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double"); } - - if (oldVersion < 3) { - List items = getItems(); - for (GpxDataItem item : items) { - updateLastModifiedTime(item); + + if (oldVersion < 5) { + boolean colorColumnExists = false; + boolean fileLastModifiedTimeColumnExists = false; + boolean splitTypeColumnExists = false; + boolean splitIntervalColumnExists = false; + SQLiteCursor cursor = db.rawQuery("PRAGMA table_info(" + GPX_TABLE_NAME + ")", null); + if (cursor.moveToFirst()) { + do { + String columnName = cursor.getString(1); + if (!colorColumnExists && columnName.equals(GPX_COL_COLOR)) { + colorColumnExists = true; + } else if (!fileLastModifiedTimeColumnExists && columnName.equals(GPX_COL_FILE_LAST_MODIFIED_TIME)) { + fileLastModifiedTimeColumnExists = true; + } else if (!splitTypeColumnExists && columnName.equals(GPX_COL_SPLIT_TYPE)) { + splitTypeColumnExists = true; + } else if (!splitIntervalColumnExists && columnName.equals(GPX_COL_SPLIT_INTERVAL)) { + splitIntervalColumnExists = true; + } + } while (cursor.moveToNext()); + } + cursor.close(); + if (!colorColumnExists) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_COLOR + " TEXT"); + } + if (!fileLastModifiedTimeColumnExists) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_FILE_LAST_MODIFIED_TIME + " long"); + List items = getItems(); + for (GpxDataItem item : items) { + updateLastModifiedTime(item); + } + } + if (!splitTypeColumnExists) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_TYPE + " int"); + } + if (!splitIntervalColumnExists) { + db.execSQL("ALTER TABLE " + GPX_TABLE_NAME + " ADD " + GPX_COL_SPLIT_INTERVAL + " double"); } } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index 48aab1fe8c..6a701a283a 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -165,7 +165,7 @@ public class DashTrackFragment extends DashBaseFragment { info.subfolder = ""; info.file = f; View v = inflater.inflate(R.layout.dash_gpx_track_item, null, false); - AvailableGPXFragment.udpateGpxInfoView(v, info, app, true); + AvailableGPXFragment.updateGpxInfoView(v, info, app, true); v.setOnClickListener(new View.OnClickListener() { @Override @@ -257,7 +257,7 @@ public class DashTrackFragment extends DashBaseFragment { AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo(); info.subfolder = ""; info.file = f; - AvailableGPXFragment.udpateGpxInfoView(pView, info, app, true); + AvailableGPXFragment.updateGpxInfoView(pView, info, app, true); updateShowOnMap(app, f, v, showOnMap); } }); diff --git a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java index ad6d7bd6d3..2d889eef05 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/AvailableGPXFragment.java @@ -1048,7 +1048,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { LayoutInflater inflater = getActivity().getLayoutInflater(); v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false); } - udpateGpxInfoView(v, child, app, false); + updateGpxInfoView(v, child, app, false); ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageButton options = (ImageButton) v.findViewById(R.id.options); @@ -1752,7 +1752,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } } - public static void udpateGpxInfoView(View v, GpxInfo child, OsmandApplication app, boolean isDashItem) { + public static void updateGpxInfoView(View v, GpxInfo child, OsmandApplication app, boolean isDashItem) { TextView viewName = ((TextView) v.findViewById(R.id.name)); if (!isDashItem) { v.findViewById(R.id.divider_list).setVisibility(View.VISIBLE);