use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method addRestorePurchasesRow.
private void addRestorePurchasesRow() {
if (!openAsDialog() && !InAppHelper.isInAppIntentoryRead()) {
restorePurchasesView = activity.getLayoutInflater().inflate(R.layout.restore_purchases_list_footer, null);
((ImageView) restorePurchasesView.findViewById(R.id.icon)).setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_reset_to_default_dark));
restorePurchasesView.findViewById(R.id.button).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
restorePurchasesView.findViewById(R.id.progressBar).setVisibility(View.VISIBLE);
activity.startInAppHelper();
}
});
listView.addFooterView(restorePurchasesView);
listView.setFooterDividersEnabled(false);
IndexItem worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
if (worldBaseMapItem == null || !worldBaseMapItem.isDownloaded()) {
restorePurchasesView.findViewById(R.id.container).setVisibility(View.GONE);
}
}
}
use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.
the class DownloadResourceGroupFragment method addSubscribeEmailRow.
private void addSubscribeEmailRow() {
if (DownloadActivity.shouldShowFreeVersionBanner(activity.getMyApplication()) && !getMyApplication().getSettings().EMAIL_SUBSCRIBED.get()) {
subscribeEmailView = activity.getLayoutInflater().inflate(R.layout.subscribe_email_header, null, false);
subscribeEmailView.findViewById(R.id.subscribe_btn).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
subscribe();
}
});
listView.addHeaderView(subscribeEmailView);
IndexItem worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
if (worldBaseMapItem == null || !worldBaseMapItem.isDownloaded() || DownloadActivity.isDownlodingPermitted(activity.getMyApplication().getSettings())) {
subscribeEmailView.findViewById(R.id.container).setVisibility(View.GONE);
}
}
}
use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.
the class DashboardOnMap method onDownloadInProgress.
@SuppressWarnings("unchecked")
public void onDownloadInProgress() {
if (visibleType == DashboardType.CONTOUR_LINES || visibleType == DashboardType.HILLSHADE) {
DownloadIndexesThread downloadThread = getMyApplication().getDownloadThread();
IndexItem downloadIndexItem = downloadThread.getCurrentDownloadingItem();
if (downloadIndexItem != null) {
int downloadProgress = downloadThread.getCurrentDownloadingItemProgress();
ArrayAdapter<ContextMenuItem> adapter = (ArrayAdapter<ContextMenuItem>) listAdapter;
for (int i = 0; i < adapter.getCount(); i++) {
ContextMenuItem item = adapter.getItem(i);
if (item != null && item.getProgressListener() != null) {
item.getProgressListener().onProgressChanged(downloadIndexItem, downloadProgress, adapter, (int) adapter.getItemId(i), i);
}
}
}
}
}
use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.
the class MapActivityActions method createMainOptionsMenu.
public ContextMenuAdapter createMainOptionsMenu() {
final OsmandMapTileView mapView = mapActivity.getMapView();
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter();
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity).setIcon(R.drawable.map_dashboard).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_dashboard_open");
MapActivity.clearPrevActivityIntent();
mapActivity.closeDrawer();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD, viewCoordinates);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity).setIcon(R.drawable.ic_action_flag_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_markers_open");
MapActivity.clearPrevActivityIntent();
MapMarkersDialogFragment.showInstance(mapActivity);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity).setIcon(R.drawable.ic_action_fav_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_myplaces_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getFavoritesActivity());
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity).setIcon(R.drawable.ic_action_search_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_search_open");
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
return true;
}
}).createItem());
if (settings.SHOW_LEGACY_SEARCH.get()) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.legacy_search, mapActivity).setIcon(R.drawable.ic_action_search_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_legacy_search_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getSearchActivity());
LatLon loc = mapActivity.getMapLocation();
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
if (mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
}
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity).setIcon(R.drawable.ic_action_gdirections_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_directions_open");
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
if (mapControlsLayer != null) {
mapControlsLayer.doRoute(false);
}
return true;
}
}).createItem());
/*
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_point_options, mapActivity)
.setIcon(R.drawable.ic_action_marker_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
return true;
}
}).createItem());
*/
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity).setIcon(R.drawable.ic_action_layers_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_map_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP, viewCoordinates);
return false;
}
}).createItem());
String d = getString(R.string.welmode_download_maps);
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
List<IndexItem> updt = app.getDownloadThread().getIndexes().getItemsToUpdate();
if (updt != null && updt.size() > 0) {
d += " (" + updt.size() + ")";
}
}
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.welmode_download_maps, null).setTitle(d).setIcon(R.drawable.ic_type_archive).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_download_maps_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getDownloadActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
if (Version.isGooglePlayEnabled(app) || Version.isDeveloperVersion(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity).setIcon(R.drawable.ic_action_osm_live).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_osm_live_open");
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
return false;
}
}).createItem());
}
if (WikivoyageDbHelper.isDbFileExists(app)) {
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_travel, mapActivity).setIcon(R.drawable.ic_action_travel).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
MapActivity.clearPrevActivityIntent();
WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
}
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.measurement_tool, mapActivity).setIcon(R.drawable.ic_action_ruler).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int position, boolean isChecked, int[] viewCoordinates) {
MeasurementToolFragment.showInstance(mapActivity.getSupportFragmentManager());
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity).setIcon(R.drawable.ic_configure_screen_dark).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_config_screen_open");
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN, viewCoordinates);
return false;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity).setIcon(R.drawable.ic_extension_dark).setListener(new ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_plugins_open");
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getPluginsActivity());
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(newIntent);
return true;
}
}).createItem());
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity).setIcon(R.drawable.ic_action_settings).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_settings_open");
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization().getSettingsActivity());
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(settings);
return true;
}
}).createItem());
/*
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
.setIcon(R.drawable.ic_action_layers_dark)
.setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
MapActivity.clearPrevActivityIntent();
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
return false;
}
}).createItem());
*/
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity).setIcon(R.drawable.ic_action_help).setListener(new ContextMenuAdapter.ItemClickListener() {
@Override
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) {
app.logEvent(mapActivity, "drawer_help_open");
Intent intent = new Intent(mapActivity, HelpActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
mapActivity.startActivity(intent);
return true;
}
}).createItem());
// ////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
// Place divider between functionality and configuration related menu items
int dividerItemIndex = -1;
for (int i = 0; i < optionsMenuHelper.length(); i++) {
if (optionsMenuHelper.getItem(i).getTitleId() == R.string.layer_map_appearance) {
dividerItemIndex = i;
break;
}
}
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
divider.setPosition(dividerItemIndex >= 0 ? dividerItemIndex : 8);
optionsMenuHelper.addItem(divider.createItem());
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
return optionsMenuHelper;
}
use of net.osmand.plus.download.IndexItem in project Osmand by osmandapp.
the class DownloadedRegionsLayer method getWorldRegionFromPoint.
private void getWorldRegionFromPoint(RotatedTileBox tb, PointF point, List<? super DownloadMapObject> dataObjects) {
int zoom = tb.getZoom();
if (zoom >= ZOOM_TO_SHOW_SELECTION_ST && zoom < ZOOM_TO_SHOW_SELECTION && data.results != null && osmandRegions.isInitialized()) {
LatLon pointLatLon = tb.getLatLonFromPixel(point.x, point.y);
int point31x = MapUtils.get31TileNumberX(pointLatLon.getLongitude());
int point31y = MapUtils.get31TileNumberY(pointLatLon.getLatitude());
List<BinaryMapDataObject> result = new LinkedList<>(data.results);
Iterator<BinaryMapDataObject> it = result.iterator();
while (it.hasNext()) {
BinaryMapDataObject o = it.next();
boolean isRegion = true;
for (int i = 0; i < o.getTypes().length; i++) {
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
if ("boundary".equals(tp.value)) {
isRegion = false;
break;
}
}
if (!isRegion || !osmandRegions.contain(o, point31x, point31y)) {
it.remove();
}
}
OsmandRegions osmandRegions = app.getRegions();
for (BinaryMapDataObject o : result) {
String fullName = osmandRegions.getFullName(o);
WorldRegion region = osmandRegions.getRegionData(fullName);
if (region != null && region.isRegionMapDownload()) {
List<IndexItem> indexItems = app.getDownloadThread().getIndexes().getIndexItems(region);
List<IndexItem> dataItems = new LinkedList<>();
IndexItem regularMapItem = null;
for (IndexItem item : indexItems) {
if (item.isDownloaded() || app.getDownloadThread().isDownloading(item)) {
dataItems.add(item);
if (item.getType() == DownloadActivityType.NORMAL_FILE) {
regularMapItem = item;
}
}
}
if (dataItems.isEmpty() && regularMapItem != null) {
dataItems.add(regularMapItem);
}
if (!dataItems.isEmpty()) {
for (IndexItem item : dataItems) {
dataObjects.add(new DownloadMapObject(o, region, item, null));
}
} else {
String downloadName = osmandRegions.getDownloadName(o);
List<LocalIndexInfo> infos = helper.getLocalIndexInfos(downloadName);
if (infos.size() == 0) {
dataObjects.add(new DownloadMapObject(o, region, null, null));
} else {
for (LocalIndexInfo info : infos) {
dataObjects.add(new DownloadMapObject(o, region, null, info));
}
}
}
}
}
}
}
Aggregations