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_selected="true"/>
|
||||
<item android:drawable="@color/list_item_light_pressed" android:state_pressed="true"/>
|
||||
|
||||
</selector>
|
|
@ -5,6 +5,7 @@
|
|||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:osmand="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:theme="@style/FreeVersionBanner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/osmo_header_dark"
|
||||
|
|
|
@ -1986,4 +1986,16 @@
|
|||
<string name="poi_industrial_timber">類型:木材</string>
|
||||
<string name="poi_industrial_refinery">類型:煉油廠</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>
|
||||
|
|
|
@ -137,6 +137,11 @@
|
|||
<item name="colorAccent">@color/color_white</item>
|
||||
</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">
|
||||
<item name="list_divider">@color/list_divider_light</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.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
@ -20,13 +21,13 @@ import net.osmand.plus.voice.MediaCommandPlayerImpl;
|
|||
import net.osmand.plus.voice.TTSCommandPlayerImpl;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
|
||||
public class LocalIndexHelper {
|
||||
|
||||
private final OsmandApplication app;
|
||||
|
||||
|
||||
|
||||
public LocalIndexHelper(OsmandApplication app){
|
||||
this.app = app;
|
||||
|
@ -38,11 +39,11 @@ public class LocalIndexHelper {
|
|||
}
|
||||
|
||||
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){
|
||||
return app.getResourceManager().getDateFormat().format(new Date(t));
|
||||
return android.text.format.DateFormat.getMediumDateFormat(app).format(new Date(t));
|
||||
}
|
||||
|
||||
public void updateDescription(LocalIndexInfo info){
|
||||
|
@ -50,7 +51,12 @@ public class LocalIndexHelper {
|
|||
if(info.getType() == LocalIndexType.MAP_DATA){
|
||||
Map<String, String> ifns = app.getResourceManager().getIndexFileNames();
|
||||
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 {
|
||||
info.setDescription(getInstalledDate(f));
|
||||
}
|
||||
|
@ -199,30 +205,36 @@ public class LocalIndexHelper {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public enum LocalIndexType {
|
||||
MAP_DATA(R.string.local_indexes_cat_map),
|
||||
TILES_DATA(R.string.local_indexes_cat_tile),
|
||||
SRTM_DATA(R.string.local_indexes_cat_srtm),
|
||||
WIKI_DATA(R.string.local_indexes_cat_wiki),
|
||||
VOICE_DATA(R.string.local_indexes_cat_voice),
|
||||
TTS_VOICE_DATA(R.string.local_indexes_cat_tts);
|
||||
SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm),
|
||||
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia),
|
||||
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up),
|
||||
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up);
|
||||
// AV_DATA(R.string.local_indexes_cat_av);;
|
||||
|
||||
private final int resId;
|
||||
|
||||
private LocalIndexType(int resId){
|
||||
@StringRes
|
||||
private final int resId;
|
||||
@DrawableRes
|
||||
private int iconResource;
|
||||
|
||||
private LocalIndexType(@StringRes int resId, @DrawableRes int iconResource){
|
||||
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){
|
||||
return ctx.getString(resId);
|
||||
}
|
||||
public int getIconResource() {
|
||||
return iconResource;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,13 +78,18 @@ public class DownloadActivity extends BaseDownloadActivity {
|
|||
updateDescriptionTextWithSize(this, downloadProgressLayout);
|
||||
int currentTab = DOWNLOAD_TAB_NUMBER;
|
||||
String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN);
|
||||
|
||||
if (tab != null) {
|
||||
if (tab.equals(DOWNLOAD_TAB)) {
|
||||
currentTab = DOWNLOAD_TAB_NUMBER;
|
||||
} else if (tab.equals(LOCAL_TAB)) {
|
||||
currentTab = LOCAL_TAB_NUMBER;
|
||||
} else if (tab.equals(UPDATES_TAB)) {
|
||||
currentTab = UPDATES_TAB_NUMBER;
|
||||
switch (tab) {
|
||||
case DOWNLOAD_TAB:
|
||||
currentTab = DOWNLOAD_TAB_NUMBER;
|
||||
break;
|
||||
case LOCAL_TAB:
|
||||
currentTab = LOCAL_TAB_NUMBER;
|
||||
break;
|
||||
case UPDATES_TAB:
|
||||
currentTab = UPDATES_TAB_NUMBER;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -390,6 +390,7 @@ public class DownloadIndexesThread {
|
|||
List<File> filesToReindex = new ArrayList<File>();
|
||||
boolean forceWifi = downloadFileHelper.isWifiConnected();
|
||||
Set<IndexItem> currentDownloads = new HashSet<IndexItem>();
|
||||
String warn = "";
|
||||
try {
|
||||
downloadCycle: while (!indexItemDownloading.isEmpty()) {
|
||||
IndexItem item = indexItemDownloading.poll();
|
||||
|
@ -419,14 +420,24 @@ public class DownloadIndexesThread {
|
|||
}
|
||||
// trackEvent(entry);
|
||||
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 {
|
||||
currentDownloadingItem = null;
|
||||
currentDownloadingItemProgress = 0;
|
||||
}
|
||||
String warn = reindexFiles(filesToReindex);
|
||||
return warn;
|
||||
//String warn = reindexFiles(filesToReindex);
|
||||
if(warn.trim().length() == 0) {
|
||||
return null;
|
||||
}
|
||||
return warn.trim();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.info("Download Interrupted");
|
||||
// do not dismiss dialog
|
||||
|
|
|
@ -124,6 +124,10 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
|
||||
protected void updateFilesToUpdate() {
|
||||
initAlreadyLoadedFiles();
|
||||
recalculateFilesToUpdate();
|
||||
}
|
||||
|
||||
private void recalculateFilesToUpdate() {
|
||||
List<IndexItem> stillUpdate = new ArrayList<IndexItem>();
|
||||
for (IndexItem item : itemsToUpdate) {
|
||||
String sfName = item.getTargetFileName();
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -68,6 +67,8 @@ import java.text.Collator;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
|
@ -79,6 +80,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
|
||||
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
|
||||
private LoadLocalIndexTask asyncLoader;
|
||||
private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>();
|
||||
private LocalIndexesAdapter listAdapter;
|
||||
private AsyncTask<LocalIndexInfo, ?, ?> operationTask;
|
||||
|
||||
|
@ -161,6 +163,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
}
|
||||
|
||||
public void reloadData() {
|
||||
List<IndexItem> itemsToUpdate = getDownloadActivity().getDownloadThread().getIndexes().getItemsToUpdate();
|
||||
filesToUpdate.clear();
|
||||
for(IndexItem ii : itemsToUpdate) {
|
||||
filesToUpdate.put(ii.getTargetFileName(), ii);
|
||||
}
|
||||
LoadLocalIndexTask current = asyncLoader;
|
||||
if(current == null || current.getStatus() == AsyncTask.Status.FINISHED ||
|
||||
current.isCancelled() || current.getResult() != null) {
|
||||
|
@ -1032,7 +1039,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
if (child.isBackupedData()) {
|
||||
icon.setImageDrawable(backup);
|
||||
} 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));
|
||||
|
@ -1050,6 +1058,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
nameTextView.setTypeface(Typeface.DEFAULT, Typeface.NORMAL);
|
||||
}
|
||||
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() > 100) {
|
||||
builder.append(DownloadActivity.formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)}));
|
||||
|
@ -1059,11 +1073,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
builder.append(" • ");
|
||||
}
|
||||
|
||||
final String mapDescription = getMapDescription(child.getFileName());
|
||||
if (mapDescription.length() > 0) {
|
||||
builder.append(mapDescription).append(" • ");
|
||||
}
|
||||
|
||||
if (child.getType() == LocalIndexType.TILES_DATA) {
|
||||
builder.append(ctx.getString(R.string.online_map));
|
||||
} else {
|
||||
|
@ -1092,6 +1101,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
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;
|
||||
}
|
||||
});
|
||||
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)
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_delete_dark));
|
||||
|
@ -1133,7 +1162,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
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")
|
||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
|
|
Loading…
Reference in a new issue