Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
6aa41aa074
9 changed files with 113 additions and 35 deletions
|
@ -3,5 +3,4 @@
|
||||||
<item android:drawable="@color/list_item_light_pressed" android:state_focused="true"/>
|
<item android:drawable="@color/list_item_light_pressed" android:state_focused="true"/>
|
||||||
<item android:drawable="@color/list_item_light_pressed" android:state_selected="true"/>
|
<item android:drawable="@color/list_item_light_pressed" android:state_selected="true"/>
|
||||||
<item android:drawable="@color/list_item_light_pressed" android:state_pressed="true"/>
|
<item android:drawable="@color/list_item_light_pressed" android:state_pressed="true"/>
|
||||||
|
|
||||||
</selector>
|
</selector>
|
|
@ -5,6 +5,7 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:theme="@style/FreeVersionBanner"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/osmo_header_dark"
|
android:background="@color/osmo_header_dark"
|
||||||
|
|
|
@ -1986,4 +1986,16 @@
|
||||||
<string name="poi_industrial_timber">類型:木材</string>
|
<string name="poi_industrial_timber">類型:木材</string>
|
||||||
<string name="poi_industrial_refinery">類型:煉油廠</string>
|
<string name="poi_industrial_refinery">類型:煉油廠</string>
|
||||||
<string name="poi_industrial_warehouse">類型:倉庫</string>
|
<string name="poi_industrial_warehouse">類型:倉庫</string>
|
||||||
|
<string name="poi_industrial_auto_wrecker">類型:車輛報廢廠</string>
|
||||||
|
<string name="poi_industrial_agriculture">類型:農耕</string>
|
||||||
|
<string name="poi_industrial_brewery">類型:啤酒廠</string>
|
||||||
|
<string name="poi_industrial_brickyard">類型:磚廠</string>
|
||||||
|
<string name="poi_industrial_intermodal_freight_terminal">類型:貨櫃集裝場</string>
|
||||||
|
<string name="poi_industrial_sawmill">類型:鋸木廠</string>
|
||||||
|
<string name="poi_industrial_water_purification">類型:水淨化廠</string>
|
||||||
|
<string name="poi_industrial_port">類型:港埠</string>
|
||||||
|
<string name="poi_industrial_depot">類型:車庫</string>
|
||||||
|
|
||||||
|
<string name="poi_note">注釋</string>
|
||||||
|
<string name="poi_watering_place">有水的地方</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -137,6 +137,11 @@
|
||||||
<item name="colorAccent">@color/color_white</item>
|
<item name="colorAccent">@color/color_white</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="FreeVersionBanner" parent="OsmandDarkTheme">
|
||||||
|
<item name="android:textColorSecondary">@color/color_white</item>
|
||||||
|
<item name="colorAccent">@color/map_widget_blue</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
<style name="OsmandDarkTheme" parent="Theme.AppCompat">
|
||||||
<item name="list_divider">@color/list_divider_light</item>
|
<item name="list_divider">@color/list_divider_light</item>
|
||||||
<item name="expandable_category_color">?android:attr/colorBackground</item>
|
<item name="expandable_category_color">?android:attr/colorBackground</item>
|
||||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.text.ParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -20,14 +21,14 @@ import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
||||||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.DrawableRes;
|
||||||
|
import android.support.annotation.StringRes;
|
||||||
|
|
||||||
|
|
||||||
public class LocalIndexHelper {
|
public class LocalIndexHelper {
|
||||||
|
|
||||||
private final OsmandApplication app;
|
private final OsmandApplication app;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public LocalIndexHelper(OsmandApplication app){
|
public LocalIndexHelper(OsmandApplication app){
|
||||||
this.app = app;
|
this.app = app;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +39,11 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstalledDateEdition(long t, TimeZone timeZone){
|
public String getInstalledDateEdition(long t, TimeZone timeZone){
|
||||||
return app.getString(R.string.local_index_installed) + ": " + app.getResourceManager().getDateFormat().format(new Date(t));
|
return android.text.format.DateFormat.getMediumDateFormat(app).format(new Date(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getInstalledDate(long t, TimeZone timeZone){
|
public String getInstalledDate(long t, TimeZone timeZone){
|
||||||
return app.getResourceManager().getDateFormat().format(new Date(t));
|
return android.text.format.DateFormat.getMediumDateFormat(app).format(new Date(t));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateDescription(LocalIndexInfo info){
|
public void updateDescription(LocalIndexInfo info){
|
||||||
|
@ -50,7 +51,12 @@ public class LocalIndexHelper {
|
||||||
if(info.getType() == LocalIndexType.MAP_DATA){
|
if(info.getType() == LocalIndexType.MAP_DATA){
|
||||||
Map<String, String> ifns = app.getResourceManager().getIndexFileNames();
|
Map<String, String> ifns = app.getResourceManager().getIndexFileNames();
|
||||||
if(ifns.containsKey(info.getFileName())) {
|
if(ifns.containsKey(info.getFileName())) {
|
||||||
info.setDescription(ifns.get(info.getFileName()));
|
try {
|
||||||
|
Date dt = app.getResourceManager().getDateFormat().parse(ifns.get(info.getFileName()));
|
||||||
|
info.setDescription(getInstalledDate(dt.getTime(), null));
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
info.setDescription(getInstalledDate(f));
|
info.setDescription(getInstalledDate(f));
|
||||||
}
|
}
|
||||||
|
@ -200,29 +206,35 @@ public class LocalIndexHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum LocalIndexType {
|
public enum LocalIndexType {
|
||||||
MAP_DATA(R.string.local_indexes_cat_map),
|
MAP_DATA(R.string.local_indexes_cat_map),
|
||||||
TILES_DATA(R.string.local_indexes_cat_tile),
|
TILES_DATA(R.string.local_indexes_cat_tile),
|
||||||
SRTM_DATA(R.string.local_indexes_cat_srtm),
|
SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm),
|
||||||
WIKI_DATA(R.string.local_indexes_cat_wiki),
|
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia),
|
||||||
VOICE_DATA(R.string.local_indexes_cat_voice),
|
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up),
|
||||||
TTS_VOICE_DATA(R.string.local_indexes_cat_tts);
|
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up);
|
||||||
// AV_DATA(R.string.local_indexes_cat_av);;
|
// AV_DATA(R.string.local_indexes_cat_av);;
|
||||||
|
|
||||||
|
@StringRes
|
||||||
private final int resId;
|
private final int resId;
|
||||||
|
@DrawableRes
|
||||||
|
private int iconResource;
|
||||||
|
|
||||||
private LocalIndexType(int resId){
|
private LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){
|
||||||
this.resId = resId;
|
this.resId = resId;
|
||||||
|
this.iconResource = iconResource;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalIndexType(@StringRes int resId){
|
||||||
|
this.resId = resId;
|
||||||
|
this.iconResource = R.drawable.ic_map;
|
||||||
}
|
}
|
||||||
public String getHumanString(Context ctx){
|
public String getHumanString(Context ctx){
|
||||||
return ctx.getString(resId);
|
return ctx.getString(resId);
|
||||||
}
|
}
|
||||||
|
public int getIconResource() {
|
||||||
|
return iconResource;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -78,13 +78,18 @@ public class DownloadActivity extends BaseDownloadActivity {
|
||||||
updateDescriptionTextWithSize(this, downloadProgressLayout);
|
updateDescriptionTextWithSize(this, downloadProgressLayout);
|
||||||
int currentTab = DOWNLOAD_TAB_NUMBER;
|
int currentTab = DOWNLOAD_TAB_NUMBER;
|
||||||
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
|
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
|
||||||
|
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
if (tab.equals(DOWNLOAD_TAB)) {
|
switch (tab) {
|
||||||
|
case DOWNLOAD_TAB:
|
||||||
currentTab = DOWNLOAD_TAB_NUMBER;
|
currentTab = DOWNLOAD_TAB_NUMBER;
|
||||||
} else if (tab.equals(LOCAL_TAB)) {
|
break;
|
||||||
|
case LOCAL_TAB:
|
||||||
currentTab = LOCAL_TAB_NUMBER;
|
currentTab = LOCAL_TAB_NUMBER;
|
||||||
} else if (tab.equals(UPDATES_TAB)) {
|
break;
|
||||||
|
case UPDATES_TAB:
|
||||||
currentTab = UPDATES_TAB_NUMBER;
|
currentTab = UPDATES_TAB_NUMBER;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -390,6 +390,7 @@ public class DownloadIndexesThread {
|
||||||
List<File> filesToReindex = new ArrayList<File>();
|
List<File> filesToReindex = new ArrayList<File>();
|
||||||
boolean forceWifi = downloadFileHelper.isWifiConnected();
|
boolean forceWifi = downloadFileHelper.isWifiConnected();
|
||||||
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
|
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
|
||||||
|
String warn = "";
|
||||||
try {
|
try {
|
||||||
downloadCycle: while (!indexItemDownloading.isEmpty()) {
|
downloadCycle: while (!indexItemDownloading.isEmpty()) {
|
||||||
IndexItem item = indexItemDownloading.poll();
|
IndexItem item = indexItemDownloading.poll();
|
||||||
|
@ -419,14 +420,24 @@ public class DownloadIndexesThread {
|
||||||
}
|
}
|
||||||
// trackEvent(entry);
|
// trackEvent(entry);
|
||||||
publishProgress(item);
|
publishProgress(item);
|
||||||
|
String wn = reindexFiles(filesToReindex);
|
||||||
|
if(!Algorithms.isEmpty(wn)) {
|
||||||
|
warn += " " + wn;
|
||||||
|
}
|
||||||
|
filesToReindex.clear();
|
||||||
|
// slow down but let update all button work properly
|
||||||
|
indexes.updateFilesToUpdate();;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
currentDownloadingItem = null;
|
currentDownloadingItem = null;
|
||||||
currentDownloadingItemProgress = 0;
|
currentDownloadingItemProgress = 0;
|
||||||
}
|
}
|
||||||
String warn = reindexFiles(filesToReindex);
|
//String warn = reindexFiles(filesToReindex);
|
||||||
return warn;
|
if(warn.trim().length() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return warn.trim();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
LOG.info("Download Interrupted");
|
LOG.info("Download Interrupted");
|
||||||
// do not dismiss dialog
|
// do not dismiss dialog
|
||||||
|
|
|
@ -124,6 +124,10 @@ public class DownloadResources extends DownloadResourceGroup {
|
||||||
|
|
||||||
protected void updateFilesToUpdate() {
|
protected void updateFilesToUpdate() {
|
||||||
initAlreadyLoadedFiles();
|
initAlreadyLoadedFiles();
|
||||||
|
recalculateFilesToUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void recalculateFilesToUpdate() {
|
||||||
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
|
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
|
||||||
for (IndexItem item : itemsToUpdate) {
|
for (IndexItem item : itemsToUpdate) {
|
||||||
String sfName = item.getTargetFileName();
|
String sfName = item.getTargetFileName();
|
||||||
|
|
|
@ -34,7 +34,6 @@ import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
import net.osmand.PlatformUtil;
|
import net.osmand.PlatformUtil;
|
||||||
|
@ -68,6 +67,8 @@ import java.text.Collator;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -79,6 +80,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
|
|
||||||
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
|
||||||
private LoadLocalIndexTask asyncLoader;
|
private LoadLocalIndexTask asyncLoader;
|
||||||
|
private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>();
|
||||||
private LocalIndexesAdapter listAdapter;
|
private LocalIndexesAdapter listAdapter;
|
||||||
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
|
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
|
||||||
|
|
||||||
|
@ -161,6 +163,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadData() {
|
public void reloadData() {
|
||||||
|
List<IndexItem> itemsToUpdate = getDownloadActivity().getDownloadThread().getIndexes().getItemsToUpdate();
|
||||||
|
filesToUpdate.clear();
|
||||||
|
for(IndexItem ii : itemsToUpdate) {
|
||||||
|
filesToUpdate.put(ii.getTargetFileName(), ii);
|
||||||
|
}
|
||||||
LoadLocalIndexTask current = asyncLoader;
|
LoadLocalIndexTask current = asyncLoader;
|
||||||
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
||||||
current.isCancelled() || current.getResult() != null) {
|
current.isCancelled() || current.getResult() != null) {
|
||||||
|
@ -1032,7 +1039,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
if (child.isBackupedData()) {
|
if (child.isBackupedData()) {
|
||||||
icon.setImageDrawable(backup);
|
icon.setImageDrawable(backup);
|
||||||
} else {
|
} else {
|
||||||
icon.setImageDrawable(sdcard);
|
int colorId = filesToUpdate.containsKey(child.getFileName()) ? R.color.color_distance : R.color.color_ok;
|
||||||
|
icon.setImageDrawable(getContentIcon(ctx, child.getType().getIconResource(), colorId));
|
||||||
}
|
}
|
||||||
|
|
||||||
nameTextView.setText(getNameToDisplay(child));
|
nameTextView.setText(getNameToDisplay(child));
|
||||||
|
@ -1050,6 +1058,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
nameTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
nameTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||||
}
|
}
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
final String mapDescription = getMapDescription(child.getFileName());
|
||||||
|
if (mapDescription.length() > 0) {
|
||||||
|
builder.append(mapDescription).append(" • ");
|
||||||
|
}
|
||||||
|
|
||||||
if (child.getSize() >= 0) {
|
if (child.getSize() >= 0) {
|
||||||
if (child.getSize() > 100) {
|
if (child.getSize() > 100) {
|
||||||
builder.append(DownloadActivity.formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)}));
|
builder.append(DownloadActivity.formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)}));
|
||||||
|
@ -1059,11 +1073,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
builder.append(" • ");
|
builder.append(" • ");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String mapDescription = getMapDescription(child.getFileName());
|
|
||||||
if (mapDescription.length() > 0) {
|
|
||||||
builder.append(mapDescription).append(" • ");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (child.getType() == LocalIndexType.TILES_DATA) {
|
if (child.getType() == LocalIndexType.TILES_DATA) {
|
||||||
builder.append(ctx.getString(R.string.online_map));
|
builder.append(ctx.getString(R.string.online_map));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1092,6 +1101,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
icon.setVisibility(View.VISIBLE);
|
icon.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Drawable getContentIcon(DownloadActivity context, int resourceId) {
|
||||||
|
return context.getMyApplication().getIconsCache().getContentIcon(resourceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable getContentIcon(DownloadActivity context, int resourceId, int colorId) {
|
||||||
|
return context.getMyApplication().getIconsCache().getIcon(resourceId, colorId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1123,6 +1140,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
final IndexItem update = filesToUpdate.get(info.getFileName());
|
||||||
|
if (update != null) {
|
||||||
|
item = optionsMenu.getMenu().add(R.string.shared_string_download)
|
||||||
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_import));
|
||||||
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
getDownloadActivity().startDownload(update);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
item = optionsMenu.getMenu().add(R.string.shared_string_delete)
|
item = optionsMenu.getMenu().add(R.string.shared_string_delete)
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
||||||
|
@ -1133,7 +1162,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
if (info.getType() == LocalIndexType.MAP_DATA && getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
||||||
item = optionsMenu.getMenu().add("Live updates")
|
item = optionsMenu.getMenu().add("Live updates")
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue