Merge pull request #988 from Bars107/master

Bugfixes and improvements.
This commit is contained in:
Alexey Pelykh 2014-12-04 17:56:43 +02:00
commit eb917ea601
8 changed files with 65 additions and 34 deletions

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="no_internet_connection">Not possible to download. Please connect to Wi-Fi to proceed.</string>
<string name="dismiss">Dismiss</string> <string name="dismiss">Dismiss</string>
<string name="everything_up_to_date">Everything up to date</string> <string name="everything_up_to_date">Everything up to date</string>
<string name="use_opengl_render">Use OpenGL rendering</string> <string name="use_opengl_render">Use OpenGL rendering</string>

View file

@ -338,8 +338,7 @@ public class MapActivityActions implements DialogProvider {
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
mapActivity.startActivity(intent); mapActivity.startActivity(intent);
} else if (standardId == R.string.context_menu_item_directions_to) { } else if (standardId == R.string.context_menu_item_directions_to) {
String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName(); targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, "");
targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, name);
enterRoutePlanningMode(null, null, false); enterRoutePlanningMode(null, null, false);
} else if (standardId == R.string.context_menu_item_directions_from) { } else if (standardId == R.string.context_menu_item_directions_from) {
String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName(); String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName();

View file

@ -80,7 +80,10 @@ public class DashUpdatesFragment extends DashBaseFragment {
updates.removeAllViews(); updates.removeAllViews();
if (list.size() < 1) { if (list.size() < 1) {
mainView.findViewById(R.id.maps).setVisibility(View.GONE);
return; return;
} else {
mainView.findViewById(R.id.maps).setVisibility(View.VISIBLE);
} }
for (int i = 0; i < list.size(); i++) { for (int i = 0; i < list.size(); i++) {

View file

@ -9,11 +9,14 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.telephony.TelephonyManager;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.access.AccessibleAlertBuilder; import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -45,7 +48,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
settings = ((OsmandApplication) getApplication()).getSettings(); settings = ((OsmandApplication) getApplication()).getSettings();
if(downloadListIndexThread == null) { if (downloadListIndexThread == null) {
downloadListIndexThread = new DownloadIndexesThread(this); downloadListIndexThread = new DownloadIndexesThread(this);
} }
prepareDownloadDirectory(); prepareDownloadDirectory();
@ -67,7 +70,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
public void updateDownloadList(List<IndexItem> list){ public void updateDownloadList(List<IndexItem> list) {
} }
@ -75,12 +78,12 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
public DownloadActivityType getDownloadType(){ public DownloadActivityType getDownloadType() {
return type; return type;
} }
public Map<IndexItem, List<DownloadEntry>> getEntriesToDownload() { public Map<IndexItem, List<DownloadEntry>> getEntriesToDownload() {
if(downloadListIndexThread == null) { if (downloadListIndexThread == null) {
return new LinkedHashMap<IndexItem, List<DownloadEntry>>(); return new LinkedHashMap<IndexItem, List<DownloadEntry>>();
} }
return downloadListIndexThread.getEntriesToDownload(); return downloadListIndexThread.getEntriesToDownload();
@ -94,20 +97,20 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
public void downloadListUpdated(){ public void downloadListUpdated() {
} }
public OsmandApplication getMyApplication(){ public OsmandApplication getMyApplication() {
return (OsmandApplication)getApplication(); return (OsmandApplication) getApplication();
} }
public void categorizationFinished(List<IndexItem> filtered, List<IndexItemCategory> cats){ public void categorizationFinished(List<IndexItem> filtered, List<IndexItemCategory> cats) {
} }
public void startDownload(IndexItem item){ public void startDownload(IndexItem item) {
if (downloadListIndexThread.getCurrentRunningTask() != null){ if (downloadListIndexThread.getCurrentRunningTask() != null) {
Toast.makeText(this, "Please wait before previous download is finished", Toast.LENGTH_SHORT).show(); Toast.makeText(this, "Please wait before previous download is finished", Toast.LENGTH_SHORT).show();
return; return;
} }
@ -119,7 +122,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
public void downloadFilesPreCheckSpace() { public void downloadFilesPreCheckSpace() {
double sz = 0; double sz = 0;
List<DownloadEntry> list = downloadListIndexThread.flattenDownloadEntries(); List<DownloadEntry> list = downloadListIndexThread.flattenDownloadEntries();
for (DownloadEntry es : list) { for (DownloadEntry es : list) {
sz += es.sizeMB; sz += es.sizeMB;
} }
// get availabile space // get availabile space
@ -141,7 +144,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
protected void downloadFilesCheckFreeVersion() { protected void downloadFilesCheckFreeVersion() {
if (Version.isFreeVersion(getMyApplication()) ) { if (Version.isFreeVersion(getMyApplication())) {
int total = settings.NUMBER_OF_FREE_DOWNLOADS.get(); int total = settings.NUMBER_OF_FREE_DOWNLOADS.get();
boolean wiki = false; boolean wiki = false;
for (IndexItem es : DownloadActivity.downloadListIndexThread.getEntriesToDownload().keySet()) { for (IndexItem es : DownloadActivity.downloadListIndexThread.getEntriesToDownload().keySet()) {
@ -168,17 +171,21 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
protected void downloadFilesCheckInternet() { protected void downloadFilesCheckInternet() {
if(!getMyApplication().getSettings().isWifiConnected()) { if (!getMyApplication().getSettings().isWifiConnected()) {
AlertDialog.Builder builder = new AlertDialog.Builder(this); if (getMyApplication().getSettings().isInternetConnectionAvailable()) {
builder.setMessage(getString(R.string.download_using_mobile_internet)); AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { builder.setMessage(getString(R.string.download_using_mobile_internet));
@Override builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
downloadFilesPreCheckSpace(); public void onClick(DialogInterface dialog, int which) {
} downloadFilesPreCheckSpace();
}); }
builder.setNegativeButton(R.string.default_buttons_no, null); });
builder.show(); builder.setNegativeButton(R.string.default_buttons_no, null);
builder.show();
} else {
AccessibleToast.makeText(this, R.string.no_internet_connection, Toast.LENGTH_LONG).show();
}
} else { } else {
downloadFilesPreCheckSpace(); downloadFilesPreCheckSpace();
} }
@ -212,12 +219,12 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
} }
private void prepareDownloadDirectory() { private void prepareDownloadDirectory() {
if(getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) { if (getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) {
boolean showedDialog = false; boolean showedDialog = false;
if(Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) { if (Build.VERSION.SDK_INT < OsmandSettings.VERSION_DEFAULTLOCATION_CHANGED) {
SuggestExternalDirectoryDialog.showDialog(this, null, null); SuggestExternalDirectoryDialog.showDialog(this, null, null);
} }
if(!showedDialog) { if (!showedDialog) {
showDialogOfFreeDownloadsIfNeeded(); showDialogOfFreeDownloadsIfNeeded();
} }
} else { } else {
@ -291,13 +298,15 @@ public class BaseDownloadActivity extends SherlockFragmentActivity {
new File(newLoc, IndexConstants.APP_DIR)) { new File(newLoc, IndexConstants.APP_DIR)) {
protected Boolean doInBackground(Void[] params) { protected Boolean doInBackground(Void[] params) {
Boolean result = super.doInBackground(params); Boolean result = super.doInBackground(params);
if(result) { if (result) {
settings.setExternalStorageDirectory(newLoc); settings.setExternalStorageDirectory(newLoc);
getMyApplication().getResourceManager().resetStoreDirectory(); getMyApplication().getResourceManager().resetStoreDirectory();
getMyApplication().getResourceManager().reloadIndexes(progress) ; getMyApplication().getResourceManager().reloadIndexes(progress);
} }
return result; return result;
}; }
;
}; };
task.execute(); task.execute();
} }

View file

@ -551,7 +551,19 @@ public class DownloadIndexesThread {
!date.equals(indexactivateddate) && !date.equals(indexactivateddate) &&
!date.equals(indexfilesdate) && !date.equals(indexfilesdate) &&
indexActivatedFileNames.containsKey(sfName)) { indexActivatedFileNames.containsKey(sfName)) {
itemsToUpdate.add(item); if (item.getType() == DownloadActivityType.NORMAL_FILE ||
item.getType() == DownloadActivityType.ROADS_FILE ||
item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE){
itemsToUpdate.add(item);
} else {
long itemSize = item.getSize();
File file = new File(((DownloadOsmandIndexesHelper.AssetIndexItem) item).getDestFile());
long oldItemSize = file.length();
if (itemSize != oldItemSize){
itemsToUpdate.add(item);
}
}
} }
} }
if (uiActivity != null){ if (uiActivity != null){

View file

@ -165,6 +165,10 @@ public class DownloadOsmandIndexesHelper {
res.add(new DownloadEntry(this, assetName, destFile, dateModified)); res.add(new DownloadEntry(this, assetName, destFile, dateModified));
return res; return res;
} }
public String getDestFile(){
return destFile;
}
} }

View file

@ -57,6 +57,9 @@ public class IndexItem implements Comparable<IndexItem> {
return timestamp; return timestamp;
} }
public long getSize(){
return containerSize;
}
public String getSizeDescription(Context ctx) { public String getSizeDescription(Context ctx) {
return size + " MB"; return size + " MB";