Fix small issues

This commit is contained in:
Victor Shcherb 2015-10-19 22:50:37 +02:00
parent d1e802a05f
commit d66031f4d7
4 changed files with 19 additions and 8 deletions

View file

@ -74,6 +74,10 @@ public class IndexItem implements Comparable<IndexItem> {
return ((double)contentSize) / (1 << 20); return ((double)contentSize) / (1 << 20);
} }
public double getArchiveSizeMB() {
return ((double)containerSize) / (1 << 20);
}
public String getSizeDescription(Context ctx) { public String getSizeDescription(Context ctx) {
return size + " MB"; return size + " MB";
} }

View file

@ -77,6 +77,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment implements Dow
ItemViewHolder viewHolder = ItemViewHolder viewHolder =
new ItemViewHolder(convertView, context); new ItemViewHolder(convertView, context);
viewHolder.setSilentCancelDownload(true); viewHolder.setSilentCancelDownload(true);
viewHolder.setShowTypeInDesc(true);
viewHolder.setShowProgressInDescr(true); viewHolder.setShowProgressInDescr(true);
convertView.setTag(viewHolder); convertView.setTag(viewHolder);
} }

View file

@ -186,7 +186,6 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
} }
} }
} }
((DownloadActivity) getActivity()).startDownload(indexItem);
if (!handled) { if (!handled) {
ItemViewHolder vh = (ItemViewHolder) v.getTag(); ItemViewHolder vh = (ItemViewHolder) v.getTag();
OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem)); OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem));

View file

@ -1,7 +1,6 @@
package net.osmand.plus.download.ui; package net.osmand.plus.download.ui;
import java.text.DateFormat; import java.text.DateFormat;
import net.osmand.access.AccessibleToast; import net.osmand.access.AccessibleToast;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -12,6 +11,7 @@ import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
import net.osmand.plus.srtmplugin.SRTMPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin;
import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -137,7 +137,7 @@ public class ItemViewHolder {
leftImageView.setImageDrawable(getContentIcon(context, leftImageView.setImageDrawable(getContentIcon(context,
indexItem.getType().getIconResource())); indexItem.getType().getIconResource()));
} }
descrTextView.setTextColor(color); descrTextView.setTextColor(textColorSecondary);
if (!isDownloading) { if (!isDownloading) {
progressBar.setVisibility(View.GONE); progressBar.setVisibility(View.GONE);
descrTextView.setVisibility(View.VISIBLE); descrTextView.setVisibility(View.VISIBLE);
@ -149,7 +149,8 @@ public class ItemViewHolder {
"" + indexItem.getSizeDescription(context) + "" + indexItem.getSizeDescription(context) +
"" + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat))); "" + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat)));
} else { } else {
descrTextView.setText(indexItem.getSizeDescription(context) + "" + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat))); descrTextView.setText(indexItem.getSizeDescription(context) + "" +
(showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat)));
} }
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import)); rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
@ -165,12 +166,17 @@ public class ItemViewHolder {
progressBar.setProgress(progress); progressBar.setProgress(progress);
if (showProgressInDesc) { if (showProgressInDesc) {
double mb = indexItem.getContentSizeMB(); double mb = indexItem.getArchiveSizeMB();
String v ;
if (progress != -1) { if (progress != -1) {
descrTextView.setText(context.getString(R.string.value_downloaded_from_max, mb * progress / 100, v = context.getString(R.string.value_downloaded_from_max, mb * progress / 100, mb);
mb));
} else { } else {
descrTextView.setText(context.getString(R.string.file_size_in_mb, mb)); v = context.getString(R.string.file_size_in_mb, mb);
}
if(showTypeInDesc) {
descrTextView.setText(indexItem.getType().getString(context) + "" +v);
} else {
descrTextView.setText(v);
} }
descrTextView.setVisibility(View.VISIBLE); descrTextView.setVisibility(View.VISIBLE);
} else { } else {
@ -208,6 +214,7 @@ public class ItemViewHolder {
return disabled; return disabled;
} }
@SuppressLint("DefaultLocale")
public RightButtonAction getClickAction(final IndexItem indexItem) { public RightButtonAction getClickAction(final IndexItem indexItem) {
RightButtonAction clickAction = RightButtonAction.DOWNLOAD; RightButtonAction clickAction = RightButtonAction.DOWNLOAD;
if (indexItem.getBasename().toLowerCase().equals(DownloadResources.WORLD_SEAMARKS_KEY) if (indexItem.getBasename().toLowerCase().equals(DownloadResources.WORLD_SEAMARKS_KEY)