From 03c2dc8d3e000bb7735b8a858b2c64bddb5062ae Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 12:27:34 +0200 Subject: [PATCH 1/7] Fixed direction to point name --- OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 87988648ff..e114f65003 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -338,8 +338,7 @@ public class MapActivityActions implements DialogProvider { intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); mapActivity.startActivity(intent); } else if (standardId == R.string.context_menu_item_directions_to) { - String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName(); - targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, name); + targets.navigateToPoint(new LatLon(latitude, longitude), true, -1, ""); enterRoutePlanningMode(null, null, false); } else if (standardId == R.string.context_menu_item_directions_from) { String name = mapActivity.getMapLayers().getContextMenuLayer().getSelectedObjectName(); From 9a342d2e72e6755ba10bc4ee9cf282bdeeabeffb Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 14:43:26 +0200 Subject: [PATCH 2/7] Try to fix updates tts files issue. --- .../osmand/plus/download/DownloadIndexFragment.java | 2 +- .../osmand/plus/download/DownloadIndexesThread.java | 12 +++++++++++- .../plus/download/DownloadOsmandIndexesHelper.java | 4 ++++ OsmAnd/src/net/osmand/plus/download/IndexItem.java | 5 ++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java index 71d7cdcc3f..da3cb1f23a 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexFragment.java @@ -256,7 +256,7 @@ public class DownloadIndexFragment extends OsmandExpandableListFragment { } return files; } - + public static File findFileInDir(File file) { if(file.isDirectory()) { File[] lf = file.listFiles(); diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 08b4419952..1cc814212f 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -551,7 +551,17 @@ public class DownloadIndexesThread { !date.equals(indexactivateddate) && !date.equals(indexfilesdate) && indexActivatedFileNames.containsKey(sfName)) { - itemsToUpdate.add(item); + if (item.getType() == DownloadActivityType.NORMAL_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){ diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java index d22efa7d4f..650660de05 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadOsmandIndexesHelper.java @@ -165,6 +165,10 @@ public class DownloadOsmandIndexesHelper { res.add(new DownloadEntry(this, assetName, destFile, dateModified)); return res; } + + public String getDestFile(){ + return destFile; + } } diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index 312dbc65dc..df440f3c4a 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -57,7 +57,10 @@ public class IndexItem implements Comparable { return timestamp; } - + public long getSize(){ + return containerSize; + } + public String getSizeDescription(Context ctx) { return size + " MB"; } From c25352fc59a7cf5fe5cfed28cfe481fff6714ae5 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 14:48:52 +0200 Subject: [PATCH 3/7] Updated fix for updates tts files. --- .../src/net/osmand/plus/download/DownloadIndexesThread.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java index 1cc814212f..383a3a7129 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadIndexesThread.java @@ -551,7 +551,9 @@ public class DownloadIndexesThread { !date.equals(indexactivateddate) && !date.equals(indexfilesdate) && indexActivatedFileNames.containsKey(sfName)) { - if (item.getType() == DownloadActivityType.NORMAL_FILE){ + 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(); From 9ea7e55ffd335ff699276ccd76afaff7bd58a384 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 17:22:37 +0200 Subject: [PATCH 4/7] Updated messages when trying to download and there's no sim card, etc. --- OsmAnd/res/values/strings.xml | 5 +++ .../plus/download/BaseDownloadActivity.java | 34 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index b73b5bb5eb..800c6e1b82 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,6 +9,11 @@ 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 --> + Your sim card need you to enter PUK. + Your sim card need you to enter PIN. + Network is locked. Please connect to Wi-Fi to be able to download. + No sim card available. Please insert sim card or connect to Wi-Fi to be able to download. + Your device doesnt support sim cards. Please connect to Wi-Fi to be able to download files. Dismiss Everything up to date Use OpenGL rendering diff --git a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java index 1db2821318..4f4946da75 100644 --- a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java @@ -9,11 +9,14 @@ import java.util.List; import java.util.Map; import android.content.ActivityNotFoundException; +import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Build; +import android.telephony.TelephonyManager; import net.osmand.IndexConstants; import net.osmand.access.AccessibleAlertBuilder; +import net.osmand.access.AccessibleToast; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -174,7 +177,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - downloadFilesPreCheckSpace(); + downloadFilesCheckSim(); } }); builder.setNegativeButton(R.string.default_buttons_no, null); @@ -184,6 +187,35 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } } + protected void downloadFilesCheckSim(){ + TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + int phoneType = telMgr.getPhoneType(); + + if (phoneType == TelephonyManager.PHONE_TYPE_NONE){ + AccessibleToast.makeText(this, R.string.sim_card_not_supported, Toast.LENGTH_LONG).show(); + return; + } + int simState = telMgr.getSimState(); + switch (simState) { + case TelephonyManager.SIM_STATE_NETWORK_LOCKED: + AccessibleToast.makeText(this, R.string.network_locked, Toast.LENGTH_LONG).show(); + break; + case TelephonyManager.SIM_STATE_PIN_REQUIRED: + AccessibleToast.makeText(this, R.string.sim_pin_required, Toast.LENGTH_LONG).show(); + break; + case TelephonyManager.SIM_STATE_PUK_REQUIRED: + AccessibleToast.makeText(this, R.string.sim_puk_required, Toast.LENGTH_LONG).show(); + break; + case TelephonyManager.SIM_STATE_READY: + downloadFilesPreCheckSpace(); + break; + case TelephonyManager.SIM_STATE_ABSENT: + case TelephonyManager.SIM_STATE_UNKNOWN: + AccessibleToast.makeText(this, R.string.no_sim_card, Toast.LENGTH_LONG).show(); + break; + } + } + @Override public void onAttachFragment(Fragment fragment) { fragList.add(new WeakReference(fragment)); From 750580cb319da4918a9820b5ee672d4bedfa8057 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 17:32:43 +0200 Subject: [PATCH 5/7] Hided updates when there's nothing to update --- OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java index 5ae42a8d04..bcb67527c4 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashUpdatesFragment.java @@ -80,7 +80,10 @@ public class DashUpdatesFragment extends DashBaseFragment { updates.removeAllViews(); if (list.size() < 1) { + mainView.findViewById(R.id.maps).setVisibility(View.GONE); return; + } else { + mainView.findViewById(R.id.maps).setVisibility(View.VISIBLE); } for (int i = 0; i < list.size(); i++) { From bfc480fd712f6961cb348d22a1b4bf970003dd57 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 17:34:38 +0200 Subject: [PATCH 6/7] Fixed string message for sim card not supported --- OsmAnd/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 800c6e1b82..9d6dbaf745 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -13,7 +13,7 @@ Your sim card need you to enter PIN. Network is locked. Please connect to Wi-Fi to be able to download. No sim card available. Please insert sim card or connect to Wi-Fi to be able to download. - Your device doesnt support sim cards. Please connect to Wi-Fi to be able to download files. + Not possible to download. Please connect to Wi-Fi to proceed. Dismiss Everything up to date Use OpenGL rendering From 33e01d42a40defa7731216d7d6fc0e616c7d5294 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 4 Dec 2014 17:50:27 +0200 Subject: [PATCH 7/7] Refactored internet connection error messages --- OsmAnd/res/values/strings.xml | 6 +- .../plus/download/BaseDownloadActivity.java | 93 +++++++------------ 2 files changed, 36 insertions(+), 63 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 9d6dbaf745..1eca00e7d5 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,11 +9,7 @@ 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 --> - Your sim card need you to enter PUK. - Your sim card need you to enter PIN. - Network is locked. Please connect to Wi-Fi to be able to download. - No sim card available. Please insert sim card or connect to Wi-Fi to be able to download. - Not possible to download. Please connect to Wi-Fi to proceed. + Not possible to download. Please connect to Wi-Fi to proceed. Dismiss Everything up to date Use OpenGL rendering diff --git a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java index 4f4946da75..9e9d791120 100644 --- a/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/BaseDownloadActivity.java @@ -48,7 +48,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); settings = ((OsmandApplication) getApplication()).getSettings(); - if(downloadListIndexThread == null) { + if (downloadListIndexThread == null) { downloadListIndexThread = new DownloadIndexesThread(this); } prepareDownloadDirectory(); @@ -70,7 +70,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } - public void updateDownloadList(List list){ + public void updateDownloadList(List list) { } @@ -78,12 +78,12 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } - public DownloadActivityType getDownloadType(){ + public DownloadActivityType getDownloadType() { return type; } public Map> getEntriesToDownload() { - if(downloadListIndexThread == null) { + if (downloadListIndexThread == null) { return new LinkedHashMap>(); } return downloadListIndexThread.getEntriesToDownload(); @@ -97,20 +97,20 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } - public void downloadListUpdated(){ + public void downloadListUpdated() { } - public OsmandApplication getMyApplication(){ - return (OsmandApplication)getApplication(); + public OsmandApplication getMyApplication() { + return (OsmandApplication) getApplication(); } - public void categorizationFinished(List filtered, List cats){ + public void categorizationFinished(List filtered, List cats) { } - public void startDownload(IndexItem item){ - if (downloadListIndexThread.getCurrentRunningTask() != null){ + public void startDownload(IndexItem item) { + if (downloadListIndexThread.getCurrentRunningTask() != null) { Toast.makeText(this, "Please wait before previous download is finished", Toast.LENGTH_SHORT).show(); return; } @@ -122,7 +122,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { public void downloadFilesPreCheckSpace() { double sz = 0; List list = downloadListIndexThread.flattenDownloadEntries(); - for (DownloadEntry es : list) { + for (DownloadEntry es : list) { sz += es.sizeMB; } // get availabile space @@ -144,7 +144,7 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } protected void downloadFilesCheckFreeVersion() { - if (Version.isFreeVersion(getMyApplication()) ) { + if (Version.isFreeVersion(getMyApplication())) { int total = settings.NUMBER_OF_FREE_DOWNLOADS.get(); boolean wiki = false; for (IndexItem es : DownloadActivity.downloadListIndexThread.getEntriesToDownload().keySet()) { @@ -171,51 +171,26 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } protected void downloadFilesCheckInternet() { - if(!getMyApplication().getSettings().isWifiConnected()) { - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(getString(R.string.download_using_mobile_internet)); - builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - downloadFilesCheckSim(); - } - }); - builder.setNegativeButton(R.string.default_buttons_no, null); - builder.show(); + if (!getMyApplication().getSettings().isWifiConnected()) { + if (getMyApplication().getSettings().isInternetConnectionAvailable()) { + AlertDialog.Builder builder = new AlertDialog.Builder(this); + builder.setMessage(getString(R.string.download_using_mobile_internet)); + builder.setPositiveButton(R.string.default_buttons_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + downloadFilesPreCheckSpace(); + } + }); + builder.setNegativeButton(R.string.default_buttons_no, null); + builder.show(); + } else { + AccessibleToast.makeText(this, R.string.no_internet_connection, Toast.LENGTH_LONG).show(); + } } else { downloadFilesPreCheckSpace(); } } - protected void downloadFilesCheckSim(){ - TelephonyManager telMgr = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); - int phoneType = telMgr.getPhoneType(); - - if (phoneType == TelephonyManager.PHONE_TYPE_NONE){ - AccessibleToast.makeText(this, R.string.sim_card_not_supported, Toast.LENGTH_LONG).show(); - return; - } - int simState = telMgr.getSimState(); - switch (simState) { - case TelephonyManager.SIM_STATE_NETWORK_LOCKED: - AccessibleToast.makeText(this, R.string.network_locked, Toast.LENGTH_LONG).show(); - break; - case TelephonyManager.SIM_STATE_PIN_REQUIRED: - AccessibleToast.makeText(this, R.string.sim_pin_required, Toast.LENGTH_LONG).show(); - break; - case TelephonyManager.SIM_STATE_PUK_REQUIRED: - AccessibleToast.makeText(this, R.string.sim_puk_required, Toast.LENGTH_LONG).show(); - break; - case TelephonyManager.SIM_STATE_READY: - downloadFilesPreCheckSpace(); - break; - case TelephonyManager.SIM_STATE_ABSENT: - case TelephonyManager.SIM_STATE_UNKNOWN: - AccessibleToast.makeText(this, R.string.no_sim_card, Toast.LENGTH_LONG).show(); - break; - } - } - @Override public void onAttachFragment(Fragment fragment) { fragList.add(new WeakReference(fragment)); @@ -244,12 +219,12 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { } private void prepareDownloadDirectory() { - if(getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) { + if (getMyApplication().getResourceManager().getIndexFileNames().isEmpty()) { 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); } - if(!showedDialog) { + if (!showedDialog) { showDialogOfFreeDownloadsIfNeeded(); } } else { @@ -323,13 +298,15 @@ public class BaseDownloadActivity extends SherlockFragmentActivity { new File(newLoc, IndexConstants.APP_DIR)) { protected Boolean doInBackground(Void[] params) { Boolean result = super.doInBackground(params); - if(result) { + if (result) { settings.setExternalStorageDirectory(newLoc); getMyApplication().getResourceManager().resetStoreDirectory(); - getMyApplication().getResourceManager().reloadIndexes(progress) ; + getMyApplication().getResourceManager().reloadIndexes(progress); } return result; - }; + } + + ; }; task.execute(); }