Small changes. Not building.

This commit is contained in:
GaidamakUA 2015-12-17 18:31:03 +02:00
parent 383d4b85e7
commit 22d13afe50
9 changed files with 47 additions and 24 deletions

View file

@ -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";

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
@ -12,14 +13,18 @@
android:padding="16dp">
<TextView
android:id="@+id/regionNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Flevoland"/>
tools:text="Flevoland"/>
<TextView
android:id="@+id/countryNameTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="The Netherlands"/>
tools:visibility="visible"
android:visibility="gone"
tools:text="The Netherlands"/>
<View
android:layout_width="match_parent"
@ -73,10 +78,10 @@
android:id="@+id/updateTimesOfDaySpinner"
android:layout_width="wrap_content"
android:layout_column="1"
android:layout_row="4"
android:layout_gravity="right"
android:visibility="gone"
android:entries="@array/update_times_of_day"/>
android:layout_row="4"
android:entries="@array/update_times_of_day"
android:visibility="gone"/>
</GridLayout>

View file

@ -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);
}

View file

@ -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<LocalIndexInfo> CREATOR = new Parcelable.Creator<LocalIndexInfo>() {
public static final Creator<LocalIndexInfo> CREATOR = new Creator<LocalIndexInfo>() {
public LocalIndexInfo createFromParcel(Parcel source) {
return new LocalIndexInfo(source);
}

View file

@ -334,7 +334,7 @@ public class DownloadActivityType {
}
return fileName;
}
public String getBasename(IndexItem indexItem) {
String fileName = indexItem.fileName;

View file

@ -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

View file

@ -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<LocalIndexInfo>());
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<LocalIndexInfo>());

View file

@ -327,7 +327,7 @@ public class LiveUpdatesFragment extends Fragment {
@Override
protected List<LocalIndexInfo> doInBackground(Void... params) {
LocalIndexHelper helper = new LocalIndexHelper(fragment.getMyActivity().getMyApplication());
return helper.getLocalIndexData(this);
return helper.getLocalFullMaps(this);
}
@Override

View file

@ -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<Boolean> liveUpdatePreference =
preferenceForLocalIndex(localIndexInfo);
final OsmandSettings.CommonPreference<Boolean> downloadViaWiFiPreference =