Search only basemap for zooms < 8. Fix issue 313, rotation.
This commit is contained in:
parent
dda3196f69
commit
5fab54f29e
6 changed files with 93 additions and 29 deletions
|
@ -139,6 +139,10 @@ public class ProgressDialogImplementation implements IProgress {
|
|||
public boolean isInterrupted() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ProgressDialog getDialog() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.osmand.plus.activities.search.SearchActivity;
|
|||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
|
@ -44,6 +45,8 @@ public class MainMenuActivity extends Activity {
|
|||
|
||||
public static final int APP_EXIT_CODE = 4;
|
||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||
|
||||
private ProgressDialog startProgressDialog;
|
||||
|
||||
|
||||
public void checkPreviousRunsForExceptions(boolean firstTime) {
|
||||
|
@ -228,7 +231,8 @@ public class MainMenuActivity extends Activity {
|
|||
return;
|
||||
}
|
||||
|
||||
((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this);
|
||||
startProgressDialog = new ProgressDialog(this);
|
||||
((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
SharedPreferences pref = getPreferences(MODE_WORLD_WRITEABLE);
|
||||
boolean firstTime = false;
|
||||
if(!pref.contains(FIRST_TIME_APP_RUN)){
|
||||
|
@ -276,6 +280,14 @@ public class MainMenuActivity extends Activity {
|
|||
checkPreviousRunsForExceptions(firstTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if(id == OsmandApplication.PROGRESS_DIALOG){
|
||||
return startProgressDialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
|
|
|
@ -129,6 +129,7 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
private Integer previousMapRotate = null;
|
||||
|
||||
private boolean isMapLinkedToLocation = false;
|
||||
private ProgressDialog startProgressDialog;
|
||||
|
||||
private boolean isMapLinkedToLocation(){
|
||||
return isMapLinkedToLocation;
|
||||
|
@ -154,19 +155,19 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
// Full screen is not used here
|
||||
// getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
setContentView(R.layout.main);
|
||||
ProgressDialog dlg = ((OsmandApplication)getApplication()).checkApplicationIsBeingInitialized(this);
|
||||
if(dlg != null){
|
||||
// Do some action on close
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener(){
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
OsmandApplication app = ((OsmandApplication)getApplication());
|
||||
if(settings.MAP_VECTOR_DATA.get() && app.getResourceManager().getRenderer().isEmpty()){
|
||||
Toast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
startProgressDialog = new ProgressDialog(this);
|
||||
startProgressDialog.setCancelable(true);
|
||||
((OsmandApplication) getApplication()).checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
// Do some action on close
|
||||
startProgressDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
OsmandApplication app = ((OsmandApplication) getApplication());
|
||||
if (settings.MAP_VECTOR_DATA.get() && app.getResourceManager().getRenderer().isEmpty()) {
|
||||
Toast.makeText(MapActivity.this, getString(R.string.no_vector_map_loaded), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
parseLaunchIntentLocation();
|
||||
|
||||
mapView = (OsmandMapTileView) findViewById(R.id.MapView);
|
||||
|
@ -268,6 +269,14 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if(id == OsmandApplication.PROGRESS_DIALOG){
|
||||
return startProgressDialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
public void changeZoom(int newZoom){
|
||||
boolean changeLocation = settings.AUTO_ZOOM_MAP.get();
|
||||
mapView.getAnimatedDraggingThread().startZooming(newZoom, changeLocation);
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.render.RendererRegistry;
|
||||
import net.osmand.plus.voice.CommandPlayer;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.app.ProgressDialog;
|
||||
|
@ -55,7 +56,6 @@ public class OsmandApplication extends Application {
|
|||
// start variables
|
||||
private ProgressDialogImplementation startDialog;
|
||||
private List<String> startingWarnings;
|
||||
private ProgressDialog progressDlg;
|
||||
private Handler uiHandler;
|
||||
private GPXFileResult gpxFileToDisplay;
|
||||
|
||||
|
@ -158,19 +158,27 @@ public class OsmandApplication extends Application {
|
|||
|
||||
}
|
||||
|
||||
public ProgressDialog checkApplicationIsBeingInitialized(Context uiContext){
|
||||
|
||||
public static final int PROGRESS_DIALOG = 5;
|
||||
|
||||
/**
|
||||
* @param activity that supports onCreateDialog({@link #PROGRESS_DIALOG}) and returns @param progressdialog
|
||||
* @param progressDialog - it should be exactly the same as onCreateDialog
|
||||
* @return
|
||||
*/
|
||||
public void checkApplicationIsBeingInitialized(Activity activity, ProgressDialog progressDialog){
|
||||
// start application if it was previously closed
|
||||
startApplication();
|
||||
synchronized (OsmandApplication.this) {
|
||||
if(startDialog != null){
|
||||
progressDlg = ProgressDialog.show(uiContext, getString(R.string.loading_data), getString(R.string.reading_indexes), true);
|
||||
startDialog.setDialog(progressDlg);
|
||||
return progressDlg;
|
||||
} else if(startingWarnings != null){
|
||||
showWarnings(startingWarnings, uiContext);
|
||||
progressDialog.setTitle(getString(R.string.loading_data));
|
||||
progressDialog.setMessage(getString(R.string.reading_indexes));
|
||||
activity.showDialog(PROGRESS_DIALOG);
|
||||
startDialog.setDialog(progressDialog);
|
||||
} else if (startingWarnings != null) {
|
||||
showWarnings(startingWarnings, activity);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isApplicationInitializing(){
|
||||
|
@ -277,21 +285,25 @@ public class OsmandApplication extends Application {
|
|||
|
||||
} finally {
|
||||
synchronized (OsmandApplication.this) {
|
||||
final ProgressDialog toDismiss;
|
||||
if(startDialog != null){
|
||||
toDismiss = startDialog.getDialog();
|
||||
} else {
|
||||
toDismiss = null;
|
||||
}
|
||||
startDialog = null;
|
||||
if (progressDlg != null) {
|
||||
final ProgressDialog toDismiss = progressDlg;
|
||||
// toDismiss.dismiss();
|
||||
|
||||
if (toDismiss != null) {
|
||||
uiHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(toDismiss.getOwnerActivity() != null){
|
||||
toDismiss.dismiss();
|
||||
toDismiss.getOwnerActivity().dismissDialog(PROGRESS_DIALOG);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
showWarnings(warnings, progressDlg.getContext());
|
||||
progressDlg = null;
|
||||
showWarnings(warnings, toDismiss.getContext());
|
||||
} else {
|
||||
startingWarnings = warnings;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import net.osmand.plus.RegionAddressRepository;
|
|||
import net.osmand.plus.ResourceManager;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.OsmandApplication;
|
||||
import android.app.Dialog;
|
||||
import android.app.ListActivity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -42,12 +43,14 @@ public class GeoIntentActivity extends ListActivity {
|
|||
|
||||
private ProgressDialog progressDlg;
|
||||
private LatLon location;
|
||||
private ProgressDialog startProgressDialog;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.search_address_offline);
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this);
|
||||
startProgressDialog = new ProgressDialog(this);
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||
location = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
final Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
|
@ -87,6 +90,14 @@ public class GeoIntentActivity extends ListActivity {
|
|||
// finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
if(id == OsmandApplication.PROGRESS_DIALOG){
|
||||
return startProgressDialog;
|
||||
}
|
||||
return super.onCreateDialog(id);
|
||||
}
|
||||
|
||||
private void showResult(final int warning, final List<MapObject> places) {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
|
|
|
@ -54,6 +54,8 @@ public class MapRenderRepositories {
|
|||
private Map<String, BinaryMapIndexReader> files = new LinkedHashMap<String, BinaryMapIndexReader>();
|
||||
private OsmandRenderer renderer;
|
||||
|
||||
private static String BASEMAP_NAME = "basemap";
|
||||
|
||||
|
||||
// lat/lon box of requested vector data
|
||||
private RectF cObjectsBox = new RectF();
|
||||
|
@ -255,8 +257,22 @@ public class MapRenderRepositories {
|
|||
|
||||
});
|
||||
}
|
||||
// search lower level zooms only in basemap for now :) before it was intersection of maps on zooms 5-7
|
||||
boolean basemapSearch = false;
|
||||
if (zoom < 8) {
|
||||
for (String f : files.keySet()) {
|
||||
if (f.toLowerCase().contains(BASEMAP_NAME)) {
|
||||
basemapSearch = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BinaryMapIndexReader c : files.values()) {
|
||||
for (String mapName : files.keySet()) {
|
||||
if(basemapSearch && mapName.toLowerCase().contains(BASEMAP_NAME)){
|
||||
continue;
|
||||
}
|
||||
BinaryMapIndexReader c = files.get(mapName);
|
||||
List<BinaryMapDataObject> res = c.searchMapIndex(searchRequest);
|
||||
if (checkWhetherInterrupted()) {
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue