diff --git a/OsmAnd-java/src/net/osmand/map/WorldRegion.java b/OsmAnd-java/src/net/osmand/map/WorldRegion.java index b29756e797..b4460aeffc 100644 --- a/OsmAnd-java/src/net/osmand/map/WorldRegion.java +++ b/OsmAnd-java/src/net/osmand/map/WorldRegion.java @@ -1,12 +1,13 @@ package net.osmand.map; -import java.util.LinkedList; -import java.util.List; - import net.osmand.data.LatLon; import net.osmand.util.Algorithms; -public class WorldRegion { +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class WorldRegion implements Serializable { public static final String WORLD_BASEMAP = "world_basemap"; public static final String AFRICA_REGION_ID = "africa"; diff --git a/OsmAnd/res/layout/dialog_live_updates_item_settings.xml b/OsmAnd/res/layout/dialog_live_updates_item_settings.xml index c8958736e8..0dcd3e44ee 100644 --- a/OsmAnd/res/layout/dialog_live_updates_item_settings.xml +++ b/OsmAnd/res/layout/dialog_live_updates_item_settings.xml @@ -1,5 +1,6 @@ @@ -12,14 +13,18 @@ android:padding="16dp"> + tools:text="Flevoland"/> + tools:visibility="visible" + android:visibility="gone" + tools:text="The Netherlands"/> + android:layout_row="4" + android:entries="@array/update_times_of_day" + android:visibility="gone"/> diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index d6e4a16d20..9ae42f5b9d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -9,6 +9,7 @@ import android.support.annotation.StringRes; import net.osmand.IndexConstants; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; +import net.osmand.map.WorldRegion; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.SQLiteTileSource; @@ -121,7 +122,9 @@ public class LocalIndexHelper { if (voiceF.isDirectory() && !MediaCommandPlayerImpl.isMyData(voiceF) && (Build.VERSION.SDK_INT >= 4)) { LocalIndexInfo info = null; if (TTSCommandPlayerImpl.isMyData(voiceF)) { - info = new LocalIndexInfo(LocalIndexType.TTS_VOICE_DATA, voiceF, backup); + final String baseName = voiceF.getName(); + WorldRegion worldRegion = app.getRegions().getRegionDataByDownloadName(baseName); + info = new LocalIndexInfo(LocalIndexType.TTS_VOICE_DATA, voiceF, backup, worldRegion); } if(info != null) { updateDescription(info); @@ -135,7 +138,7 @@ public class LocalIndexHelper { for (File voiceF : listFilesSorted(voiceDir)) { if (voiceF.isDirectory() && MediaCommandPlayerImpl.isMyData(voiceF)) { LocalIndexInfo info = null; - info = new LocalIndexInfo(LocalIndexType.VOICE_DATA, voiceF, backup); + info = new LocalIndexInfo(LocalIndexType.VOICE_DATA, voiceF, backup, worldRegion); if(info != null){ updateDescription(info); result.add(info); @@ -150,12 +153,12 @@ public class LocalIndexHelper { if (tilesPath.canRead()) { for (File tileFile : listFilesSorted(tilesPath)) { if (tileFile.isFile() && tileFile.getName().endsWith(SQLiteTileSource.EXT)) { - LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup); + LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup, worldRegion); updateDescription(info); result.add(info); loadTask.loadFile(info); } else if (tileFile.isDirectory()) { - LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup); + LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.TILES_DATA, tileFile, backup, worldRegion); if(!TileSourceManager.isTileSourceMetaInfoExist(tileFile)){ info.setCorrupted(true); @@ -182,7 +185,7 @@ public class LocalIndexHelper { if (mapPath.canRead()) { for (File mapFile : listFilesSorted(mapPath)) { if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { - LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.SRTM_DATA, mapFile, false); + LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.SRTM_DATA, mapFile, false, worldRegion); updateDescription(info); result.add(info); loadTask.loadFile(info); @@ -195,7 +198,7 @@ public class LocalIndexHelper { if (mapPath.canRead()) { for (File mapFile : listFilesSorted(mapPath)) { if (mapFile.isFile() && mapFile.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) { - LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.WIKI_DATA, mapFile, false); + LocalIndexInfo info = new LocalIndexInfo(LocalIndexType.WIKI_DATA, mapFile, false, worldRegion); updateDescription(info); result.add(info); loadTask.loadFile(info); @@ -214,7 +217,7 @@ public class LocalIndexHelper { } else if(mapFile.getName().endsWith(IndexConstants.BINARY_WIKI_MAP_INDEX_EXT)) { lt = LocalIndexType.WIKI_DATA; } - LocalIndexInfo info = new LocalIndexInfo(lt, mapFile, backup); + LocalIndexInfo info = new LocalIndexInfo(lt, mapFile, backup, worldRegion); if(loadedMaps.containsKey(mapFile.getName()) && !backup){ info.setLoaded(true); } diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexInfo.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexInfo.java index e5b10e9653..97ace54227 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexInfo.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexInfo.java @@ -2,7 +2,9 @@ package net.osmand.plus.activities; import android.os.Parcel; import android.os.Parcelable; +import android.support.annotation.NonNull; +import net.osmand.map.WorldRegion; import net.osmand.plus.GPXUtilities.GPXFile; import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; @@ -24,12 +26,16 @@ public class LocalIndexInfo implements Parcelable { private boolean singleFile; private int kbSize = -1; + private final WorldRegion worldRegion; + // UI state expanded private boolean expanded; private GPXFile gpxFile; - public LocalIndexInfo(LocalIndexType type, File f, boolean backuped) { + public LocalIndexInfo(@NonNull LocalIndexType type, @NonNull File f, boolean backuped, + @NonNull WorldRegion worldRegion) { + this.worldRegion = worldRegion; pathToData = f.getAbsolutePath(); fileName = f.getName(); name = formatName(f.getName()); @@ -50,10 +56,12 @@ public class LocalIndexInfo implements Parcelable { } // Special domain object represents category - public LocalIndexInfo(LocalIndexType type, boolean backup, String subfolder) { + public LocalIndexInfo(@NonNull LocalIndexType type, boolean backup, @NonNull String subfolder, + @NonNull WorldRegion worldRegion) { this.type = type; backupedData = backup; this.subfolder = subfolder; + this.worldRegion = worldRegion; } public void setCorrupted(boolean corrupted) { @@ -177,6 +185,7 @@ public class LocalIndexInfo implements Parcelable { dest.writeString(this.fileName); dest.writeByte(singleFile ? (byte) 1 : (byte) 0); dest.writeInt(this.kbSize); + dest.writeSerializable(this.worldRegion); dest.writeByte(expanded ? (byte) 1 : (byte) 0); } @@ -194,10 +203,11 @@ public class LocalIndexInfo implements Parcelable { this.fileName = in.readString(); this.singleFile = in.readByte() != 0; this.kbSize = in.readInt(); + this.worldRegion = (WorldRegion) in.readSerializable(); this.expanded = in.readByte() != 0; } - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { + public static final Creator CREATOR = new Creator() { public LocalIndexInfo createFromParcel(Parcel source) { return new LocalIndexInfo(source); } diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java index 883886b506..80dd21a718 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivityType.java @@ -334,7 +334,7 @@ public class DownloadActivityType { } return fileName; } - + public String getBasename(IndexItem indexItem) { String fileName = indexItem.fileName; diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index cc380bd8b6..07cb032a8b 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -367,7 +367,7 @@ public class ItemViewHolder { tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA : LocalIndexType.VOICE_DATA; } - final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false); + final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false, worldRegion); AlertDialog.Builder confirm = new AlertDialog.Builder(context); confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 7da6bdfec4..3a52275f4b 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -787,7 +787,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement return i; } } - LocalIndexInfo newCat = new LocalIndexInfo(val.getType(), backuped, val.getSubfolder()); + LocalIndexInfo newCat = new LocalIndexInfo(val.getType(), backuped, val.getSubfolder(), worldRegion); category.add(newCat); data.put(newCat, new ArrayList()); return newCat; @@ -864,7 +864,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } if (found == -1) { found = category.size(); - category.add(new LocalIndexInfo(info.getType(), info.isBackupedData(), info.getSubfolder())); + category.add(new LocalIndexInfo(info.getType(), info.isBackupedData(), info.getSubfolder(), worldRegion)); } if (!data.containsKey(category.get(found))) { data.put(category.get(found), new ArrayList()); diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java index a4917e4271..16d7e2414c 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesFragment.java @@ -327,7 +327,7 @@ public class LiveUpdatesFragment extends Fragment { @Override protected List doInBackground(Void... params) { LocalIndexHelper helper = new LocalIndexHelper(fragment.getMyActivity().getMyApplication()); - return helper.getLocalIndexData(this); + return helper.getLocalFullMaps(this); } @Override diff --git a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java index 132db92a1c..0d7d7d4654 100644 --- a/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/liveupdates/LiveUpdatesSettingsDialogFragment.java @@ -15,6 +15,7 @@ import android.view.LayoutInflater; import android.view.View; import android.widget.AdapterView; import android.widget.Spinner; +import android.widget.TextView; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; @@ -45,11 +46,14 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment { View view = LayoutInflater.from(getActivity()) .inflate(R.layout.dialog_live_updates_item_settings, null); + final TextView regionNameTextView = (TextView) view.findViewById(R.id.regionNameTextView); + final TextView countryNameTextView = (TextView) view.findViewById(R.id.countryNameTextView); final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.liveUpdatesSwitch); final SwitchCompat downloadOverWiFiSwitch = (SwitchCompat) view.findViewById(R.id.downloadOverWiFiSwitch); final Spinner updateFrequencySpinner = (Spinner) view.findViewById(R.id.updateFrequencySpinner); final Spinner updateTimesOfDaySpinner = (Spinner) view.findViewById(R.id.updateTimesOfDaySpinner); + regionNameTextView.setText(localIndexInfo.getName()); final OsmandSettings.CommonPreference liveUpdatePreference = preferenceForLocalIndex(localIndexInfo); final OsmandSettings.CommonPreference downloadViaWiFiPreference =