private void selectModel(HistoryEntry model) { helper.selectEntry(model, this); OsmandSettings settings = OsmandSettings.getOsmandSettings(SearchHistoryActivity.this); settings.setMapLocationToShow( model.getLat(), model.getLon(), settings.getLastKnownMapZoom(), null, model.getName()); MapActivity.launchMapActivityMoveToTop(this); }
public static void initPlugins(OsmandApplication app) { OsmandSettings settings = app.getSettings(); Set<String> enabledPlugins = settings.getEnabledPlugins(); allPlugins.add(new OsmandRasterMapsPlugin(app)); allPlugins.add(new OsmandMonitoringPlugin(app)); allPlugins.add(new OsMoPlugin(app)); checkMarketPlugin( app, new SRTMPlugin(app), true, SRTM_PLUGIN_COMPONENT_PAID, SRTM_PLUGIN_COMPONENT); // ? questionable - definitely not market plugin // checkMarketPlugin(app, new TouringViewPlugin(app), false, TouringViewPlugin.COMPONENT, // null); checkMarketPlugin(app, new NauticalMapsPlugin(app), false, NauticalMapsPlugin.COMPONENT, null); checkMarketPlugin(app, new SkiMapsPlugin(app), false, SkiMapsPlugin.COMPONENT, null); // checkMarketPlugin(app, new RoutePointsPlugin(app), false /*FIXME*/, // RoutePointsPlugin.ROUTE_POINTS_PLUGIN_COMPONENT, null); allPlugins.add(new AudioVideoNotesPlugin(app)); checkMarketPlugin( app, new ParkingPositionPlugin(app), false, ParkingPositionPlugin.PARKING_PLUGIN_COMPONENT, null); allPlugins.add(new DistanceCalculatorPlugin(app)); allPlugins.add(new AccessibilityPlugin(app)); allPlugins.add(new OsmEditingPlugin(app)); allPlugins.add(new OsmandDevelopmentPlugin(app)); if (android.os.Build.VERSION.SDK_INT >= 19) { allPlugins.add(new net.osmand.plus.smartnaviwatch.SmartNaviWatchPlugin(app)); } activatePlugins(app, enabledPlugins); }
protected void parseLaunchIntentLocation() { Intent intent = getIntent(); if (intent != null && intent.getData() != null) { Uri data = intent.getData(); if ("http".equalsIgnoreCase(data.getScheme()) && "download.osmand.net".equals(data.getHost()) && "/go".equals(data.getPath())) { String lat = data.getQueryParameter("lat"); String lon = data.getQueryParameter("lon"); if (lat != null && lon != null) { try { double lt = Double.parseDouble(lat); double ln = Double.parseDouble(lon); String zoom = data.getQueryParameter("z"); int z = settings.getLastKnownMapZoom(); if (zoom != null) { z = Integer.parseInt(zoom); } settings.setMapLocationToShow(lt, ln, z, getString(R.string.shared_location)); } catch (NumberFormatException e) { } } } } }
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); LatLon startPoint = null; if (intent != null) { double lat = intent.getDoubleExtra(SEARCH_LAT, 0); double lon = intent.getDoubleExtra(SEARCH_LON, 0); if (lat != 0 || lon != 0) { startPoint = new LatLon(lat, lon); } } if (startPoint == null && getParent() instanceof SearchActivity) { startPoint = ((SearchActivity) getParent()).getSearchPoint(); } if (startPoint == null) { startPoint = settings.getLastKnownMapLocation(); } LatLon pointToNavigate = settings.getPointToNavigate(); if (!Algoritms.objectEquals(pointToNavigate, this.destinationLocation) || !Algoritms.objectEquals(startPoint, this.lastKnownMapLocation)) { destinationLocation = pointToNavigate; selectedDestinationLocation = destinationLocation; lastKnownMapLocation = startPoint; searchTransport(); } }
@Override protected void onResume() { super.onResume(); searchPoint = osmandSettings.getLastSearchedPoint(); Intent intent = getIntent(); if (intent != null) { selectAddressMode = intent.hasExtra(SELECT_ADDRESS_POINT_INTENT_KEY); } else { selectAddressMode = false; } findViewById(R.id.TopTextView).setVisibility(selectAddressMode ? View.VISIBLE : View.GONE); region = null; postcode = null; city = null; street = null; building = null; region = osmandSettings.getLastSearchedRegion(); RegionAddressRepository reg = ((OsmandApplication) getApplication()).getResourceManager().getRegionRepository(region); if (reg != null && reg.useEnglishNames() != osmandSettings.USE_ENGLISH_NAMES.get()) { reg.setUseEnglishNames(osmandSettings.USE_ENGLISH_NAMES.get()); } loadData(); updateUI(); }
public static void showEditInstance(final Amenity amenity, final AppCompatActivity activity) { final OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); final OpenstreetmapUtil openstreetmapUtilToLoad; if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); openstreetmapUtilToLoad = new OpenstreetmapLocalUtil(plugin, activity); } else if (!settings.isInternetConnectionAvailable(true)) { openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); } else { openstreetmapUtilToLoad = new OpenstreetmapRemoteUtil(activity); } new AsyncTask<Void, Void, Node>() { @Override protected Node doInBackground(Void... params) { return openstreetmapUtilToLoad.loadNode(amenity); } protected void onPostExecute(Node n) { if (n != null) { EditPoiDialogFragment fragment = EditPoiDialogFragment.createInstance(n, amenity); fragment.show(activity.getSupportFragmentManager(), TAG); } else { AccessibleToast.makeText( activity, activity.getString(R.string.poi_error_poi_not_found), Toast.LENGTH_SHORT) .show(); } } }.execute(); }
@Override public boolean onContextItemSelected(MenuItem item) { int pos = ((android.widget.AdapterView.AdapterContextMenuInfo) item.getMenuInfo()).position; int itemId = item.getItemId(); if (itemId == R.id.showmod) { OsmandSettings settings = getMyApplication().getSettings(); OsmPoint info = (OsmPoint) listAdapter.getItem(pos); settings.setMapLocationToShow( info.getLatitude(), info.getLongitude(), settings.getLastKnownMapZoom()); MapActivity.launchMapActivityMoveToTop(LocalOpenstreetmapActivity.this); return true; } else if (itemId == R.id.deletemod) { OsmPoint info = (OsmPoint) listAdapter.getItem(pos); if (info.getGroup() == OsmPoint.Group.POI) { dbpoi.deletePOI((OpenstreetmapPoint) info); } else if (info.getGroup() == OsmPoint.Group.BUG) { dbbug.deleteAllBugModifications((OsmNotesPoint) info); } listAdapter.delete(info); return true; } else if (itemId == R.id.uploadmods) { toUpload = new OsmPoint[] {listAdapter.getItem(pos)}; showDialog(DIALOG_PROGRESS_UPLOAD); return true; } return super.onContextItemSelected(item); }
@Override public void setup(OsmandApplication app) { super.setup(app); originalSettings = createSettings(app.getSettings().getSettingsAPI()); selectedTourPref = originalSettings.registerStringPreference(SELECTED_TOUR, null).makeGlobal(); accessCodePref = originalSettings.registerStringPreference(ACCESS_CODE, "").makeGlobal(); toursFolder = new File(originalSettings.getExternalStorageDirectory(), "osmand/tours"); }
public static void installMapLayers( final Activity activity, final DialogInterface.OnClickListener onClickListener) { final OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); final Map<String, String> entriesMap = settings.getTileSourceEntries(); if (!settings.isInternetConnectionAvailable(true)) { Toast.makeText(activity, R.string.internet_not_available, Toast.LENGTH_LONG).show(); return; } final List<TileSourceTemplate> downloaded = TileSourceManager.downloadTileSourceTemplates(); if (downloaded == null || downloaded.isEmpty()) { Toast.makeText(activity, R.string.error_io_error, Toast.LENGTH_SHORT).show(); return; } Builder builder = new AlertDialog.Builder(activity); String[] names = new String[downloaded.size()]; for (int i = 0; i < names.length; i++) { names[i] = downloaded.get(i).getName(); } final boolean[] selected = new boolean[downloaded.size()]; builder.setMultiChoiceItems( names, selected, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { selected[which] = isChecked; if (entriesMap.containsKey(downloaded.get(which).getName()) && isChecked) { Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT) .show(); } } }); builder.setNegativeButton(R.string.default_buttons_cancel, null); builder.setTitle(R.string.select_tile_source_to_install); builder.setPositiveButton( R.string.default_buttons_apply, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { List<TileSourceTemplate> toInstall = new ArrayList<TileSourceTemplate>(); for (int i = 0; i < selected.length; i++) { if (selected[i]) { toInstall.add(downloaded.get(i)); } } for (TileSourceTemplate ts : toInstall) { settings.installTileSource(ts); } if (onClickListener != null) { onClickListener.onClick(dialog, which); } } }); builder.show(); }
public OsmBugsUtil getOsmbugsUtil(OpenStreetNote bug) { OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); if ((bug != null && bug.isLocal()) || settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { return local; } else { return remote; } }
public ShowDeleteDialogAsyncTask(AppCompatActivity activity) { this.activity = activity; OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings(); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); } else if (!settings.isInternetConnectionAvailable(true)) { openstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); } else { openstreetmapUtil = new OpenstreetmapRemoteUtil(activity); } }
public List<String> onIndexingFiles(IProgress progress, Map<String, String> indexFileNames) { ArrayList<TourInformation> tourPresent = new ArrayList<TourInformation>(); List<String> warns = new ArrayList<String>(); selectedTour = null; if (toursFolder.exists()) { File[] availableTours = toursFolder.listFiles(); if (availableTours != null) { String selectedName = selectedTourPref.get(); for (File tr : availableTours) { if (tr.isDirectory()) { boolean selected = selectedName != null && selectedName.equals(tr.getName()); String date = app.getResourceManager() .getDateFormat() .format(new Date(DownloadIndexActivity.findFileInDir(tr).lastModified())); indexFileNames.put(tr.getName(), date); final TourInformation tourInformation = new TourInformation(tr); tourPresent.add(tourInformation); if (selected) { reloadSelectedTour(progress, tr, tourInformation, warns); } } } if (selectedName == null) { app.getSettings().setSettingsAPI(originalSettings.getSettingsAPI()); } } } this.tourPresent = tourPresent; return warns; }
protected void select(int mode) { LatLon searchPoint = settings.getLastSearchedPoint(); AddressInformation ai = getAddressInformation(); if (ai != null) { if (mode == ADD_TO_FAVORITE) { Bundle b = new Bundle(); Dialog dlg = FavoriteDialogs.createAddFavouriteDialog(getActivity(), b); dlg.show(); FavoriteDialogs.prepareAddFavouriteDialog( getActivity(), dlg, b, searchPoint.getLatitude(), searchPoint.getLongitude(), new PointDescription(PointDescription.POINT_TYPE_ADDRESS, ai.objectName)); } else if (mode == NAVIGATE_TO) { DirectionsDialogs.directionsToDialogAndLaunchMap( getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), ai.getHistoryName()); } else if (mode == ADD_WAYPOINT) { DirectionsDialogs.addWaypointDialogAndLaunchMap( getActivity(), searchPoint.getLatitude(), searchPoint.getLongitude(), ai.getHistoryName()); } else if (mode == SHOW_ON_MAP) { showOnMap(searchPoint, ai); } } }
@Override protected void onListItemClick(ListView l, View v, int position, long id) { if (!isSelectFavoriteMode()) { QuickAction qa = new QuickAction(v); FavouritePoint point = favouritesAdapter.getItem(position); String name = getString(R.string.favorite) + ": " + point.getName(); LatLon location = new LatLon(point.getLatitude(), point.getLongitude()); View.OnClickListener onshow = new View.OnClickListener() { @Override public void onClick(View v) { settings.SHOW_FAVORITES.set(true); } }; MapActivityActions.createDirectionsActions( qa, location, point, name, settings.getLastKnownMapZoom(), this, true, onshow); qa.show(); } else { Intent intent = getIntent(); intent.putExtra(SELECT_FAVORITE_POINT_INTENT_KEY, favouritesAdapter.getItem(position)); setResult(SELECT_FAVORITE_POINT_RESULT_OK, intent); finish(); } }
public void updateLocation(Location currentLocation) { if (isFollowingMode() || (settings.getPointToStart() == null && isRoutePlanningMode) || app.getLocationProvider().getLocationSimulation().isRouteAnimating()) { setCurrentLocation(currentLocation, false); } }
private Collection<String> listAlreadyDownloadedWithAlternatives() { Set<String> files = new TreeSet<String>(); File externalStorageDirectory = settings.getExternalStorageDirectory(); // files.addAll(listWithAlternatives(new File(externalStorageDirectory, // ResourceManager.POI_PATH),POI_INDEX_EXT,POI_INDEX_EXT_ZIP,POI_TABLE_VERSION)); files.addAll( listWithAlternatives( new File(externalStorageDirectory, ResourceManager.APP_DIR), BINARY_MAP_INDEX_EXT, BINARY_MAP_INDEX_EXT_ZIP, BINARY_MAP_VERSION)); files.addAll( listWithAlternatives( new File(externalStorageDirectory, ResourceManager.BACKUP_PATH), BINARY_MAP_INDEX_EXT, BINARY_MAP_INDEX_EXT_ZIP, BINARY_MAP_VERSION)); files.addAll( listWithAlternatives( new File(externalStorageDirectory, ResourceManager.VOICE_PATH), "", VOICE_INDEX_EXT_ZIP, VOICE_VERSION)); files.addAll( listWithAlternatives( new File(externalStorageDirectory, ResourceManager.VOICE_PATH), "", TTSVOICE_INDEX_EXT_ZIP, TTSVOICE_VERSION)); return files; }
private void fillTileSourcesToPreference( ListPreference tileSourcePreference, String value, boolean addNone) { Map<String, String> entriesMap = osmandSettings.getTileSourceEntries(); int add = addNone ? 1 : 0; String[] entries = new String[entriesMap.size() + 1 + add]; String[] values = new String[entriesMap.size() + 1 + add]; int ki = 0; if (addNone) { entries[ki] = getString(R.string.default_none); values[ki] = ""; ki++; } if (value == null) { value = ""; } for (Map.Entry<String, String> es : entriesMap.entrySet()) { entries[ki] = es.getValue(); values[ki] = es.getKey(); ki++; } entries[ki] = getString(R.string.install_more); values[ki] = MORE_VALUE; fill(tileSourcePreference, entries, values, value); }
public boolean shouldShow(OsmandSettings settings, MapActivity activity, String tag) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { return false; } return !settings.isExternalStorageDirectorySpecifiedV19() && super.shouldShow(settings, activity, tag); }
@Override protected void onResume() { super.onResume(); selectAddress = getIntent() != null && getIntent().getBooleanExtra(SELECT_ADDRESS, false); setOnItemClickListener( new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { T repo = getListAdapter().getItem(position); itemSelectedBase(repo, view); } }); Intent intent = getIntent(); if (intent != null) { if (intent.hasExtra(SearchActivity.SEARCH_LAT) && intent.hasExtra(SearchActivity.SEARCH_LON)) { double lat = intent.getDoubleExtra(SearchActivity.SEARCH_LAT, 0); double lon = intent.getDoubleExtra(SearchActivity.SEARCH_LON, 0); locationToSearch = new LatLon(lat, lon); } } if (locationToSearch == null) { locationToSearch = settings.getLastKnownMapLocation(); } }
@Override protected void onResume() { super.onResume(); Intent intent = getIntent(); if (intent != null) { double lat = intent.getDoubleExtra(SEARCH_LAT, 0); double lon = intent.getDoubleExtra(SEARCH_LON, 0); if (lat != 0 || lon != 0) { location = new LatLon(lat, lon); } } if (location == null && getParent() instanceof SearchActivity) { location = ((SearchActivity) getParent()).getSearchPoint(); } if (location == null) { location = OsmandSettings.getOsmandSettings(this).getLastKnownMapLocation(); } List<HistoryEntry> historyEntries = helper.getHistoryEntries(this); getListView().removeFooterView(clearButton); if (!historyEntries.isEmpty()) { getListView().addFooterView(clearButton); } setListAdapter(new HistoryAdapter(historyEntries)); }
public void updateApplicationModeSettings() { // update vector renderer RendererRegistry registry = app.getRendererRegistry(); RenderingRulesStorage newRenderer = registry.getRenderer(settings.RENDERER.get()); if (newRenderer == null) { newRenderer = registry.defaultRender(); } if (registry.getCurrentSelectedRenderer() != newRenderer) { registry.setCurrentSelectedRender(newRenderer); app.getResourceManager().getRenderer().clearCache(); } mapViewTrackingUtilities.updateSettings(); app.getRoutingHelper().setAppMode(settings.getApplicationMode()); if (mapLayers.getMapInfoLayer() != null) { mapLayers.getMapInfoLayer().recreateControls(); } mapLayers.updateLayers(mapView); app.getDaynightHelper() .startSensorIfNeeded( new StateChangedListener<Boolean>() { @Override public void stateChanged(Boolean change) { getMapView().refreshMap(true); } }); getMapView().refreshMap(true); }
private void updateApplicationDirTextAndSummary() { if (applicationDir != null) { String storageDir = osmandSettings.getExternalStorageDirectory().getAbsolutePath(); applicationDir.setText(storageDir); applicationDir.setSummary(storageDir); } }
@Override public void onListItemClick(ListView parent, View v, int position, long id) { final RouteInfoLocation item = ((TransportStopAdapter) getListAdapter()).getItem(position); Builder builder = new AlertDialog.Builder(this); List<String> items = new ArrayList<String>(); final List<TransportStop> stops = item.getDirection() ? item.getRoute().getForwardStops() : item.getRoute().getBackwardStops(); LatLon locationToGo = getLocationToGo(); LatLon locationToStart = getLocationToStart(); builder.setTitle( getString(R.string.transport_stop_to_go_out) + "\n" + getInformation(item, stops, getCurrentRouteLocation(), true)); // $NON-NLS-1$ int ind = 0; for (TransportStop st : stops) { StringBuilder n = new StringBuilder(50); n.append(ind++); if (st == item.getStop()) { n.append("!! "); // $NON-NLS-1$ } else { n.append(". "); // $NON-NLS-1$ } String name = st.getName(settings.usingEnglishNames()); if (locationToGo != null) { n.append(name).append(" - ["); // $NON-NLS-1$ n.append( OsmAndFormatter.getFormattedDistance( (int) MapUtils.getDistance(locationToGo, st.getLocation()), SearchTransportActivity.this)) .append("]"); // $NON-NLS-1$ } else if (locationToStart != null) { n.append("[") .append( OsmAndFormatter.getFormattedDistance( (int) MapUtils.getDistance(locationToStart, st.getLocation()), SearchTransportActivity.this)) .append("] - "); // $NON-NLS-1$ //$NON-NLS-2$ n.append(name); } else { n.append(name); } items.add(n.toString()); } builder.setItems( items.toArray(new String[items.size()]), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { int i = which; if (i >= 0) { TransportStop stop = stops.get(i); showContextMenuOnStop(stop, item, i); } } }); builder.show(); }
public void checkPreviousRunsForExceptions(boolean firstTime) { long size = getPreferences(MODE_WORLD_READABLE).getLong(EXCEPTION_FILE_SIZE, 0); final File file = OsmandSettings.extendOsmandPath(getApplicationContext(), OsmandApplication.EXCEPTION_PATH); if (file.exists() && file.length() > 0) { if (size != file.length() && !firstTime) { String msg = MessageFormat.format( getString(R.string.previous_run_crashed), OsmandApplication.EXCEPTION_PATH); Builder builder = new AlertDialog.Builder(MainMenuActivity.this); builder.setMessage(msg).setNeutralButton(getString(R.string.close), null); builder.setPositiveButton( R.string.send_report, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra( Intent.EXTRA_EMAIL, new String[] {"*****@*****.**"}); // $NON-NLS-1$ intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); intent.setType("vnd.android.cursor.dir/email"); // $NON-NLS-1$ intent.putExtra(Intent.EXTRA_SUBJECT, "OsmAnd bug"); // $NON-NLS-1$ StringBuilder text = new StringBuilder(); text.append("\nDevice : ").append(Build.DEVICE); // $NON-NLS-1$ text.append("\nBrand : ").append(Build.BRAND); // $NON-NLS-1$ text.append("\nModel : ").append(Build.MODEL); // $NON-NLS-1$ text.append("\nProduct : ").append(Build.PRODUCT); // $NON-NLS-1$ text.append("\nBuild : ").append(Build.DISPLAY); // $NON-NLS-1$ text.append("\nVersion : ").append(Build.VERSION.RELEASE); // $NON-NLS-1$ text.append("\nApp Version : ").append(Version.APP_NAME_VERSION); // $NON-NLS-1$ try { PackageInfo info = getPackageManager().getPackageInfo(getPackageName(), 0); if (info != null) { text.append("\nApk Version : ") .append(info.versionName) .append(" ") .append(info.versionCode); // $NON-NLS-1$ //$NON-NLS-2$ } } catch (NameNotFoundException e) { } intent.putExtra(Intent.EXTRA_TEXT, text.toString()); startActivity(Intent.createChooser(intent, getString(R.string.send_report))); } }); builder.show(); } getPreferences(MODE_WORLD_READABLE) .edit() .putLong(EXCEPTION_FILE_SIZE, file.length()) .commit(); } else { if (size > 0) { getPreferences(MODE_WORLD_READABLE).edit().putLong(EXCEPTION_FILE_SIZE, 0).commit(); } } }
private void copyFilesForAndroid19() { final String newLoc = settings.getDefaultExternalStorageLocation(); MoveFilesToDifferentDirectory task = new MoveFilesToDifferentDirectory( DownloadIndexActivity.this, new File(settings.getExternalStorageDirectory(), IndexConstants.APP_DIR), new File(newLoc, IndexConstants.APP_DIR)) { protected Boolean doInBackground(Void[] params) { Boolean result = super.doInBackground(params); if (result) { settings.setExternalStorageDirectory(newLoc); getMyApplication().getResourceManager().resetStoreDirectory(); getMyApplication().getResourceManager().reloadIndexes(progress); } return result; }; }; task.execute(); }
public static <T> List<T> handleNumberOfRows( List<T> list, OsmandSettings settings, String rowNumberTag) { int numberOfRows = settings.registerIntPreference(rowNumberTag, 3).makeGlobal().get(); if (list.size() > numberOfRows) { while (list.size() != numberOfRows) { list.remove(numberOfRows); } } return list; }
@Override public void onAttach(Activity activity) { super.onAttach(activity); OsmandSettings settings = getMyApplication().getSettings(); OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); if (settings.OFFLINE_EDITION.get() || !settings.isInternetConnectionAvailable(true)) { mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); } else if (!settings.isInternetConnectionAvailable(true)) { mOpenstreetmapUtil = new OpenstreetmapLocalUtil(plugin, activity); } else { mOpenstreetmapUtil = new OpenstreetmapRemoteUtil(activity); } node = (Node) getArguments().getSerializable(KEY_AMENITY_NODE); allTranslatedSubTypes = getMyApplication().getPoiTypes().getAllTranslatedNames(); Amenity amenity = (Amenity) getArguments().getSerializable(KEY_AMENITY); editPoiData = new EditPoiData(amenity, node, allTranslatedSubTypes); }
public void showOnMap(boolean navigateTo) { if (searchPoint == null) { return; } String historyName = null; String objectName = ""; int zoom = 12; if (!Algoritms.isEmpty(street2) && !Algoritms.isEmpty(street)) { String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; objectName = street; historyName = MessageFormat.format( getString(R.string.search_history_int_streets), street, street2, cityName); zoom = 16; } else if (!Algoritms.isEmpty(building)) { String cityName = !Algoritms.isEmpty(postcode) ? postcode : city; objectName = street + " " + building; historyName = MessageFormat.format( getString(R.string.search_history_building), building, street, cityName); zoom = 16; } else if (!Algoritms.isEmpty(street)) { String cityName = postcode != null ? postcode : city; objectName = street; historyName = MessageFormat.format(getString(R.string.search_history_street), street, cityName); zoom = 15; } else if (!Algoritms.isEmpty(city)) { historyName = MessageFormat.format(getString(R.string.search_history_city), city); objectName = city; zoom = 13; } if (selectAddressMode) { Intent intent = getIntent(); intent.putExtra(SELECT_ADDRESS_POINT_INTENT_KEY, objectName); intent.putExtra(SELECT_ADDRESS_POINT_LAT, searchPoint.getLatitude()); intent.putExtra(SELECT_ADDRESS_POINT_LON, searchPoint.getLongitude()); setResult(SELECT_ADDRESS_POINT_RESULT_OK, intent); finish(); } else { if (navigateTo) { OsmandApplication app = (OsmandApplication) getApplication(); app.getTargetPointsHelper() .navigatePointDialogAndLaunchMap( SearchAddressActivity.this, searchPoint.getLatitude(), searchPoint.getLongitude(), historyName); } else { osmandSettings.setMapLocationToShow( searchPoint.getLatitude(), searchPoint.getLongitude(), zoom, historyName); MapActivity.launchMapActivityMoveToTop(SearchAddressActivity.this); } } }
private void updateDescriptionTextWithSize() { File dir = OsmandSettings.getOsmandSettings(this).extendOsmandPath(""); String size = formatGb.format(new Object[] {0}); if (dir.canRead()) { StatFs fs = new StatFs(dir.getAbsolutePath()); size = formatGb.format( new Object[] {(float) (fs.getAvailableBlocks()) * fs.getBlockSize() / (1 << 30)}); } ((TextView) findViewById(R.id.DescriptionText)) .setText(getString(R.string.local_index_description, size)); }
@Override protected void onPause() { super.onPause(); app.getLocationProvider().pauseAllUpdates(); app.getDaynightHelper().stopSensorIfNeeded(); settings.APPLICATION_MODE.removeListener(applicationModeListener); settings.setLastKnownMapLocation((float) mapView.getLatitude(), (float) mapView.getLongitude()); AnimateDraggingMapThread animatedThread = mapView.getAnimatedDraggingThread(); if (animatedThread.isAnimating() && animatedThread.getTargetZoom() != 0) { settings.setMapLocationToShow( animatedThread.getTargetLatitude(), animatedThread.getTargetLongitude(), (int) animatedThread.getTargetZoom()); } settings.setLastKnownMapZoom(mapView.getZoom()); settings.MAP_ACTIVITY_ENABLED.set(false); app.getResourceManager().interruptRendering(); app.getResourceManager().setBusyIndicator(null); OsmandPlugin.onMapActivityPause(this); }