From 7355cafc668bef8a29ddd2eff51a371652e52087 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Fri, 2 Oct 2015 15:59:37 +0300 Subject: [PATCH] Merge --- .../plus/download/items/ItemViewHolder.java | 17 ++++++++-- .../plus/download/items/ItemsListBuilder.java | 9 ++---- .../download/items/RegionItemsFragment.java | 31 ++++++------------- .../details/AmenityMenuBuilder.java | 2 +- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java index 3a8dc62ce4..9b4ad7ef90 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemViewHolder.java @@ -19,6 +19,7 @@ public class ItemViewHolder { private final ImageView leftImageView; private final ImageView rightImageButton; private final ProgressBar progressBar; + private boolean srtmDisabled; public ItemViewHolder(View convertView) { nameTextView = (TextView) convertView.findViewById(R.id.name); @@ -28,18 +29,30 @@ public class ItemViewHolder { progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar); } + public void setSrtmDisabled(boolean srtmDisabled) { + this.srtmDisabled = srtmDisabled; + } + public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context, boolean showTypeInTitle, boolean showTypeInDesc) { + boolean light = context.getMyApplication().getSettings().isLightContent(); + if (indexItem.getType() == DownloadActivityType.VOICE_FILE) { nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions())); } else { - if (showTypeInTitle) { + if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE && srtmDisabled) { + nameTextView.setText(context.getString(R.string.srtm_plugin_disabled)); + nameTextView.setTextColor(context.getResources().getColor(light ? android.R.color.secondary_text_light : android.R.color.secondary_text_dark)); + } else if (showTypeInTitle) { nameTextView.setText(indexItem.getType().getString(context)); } else { nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions())); } } - if (showTypeInDesc) { + + if (!showTypeInTitle && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE && srtmDisabled) { + descrTextView.setText(indexItem.getType().getString(context)); + } else if (showTypeInDesc) { descrTextView.setText(indexItem.getType().getString(context) + " • " + indexItem.getSizeDescription(context)); } else { descrTextView.setText(indexItem.getSizeDescription(context)); diff --git a/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java b/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java index dc23390a7d..bd3cac874d 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java +++ b/OsmAnd/src/net/osmand/plus/download/items/ItemsListBuilder.java @@ -6,6 +6,7 @@ import net.osmand.PlatformUtil; import net.osmand.map.OsmandRegions; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; import net.osmand.plus.WorldRegion; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; @@ -326,12 +327,6 @@ public class ItemsListBuilder { if (hasSrtm && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) continue; - if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { - resItem.setTitle("srtm_disabled"); // todo: constant - resItem.setContentSize(0); - resItem.setContainerSize(0); - } - if (!hasSrtm && indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) hasSrtm = true; } @@ -362,6 +357,7 @@ public class ItemsListBuilder { Collections.sort(allResourceItems, new ResourceItemComparator()); Collections.sort(regionMapItems, new ResourceItemComparator()); + /* boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null; if (nauticalPluginDisabled) { @@ -376,5 +372,6 @@ public class ItemsListBuilder { regionMapItems.remove(seamarksMapItem); } } + */ } } diff --git a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java index b50ac05070..35544efcfd 100644 --- a/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/items/RegionItemsFragment.java @@ -15,9 +15,11 @@ import android.widget.TextView; import net.osmand.PlatformUtil; import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.WorldRegion; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.srtmplugin.SRTMPlugin; import org.apache.commons.logging.Log; @@ -111,26 +113,6 @@ public class RegionItemsFragment extends Fragment { return view; } - public static void setListViewHeightBasedOnChildren(ListView listView) { - ListAdapter listAdapter = listView.getAdapter(); - if (listAdapter == null) { - // pre-condition - return; - } - - int totalHeight = 0; - for (int i = 0; i < listAdapter.getCount(); i++) { - View listItem = listAdapter.getView(i, null, listView); - listItem.measure(0, 0); - totalHeight += listItem.getMeasuredHeight(); - } - - ViewGroup.LayoutParams params = listView.getLayoutParams(); - params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); - listView.setLayoutParams(params); - listView.requestLayout(); - } - @Override public void onSaveInstanceState(Bundle outState) { outState.putSerializable(REGION_KEY, region); @@ -172,7 +154,6 @@ public class RegionItemsFragment extends Fragment { } else { textView.setVisibility(View.VISIBLE); listView.setVisibility(View.VISIBLE); - setListViewHeightBasedOnChildren(listView); } } @@ -189,9 +170,11 @@ public class RegionItemsFragment extends Fragment { } private static class MapsAdapter extends ArrayAdapter { + private boolean srtmDisabled; public MapsAdapter(Context context) { super(context, R.layout.simple_list_menu_item); + srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null; } @Override @@ -205,6 +188,8 @@ public class RegionItemsFragment extends Fragment { } else { viewHolder = (ItemViewHolder) convertView.getTag(); } + viewHolder.setSrtmDisabled(srtmDisabled); + ItemsListBuilder.ResourceItem item = getItem(position); viewHolder.bindIndexItem(item.getIndexItem(), (DownloadActivity) getContext(), true, false); return convertView; @@ -212,9 +197,11 @@ public class RegionItemsFragment extends Fragment { } private static class RegionsAdapter extends ArrayAdapter { + private boolean srtmDisabled; public RegionsAdapter(Context context) { super(context, R.layout.two_line_with_images_list_item); + srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null; } @Override @@ -228,6 +215,8 @@ public class RegionItemsFragment extends Fragment { } else { viewHolder = (ItemViewHolder) convertView.getTag(); } + viewHolder.setSrtmDisabled(srtmDisabled); + Object item = getItem(position); if (item instanceof WorldRegion) { viewHolder.bindRegion((WorldRegion) item, (DownloadActivity) getContext()); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java index 53a2430db5..bf46644f6e 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/details/AmenityMenuBuilder.java @@ -75,7 +75,7 @@ public class AmenityMenuBuilder extends MenuBuilder { LinearLayout.LayoutParams llTextParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); llTextParams.setMargins(0, isFirstRow() ? dpToPx(8f) - dpToPx(SHADOW_HEIGHT_BOTTOM_DP) : dpToPx(8f), 0, dpToPx(8f)); textView.setLayoutParams(llTextParams); - textView.setTextSize(16); // todo: create constant + textView.setTextSize(16); textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark)); textView.setAutoLinkMask(Linkify.ALL);