This commit is contained in:
Alexey Kulish 2015-10-02 15:59:37 +03:00
parent 7c421fc5f1
commit 7355cafc66
4 changed files with 29 additions and 30 deletions

View file

@ -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));

View file

@ -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);
}
}
*/
}
}

View file

@ -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<ItemsListBuilder.ResourceItem> {
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());

View file

@ -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);