Text with download date for maps.
This commit is contained in:
parent
3110862202
commit
be51e45f43
7 changed files with 111 additions and 29 deletions
|
@ -37,17 +37,31 @@
|
|||
android:textSize="@dimen/default_list_text_size"
|
||||
tools:text="Germany"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="25"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Map, Contour Lines, Wikipedia"
|
||||
tools:visibility="gone"/>
|
||||
<TextView
|
||||
android:id="@+id/description"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="25"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Contour Lines"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/mapDateTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="25"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
tools:text="Local version: 10/3/2015"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/progressBar"
|
||||
|
@ -65,10 +79,10 @@
|
|||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="@dimen/dashFavIconMargin"
|
||||
android:background="?attr/dashboard_button"
|
||||
tools:src="@drawable/ic_action_import"
|
||||
android:scaleType="center"
|
||||
tools:visibility="visible"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone"
|
||||
tools:src="@drawable/ic_action_import"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/rightButton"
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.download;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -9,6 +10,7 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
|
@ -26,7 +28,6 @@ import android.widget.ProgressBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -43,8 +44,6 @@ import net.osmand.plus.download.items.WorldItemsFragment;
|
|||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
@ -566,8 +565,8 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
}
|
||||
|
||||
|
||||
public void initFreeVersionBanner(View header) {
|
||||
visibleBanner = new BannerAndDownloadFreeVersion(header, this);
|
||||
public void initFreeVersionBanner(View view) {
|
||||
visibleBanner = new BannerAndDownloadFreeVersion(view, this);
|
||||
updateProgress(true);
|
||||
}
|
||||
|
||||
|
@ -584,11 +583,13 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
private static class ToggleCollapseFreeVersionBanner implements View.OnClickListener {
|
||||
private final View freeVersionDescriptionTextView;
|
||||
private final View buttonsLinearLayout;
|
||||
private final View freeVersionTitle;
|
||||
|
||||
private ToggleCollapseFreeVersionBanner(View freeVersionDescriptionTextView,
|
||||
View buttonsLinearLayout) {
|
||||
View buttonsLinearLayout, View freeVersionTitle) {
|
||||
this.freeVersionDescriptionTextView = freeVersionDescriptionTextView;
|
||||
this.buttonsLinearLayout = buttonsLinearLayout;
|
||||
this.freeVersionTitle = freeVersionTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -599,6 +600,7 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
} else {
|
||||
freeVersionDescriptionTextView.setVisibility(View.VISIBLE);
|
||||
buttonsLinearLayout.setVisibility(View.VISIBLE);
|
||||
freeVersionTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -694,7 +696,8 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
}
|
||||
});
|
||||
laterButton.setOnClickListener(
|
||||
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView, buttonsLinearLayout));
|
||||
new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout, freeVersionBannerTitle));
|
||||
}
|
||||
|
||||
private void updateFreeVersionBanner() {
|
||||
|
@ -712,7 +715,7 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
downloadsLeftTextView.setText(ctx.getString(R.string.downloads_left_template, downloadsLeft));
|
||||
// TODO review logic
|
||||
freeVersionBanner.setOnClickListener(new ToggleCollapseFreeVersionBanner(freeVersionDescriptionTextView,
|
||||
buttonsLinearLayout));
|
||||
buttonsLinearLayout, freeVersionBannerTitle));
|
||||
}
|
||||
|
||||
private void updateAvailableDownloads(int activeTasks) {
|
||||
|
@ -733,5 +736,4 @@ public class DownloadActivity extends BaseDownloadActivity implements RegionDial
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import net.osmand.plus.download.DownloadActivityType;
|
|||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Map;
|
||||
|
||||
public class ItemViewHolder {
|
||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
|
||||
|
||||
|
@ -32,6 +35,11 @@ public class ItemViewHolder {
|
|||
private final ImageView rightImageButton;
|
||||
private final Button rightButton;
|
||||
private final ProgressBar progressBar;
|
||||
private final TextView mapDateTextView;
|
||||
|
||||
private final Map<String, String> indexFileNames;
|
||||
private final Map<String, String> indexActivatedFileNames;
|
||||
private final java.text.DateFormat dateFormat;
|
||||
|
||||
private boolean srtmDisabled;
|
||||
private boolean nauticalPluginDisabled;
|
||||
|
@ -48,13 +56,21 @@ public class ItemViewHolder {
|
|||
ASK_FOR_FULL_VERSION_PURCHASE
|
||||
}
|
||||
|
||||
public ItemViewHolder(View convertView) {
|
||||
public ItemViewHolder(View convertView,
|
||||
DateFormat dateFormat,
|
||||
Map<String, String> indexFileNames,
|
||||
Map<String, String> indexActivatedFileNames) {
|
||||
this.indexFileNames = indexFileNames;
|
||||
this.indexActivatedFileNames = indexActivatedFileNames;
|
||||
this.dateFormat = dateFormat;
|
||||
nameTextView = (TextView) convertView.findViewById(R.id.name);
|
||||
descrTextView = (TextView) convertView.findViewById(R.id.description);
|
||||
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
|
||||
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
|
||||
rightButton = (Button) convertView.findViewById(R.id.rightButton);
|
||||
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
|
||||
mapDateTextView = (TextView) convertView.findViewById(R.id.mapDateTextView);
|
||||
;
|
||||
|
||||
TypedValue typedValue = new TypedValue();
|
||||
Resources.Theme theme = convertView.getContext().getTheme();
|
||||
|
@ -177,6 +193,26 @@ public class ItemViewHolder {
|
|||
leftImageView.setImageDrawable(getContextIcon(context, indexItem.getType().getIconResource()));
|
||||
nameTextView.setTextColor(textColorPrimary);
|
||||
}
|
||||
|
||||
if (indexFileNames != null && indexItem.isAlreadyDownloaded(indexFileNames)) {
|
||||
boolean outdated = false;
|
||||
String date = null;
|
||||
if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) {
|
||||
// TODO write logic for outdated
|
||||
date = indexItem.getDate(dateFormat);
|
||||
} else {
|
||||
String sfName = indexItem.getTargetFileName();
|
||||
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
|
||||
date = updatableResource ? indexActivatedFileNames.get(sfName) : indexFileNames.get(sfName);
|
||||
outdated = DownloadActivity.downloadListIndexThread.checkIfItemOutdated(indexItem);
|
||||
}
|
||||
String updateDescr = context.getResources().getString(R.string.local_index_installed) + ": "
|
||||
+ date;
|
||||
mapDateTextView.setText(updateDescr);
|
||||
int colorId = outdated ? R.color.color_distance : R.color.color_ok;
|
||||
mapDateTextView.setTextColor(context.getResources().getColor(colorId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void bindRegion(WorldRegion region, DownloadActivity context) {
|
||||
|
|
|
@ -120,6 +120,10 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public DownloadActivity getMyActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
private void fillRegionItemsAdapter(ItemsListBuilder builder) {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.clear();
|
||||
|
@ -207,7 +211,10 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
@ -223,7 +230,10 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
|||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
|
@ -110,6 +110,10 @@ public class SearchItemsFragment extends Fragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public DownloadActivity getMyActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
private void fillSearchItemsAdapter() {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.clear();
|
||||
|
@ -191,7 +195,10 @@ public class SearchItemsFragment extends Fragment {
|
|||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
|
@ -14,7 +14,6 @@ import android.widget.TextView;
|
|||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.WorldRegion;
|
||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
|
@ -113,6 +112,10 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public DownloadActivity getMyActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
private void fillVoiceItemsAdapter(ItemsListBuilder builder) {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.clear();
|
||||
|
@ -181,7 +184,10 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
|||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
|
@ -92,6 +92,10 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
return (OsmandApplication) getActivity().getApplication();
|
||||
}
|
||||
|
||||
public DownloadActivity getMyActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
||||
private void fillWorldItemsAdapter(ItemsListBuilder builder) {
|
||||
if (listAdapter != null) {
|
||||
listAdapter.clear();
|
||||
|
@ -260,7 +264,10 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
|||
if (convertView == null) {
|
||||
convertView = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||
viewHolder = new ItemViewHolder(convertView);
|
||||
viewHolder = new ItemViewHolder(convertView,
|
||||
getMyApplication().getResourceManager().getDateFormat(),
|
||||
getMyActivity().getIndexActivatedFileNames(),
|
||||
getMyActivity().getIndexFileNames());
|
||||
convertView.setTag(viewHolder);
|
||||
} else {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
|
Loading…
Reference in a new issue