From 178b1dab59a680d1715ebe5ba9c28f74ba666819 Mon Sep 17 00:00:00 2001 From: Leif Larsson Date: Tue, 20 Oct 2015 16:42:13 +0200 Subject: [PATCH 01/33] Translated using Weblate (Swedish) Currently translated at 99.2% (1756 of 1769 strings) --- OsmAnd/res/values-sv/strings.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-sv/strings.xml b/OsmAnd/res/values-sv/strings.xml index bd5e2f1cbb..564860197b 100644 --- a/OsmAnd/res/values-sv/strings.xml +++ b/OsmAnd/res/values-sv/strings.xml @@ -2048,4 +2048,5 @@ Uppdatera alla (%1$s MB) Gratis nedladdningar hämtade Du kan ange hur många gratis nedladdningar som du har gjort - +Hämtar - %1$d fil(er) + From 51e3709fadcf5ec2e23ad28a34c7a98097ce678a Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 20 Oct 2015 19:39:48 +0300 Subject: [PATCH 02/33] Downloads search in progress --- .../download/ui/DownloadGroupViewHolder.java | 71 ++++ .../ui/DownloadResourceGroupFragment.java | 96 +---- .../download/ui/SearchDialogFragment.java | 357 ++++++++++++++++-- .../plus/download/ui/SearchItemsFragment.java | 337 ----------------- 4 files changed, 413 insertions(+), 448 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/download/ui/DownloadGroupViewHolder.java delete mode 100644 OsmAnd/src/net/osmand/plus/download/ui/SearchItemsFragment.java diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadGroupViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadGroupViewHolder.java new file mode 100644 index 0000000000..a95e75a6f4 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadGroupViewHolder.java @@ -0,0 +1,71 @@ +package net.osmand.plus.download.ui; + +import android.graphics.drawable.Drawable; +import android.view.View; +import android.widget.TextView; + +import net.osmand.plus.IconsCache; +import net.osmand.plus.R; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadActivityType; +import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.IndexItem; + +public class DownloadGroupViewHolder { + TextView textView; + private DownloadActivity ctx; + + public DownloadGroupViewHolder(DownloadActivity ctx, View v) { + this.ctx = ctx; + textView = (TextView) v.findViewById(R.id.title); + } + + private boolean isParentWorld(DownloadResourceGroup group) { + return group.getParentGroup() == null + || group.getParentGroup().getType() == DownloadResourceGroup.DownloadResourceGroupType.WORLD; + } + + private Drawable getIconForGroup(DownloadResourceGroup group) { + Drawable iconLeft; + if (group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_REC + || group.getType() == DownloadResourceGroup.DownloadResourceGroupType.VOICE_TTS) { + iconLeft = ctx.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_volume_up); + } else { + IconsCache cache = ctx.getMyApplication().getIconsCache(); + if (isParentWorld(group) || isParentWorld(group.getParentGroup())) { + iconLeft = cache.getContentIcon(R.drawable.ic_world_globe_dark); + } else { + DownloadResourceGroup ggr = group + .getSubGroupById(DownloadResourceGroup.DownloadResourceGroupType.REGION_MAPS.getDefaultId()); + iconLeft = cache.getContentIcon(R.drawable.ic_map); + if (ggr != null && ggr.getIndividualResources() != null) { + IndexItem item = null; + for (IndexItem ii : ggr.getIndividualResources()) { + if (ii.getType() == DownloadActivityType.NORMAL_FILE + || ii.getType() == DownloadActivityType.ROADS_FILE) { + if (ii.isDownloaded() || ii.isOutdated()) { + item = ii; + break; + } + } + } + if (item != null) { + if (item.isOutdated()) { + iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_distance); + } else { + iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_ok); + } + } + } + } + } + return iconLeft; + } + + public void bindItem(DownloadResourceGroup group) { + Drawable iconLeft = getIconForGroup(group); + textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null); + String name = group.getName(ctx); + textView.setText(name); + } +} diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java index 81873cbc80..5f539a4f7a 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java @@ -1,31 +1,11 @@ package net.osmand.plus.download.ui; -import java.util.ArrayList; -import java.util.List; - -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; -import net.osmand.plus.download.DownloadActivityType; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.DownloadResourceGroup; -import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; -import net.osmand.plus.download.DownloadResources; -import net.osmand.plus.download.IndexItem; -import net.osmand.util.Algorithms; import android.content.Context; -import android.content.DialogInterface; import android.content.res.Resources; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.view.MenuItemCompat; -import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.util.TypedValue; import android.view.LayoutInflater; @@ -39,6 +19,22 @@ import android.widget.ExpandableListView; import android.widget.ExpandableListView.OnChildClickListener; import android.widget.TextView; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; +import net.osmand.plus.download.DownloadResources; +import net.osmand.plus.download.IndexItem; +import net.osmand.util.Algorithms; + +import java.util.ArrayList; +import java.util.List; + public class DownloadResourceGroupFragment extends DialogFragment implements DownloadEvents, OnChildClickListener { public static final int RELOAD_ID = 0; public static final int SEARCH_ID = 1; @@ -230,66 +226,6 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow return fragment; } - - - private static class DownloadGroupViewHolder { - TextView textView; - private DownloadActivity ctx; - - public DownloadGroupViewHolder(DownloadActivity ctx, View v) { - this.ctx = ctx; - textView = (TextView) v.findViewById(R.id.title); - } - - private boolean isParentWorld(DownloadResourceGroup group) { - return group.getParentGroup() == null - || group.getParentGroup().getType() == DownloadResourceGroupType.WORLD; - } - - private Drawable getIconForGroup(DownloadResourceGroup group) { - Drawable iconLeft; - if (group.getType() == DownloadResourceGroupType.VOICE_REC - || group.getType() == DownloadResourceGroupType.VOICE_TTS) { - iconLeft = ctx.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_volume_up); - } else { - IconsCache cache = ctx.getMyApplication().getIconsCache(); - if (isParentWorld(group) || isParentWorld(group.getParentGroup())) { - iconLeft = cache.getContentIcon(R.drawable.ic_world_globe_dark); - } else { - DownloadResourceGroup ggr = group - .getSubGroupById(DownloadResourceGroupType.REGION_MAPS.getDefaultId()); - iconLeft = cache.getContentIcon(R.drawable.ic_map); - if (ggr != null && ggr.getIndividualResources() != null) { - IndexItem item = null; - for (IndexItem ii : ggr.getIndividualResources()) { - if (ii.getType() == DownloadActivityType.NORMAL_FILE - || ii.getType() == DownloadActivityType.ROADS_FILE) { - if (ii.isDownloaded() || ii.isOutdated()) { - item = ii; - break; - } - } - } - if (item != null) { - if (item.isOutdated()) { - iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_distance); - } else { - iconLeft = cache.getIcon(R.drawable.ic_map, R.color.color_ok); - } - } - } - } - } - return iconLeft; - } - - public void bindItem(DownloadResourceGroup group) { - Drawable iconLeft = getIconForGroup(group); - textView.setCompoundDrawablesWithIntrinsicBounds(iconLeft, null, null, null); - String name = group.getName(ctx); - textView.setText(name); - } - } public static class DownloadResourceGroupAdapter extends OsmandBaseExpandableListAdapter { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 4208fd283c..9793d5adc3 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -1,34 +1,50 @@ package net.osmand.plus.download.ui; +import android.content.res.TypedArray; import android.os.Bundle; import android.support.v4.app.DialogFragment; -import android.support.v4.app.Fragment; import android.support.v7.widget.Toolbar; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; +import android.widget.BaseAdapter; +import android.widget.ExpandableListView; +import android.widget.Filter; +import android.widget.Filterable; +import android.widget.LinearLayout; +import android.widget.ListView; import android.widget.RelativeLayout; import android.widget.RelativeLayout.LayoutParams; import android.widget.SearchView; + +import net.osmand.Collator; +import net.osmand.OsmAndCollator; +import net.osmand.map.OsmandRegions; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.DownloadResources; +import net.osmand.plus.download.IndexItem; -// FIXME -public class SearchDialogFragment extends DialogFragment { +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; - public static DialogFragment createInstance(String tg) { - return new SearchDialogFragment(); - } - - - - /*extends DialogFragment implements DownloadEvents { +public class SearchDialogFragment extends DialogFragment implements DownloadEvents, OnItemClickListener { public static final String TAG = "SearchDialogFragment"; private static final String SEARCH_TEXT_DLG_KEY = "search_text_dlg_key"; + private ListView listView; + private SearchListAdapter listAdapter; + private BannerAndDownloadFreeVersion banner; private String searchText; private SearchView search; @@ -63,6 +79,24 @@ public class SearchDialogFragment extends DialogFragment { } }); + banner = new BannerAndDownloadFreeVersion(view, (DownloadActivity) getActivity()); + + LinearLayout ll = (LinearLayout) view; + ExpandableListView expandablelistView = (ExpandableListView) view.findViewById(android.R.id.list); + ll.removeView(expandablelistView); + + listView = new ListView(getActivity()); + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0); + layoutParams.weight = 1; + layoutParams.setMargins(0, 0, 0, 0); + listView.setLayoutParams(layoutParams); + ll.addView(listView); + + listView.setOnItemClickListener(this); + listAdapter = new SearchListAdapter(getDownloadActivity()); + listView.setOnItemClickListener(this); + listView.setAdapter(listAdapter); + search = new SearchView(getActivity()); RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); @@ -95,25 +129,46 @@ public class SearchDialogFragment extends DialogFragment { @Override public boolean onQueryTextChange(String newText) { - Fragment f = getChildFragmentManager().findFragmentByTag(SearchItemsFragment.TAG); - if (f != null) { - ((SearchItemsFragment) f).updateSearchText(newText); - return true; - } - return false; + updateSearchText(newText); + return true; } }); - Fragment fragment = getChildFragmentManager().findFragmentById(R.id.fragmentContainer); - if (fragment == null) { - getChildFragmentManager().beginTransaction().add(R.id.fragmentContainer, - SearchItemsFragment.createInstance(searchText), SearchItemsFragment.TAG).commit(); - } - - getDownloadActivity().registerFreeVersionBanner(view); return view; } + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + setShowsDialog(true); + listView.setBackgroundColor(getResources().getColor( + getMyApplication().getSettings().isLightContent() ? R.color.bg_color_light : R.color.bg_color_dark)); + } + + @Override + public void newDownloadIndexes() { + if(banner != null) { + banner.updateBannerInProgress(); + } + updateSearchText(searchText); + } + + @Override + public void downloadHasFinished() { + if(banner != null) { + banner.updateBannerInProgress(); + } + listAdapter.notifyDataSetChanged(); + } + + @Override + public void downloadInProgress() { + if(banner != null) { + banner.updateBannerInProgress(); + } + listAdapter.notifyDataSetChanged(); + } + @Override public void onSaveInstanceState(Bundle outState) { outState.putString(SEARCH_TEXT_DLG_KEY, searchText); @@ -126,6 +181,11 @@ public class SearchDialogFragment extends DialogFragment { search.setIconified(false); } + public void updateSearchText(String searchText) { + this.searchText = searchText; + listAdapter.getFilter().filter(searchText); + } + private OsmandApplication getMyApplication() { return (OsmandApplication) getActivity().getApplication(); } @@ -134,13 +194,6 @@ public class SearchDialogFragment extends DialogFragment { return (DownloadActivity) getActivity(); } - public void newDownloadIndexes() { - Fragment f = getChildFragmentManager().findFragmentByTag(SearchItemsFragment.TAG); - if (f != null) { - ((SearchItemsFragment) f).onCategorizationFinished(); - } - } - public static SearchDialogFragment createInstance(String searchText) { Bundle bundle = new Bundle(); bundle.putString(SEARCH_TEXT_DLG_KEY, searchText); @@ -148,5 +201,247 @@ public class SearchDialogFragment extends DialogFragment { fragment.setArguments(bundle); return fragment; } - */ + + @Override + public void onItemClick(AdapterView parent, View v, int position, long id) { + Object obj = listAdapter.getItem(position); + if (obj instanceof DownloadResourceGroup) { + String uniqueId = ((DownloadResourceGroup) obj).getUniqueId(); + final DownloadResourceGroupFragment regionDialogFragment = DownloadResourceGroupFragment + .createInstance(uniqueId); + ((DownloadActivity) getActivity()).showDialog(getActivity(), regionDialogFragment); + } else if (obj instanceof IndexItem) { + IndexItem indexItem = (IndexItem) obj; + ItemViewHolder vh = (ItemViewHolder) v.getTag(); + View.OnClickListener ls = vh.getRightButtonAction(indexItem, vh.getClickAction(indexItem), null); + ls.onClick(v); + } + } + + private class SearchListAdapter extends BaseAdapter implements Filterable { + + private SearchIndexFilter mFilter; + + private List items = new LinkedList<>(); + private DownloadActivity ctx; + + public SearchListAdapter(DownloadActivity ctx) { + this.ctx = ctx; + TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary}); + ta.recycle(); + } + + public void clear() { + items.clear(); + notifyDataSetChanged(); + } + + @Override + public Object getItem(int position) { + return items.get(position); + } + + @Override + public int getCount() { + return items.size(); + } + + @Override + public long getItemId(int position) { + return position; + } + + @Override + public int getItemViewType(int position) { + Object obj = items.get(position); + if (obj instanceof IndexItem) { + return 0; + } else { + return 1; + } + } + + @Override + public int getViewTypeCount() { + return 2; + } + + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + final Object obj = items.get(position); + if (obj instanceof IndexItem) { + + IndexItem item = (IndexItem) obj; + ItemViewHolder viewHolder; + if (convertView != null && convertView.getTag() instanceof ItemViewHolder) { + viewHolder = (ItemViewHolder) convertView.getTag(); + } else { + convertView = LayoutInflater.from(parent.getContext()).inflate( + R.layout.two_line_with_images_list_item, parent, false); + viewHolder = new ItemViewHolder(convertView, getDownloadActivity()); + viewHolder.setShowRemoteDate(true); + convertView.setTag(viewHolder); + } + viewHolder.setShowTypeInDesc(true); + viewHolder.bindIndexItem(item, null); + } else { + DownloadResourceGroup group = (DownloadResourceGroup) obj; + DownloadGroupViewHolder viewHolder; + if (convertView != null && convertView.getTag() instanceof DownloadGroupViewHolder) { + viewHolder = (DownloadGroupViewHolder) convertView.getTag(); + } else { + convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.simple_list_menu_item, + parent, false); + viewHolder = new DownloadGroupViewHolder(getDownloadActivity(), convertView); + convertView.setTag(viewHolder); + } + viewHolder.bindItem(group); + } + return convertView; + } + + + @Override + public boolean hasStableIds() { + return false; + } + + @Override + public Filter getFilter() { + if (mFilter == null) { + mFilter = new SearchIndexFilter(); + } + return mFilter; + } + + private final class SearchIndexFilter extends Filter { + + private OsmandRegions osmandRegions; + + public SearchIndexFilter() { + this.osmandRegions = ctx.getMyApplication().getRegions(); + } + + private void processGroup(DownloadResourceGroup group, List filter, List> conds) { + String indexLC = group.getName(ctx).toLowerCase(); + if (isMatch(conds, false, indexLC)) { + filter.add(group); + } + if (group.getGroups() != null) { + for (DownloadResourceGroup g : group.getGroups()) { + processGroup(g, filter, conds); + } + } + } + + @Override + protected FilterResults performFiltering(CharSequence constraint) { + DownloadResources root = ctx.getDownloadThread().getIndexes(); + + FilterResults results = new FilterResults(); + if (constraint == null || constraint.length() < 2) { + results.values = new ArrayList<>(); + results.count = 0; + } else { + String[] ors = constraint.toString().split(","); + List> conds = new ArrayList<>(); + for (String or : ors) { + final ArrayList cond = new ArrayList<>(); + for (String term : or.split("\\s")) { + final String t = term.trim().toLowerCase(); + if (t.length() > 0) { + cond.add(t); + } + } + if (cond.size() > 0) { + conds.add(cond); + } + } + + List filter = new ArrayList<>(); + processGroup(root, filter, conds); + + /* + List regions = new ArrayList<>(); + for (WorldRegion region : worldRegions) { + String indexLC = region.getName().toLowerCase(); + if (isMatch(conds, false, indexLC)) { + regions.add(region); + } + } + + for (WorldRegion region : regions) { + if (region.getSubregions().size() > 0) { + filter.add(region); + } + + List items = getDownloadActivity().getIndexItemsByRegion(region); + if (items.size() > 1) { + if (!filter.contains(region)) { + filter.add(region); + } + } else { + filter.addAll(items); + } + } + */ + + final Collator collator = OsmAndCollator.primaryCollator(); + Collections.sort(filter, new Comparator() { + @Override + public int compare(Object obj1, Object obj2) { + String str1; + String str2; + if (obj1 instanceof DownloadResourceGroup) { + str1 = ((DownloadResourceGroup) obj1).getName(ctx); + } else { + str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions, false); + } + if (obj2 instanceof DownloadResourceGroup) { + str2 = ((DownloadResourceGroup) obj2).getName(ctx); + } else { + str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions, false); + } + return collator.compare(str1, str2); + } + }); + + results.values = filter; + results.count = filter.size(); + } + return results; + } + + private boolean isMatch(List> conditions, boolean matchByDefault, String text) { + boolean res = matchByDefault; + for (List or : conditions) { + boolean tadd = true; + for (String var : or) { + if (!text.contains(var)) { + tadd = false; + break; + } + } + if (!tadd) { + res = false; + } else { + res = true; + break; + } + } + return res; + } + + @SuppressWarnings("unchecked") + @Override + protected void publishResults(CharSequence constraint, FilterResults results) { + items.clear(); + List values = (List) results.values; + if (values != null && !values.isEmpty()) { + items.addAll(values); + } + notifyDataSetChanged(); + } + } + } } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchItemsFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchItemsFragment.java deleted file mode 100644 index 35b6acf0bb..0000000000 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchItemsFragment.java +++ /dev/null @@ -1,337 +0,0 @@ -package net.osmand.plus.download.ui; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; - -import net.osmand.Collator; -import net.osmand.OsmAndCollator; -import net.osmand.map.OsmandRegions; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.R; -import net.osmand.plus.WorldRegion; -import net.osmand.plus.download.BaseDownloadActivity; -import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.IndexItem; -import android.content.Context; -import android.content.res.TypedArray; -import android.os.Bundle; -import android.support.v4.app.Fragment; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.Filter; -import android.widget.Filterable; -import android.widget.ListView; - -//FIXME merge into search dialog fragment -public class SearchItemsFragment { /*extends Fragment implements DownloadEvents { - public static final String TAG = "SearchItemsFragment"; - - private SearchItemsAdapter listAdapter; - - private static final String SEARCH_TEXT_KEY = "world_region_id_key"; - private String searchText; - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setHasOptionsMenu(true); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - View view = inflater.inflate(R.layout.download_search_items_fragment, container, false); - if (savedInstanceState != null) { - searchText = savedInstanceState.getString(SEARCH_TEXT_KEY); - } - if (searchText == null) { - searchText = getArguments().getString(SEARCH_TEXT_KEY); - } - if (searchText == null) - searchText = ""; - - ListView listView = (ListView) view.findViewById(android.R.id.list); - listAdapter = new SearchItemsAdapter(getActivity()); - listView.setAdapter(listAdapter); - listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int position, long id) { - doItemClick(view, position); - } - }); - fillSearchItemsAdapter(); - - return view; - } - - @Override - public void onSaveInstanceState(Bundle outState) { - outState.putString(SEARCH_TEXT_KEY, searchText); - super.onSaveInstanceState(outState); - } - - public boolean doItemClick(View view, int position) { - Object obj = listAdapter.getItem(position); - if (obj instanceof WorldRegion) { - WorldRegion region = (WorldRegion) obj; - getDownloadActivity().showDialog(getActivity(), RegionDialogFragment.createInstance(region.getRegionId())); - return true; - } else if (obj instanceof ItemsListBuilder.ResourceItem) { - if (((ItemViewHolder) view.getTag()).isItemAvailable()) { - IndexItem indexItem = ((ItemsListBuilder.ResourceItem) obj).getIndexItem(); - ((BaseDownloadActivity) getActivity()).startDownload(indexItem); - return true; - } - } else if (obj instanceof IndexItem) { - if (((ItemViewHolder) view.getTag()).isItemAvailable()) { - IndexItem indexItem = (IndexItem) obj; - ((BaseDownloadActivity) getActivity()).startDownload(indexItem); - return true; - } - } - return false; - } - - public OsmandApplication getMyApplication() { - return (OsmandApplication) getActivity().getApplication(); - } - - public DownloadActivity getMyActivity() { - return (DownloadActivity) getActivity(); - } - - private void fillSearchItemsAdapter() { - if (listAdapter != null) { - listAdapter.clear(); - List flattenedList = getMyApplication().getWorldRegion().getFlattenedSubregions(); - List indexItems = getDownloadActivity().getIndexFiles(); - if (flattenedList != null && flattenedList.size() > 0 && - indexItems != null && indexItems.size() > 0) { - listAdapter.addWorldRegions(flattenedList); - listAdapter.addIndexItems(indexItems); - listAdapter.notifyDataSetChanged(); - } - } - } - - public void onCategorizationFinished() { - fillSearchItemsAdapter(); - } - - public void updateSearchText(String searchText) { - this.searchText = searchText; - if(listAdapter != null){ - listAdapter.getFilter().filter(searchText); - } - } - - private DownloadActivity getDownloadActivity() { - return (DownloadActivity) getActivity(); - } - - public static SearchItemsFragment createInstance(String regionId) { - Bundle bundle = new Bundle(); - bundle.putString(SEARCH_TEXT_KEY, regionId); - SearchItemsFragment fragment = new SearchItemsFragment(); - fragment.setArguments(bundle); - return fragment; - } - - private class SearchItemsAdapter extends BaseAdapter implements Filterable { - - private SearchIndexFilter mFilter; - - private List worldRegions = new LinkedList<>(); - private List indexItems = new LinkedList<>(); - private List items = new LinkedList<>(); - - private OsmandRegions osmandRegions; - - public SearchItemsAdapter(Context ctx) { - osmandRegions = getMyApplication().getResourceManager().getOsmandRegions(); - TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary}); - ta.recycle(); - } - - public void clear() { - worldRegions.clear(); - indexItems.clear(); - items.clear(); - notifyDataSetChanged(); - } - - public void addWorldRegions(List worldRegions) { - this.worldRegions.addAll(worldRegions); - } - - public void addIndexItems(List indexItems) { - this.indexItems.addAll(indexItems); - } - - @Override - public Object getItem(int position) { - return items.get(position); - } - - @Override - public int getCount() { - return items.size(); - } - - @Override - public long getItemId(int position) { - return position; - } - - @Override - public View getView(int position, View convertView, ViewGroup parent) { - final Object item = getItem(position); - ItemViewHolder viewHolder; - if (convertView == null) { - convertView = LayoutInflater.from(parent.getContext()) - .inflate(R.layout.two_line_with_images_list_item, parent, false); - viewHolder = new ItemViewHolder(convertView, - getMyActivity(), - getMyApplication().getResourceManager().getDateFormat()); - convertView.setTag(viewHolder); - } else { - viewHolder = (ItemViewHolder) convertView.getTag(); - } - if (item instanceof WorldRegion) { - viewHolder.bindRegion((WorldRegion) item); - } else if (item instanceof IndexItem) { - viewHolder.bindIndexItem((IndexItem) item, false, true); - } else { - throw new IllegalArgumentException("Item must be of type WorldRegion or " + - "IndexItem but is of type:" + item.getClass()); - } - - return convertView; - } - - @Override - public boolean hasStableIds() { - return false; - } - - @Override - public Filter getFilter() { - if (mFilter == null) { - mFilter = new SearchIndexFilter(); - } - return mFilter; - } - - private final class SearchIndexFilter extends Filter { - @Override - protected FilterResults performFiltering(CharSequence constraint) { - FilterResults results = new FilterResults(); - if (constraint == null || constraint.length() < 2) { - results.values = new ArrayList<>(); - results.count = 0; - } else { - String[] ors = constraint.toString().split(","); - List> conds = new ArrayList<>(); - for (String or : ors) { - final ArrayList cond = new ArrayList<>(); - for (String term : or.split("\\s")) { - final String t = term.trim().toLowerCase(); - if (t.length() > 0) { - cond.add(t); - } - } - if (cond.size() > 0) { - conds.add(cond); - } - } - - List filter = new ArrayList<>(); - List regions = new ArrayList<>(); - for (WorldRegion region : worldRegions) { - String indexLC = region.getName().toLowerCase(); - if (isMatch(conds, false, indexLC)) { - regions.add(region); - } - } - - for (WorldRegion region : regions) { - if (region.getSubregions().size() > 0) { - filter.add(region); - } - - List items = getDownloadActivity().getIndexItemsByRegion(region); - if (items.size() > 1) { - if (!filter.contains(region)) { - filter.add(region); - } - } else { - filter.addAll(items); - } - } - - final Collator collator = OsmAndCollator.primaryCollator(); - Collections.sort(filter, new Comparator() { - @Override - public int compare(Object obj1, Object obj2) { - String str1; - String str2; - if (obj1 instanceof WorldRegion) { - str1 = ((WorldRegion) obj1).getName(); - } else { - str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions, false); - } - if (obj2 instanceof WorldRegion) { - str2 = ((WorldRegion) obj2).getName(); - } else { - str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions, false); - } - return collator.compare(str1, str2); - } - }); - - results.values = filter; - results.count = filter.size(); - } - return results; - } - - private boolean isMatch(List> conditions, boolean matchByDefault, String text) { - boolean res = matchByDefault; - for (List or : conditions) { - boolean tadd = true; - for (String var : or) { - if (!text.contains(var)) { - tadd = false; - break; - } - } - if (!tadd) { - res = false; - } else { - res = true; - break; - } - } - return res; - } - - @SuppressWarnings("unchecked") - @Override - protected void publishResults(CharSequence constraint, FilterResults results) { - items.clear(); - List values = (List) results.values; - if (values != null && !values.isEmpty()) { - items.addAll(values); - } - notifyDataSetChanged(); - } - } - } - */ -} From 6cb0d014af6b677ef70b9091e8ddd8884677dbf7 Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Tue, 20 Oct 2015 19:55:44 +0200 Subject: [PATCH 03/33] Translated using Weblate (Sardinian) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-sc/strings.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OsmAnd/res/values-sc/strings.xml b/OsmAnd/res/values-sc/strings.xml index 0497fa6014..0480cfac30 100644 --- a/OsmAnd/res/values-sc/strings.xml +++ b/OsmAnd/res/values-sc/strings.xml @@ -894,10 +894,10 @@ Europa Europa - Frantza Europa - Germània - Europa/Àsia - Rùssia + Rùssia Àfrica Àsia - Oceània + Austràlia e Otzeània Mapas mundiales e de base Wikipedia (non in lìnia) Impostaduras dislindadas de su profilu @@ -2138,7 +2138,7 @@ Seguru ses de bòlere iscarrigare mapas petzi istadales, fintzas si tenes giai cussas cumpridas? %1$.1f dae %2$.1f MB %.1f MB -Agiorna totu (%1$s Mb) +Agiorna totu (%1$s MB) Iscarrigamentos gratùitos impreados Podes impostare cantos iscarrigamentos gratùitos as impreadu From c78f1f3dd7a2eb0660be5ef6cbb5e3aec686ea34 Mon Sep 17 00:00:00 2001 From: Franco Date: Tue, 20 Oct 2015 20:02:04 +0200 Subject: [PATCH 04/33] Translated using Weblate (Argentinean Spanish) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-es-rAR/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-es-rAR/strings.xml b/OsmAnd/res/values-es-rAR/strings.xml index 54732659eb..4593d381c2 100644 --- a/OsmAnd/res/values-es-rAR/strings.xml +++ b/OsmAnd/res/values-es-rAR/strings.xml @@ -1307,10 +1307,10 @@ Europa Europa - Francia Europa - Alemania - Europa/Asia - Rusia + Rusia África Asia - Oceanía + Australia y Oceanía Mapas mundiales y temáticos Wikipedia mundial Avisos de voz (grabado, funciones limitadas) From 7aa63847dfcf9a862efe1e2f50b0d0e79113972e Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 20 Oct 2015 22:01:46 +0300 Subject: [PATCH 05/33] Downloads search done --- .../download/ui/SearchDialogFragment.java | 65 +++++++++++-------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 9793d5adc3..3ee2ee0202 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -27,8 +27,10 @@ import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion; +import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadResourceGroup; +import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; @@ -323,10 +325,44 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven } private void processGroup(DownloadResourceGroup group, List filter, List> conds) { - String indexLC = group.getName(ctx).toLowerCase(); - if (isMatch(conds, false, indexLC)) { + String name = group.getName(ctx).toLowerCase(); + if (group.getType().isScreen() && group.getParentGroup() != null + && group.getParentGroup().getParentGroup() != null + && group.getParentGroup().getParentGroup().getType() != DownloadResourceGroupType.WORLD + && isMatch(conds, false, name)) { + filter.add(group); + + for (DownloadResourceGroup g : group.getGroups()) { + if (g.getType() == DownloadResourceGroupType.REGION_MAPS) { + if (g.getIndividualResources() != null) { + for (IndexItem item : g.getIndividualResources()) { + if (item.getType() == DownloadActivityType.NORMAL_FILE) { + filter.add(item); + break; + } + } + } + break; + } + } } + + // process other maps & voice prompts + if (group.getType() == DownloadResourceGroupType.OTHER_MAPS_HEADER + || group.getType() == DownloadResourceGroupType.VOICE_HEADER_REC + || group.getType() == DownloadResourceGroupType.VOICE_HEADER_TTS) { + if (group.getIndividualResources() != null) { + for (IndexItem item : group.getIndividualResources()) { + name = item.getVisibleName(ctx, osmandRegions, false).toLowerCase(); + if (isMatch(conds, false, name)) { + filter.add(item); + break; + } + } + } + } + if (group.getGroups() != null) { for (DownloadResourceGroup g : group.getGroups()) { processGroup(g, filter, conds); @@ -361,31 +397,6 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven List filter = new ArrayList<>(); processGroup(root, filter, conds); - /* - List regions = new ArrayList<>(); - for (WorldRegion region : worldRegions) { - String indexLC = region.getName().toLowerCase(); - if (isMatch(conds, false, indexLC)) { - regions.add(region); - } - } - - for (WorldRegion region : regions) { - if (region.getSubregions().size() > 0) { - filter.add(region); - } - - List items = getDownloadActivity().getIndexItemsByRegion(region); - if (items.size() > 1) { - if (!filter.contains(region)) { - filter.add(region); - } - } else { - filter.addAll(items); - } - } - */ - final Collator collator = OsmAndCollator.primaryCollator(); Collections.sort(filter, new Comparator() { @Override From 761ecc4aeec556e831b2f132ebefaf160d67bce1 Mon Sep 17 00:00:00 2001 From: Thomas Tonino Date: Tue, 20 Oct 2015 20:00:57 +0200 Subject: [PATCH 06/33] Translated using Weblate (Dutch) Currently translated at 95.4% (1688 of 1769 strings) --- OsmAnd/res/values-nl/strings.xml | 51 +++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/OsmAnd/res/values-nl/strings.xml b/OsmAnd/res/values-nl/strings.xml index a7fc367caf..83a8576a32 100644 --- a/OsmAnd/res/values-nl/strings.xml +++ b/OsmAnd/res/values-nl/strings.xml @@ -1576,13 +1576,13 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A Gebruik bij voorkeur autowegen Kortste route Kortste route gebruiken - Geen tolwegen + Vermijd tolwegen Vermijd tolwegen - Geen onverharde wegen + Vermijd onverharde wegen Vermijd onverharde wegen - Geen veerboten + Vermijd veerboten Vermijd veerboten - Geen autowegen + Vermijd autowegen Vermijd autowegen Geef het gewicht van het voertuig voor de routeplanning Gewicht voertuig @@ -1838,7 +1838,7 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A Swahili Hebreeuws Vooruit - Thuis + Overzicht Stuur tracking-data naar een webservice als een GPX-track wordt gemaakt. Online tracking (GPX vereist) Start online tracking @@ -1848,7 +1848,7 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A Start nieuw segment Houden Onderbreek - GPS Slaapstand inschakelen + GPS slaapstand inschakelen GPS ontwaak-interval Onderbreek GPS slaapstand? Perzisch @@ -2269,4 +2269,41 @@ Afghanistan, Albanie, Algerije, Andorra, Angola, Anguilla, Antigua en Barbuda, A Probeer het opnieuw Fout: {0} Wilt u OsmAnd beoordelen op Google Play? Alvast heel erg bedankt. - + Deze categorienaam bestaat al. Kies een andere. + Categorienaam + Voeg categorie toe + Regio\'s + Kaarten van regio\'s + Wereldkaarten + Reliëfschaduw uitgeschakeld + Hoogtelijnen uitgeschakeld + Categorie toevoegen + Kies categorie + Systeem om snelheid te meten + Snelheidsmeting + nm + Zeemijlen + Kilometer per uur + Mijl per uur + Meter per seconde + Minuten per kilometer + Minuten per mijl + Zeemijlen per uur (knopen) + Knopen + min/m + min/km + m/s + + Spoor registreren + Navigatie + Eigenschappen van favoriet + Stop simuleren van positie + Simuleer met een GPX-spoor of een berekende route + Adres nog niet bekend + GPX-bestand met aantekeningen + Locaties + Plugins + Vermijd shuttle-trein + Vermijd shuttle-trein + Wikipedia + From 4c5dd3aa9fe683079c6b44babc51e3b6208f0191 Mon Sep 17 00:00:00 2001 From: Evgenii Martynenko Date: Tue, 20 Oct 2015 20:04:11 +0200 Subject: [PATCH 07/33] Translated using Weblate (Russian) Currently translated at 99.3% (1757 of 1769 strings) --- OsmAnd/res/values-ru/strings.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index 0027174c9a..46a15f94a1 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -2146,4 +2146,6 @@ %1$.1f из %2$.1f Мб %.1f Мб Обновить все (%1$s Мб) +Использовано бесплатных загрузок + Вы можете посмотреть сколько бесплатных загрузок вы использовали From fd83bd1ac043d31786de487481d8838595dade2d Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Tue, 20 Oct 2015 20:30:44 +0200 Subject: [PATCH 08/33] Translated using Weblate (Sardinian) Currently translated at 58.7% (1200 of 2043 strings) --- OsmAnd/res/values-sc/phrases.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/OsmAnd/res/values-sc/phrases.xml b/OsmAnd/res/values-sc/phrases.xml index e4626dc27b..a09395b23a 100644 --- a/OsmAnd/res/values-sc/phrases.xml +++ b/OsmAnd/res/values-sc/phrases.xml @@ -1299,4 +1299,5 @@ Pompa Edifìtziu + Indicadore istradale From de13a0d151908004f24266460327446a43b3291f Mon Sep 17 00:00:00 2001 From: ace shadow Date: Tue, 20 Oct 2015 21:14:38 +0200 Subject: [PATCH 09/33] Translated using Weblate (Slovak) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-sk/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values-sk/strings.xml b/OsmAnd/res/values-sk/strings.xml index 5f44906b8b..d95c243a2d 100644 --- a/OsmAnd/res/values-sk/strings.xml +++ b/OsmAnd/res/values-sk/strings.xml @@ -242,10 +242,10 @@ Európa - Francúzsko Európa - Nemecko Európa - Európa/Ázia - Rusko + Rusko Afrika Ázia - Oceánia + Austrália a Oceánia Celosvetové a tematické mapy Celosvetové body z Wikipedie Hlasové povely (nahrávky, obmedzená funkcionalita) From 62fb7bd870e500525749339adf79f8e3f9ac2b5d Mon Sep 17 00:00:00 2001 From: xmd5a Date: Tue, 20 Oct 2015 21:54:37 +0300 Subject: [PATCH 10/33] Update phrases --- OsmAnd/res/values-ru/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 05d711c670..c02f2776e9 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -152,7 +152,7 @@ Шиномонтаж Пункт техосмотра Автомойка - Заправка + Автомобильная заправка Зарядная станция Ремонтная эстакада/яма Компрессор для подкачки шин From 219bfe79ff64c440dbf63da812059f6471a7d567 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Tue, 20 Oct 2015 22:52:51 +0300 Subject: [PATCH 11/33] Update phrases --- OsmAnd/res/values-ru/phrases.xml | 1 + OsmAnd/res/values/phrases.xml | 2 ++ 2 files changed, 3 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index c02f2776e9..30ad9b1002 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -2199,5 +2199,6 @@ Состояние ступеней: среднее Состояние ступеней: плохое + Пирамида из камней \ No newline at end of file diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index b477df732c..134d668344 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -2203,4 +2203,6 @@ Step condition: uneven Step condition: rough + Cairn + From 9b96c746523d4818630ae998619fb0307916d0b8 Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Tue, 20 Oct 2015 21:28:46 +0200 Subject: [PATCH 12/33] Translated using Weblate (Sardinian) Currently translated at 58.9% (1205 of 2043 strings) --- OsmAnd/res/values-sc/phrases.xml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OsmAnd/res/values-sc/phrases.xml b/OsmAnd/res/values-sc/phrases.xml index a09395b23a..8b85f7889f 100644 --- a/OsmAnd/res/values-sc/phrases.xml +++ b/OsmAnd/res/values-sc/phrases.xml @@ -1084,7 +1084,7 @@ Ufìtziu de informatziones Tèrminal de informatziones Mapa pro escursionismu - Informatziones istòricas + Sinnale de informatziones: istòria Sinnu Audioghia Atzessu a ìnternet: eja @@ -1300,4 +1300,8 @@ Edifìtziu Indicadore istradale + Sinnale de informatziones: natura + Sinnale de informatziones: fàuna agreste + Modellu tàtile + Mapa tàtile From 885bd84d9739b96fdb38465ee35ea98217defb00 Mon Sep 17 00:00:00 2001 From: Mirco Zorzo Date: Tue, 20 Oct 2015 22:02:26 +0200 Subject: [PATCH 13/33] Translated using Weblate (Italian) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-it/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-it/strings.xml b/OsmAnd/res/values-it/strings.xml index 67c9276fd4..9748dc9088 100644 --- a/OsmAnd/res/values-it/strings.xml +++ b/OsmAnd/res/values-it/strings.xml @@ -852,7 +852,7 @@ Europa Europa - Francia Europa - Germania - Europa/Asia - Russia + Russia Africa Asia Oceania From de64a0ba8cdbdbf77e593ab209c8cfefdc956229 Mon Sep 17 00:00:00 2001 From: jan madsen Date: Tue, 20 Oct 2015 06:55:16 +0200 Subject: [PATCH 14/33] Translated using Weblate (Danish) Currently translated at 100.0% (2044 of 2044 strings) --- OsmAnd/res/values-da/phrases.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/OsmAnd/res/values-da/phrases.xml b/OsmAnd/res/values-da/phrases.xml index 85fa1bd927..9986886013 100644 --- a/OsmAnd/res/values-da/phrases.xml +++ b/OsmAnd/res/values-da/phrases.xml @@ -2249,4 +2249,6 @@ Trintilstand: ujævn Trintilstand: ru +Varde + From 97eaa00e661e95620c48e3082bbe1f2ddd97a7ee Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 11:11:57 +0300 Subject: [PATCH 15/33] Fix empty groups in downloads --- .../plus/download/ui/DownloadResourceGroupFragment.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java index 87bde6bfcc..1707e74647 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/DownloadResourceGroupFragment.java @@ -1,6 +1,5 @@ package net.osmand.plus.download.ui; -import android.content.Context; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Bundle; @@ -102,10 +101,15 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow listAdapter = new DownloadResourceGroupAdapter(activity); listView.setAdapter(listAdapter); - reloadData(); return view; } + @Override + public void onResume() { + super.onResume(); + reloadData(); + } + private void reloadData() { DownloadResources indexes = activity.getDownloadThread().getIndexes(); group = indexes.getGroupById(groupId); From 1b4480bafcc5b2c3095ec07dec4402da96b216df Mon Sep 17 00:00:00 2001 From: ezjerry liao Date: Wed, 21 Oct 2015 04:37:44 +0200 Subject: [PATCH 16/33] Translated using Weblate (Chinese (Taiwan)) Currently translated at 89.5% (1831 of 2044 strings) --- OsmAnd/res/values-zh-rTW/phrases.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OsmAnd/res/values-zh-rTW/phrases.xml b/OsmAnd/res/values-zh-rTW/phrases.xml index cb007da939..2aa2147ed3 100644 --- a/OsmAnd/res/values-zh-rTW/phrases.xml +++ b/OsmAnd/res/values-zh-rTW/phrases.xml @@ -1977,4 +1977,13 @@ 培訓:航空 培訓:美容美髮 + 紀念性物件 + + 類型:石油工業 + 類型:井址 + 類型:工廠 + 類型:瓦斯工業 + 類型:木材 + 類型:煉油廠 + 類型:倉庫 From b97cde8616e36bcccd496e5463360b8df2cecfe5 Mon Sep 17 00:00:00 2001 From: elPresidento Date: Wed, 21 Oct 2015 10:11:48 +0200 Subject: [PATCH 17/33] Translated using Weblate (Czech) Currently translated at 54.3% (1110 of 2044 strings) --- OsmAnd/res/values-cs/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-cs/phrases.xml b/OsmAnd/res/values-cs/phrases.xml index 43c7622223..3b2fc77922 100644 --- a/OsmAnd/res/values-cs/phrases.xml +++ b/OsmAnd/res/values-cs/phrases.xml @@ -341,7 +341,7 @@ E10 (10% Bioetanol) E20 (20% Etanol) E85 - (85% Etanol) - E85 - (85% Etanol) + Etanol Kapalný vodík Nabíjení Servisní rampa From 960db5d627ea854128f44060184e900d8fbca62f Mon Sep 17 00:00:00 2001 From: Ajeje Brazorf Date: Tue, 20 Oct 2015 23:27:27 +0200 Subject: [PATCH 18/33] Translated using Weblate (Sardinian) Currently translated at 60.0% (1228 of 2044 strings) --- OsmAnd/res/values-sc/phrases.xml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-sc/phrases.xml b/OsmAnd/res/values-sc/phrases.xml index 8b85f7889f..358b40b351 100644 --- a/OsmAnd/res/values-sc/phrases.xml +++ b/OsmAnd/res/values-sc/phrases.xml @@ -1064,12 +1064,12 @@ Arena - Si podet pipare in un’aposentu indipendente e iscrobadu de su totu + Si podet pipare in un’aposentu isoladu Pipadores ebbia - B’est de pagare unu pedàgiu - Non b’est perunu pedàgiu - B’est de pagare unu pedàgiu pro veìculos pesantes + Pedàgiu + Perunu pedàgiu + Pedàgiu pro veìculos pesantes Mapa tziclìstica Caraterìstica de s’abba: minerale Caraterìsica de s’abba: ludu @@ -1304,4 +1304,27 @@ Sinnale de informatziones: fàuna agreste Modellu tàtile Mapa tàtile + Sinnale de informatziones: fundos/prantas + Sinnale de informatziones: geologia + Sinnale de informatziones: trasportu pùblicu + Sinnale de informatziones: tecnologia + Sinnale de informatziones: astronomia + + Tziminera + Chene tziminera + + Cobertu + Chene cobertura + + Non si podet pipare + Si podet pipare in foras ebbia + Si podet pipare + Si podet pipare in un’aposentu a un’ala + Cun pamentu tàtile + Chene pamentu tàtile + Cun sonu + Chene sonu + Cun sonu petzi cando est possìbile colare + + Àrea de servìtziu From cc2cb51c4afff0f223cb1cc1ef810edd5bf71e6c Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 11:55:15 +0300 Subject: [PATCH 19/33] Changed favorite icon --- .../plus/base/FavoriteImageDrawable.java | 83 ++++++------------- 1 file changed, 26 insertions(+), 57 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java index 5f1ecb338e..8a4b70e09e 100644 --- a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java +++ b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java @@ -1,61 +1,48 @@ package net.osmand.plus.base; -import java.util.TreeMap; - -import net.osmand.plus.R; import android.content.Context; import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; -import android.graphics.Paint.Style; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; import android.graphics.Rect; import android.graphics.drawable.Drawable; -import android.util.DisplayMetrics; -import android.view.WindowManager; + +import net.osmand.plus.R; + +import java.util.TreeMap; public class FavoriteImageDrawable extends Drawable { private int color; - Paint paintInnerCircle; + private Paint paintIcon; + private Paint paintBackground; + private Bitmap favIcon; + private Bitmap favBackground; private Resources resources; - private Paint paintOuter; - private Drawable drawable; - private float density; - public FavoriteImageDrawable(Context ctx, int color, float d) { + public FavoriteImageDrawable(Context ctx, int color) { this.resources = ctx.getResources(); this.color = color; - WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE); - this.density = d; - if (this.density == 0) { - DisplayMetrics dm = new DisplayMetrics(); - mgr.getDefaultDisplay().getMetrics(dm); - density = dm.density; - } - drawable = getResources().getDrawable(R.drawable.ic_action_fav_dark); - paintOuter = new Paint(); - paintOuter.setAntiAlias(true); - paintOuter.setStyle(Style.FILL_AND_STROKE); - paintInnerCircle = new Paint(); - paintInnerCircle.setStyle(Style.FILL_AND_STROKE); - paintOuter.setColor(color == 0 || color == Color.BLACK ? 0x88555555 : color); - paintInnerCircle.setColor(color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) - : color); - paintInnerCircle.setAntiAlias(true); + paintIcon = new Paint(); + paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); + paintBackground = new Paint(); + favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_action_fav_dark); + favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_shield); } @Override public int getIntrinsicHeight() { - return (int) (24 * density); -// return (int) (drawable.getIntrinsicHeight() + 8 * density); + return favBackground.getHeight(); } @Override public int getIntrinsicWidth() { - return (int) (24 * density); -// return (int) (drawable.getIntrinsicWidth() + 8 * density); + return favBackground.getWidth(); } public int getColor() { @@ -66,27 +53,11 @@ public class FavoriteImageDrawable extends Drawable { return resources; } - @Override - protected void onBoundsChange(Rect bounds) { - super.onBoundsChange(bounds); - Rect bs = new Rect(bounds); - bs.inset((int) (4 * density), (int) (4 * density)); - // int min = Math.min(bounds.width(), bounds.height()); - // bs.inset((int)(bs.width() - min + 3 * density) / 2, - // (int) (bs.height() - min + 3 * density) / 2); - drawable.setBounds(bs); - } - @Override public void draw(Canvas canvas) { - // int max = Math.max(drawable.getMinimumHeight(), drawable.getMinimumWidth()); Rect bs = getBounds(); - int min = Math.min(bs.width(), bs.height()); - int r = (int) (min / 2); - int rs = (int) (min / 2 - 1); - canvas.drawCircle(min / 2, min / 2, r, paintOuter); - canvas.drawCircle(min / 2, min / 2, rs, paintInnerCircle); - drawable.draw(canvas); + canvas.drawBitmap(favBackground, bs.exactCenterX() - favBackground.getWidth() / 2f, bs.exactCenterY() - favBackground.getHeight() / 2f, paintBackground); + canvas.drawBitmap(favIcon, bs.exactCenterX() - favIcon.getWidth() / 2f, bs.exactCenterY() - favIcon.getHeight() / 2f, paintIcon); } public void drawBitmapInCenter(Canvas canvas, int x, int y) { @@ -104,27 +75,25 @@ public class FavoriteImageDrawable extends Drawable { @Override public void setAlpha(int alpha) { - paintInnerCircle.setAlpha(alpha); - + paintBackground.setAlpha(alpha); } @Override public void setColorFilter(ColorFilter cf) { - paintInnerCircle.setColorFilter(cf); + paintIcon.setColorFilter(cf); } - private static TreeMap cache = new TreeMap(); + private static TreeMap cache = new TreeMap<>(); public static FavoriteImageDrawable getOrCreate(Context a, int color, float density) { color = color | 0xff000000; int hash = (color << 2) + (int) (density * 6); FavoriteImageDrawable drawable = cache.get(hash); if (drawable == null) { - drawable = new FavoriteImageDrawable(a, color, density); + drawable = new FavoriteImageDrawable(a, color); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); cache.put(hash, drawable); } return drawable; } - } From 6d988484f15137d5a63a7d331ccb49d957ac804b Mon Sep 17 00:00:00 2001 From: elPresidento Date: Wed, 21 Oct 2015 10:12:16 +0200 Subject: [PATCH 20/33] Translated using Weblate (Czech) Currently translated at 54.3% (1111 of 2044 strings) --- OsmAnd/res/values-cs/phrases.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-cs/phrases.xml b/OsmAnd/res/values-cs/phrases.xml index 3b2fc77922..c992f0d134 100644 --- a/OsmAnd/res/values-cs/phrases.xml +++ b/OsmAnd/res/values-cs/phrases.xml @@ -487,7 +487,7 @@ Výzkumný ústav Informační technologie Redakce novin - Architekt + Architektonická kancelář Reklamní kancelář Vzdělávací instituce Studio From d3fd15a1a0a0b64f05d6470a1e821c20b3d31d88 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 12:40:59 +0300 Subject: [PATCH 21/33] Fix downloads search --- .../net/osmand/plus/download/ui/SearchDialogFragment.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java index 3ee2ee0202..430bac41f0 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/SearchDialogFragment.java @@ -325,7 +325,13 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven } private void processGroup(DownloadResourceGroup group, List filter, List> conds) { - String name = group.getName(ctx).toLowerCase(); + String name = null; + if (group.getRegion() != null && group.getRegion().getSearchText() != null) { + name = group.getRegion().getSearchText().toLowerCase(); + } + if (name == null) { + name = group.getName(ctx).toLowerCase(); + } if (group.getType().isScreen() && group.getParentGroup() != null && group.getParentGroup().getParentGroup() != null && group.getParentGroup().getParentGroup().getType() != DownloadResourceGroupType.WORLD From e880d2a1a23a3931304c2b6467a9501f83e6d360 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Oct 2015 11:54:59 +0200 Subject: [PATCH 22/33] Small refactoring --- .../DashboardSettingsDialogFragment.java | 145 ++++++++++-------- .../tools/NumberPickerDialogFragment.java | 9 +- 2 files changed, 83 insertions(+), 71 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java index 0959145122..18b4d1dd6f 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/DashboardSettingsDialogFragment.java @@ -40,6 +40,8 @@ public class DashboardSettingsDialogFragment extends DialogFragment private DashFragmentAdapter mAdapter; private int textColorPrimary; private int textColorSecondary; + private static final int MAXIMUM_NUMBER_OF_ROWS = 10; + private static final int DEFAULT_NUMBER_OF_ROWS = 5; @Override public void onAttach(Activity activity) { @@ -104,7 +106,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment DashboardOnMap.SHOULD_SHOW + fragmentData.tag, true) .makeGlobal().set(shouldShow[i]); if (fragmentData.rowNumberTag != null) { - settings.registerIntPreference(fragmentData.rowNumberTag, 5) + settings.registerIntPreference(fragmentData.rowNumberTag, DEFAULT_NUMBER_OF_ROWS) .makeGlobal().set(numberOfRows[i]); } } @@ -136,42 +138,38 @@ public class DashboardSettingsDialogFragment extends DialogFragment private class DashFragmentAdapter extends ArrayAdapter { private final boolean[] checkedItems; private final int[] numbersOfRows; - private final int colorBlue; - public DashFragmentAdapter(@NonNull Context context, - @NonNull List objects, - @NonNull boolean[] checkedItems, - @NonNull int[] numbersOfRows) { + public DashFragmentAdapter(@NonNull Context context, @NonNull List objects, + @NonNull boolean[] checkedItems, @NonNull int[] numbersOfRows) { super(context, 0, objects); this.checkedItems = checkedItems; this.numbersOfRows = numbersOfRows; - colorBlue = getContext().getResources().getColor(R.color.dashboard_blue); + } - public DashFragmentAdapter(@NonNull Context context, - @NonNull List objects, - @NonNull OsmandSettings settings) { + public DashFragmentAdapter(@NonNull Context context, @NonNull List objects, + @NonNull OsmandSettings settings) { super(context, 0, objects); numbersOfRows = new int[objects.size()]; checkedItems = new boolean[objects.size()]; for (int i = 0; i < objects.size(); i++) { - checkedItems[i] = settings.registerBooleanPreference( - DashboardOnMap.SHOULD_SHOW + objects.get(i).tag, true).makeGlobal().get(); + checkedItems[i] = settings + .registerBooleanPreference(DashboardOnMap.SHOULD_SHOW + objects.get(i).tag, true).makeGlobal() + .get(); if (objects.get(i).tag != null) { - numbersOfRows[i] = settings.registerIntPreference(objects.get(i).rowNumberTag, 5) - .makeGlobal().get(); + numbersOfRows[i] = settings.registerIntPreference(objects.get(i).rowNumberTag, 5).makeGlobal() + .get(); } } - colorBlue = getContext().getResources().getColor(R.color.dashboard_blue); } @Override public View getView(final int position, View convertView, ViewGroup parent) { final DashViewHolder viewHolder; if (convertView == null) { - convertView = LayoutInflater.from(getContext()).inflate( - R.layout.dashboard_settings_dialog_item, parent, false); - viewHolder = new DashViewHolder(convertView); + convertView = LayoutInflater.from(getContext()).inflate(R.layout.dashboard_settings_dialog_item, + parent, false); + viewHolder = new DashViewHolder(this, convertView, getContext()); } else { viewHolder = (DashViewHolder) convertView.getTag(); } @@ -188,56 +186,26 @@ public class DashboardSettingsDialogFragment extends DialogFragment return numbersOfRows; } - private class DashViewHolder { - final TextView textView; - final CompoundButton compoundButton; - final TextView numberOfRowsTextView; - private int position; - - public DashViewHolder(View view) { - this.numberOfRowsTextView = (TextView) view.findViewById(R.id.numberOfRowsTextView); - this.textView = (TextView) view.findViewById(R.id.text); - this.compoundButton = (CompoundButton) view.findViewById(R.id.check_item); - } - - public void bindDashView(DashFragmentData fragmentData, int position) { - if (fragmentData.hasRows()) { - numberOfRowsTextView.setVisibility(View.VISIBLE); - numberOfRowsTextView.setText(String.valueOf(numbersOfRows[position])); - numberOfRowsTextView.setTextColor(checkedItems[position] ? colorBlue : - textColorSecondary); - } else { - numberOfRowsTextView.setVisibility(View.GONE); - } - textView.setText(fragmentData.titleStringId); - textView.setTextColor(checkedItems[position] ? textColorPrimary : - textColorSecondary); - this.position = position; - - compoundButton.setChecked(checkedItems[position]); - compoundButton.setTag(this); - compoundButton.setOnCheckedChangeListener(onTurnedOnOffListener); - - numberOfRowsTextView.setTag(this); - numberOfRowsTextView.setOnClickListener(onNumberClickListener); - } + public boolean isChecked(int position) { + return checkedItems[position]; } - final CompoundButton.OnCheckedChangeListener onTurnedOnOffListener = - new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton compoundButton, boolean b) { - DashViewHolder localViewHolder = (DashViewHolder) compoundButton.getTag(); - if (localViewHolder == null) return; - checkedItems[localViewHolder.position] = b; - localViewHolder.textView.setTextColor( - checkedItems[localViewHolder.position] ? textColorPrimary - : textColorSecondary); - localViewHolder.numberOfRowsTextView.setTextColor( - checkedItems[localViewHolder.position] ? colorBlue - : textColorSecondary); - } - }; + public int getNumberOfRows(int position) { + return numbersOfRows[position]; + } + + final CompoundButton.OnCheckedChangeListener onTurnedOnOffListener = new CompoundButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(CompoundButton compoundButton, boolean b) { + DashViewHolder localViewHolder = (DashViewHolder) compoundButton.getTag(); + if (localViewHolder == null) { + return; + } + int position = localViewHolder.position; + checkedItems[position] = b; + localViewHolder.bindDashView(getItem(position), position); + } + }; final View.OnClickListener onNumberClickListener = new View.OnClickListener() { @Override @@ -246,10 +214,51 @@ public class DashboardSettingsDialogFragment extends DialogFragment String header = getContext().getString(getItem(localViewHolder.position).titleStringId); String subheader = getContext().getResources().getString(R.string.count_of_lines); final String stringPosition = String.valueOf(localViewHolder.position); - NumberPickerDialogFragment - .createInstance(header, subheader, stringPosition, 5) + NumberPickerDialogFragment.createInstance(header, subheader, stringPosition, getNumberOfRows(localViewHolder.position), MAXIMUM_NUMBER_OF_ROWS) .show(getChildFragmentManager(), NumberPickerDialogFragment.TAG); } }; + + } + + private class DashViewHolder { + final TextView textView; + final CompoundButton compoundButton; + final TextView numberOfRowsTextView; + private int position; + private int colorBlue; + private DashFragmentAdapter dashFragmentAdapter; + + public DashViewHolder(DashFragmentAdapter dashFragmentAdapter, View view, Context ctx) { + this.dashFragmentAdapter = dashFragmentAdapter; + this.numberOfRowsTextView = (TextView) view.findViewById(R.id.numberOfRowsTextView); + this.textView = (TextView) view.findViewById(R.id.text); + this.compoundButton = (CompoundButton) view.findViewById(R.id.check_item); + colorBlue = ctx.getResources().getColor(R.color.dashboard_blue); + } + + public void bindDashView(DashFragmentData fragmentData, int position) { + if (fragmentData.hasRows()) { + numberOfRowsTextView.setVisibility(View.VISIBLE); + numberOfRowsTextView.setText(String.valueOf(dashFragmentAdapter.getNumberOfRows(position))); + numberOfRowsTextView.setTextColor(dashFragmentAdapter.isChecked(position) ? colorBlue : + textColorSecondary); + } else { + numberOfRowsTextView.setVisibility(View.GONE); + } + textView.setText(fragmentData.titleStringId); + textView.setTextColor(dashFragmentAdapter.isChecked(position)? textColorPrimary : + textColorSecondary); + this.position = position; + + compoundButton.setChecked(dashFragmentAdapter.isChecked(position)); + compoundButton.setTag(this); + compoundButton.setOnCheckedChangeListener(dashFragmentAdapter.onTurnedOnOffListener); + + numberOfRowsTextView.setTag(this); + numberOfRowsTextView.setOnClickListener(dashFragmentAdapter.onNumberClickListener); + } + + } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/tools/NumberPickerDialogFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/tools/NumberPickerDialogFragment.java index 9ffd62bed9..9c20d4a0d6 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/tools/NumberPickerDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/tools/NumberPickerDialogFragment.java @@ -22,6 +22,7 @@ public class NumberPickerDialogFragment extends DialogFragment { private static final String HEADER_TEXT = "header_text"; private static final String SUBHEADER_TEXT = "subheader_text"; private static final String NUMBER_OF_ITEMS = "number_of_items"; + private static final String CURRENT_NUMBER = "current_number"; @NonNull @Override @@ -34,13 +35,14 @@ public class NumberPickerDialogFragment extends DialogFragment { String headerText = args.getString(HEADER_TEXT); String subHeaderText = args.getString(SUBHEADER_TEXT); int numberOfItems = args.getInt(NUMBER_OF_ITEMS); + int currentNumber = args.getInt(CURRENT_NUMBER); String[] items = new String[numberOfItems]; for (int i = 0; i < numberOfItems; i++) { items[i] = String.valueOf(i + 1); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); - builder.setSingleChoiceItems(items, 0, null) + builder.setSingleChoiceItems(items, Math.max(0, currentNumber - 1), null) .setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { @@ -65,12 +67,13 @@ public class NumberPickerDialogFragment extends DialogFragment { } public static NumberPickerDialogFragment createInstance(String header, String subheader, - String tag, int number) { + String tag, int currentRow, int maxNumber) { Bundle args = new Bundle(); args.putString(HEADER_TEXT, header); args.putString(SUBHEADER_TEXT, subheader); args.putString(NUMBER_TAG, tag); - args.putInt(NUMBER_OF_ITEMS, number); + args.putInt(CURRENT_NUMBER, currentRow); + args.putInt(NUMBER_OF_ITEMS, maxNumber); NumberPickerDialogFragment fragment = new NumberPickerDialogFragment(); fragment.setArguments(args); return fragment; From 3a06297ec6739cadfce25c7a4145b162643adbc3 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Oct 2015 12:04:39 +0200 Subject: [PATCH 23/33] Don't add parent to index --- OsmAnd-java/src/net/osmand/map/OsmandRegions.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java index 03c25c0f5f..5ed5f4e17b 100644 --- a/OsmAnd-java/src/net/osmand/map/OsmandRegions.java +++ b/OsmAnd-java/src/net/osmand/map/OsmandRegions.java @@ -422,9 +422,10 @@ public class OsmandRegions { } fullNamesToLocaleNames.put(fullName, locPrefix + " " + locName); fullNamesNoParentToLocaleNames.put(fullName, locName); - String index = fullNamesToLowercaseIndex.get(fullName); - String prindex = fullNamesToLowercaseIndex.get(parentFullName); - fullNamesToLowercaseIndex.put(fullName, index + " " + prindex); + // don't add parent to index +// String index = fullNamesToLowercaseIndex.get(fullName); +// String prindex = fullNamesToLowercaseIndex.get(parentFullName); +// fullNamesToLowercaseIndex.put(fullName, index + " " + prindex); } } From 34b3ff41e9a59b81ae00156ddc5cda99d59a0224 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Oct 2015 12:37:56 +0200 Subject: [PATCH 24/33] Fix favorite rename --- OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java | 13 +++++++++++-- .../plus/activities/FavoritesTreeFragment.java | 5 +++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index c3ddddf135..fa9411d067 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -575,10 +575,19 @@ public class FavouritesDbHelper { } } if (!group.name.equals(newName)) { - FavoriteGroup gr = flatGroups.get(group.name); - group.name = newName; + FavoriteGroup gr = flatGroups.remove(group.name); + gr.name = newName; + FavoriteGroup renamedGroup = flatGroups.get(gr.name); + boolean existing = renamedGroup != null; + if(renamedGroup == null) { + renamedGroup = gr; + flatGroups.put(gr.name, gr); + } for(FavouritePoint p : gr.points) { p.setCategory(newName); + if(existing) { + renamedGroup.points.add(p); + } } } saveCurrentPointsIntoFile(); diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 93978655e6..4603114e71 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -35,7 +35,6 @@ import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; - import net.osmand.access.AccessibleToast; import net.osmand.data.FavouritePoint; import net.osmand.data.LatLon; @@ -54,6 +53,7 @@ import net.osmand.plus.base.FavoriteImageDrawable; import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.myplaces.FavoritesActivity; +import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import java.io.File; @@ -514,7 +514,8 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { public void onClick(DialogInterface dialog, int which) { int clr = list.get(colorSpinner.getSelectedItemPosition()); String name = nameEditText.getText().toString(); - if (clr != intColor || group.visible != checkBox.isChecked()) { + if (clr != intColor || group.visible != checkBox.isChecked() || + !Algorithms.objectEquals(group.name, name)) { getMyApplication().getFavorites().editFavouriteGroup(group, name, clr, checkBox.isChecked()); favouritesAdapter.notifyDataSetInvalidated(); From e2bc3b9221bba44039abaa311137b8f7bbb9f9c0 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Oct 2015 12:56:04 +0200 Subject: [PATCH 25/33] fix --- .../net/osmand/plus/activities/FavoritesTreeFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 4603114e71..26557be20b 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -514,10 +514,13 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { public void onClick(DialogInterface dialog, int which) { int clr = list.get(colorSpinner.getSelectedItemPosition()); String name = nameEditText.getText().toString(); - if (clr != intColor || group.visible != checkBox.isChecked() || - !Algorithms.objectEquals(group.name, name)) { + boolean nameChanged = !Algorithms.objectEquals(group.name, name); + if (clr != intColor || group.visible != checkBox.isChecked() || nameChanged) { getMyApplication().getFavorites().editFavouriteGroup(group, name, clr, checkBox.isChecked()); + if(nameChanged) { + favouritesAdapter.synchronizeGroups(); + } favouritesAdapter.notifyDataSetInvalidated(); } From ac8c6d7cd8082a30dac19ebf0bed43d903248bc7 Mon Sep 17 00:00:00 2001 From: Viktar Palstsiuk Date: Wed, 21 Oct 2015 13:39:08 +0200 Subject: [PATCH 26/33] Translated using Weblate (Belarusian) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-be/strings.xml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/OsmAnd/res/values-be/strings.xml b/OsmAnd/res/values-be/strings.xml index 23df4b71c8..266335f37a 100644 --- a/OsmAnd/res/values-be/strings.xml +++ b/OsmAnd/res/values-be/strings.xml @@ -608,10 +608,10 @@ Эўропа Эўропа - Францыя Эўропа - Германія - Эўразія - РФ + РФ Афрыка Азія - Акеанія + Аўстралія і Акеанія Сусьветныя і тэматычныя мапы Сусьветная Вікіпэдыя Галасавыя падказкі (запісаныя, абмежаваныя магчымасьці) @@ -2145,5 +2145,7 @@ Вы ўпэўненыя, што хочаце сьцягнуць мапу аўтадарог, нават калі ў вас ёсць поўная мапа? %1$.1f з %2$.1f Мб %.1f Мб - Абнавіць усе (%1$s Мб) - + Абнавіць усе (%1$s МБ) + Выкарыстана бясплатных загрузак + Вы можаце паглядзець колькі бясплатных загрузак вы выкарысталі + From 76f20fa5ee030dcfaf6b42fc274a4402af3d5396 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 14:53:25 +0300 Subject: [PATCH 27/33] Fix default favorite color --- OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java index 8a4b70e09e..53b547ae24 100644 --- a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java +++ b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java @@ -5,6 +5,7 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; +import android.graphics.Color; import android.graphics.ColorFilter; import android.graphics.Paint; import android.graphics.PorterDuff; @@ -29,7 +30,8 @@ public class FavoriteImageDrawable extends Drawable { this.resources = ctx.getResources(); this.color = color; paintIcon = new Paint(); - paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); + int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color; + paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN)); paintBackground = new Paint(); favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_action_fav_dark); favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_shield); From 7971899220d305ad800b43f260dfdae28f0a8971 Mon Sep 17 00:00:00 2001 From: Dmitriy Prodchenko Date: Wed, 21 Oct 2015 14:59:03 +0300 Subject: [PATCH 28/33] Background for Favorites. New background icon for Favorite, and star icon. --- OsmAnd/res/drawable-hdpi/map_favorite.png | Bin 0 -> 1269 bytes .../drawable-hdpi/map_white_favorite_shield.png | Bin 0 -> 2491 bytes OsmAnd/res/drawable-mdpi/map_favorite.png | Bin 0 -> 1162 bytes .../drawable-mdpi/map_white_favorite_shield.png | Bin 0 -> 1962 bytes OsmAnd/res/drawable-xhdpi/map_favorite.png | Bin 0 -> 1368 bytes .../drawable-xhdpi/map_white_favorite_shield.png | Bin 0 -> 3157 bytes OsmAnd/res/drawable-xxhdpi/map_favorite.png | Bin 0 -> 1547 bytes .../map_white_favorite_shield.png | Bin 0 -> 4517 bytes 8 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 OsmAnd/res/drawable-hdpi/map_favorite.png create mode 100644 OsmAnd/res/drawable-hdpi/map_white_favorite_shield.png create mode 100644 OsmAnd/res/drawable-mdpi/map_favorite.png create mode 100644 OsmAnd/res/drawable-mdpi/map_white_favorite_shield.png create mode 100644 OsmAnd/res/drawable-xhdpi/map_favorite.png create mode 100644 OsmAnd/res/drawable-xhdpi/map_white_favorite_shield.png create mode 100644 OsmAnd/res/drawable-xxhdpi/map_favorite.png create mode 100644 OsmAnd/res/drawable-xxhdpi/map_white_favorite_shield.png diff --git a/OsmAnd/res/drawable-hdpi/map_favorite.png b/OsmAnd/res/drawable-hdpi/map_favorite.png new file mode 100644 index 0000000000000000000000000000000000000000..e8307094fa23a45135f82e5e546041ae7aab7e9a GIT binary patch literal 1269 zcmbVMTWB0r7@j7$*uaL0(Zu@TI4!j5&NVx`GvjXS>?NBOcbjb2c0r|?ojIEf$y_os z$!@kQ=7QRw54E)q#cFK5pv8oM2*rkmst+nri&Qiz0UMMmC{n6eOEI3=>_#6#9~_uD z=RfEF{{Q=LGuf3+c$>C1Aqe74cE&PrZFAq-J@ET|F?<~^_c-yKv)3p%Macq)s2F*G zCN-%SWPqfM41NYe2+}yLW^+z1^_UtlL`gFt8bLz4OQt0E0|(86UR4icznz`O zP*n+I``HwgGNYhR?JQehZ#kWn%l$I1V7qsrp^^X%Xuy%sk~W~*LMe<@?Fw-39+Mba zRdM>m*cz!^stb)87C>1dfXfu^M}s^;vwIdka~xA3$zric6x#{I>LqEO=Shko83u3Rhcuu&$ygYJH-w@p0>@EQJIiu7&2co&QhplG z^Kt;^0tzTl4A0AoRJXGcp5o{jBT~U&FfP(`oQ;T)jt(&pjMEGk;iK_7HmTc=q|2c0 zTZO)B*uX8ZLev71V^~?k7^rtaSD)b+cAsIQ(P*{m=+6DBt{6r80k=$RQOAI#4g;mb zGBmWBXF=V7LxE=e49ocOpd_(4o%b_1pO*?a$4dTuo(u3iM`Ja-@_+M3LQ;cO=8P)&->WP{vW*#vH7*e z$s?U}jbFX~%}YDyZaaCkEju&)X#VDoza|eo^?vKIqm{+u%lztmFLN;P<_G)cU!1)$ zcymhJ{PObl9N{g`&7|&(5b18u0RQFK(-)q&=;{8t`NM`gmPdV89^N zF26NSyffC)IkCNS^ib+t*7WQ!k;H7n8&{g>(*4bMFCAQX_v*z;aLcKl6|u7L4(~i`V(LA8(vEec#0Amnw;c10PANKJ)Uf z1LwDV^6B9}{om$>g|sK$E)6wYSZNJkyEL=<`&6a1 Y2YE(mNqn~_^pN`_O2*T%nMlw0KZcI80ssI2 literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-hdpi/map_white_favorite_shield.png b/OsmAnd/res/drawable-hdpi/map_white_favorite_shield.png new file mode 100644 index 0000000000000000000000000000000000000000..018ceae395b3f13508da31beff99242d9dcb4865 GIT binary patch literal 2491 zcmbVOc|4T+8Xrrxu7e0!=Zv(-tY*f{G=niDG{}+?F)Jf8@0g_-Dh*2Fp2o>7IVi+Q zDp^8K+UR7D%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!~Zr|Xey+`)O=;Sy3kH6pLaQ#EOAFkc0 z_kU|Fd~v?pDg&|0Iy@*|yK(>bC=UnLUQZtR<;#2Be-@hu$2SffU%&jdYNxpCmsbA$ z;PCpb+hO1JKJJgt>U}?5s|cC(>iBn~@UMNVQt9l_v;2!=qdy#Y*fW*c^X%^F#;?}O wp@H4I{_go0PJ({UDpjX99?X7nl>-krcjMe||GfC>Qu22wmnO^~3+J!C0o0dn$^ZZW literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-mdpi/map_white_favorite_shield.png b/OsmAnd/res/drawable-mdpi/map_white_favorite_shield.png new file mode 100644 index 0000000000000000000000000000000000000000..fbbff9a5502297b8aab86bedffb4dfc0f83cb6a2 GIT binary patch literal 1962 zcmbVNc~leU7LUjS#0P3w6mbcove+h*$)15IBtv8i65v2cRhT3LL`WuN1{0B5e60eN zYPGIaKm`{RIrZ^C0kLdtq#!OxwNxpmMT=;w90aYF+6jX1{o&~!Z_b(dzWaUmckl0R zX9{DYSGhRPcc#&3F5zKFEVVAOy-p6)H;`3zj9R?NP$e0Mr;=vWgwaB@xEiB}>(MkU z7DKfgv)ZvB8g2RpUA&T1%A;Tnu4ke)9i~NZq|h{4&`OID)ns5KU5%yb3}WDM!&d-Z zrxgQmlGYY$;r@&w7|+0^dJjN8PH=SO1J1U4Fqfv0~2;(YHvFR z0s4drnIQ&VlTylK=u+H-(RoZhL&Ji&bb*Ko@%RFf;5|BSJk{C!QNh1t`X0w@T<}h(n8VHF*B9O%f*=z=-!5}soNYuhG5KE>k zAQ+)B>5QZfH_&YsQ8k`TiUEr0>k#xtx%`b`12LH>DrKMrHG&Y61?u&-xF)m-G8X$U zjkjtO@f(d87>f~jwn;cN% z{EQ^)Rw)11-n~rs=2bWLdLR1aO3SME_2r{;Vv7o|bZFV##6Z-A6Salydlm`rXfKR> z@a)dZyF`~$rP1xOmteUsQMSfk>7yM~85h?1rmfqyrd-i=-pOZHg(ShjK)dzP{%+2_ zwS||NP2K(BPvW}(XW;%4WcU01C;t3%^Cq+TneMezOM;bH69vuCg7=jU%78d|?0j&m@ovaT*k z2*X4F{ywvLbaZs}f9~#T!}jR#l<@}9-(%Nl-c$HXU) zqB2)|v~}P}t)k^z*2Wdy!`L@=J_i(^u0M1=9od!i-1#K>s-2s=&?6MGGe>9dMu28o zVCOFxF5^v+47-ZOr;CQ#3TE6+4$wz@D^7jdZ|8f_y1cB`$2VnDz?OpCw&#Aoj^_Mw zu0F3q_KC8f@b;b>WSRQl=~X5S!@ze6Ex9X7*S8he=-mz9cD3hwU)O{S$w^7SpQ@^g z-dR`c9w-u_*JdyE^z{7ZNLcR4ssZP$4QVNoe@3Y0b(LQ=oS*r1-@}m+f-eyGJ%02k z>Plzl#WKUv(4XpWIB5f=r%E@)v>k74Z8e;-+AaOvdzXXVG=5;+2iqKiD#s<9|bV>(Smj zeSF1ljh$h8EEm1Ky=O*7MwV{Z;oEhCdxJg$!1|-$Q@3q?`-H%`o2w6e_~QClWZpEI XntVJ&ZmYJp{XN4&qme2}%D?^sIrj-= literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-xhdpi/map_favorite.png b/OsmAnd/res/drawable-xhdpi/map_favorite.png new file mode 100644 index 0000000000000000000000000000000000000000..e2e02d791e27a2d44f04af2e8b473f777dba4442 GIT binary patch literal 1368 zcmbVMYfKzf6doP|(okun)e0e#!N#^aI}dht9U9bq1w8M=?4 z))kueN5zPRHmxm2Yi)vp4QVuumKsAOk*1}_2gR0>s*Tx3V$dcv24{gqe~|ugl9_wY zz2`gUJFhudU$-SM_pw|60P?&w?gncGlW$Iz^)+I#Icr&OdYVkX8Z^VKE&?t=;RO+E$UmW-ejf}=1>Gejwa;^5K)S>ALZ z$TYaCmwZ{06AGE8#vn*I9JYl^ZK~daU^Go5D30JbY-zwoR595ItQaLJ3vSWibxAWN zRRNP0Sx#*?osh+JF$7uj`IZeU#!{lJlpzsTLogeP$Z|5S1#QD@5dWpIqP7u;Y9i7g z8fv@FTlEN*q`+40?(Zn6Xt80Q)g`MaY@1u<+htKPy>2ID-Pi<4U?>VjO9_I4F^a-q z0<~i>NAnJtatLA&#c7%s*p!`>@YU5MSxMtGNqT4u^AMG;O1zr%P=pJ^3EEYe!g>|M zWEEaa`Iao-OIYf@Sf)xBSyR;ms@j(7g8GnZszylFz^bZ+s)HLFB}Guf#-?PM7Nd5H zy0ljms&!Qc7xK(VD{u&6xE&{OJ4~`H0b`sUhiQ%t!W6;UIgWDBG=)J+c;Wx%53xug z$!7Ua^Q4Zfj!bTsN5K-7he=ed3DT`m*<=6m0{}>ic-^i*WHQnBS#5@^pzDbjABGDK zxmK<1%ui&>@$Dx^!fzC;yXV-{mifn;j;uo8VH>x`UAUqA!^4S~t?1%F;oZ96*=vce z?jNV7PWHTg^w@j(``;Ox2yPqgU8SuZ%Kmd#Zb1=w6COOhGiT$gg?)!w=(8#_xX+T&4uYuQJlSfWB-720;$_q|G=*9@$&=HaC#>miiWOp zF#lx5k?ip5@eSdd7mB^tHbSb)|EFsi5Yv=_U_UO{-sO# z>bswCSEkT&Gyai_kIt7whQ2;pQ{nvm`O#n3ANwX+Uh~yK@+akv7S5i|eT(C2JCNON zTl~#eJGwmA`rkh=h&`wG_RJ8cr*jhVt+S_II7@43ldpXKciH^rOY=u=r60f3ye|zX XHqI1h_`AMH{_DJ+I`>DFyW{@=v3cT5 literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-xhdpi/map_white_favorite_shield.png b/OsmAnd/res/drawable-xhdpi/map_white_favorite_shield.png new file mode 100644 index 0000000000000000000000000000000000000000..9d20a1a171ded01e87dee68143bea9b8fb95be0f GIT binary patch literal 3157 zcmbVOc|25WAD@^?cA`jWjA;?GHhWpdE^Ct!l4d)YVuqQqD{Cq>#g(lxB)TM-q}LQe z$dX%{gbFFNqUhCf)9pRFb>H`o`?-I-&*yW_^ZcIk`+k4F=eL}5j(B-EX{fGJg+L%0 zF3$FJaNfFbsVo8S)cJ=(a55A-_=L*c@$tzcVYs31WYAZ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cy z?0cSBbexs5SWPScX!hJ9`sNv&m0POD5+<>WxwP#;+x`Ro?!1(0W?`1IjJ{%2S5R8D)&{IQ$~ ZIdg4&NN{a-^1_e4i-U*#C0l07e*i{zPOSg{ literal 0 HcmV?d00001 diff --git a/OsmAnd/res/drawable-xxhdpi/map_favorite.png b/OsmAnd/res/drawable-xxhdpi/map_favorite.png new file mode 100644 index 0000000000000000000000000000000000000000..682fff7b51bb0e1a7d887350f3aea446a492955a GIT binary patch literal 1547 zcmbVMeN5D57(X~g#z$l`DuTgU-GV@`y>h*~Hk^p}p@$xFc*toSqu2JJfqvLl??6We zi$k-?rl|2_er;2yTSTYcHl2KkxH;WsrkjkB_=PybB5KTZ35NBMbNj>i$C|Y7`@HY- zd!FC()wP8Ma}wiH;xrmfqI0gTNL`We8ylm3OQQd7P?t%H-K#7V{7Qh77)>56_!z*+ zk>yMgL(zCWa|W}9MP z;37sAmP?dc5C60XSk2vw9fcKDHpBvnRf|Ga*#v4i$MA~NW&zb39nI2&*^D6B7-oj_ zX0sl`5Q84_;gk_F8)?Rmpg2y^WW>(%@D7vFYDd)qnC!S-Z^!UFyTgtc?HD@SWHUIB z2-eBV3dvJU#5b$@9>HQS#1dACAr(RL2trk)3koX)MUX255wKc^s}7`>uskgU38Xyx%VvycvKq1^m`XMt$8hk#p5y#DXa0E~P z-~7QUDLC9L|7o7ck=l{r?Xyu(g=fRW@ahCf>Zo*=Z+B@l(V0$Lo+sG-=hk!i9firO zZ+d$cRf-c#C&Z6aJ44sLcR^hy(LMgm9cRzu=o{mdo72*Dw)oK4-Mf!xED@((F3XwN zn3TWaY@fe=@ZNQ-C5gYAnXX=UYok z6EEJn?$}p9CbYjzzMNkX|FFq-8NE2>ZhP!da~*r}z5JNCnEP?Rr@AxtSeq*6xM%Dc zEmF&bmwVo^Xd8@=8c*-6o2uKPo$#o&ZF(@iGA6{G$^7Qaac2|OFmm$J2jfEV>-UVm z7u|Bo@BwJ;DJ~8zTsmQ>dv@@Pj{8^H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!h`)XFrg5!5)TXIDub^k>&`>9oPxc9@_0Ocxp=gEcqei;A3^S8 zRRPS3`2QEm#}(KFWAv#Dv#k?gp!hy|CcXcl$qJwlCg)AJ2-qh)#ytv zJEa-?@fE2*Yptt3{=OrxRS`xRyVD1(pQb*wO9&wYuy>njWaMfXmdZ&)6Wcq zD-ql87?&Iz95{Zzh$IUA*5TCm2t$xJ^5d>qsxuic;}9Q@T?)kL_OwNQ3lfdJeA$j6 z*olZ&?0P>~D&R@ltU zjDyVM(9^M3Y`{2| zwB+OlJ6qcqtSHC=@fGeYH6?3jqdDEFIiT^lh)ALK<%3v(H6OVa2efXIGTc4M$ zScxlw7mdG*S(LpOiQ2Eri}wEVaWpHCRkL(!Kt*&Q5_z-)NvX?Ma$CFd)fkhzOVQFn zC*53`HDxUlWX}z$9NjA|DUtsEY34Bsjj+N2RCbPUL`7v^t&%$(-ozEywm9W;aYr+7 zu}kdp4zLB9{66ehZ=i>pz^_Fa+KTt!SIs=<)nxL!5T@>40l9MJV{0B(5)(XVt~Q#OYLmc=0lY zQiG5u_$Kn9=Q~)|K$P2C4nwGj3U;G)cti{z9gJP!Fpm$FFxug2xJ8KJrYmB6S#x5l z;jonz+lt#g{nE0M4X5T;BNN7iLDG94*OJgz;P)^q%f%I}StH9ShqIsEG_H=ZwTB%| j=V@Q(dvxd;#mWMX)Jy)|)AHDlA1B5J=K9sTZqfe(6dL)c literal 0 HcmV?d00001 From 93a6ec6ecbc7d6d1f9cec8a5307d51eeec1f33a3 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 15:16:29 +0300 Subject: [PATCH 29/33] Fixes: Fav icon and FAB color --- OsmAnd/res/drawable/fab_background.xml | 5 +++++ OsmAnd/res/drawable/fab_background_normal.xml | 22 +++++++++++++++++++ .../res/drawable/fab_background_pressed.xml | 21 ++++++++++++++++++ .../res/layout/map_context_menu_fragment.xml | 6 ++--- OsmAnd/res/values/colors.xml | 6 +++-- .../plus/base/FavoriteImageDrawable.java | 4 ++-- 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 OsmAnd/res/drawable/fab_background.xml create mode 100644 OsmAnd/res/drawable/fab_background_normal.xml create mode 100644 OsmAnd/res/drawable/fab_background_pressed.xml diff --git a/OsmAnd/res/drawable/fab_background.xml b/OsmAnd/res/drawable/fab_background.xml new file mode 100644 index 0000000000..1acc34de82 --- /dev/null +++ b/OsmAnd/res/drawable/fab_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/fab_background_normal.xml b/OsmAnd/res/drawable/fab_background_normal.xml new file mode 100644 index 0000000000..956991b2f5 --- /dev/null +++ b/OsmAnd/res/drawable/fab_background_normal.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/drawable/fab_background_pressed.xml b/OsmAnd/res/drawable/fab_background_pressed.xml new file mode 100644 index 0000000000..09ed741f00 --- /dev/null +++ b/OsmAnd/res/drawable/fab_background_pressed.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index c70438b853..ff6a64fb24 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -190,11 +190,11 @@ diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index cdbca7c3fa..5bb0936234 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -31,8 +31,10 @@ #be39464d #fff #333b40 - - + + #ff8f00 + #e58200 + #ff8f00 #4C000000 #fff diff --git a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java index 53b547ae24..86c12d3169 100644 --- a/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java +++ b/OsmAnd/src/net/osmand/plus/base/FavoriteImageDrawable.java @@ -33,8 +33,8 @@ public class FavoriteImageDrawable extends Drawable { int col = color == 0 || color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : color; paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.SRC_IN)); paintBackground = new Paint(); - favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.ic_action_fav_dark); - favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_shield); + favIcon = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_favorite); + favBackground = BitmapFactory.decodeResource(ctx.getResources(), R.drawable.map_white_favorite_shield); } @Override From 88e60487f69ddc8a926b00349bb22b8bdc742859 Mon Sep 17 00:00:00 2001 From: ezjerry liao Date: Wed, 21 Oct 2015 14:14:04 +0200 Subject: [PATCH 30/33] Translated using Weblate (Chinese (Taiwan)) Currently translated at 100.0% (1769 of 1769 strings) --- OsmAnd/res/values-zh-rTW/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OsmAnd/res/values-zh-rTW/strings.xml b/OsmAnd/res/values-zh-rTW/strings.xml index 1cf1e43d7e..bf05a6d55c 100644 --- a/OsmAnd/res/values-zh-rTW/strings.xml +++ b/OsmAnd/res/values-zh-rTW/strings.xml @@ -2124,7 +2124,7 @@ 在背景執行 定義速度測定系統 測定速度 - 海浬 + 海里 公里每小時 英里每小時 From 7263b58fe7d44e3f643421c5c61ff172794526e1 Mon Sep 17 00:00:00 2001 From: xmd5a Date: Wed, 21 Oct 2015 15:50:23 +0300 Subject: [PATCH 31/33] Update phrases --- OsmAnd/res/values-ru/phrases.xml | 15 +++++++++++++++ OsmAnd/res/values/phrases.xml | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/OsmAnd/res/values-ru/phrases.xml b/OsmAnd/res/values-ru/phrases.xml index 30ad9b1002..2ad673cc35 100644 --- a/OsmAnd/res/values-ru/phrases.xml +++ b/OsmAnd/res/values-ru/phrases.xml @@ -2201,4 +2201,19 @@ Пирамида из камней + Фасадная декорация + Дефибриллятор + Дефибриллятор: есть + + Тип: братская могила + Тип: тумулус + Тип: вырезанная в камне + Тип: гипогей + Тип: усыпальница + Тип: колумбарий + Тип: мавзолей + Тип: саркофаг + Тип: крипта + Тип: пирамида + \ No newline at end of file diff --git a/OsmAnd/res/values/phrases.xml b/OsmAnd/res/values/phrases.xml index 134d668344..f73a3eebbb 100644 --- a/OsmAnd/res/values/phrases.xml +++ b/OsmAnd/res/values/phrases.xml @@ -2205,4 +2205,19 @@ Cairn + Fassade decoration + Defibrillator + Defibrillator: yes + + Type: war grave + Type: tumulus + Type: rock-cut + Type: hypogeum + Type: vault + Type: columbarium + Type: mausoleum + Type: sarcophagus + Type: crypt + Type: pyramid + From 6c0d8e8f97999c8cca6ce81161813f274d977a44 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Wed, 21 Oct 2015 15:59:27 +0300 Subject: [PATCH 32/33] Fix --- ...fab_background.xml => fab_background_style.xml} | 0 OsmAnd/res/layout/map_context_menu_fragment.xml | 6 +++--- .../net/osmand/plus/download/DownloadActivity.java | 14 ++++++++++---- .../mapcontextmenu/MapContextMenuFragment.java | 4 ++-- .../design/src/main/res/values/dimens.xml | 1 + 5 files changed, 16 insertions(+), 9 deletions(-) rename OsmAnd/res/drawable/{fab_background.xml => fab_background_style.xml} (100%) diff --git a/OsmAnd/res/drawable/fab_background.xml b/OsmAnd/res/drawable/fab_background_style.xml similarity index 100% rename from OsmAnd/res/drawable/fab_background.xml rename to OsmAnd/res/drawable/fab_background_style.xml diff --git a/OsmAnd/res/layout/map_context_menu_fragment.xml b/OsmAnd/res/layout/map_context_menu_fragment.xml index ff6a64fb24..e779c35267 100644 --- a/OsmAnd/res/layout/map_context_menu_fragment.xml +++ b/OsmAnd/res/layout/map_context_menu_fragment.xml @@ -190,11 +190,11 @@ diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 901d0502bc..d9887385cd 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -68,10 +68,16 @@ public class DownloadActivity extends BaseDownloadActivity { int currentTab = 0; String tab = getIntent() == null || getIntent().getExtras() == null ? null : getIntent().getExtras().getString(TAB_TO_OPEN); if (tab != null) { - if (tab.equals(DOWNLOAD_TAB)) { - currentTab = 1; - } else if (tab.equals(UPDATES_TAB)) { - currentTab = 2; + switch (tab) { + case DOWNLOAD_TAB: + currentTab = 0; + break; + case LOCAL_TAB: + currentTab = 1; + break; + case UPDATES_TAB: + currentTab = 2; + break; } } visibleBanner = new BannerAndDownloadFreeVersion(findViewById(R.id.mainLayout), this); diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java index b10c8ebf73..0d4f06bda1 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/MapContextMenuFragment.java @@ -52,7 +52,7 @@ public class MapContextMenuFragment extends Fragment { public static final String TAG = "MapContextMenuFragment"; private static final Log LOG = PlatformUtil.getLog(MapContextMenuFragment.class); - public static final float FAB_PADDING_TOP = 10f; + public static final float FAB_PADDING_TOP_DP = 4f; public static final float MARKER_PADDING_DP = 20f; public static final float MARKER_PADDING_X_DP = 50f; @@ -125,7 +125,7 @@ public class MapContextMenuFragment extends Fragment { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - fabPaddingTopPx = dpToPx(FAB_PADDING_TOP); + fabPaddingTopPx = dpToPx(FAB_PADDING_TOP_DP); markerPaddingPx = dpToPx(MARKER_PADDING_DP); markerPaddingXPx = dpToPx(MARKER_PADDING_X_DP); diff --git a/eclipse-compile/design/src/main/res/values/dimens.xml b/eclipse-compile/design/src/main/res/values/dimens.xml index 45e83e6088..7029deaa73 100644 --- a/eclipse-compile/design/src/main/res/values/dimens.xml +++ b/eclipse-compile/design/src/main/res/values/dimens.xml @@ -22,6 +22,7 @@ 56dp 40dp 0.5dp + 62dp 320dp 12dp From a827bfe32504e08357b0e84c872b5af73bac4a9c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 21 Oct 2015 15:10:10 +0200 Subject: [PATCH 33/33] Fix --- .../net/osmand/plus/FavouritesDbHelper.java | 28 +- .../activities/FavoritesTreeFragment.java | 65 ++-- .../plus/activities/LocalIndexHelper.java | 2 - .../activities/search/SearchPOIActivity.java | 5 - .../plus/download/DownloadActivity.java | 41 +++ .../net/osmand/plus/download/IndexItem.java | 4 +- .../plus/download/ui/ItemViewHolder.java | 104 +++++-- .../download/ui/LocalIndexesFragment.java | 280 ++++++++---------- .../plus/resources/ResourceManager.java | 3 +- 9 files changed, 302 insertions(+), 230 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index fa9411d067..02346396f6 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -1,18 +1,5 @@ package net.osmand.plus; -import android.app.AlertDialog; -import android.content.Context; - -import net.osmand.PlatformUtil; -import net.osmand.data.FavouritePoint; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.GPXUtilities.WptPt; -import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; -import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; -import net.osmand.util.Algorithms; - -import org.apache.tools.bzip2.CBZip2OutputStream; - import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -25,6 +12,19 @@ import java.util.List; import java.util.Map; import java.util.Set; +import net.osmand.PlatformUtil; +import net.osmand.data.FavouritePoint; +import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.WptPt; +import net.osmand.plus.api.SQLiteAPI.SQLiteConnection; +import net.osmand.plus.api.SQLiteAPI.SQLiteCursor; +import net.osmand.util.Algorithms; + +import org.apache.tools.bzip2.CBZip2OutputStream; + +import android.app.AlertDialog; +import android.content.Context; + public class FavouritesDbHelper { public interface FavoritesUpdatedListener { @@ -582,6 +582,8 @@ public class FavouritesDbHelper { if(renamedGroup == null) { renamedGroup = gr; flatGroups.put(gr.name, gr); + } else { + favoriteGroups.remove(gr); } for(FavouritePoint p : gr.points) { p.setCategory(newName); diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java index 26557be20b..048e8f182d 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesTreeFragment.java @@ -1,5 +1,37 @@ package net.osmand.plus.activities; +import gnu.trove.list.array.TIntArrayList; + +import java.io.File; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import net.osmand.access.AccessibleToast; +import net.osmand.data.FavouritePoint; +import net.osmand.data.LatLon; +import net.osmand.data.PointDescription; +import net.osmand.plus.FavouritesDbHelper; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; +import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmAndFormatter; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandSettings; +import net.osmand.plus.R; +import net.osmand.plus.TargetPointsHelper; +import net.osmand.plus.base.FavoriteImageDrawable; +import net.osmand.plus.helpers.AndroidUiHelper; +import net.osmand.plus.helpers.ColorDialogs; +import net.osmand.plus.myplaces.FavoritesActivity; +import net.osmand.util.Algorithms; +import net.osmand.util.MapUtils; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; @@ -35,38 +67,6 @@ import android.widget.ImageView; import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; -import net.osmand.access.AccessibleToast; -import net.osmand.data.FavouritePoint; -import net.osmand.data.LatLon; -import net.osmand.data.PointDescription; -import net.osmand.plus.FavouritesDbHelper; -import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; -import net.osmand.plus.GPXUtilities; -import net.osmand.plus.GPXUtilities.GPXFile; -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmAndFormatter; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandSettings; -import net.osmand.plus.R; -import net.osmand.plus.TargetPointsHelper; -import net.osmand.plus.base.FavoriteImageDrawable; -import net.osmand.plus.helpers.AndroidUiHelper; -import net.osmand.plus.helpers.ColorDialogs; -import net.osmand.plus.myplaces.FavoritesActivity; -import net.osmand.util.Algorithms; -import net.osmand.util.MapUtils; - -import java.io.File; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import gnu.trove.list.array.TIntArrayList; public class FavoritesTreeFragment extends OsmandExpandableListFragment { @@ -527,7 +527,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment { } }); builder.show(); - } private void deleteFavoritesAction() { diff --git a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java index fd47b46c6d..e7d1b9f202 100644 --- a/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java +++ b/OsmAnd/src/net/osmand/plus/activities/LocalIndexHelper.java @@ -2,7 +2,6 @@ package net.osmand.plus.activities; import java.io.File; -import java.text.DateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -19,7 +18,6 @@ import net.osmand.plus.SQLiteTileSource; import net.osmand.plus.download.ui.LocalIndexesFragment.LoadLocalIndexTask; import net.osmand.plus.voice.MediaCommandPlayerImpl; import net.osmand.plus.voice.TTSCommandPlayerImpl; -import net.osmand.util.Algorithms; import android.content.Context; import android.os.Build; diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java index 063c650c30..7647126075 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchPOIActivity.java @@ -34,13 +34,11 @@ import net.osmand.plus.activities.EditPOIFilterActivity; import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.OsmandListActivity; import net.osmand.plus.dashboard.DashLocationFragment; -import net.osmand.plus.dialogs.DirectionsDialogs; import net.osmand.plus.poi.NominatimPoiFilter; import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter.AmenityNameFilter; import net.osmand.plus.render.RenderingIcons; import net.osmand.plus.views.DirectionDrawable; -import net.osmand.plus.views.POIMapLayer; import net.osmand.util.Algorithms; import net.osmand.util.MapUtils; import net.osmand.util.OpeningHoursParser; @@ -58,10 +56,7 @@ import android.support.v4.view.MenuItemCompat; import android.support.v7.widget.PopupMenu; import android.support.v7.widget.Toolbar; import android.text.Editable; -import android.text.SpannableString; import android.text.TextWatcher; -import android.text.method.LinkMovementMethod; -import android.text.util.Linkify; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; diff --git a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java index 901d0502bc..0312b75508 100644 --- a/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java +++ b/OsmAnd/src/net/osmand/plus/download/DownloadActivity.java @@ -7,6 +7,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; +import net.osmand.IProgress; +import net.osmand.access.AccessibleToast; import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandSettings; import net.osmand.plus.R; @@ -36,6 +38,7 @@ import android.view.MenuItem; import android.view.View; import android.widget.ProgressBar; import android.widget.TextView; +import android.widget.Toast; public class DownloadActivity extends BaseDownloadActivity { private List localIndexInfos = new ArrayList<>(); @@ -345,6 +348,44 @@ public class DownloadActivity extends BaseDownloadActivity { } } } + + public void reloadLocalIndexes() { + AsyncTask> task = new AsyncTask>() { + @Override + protected void onPreExecute() { + super.onPreExecute(); + setSupportProgressBarIndeterminateVisibility(true); + } + + @Override + protected List doInBackground(Void... params) { + return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS, + new ArrayList() + ); + } + + @Override + protected void onPostExecute(List warnings) { + setSupportProgressBarIndeterminateVisibility(false); + if (!warnings.isEmpty()) { + final StringBuilder b = new StringBuilder(); + boolean f = true; + for (String w : warnings) { + if (f) { + f = false; + } else { + b.append('\n'); + } + b.append(w); + } + AccessibleToast.makeText(DownloadActivity.this, b.toString(), Toast.LENGTH_LONG).show(); + } + newDownloadIndexes(); + } + }; + task.execute(); + + } @SuppressWarnings("deprecation") diff --git a/OsmAnd/src/net/osmand/plus/download/IndexItem.java b/OsmAnd/src/net/osmand/plus/download/IndexItem.java index b7b4fd112c..b694ca8290 100644 --- a/OsmAnd/src/net/osmand/plus/download/IndexItem.java +++ b/OsmAnd/src/net/osmand/plus/download/IndexItem.java @@ -126,7 +126,7 @@ public class IndexItem implements Comparable { return type.getBasename(this); } - private File getTargetFile(OsmandApplication ctx) { + public File getTargetFile(OsmandApplication ctx) { String basename; if (type == DownloadActivityType.HILLSHADE_FILE) { basename = (FileNameTranslationHelper.HILL_SHADE + getBasename()).replace("_", " "); @@ -171,7 +171,7 @@ public class IndexItem implements Comparable { } public boolean isOutdated() { - return outdated; + return outdated && getType() != DownloadActivityType.HILLSHADE_FILE ; } public void setOutdated(boolean outdated) { diff --git a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java index 1297e547ba..e3db693e0f 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/ItemViewHolder.java @@ -1,26 +1,34 @@ package net.osmand.plus.download.ui; +import java.io.File; import java.text.DateFormat; import net.osmand.access.AccessibleToast; import net.osmand.plus.OsmandPlugin; import net.osmand.plus.R; import net.osmand.plus.Version; +import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; +import net.osmand.plus.activities.LocalIndexInfo; import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivityType; import net.osmand.plus.download.DownloadResourceGroup; import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.IndexItem; +import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask; +import net.osmand.plus.helpers.FileNameTranslationHelper; import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin; import net.osmand.plus.srtmplugin.SRTMPlugin; import android.annotation.SuppressLint; +import android.app.AlertDialog.Builder; import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.net.Uri; import android.support.v7.app.AlertDialog; +import android.support.v7.widget.PopupMenu; import android.util.TypedValue; +import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; @@ -137,8 +145,7 @@ public class ItemViewHolder { } int color = textColorSecondary; if(indexItem.isDownloaded() && !isDownloading) { - int colorId = indexItem.getType() != DownloadActivityType.HILLSHADE_FILE && - indexItem.isOutdated() ? R.color.color_distance : R.color.color_ok; + int colorId = indexItem.isOutdated() ? R.color.color_distance : R.color.color_ok; color = context.getResources().getColor(colorId); } if (indexItem.isDownloaded()) { @@ -170,14 +177,7 @@ public class ItemViewHolder { descrTextView.setText(indexItem.getSizeDescription(context) + " • " + (showRemoteDate ? indexItem.getRemoteDate(dateFormat) : indexItem.getLocalDate(dateFormat))); } - - rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import)); - rightImageButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - download(indexItem, parentOptional); - } - }); + } else { progressBar.setVisibility(View.VISIBLE); progressBar.setIndeterminate(progress == -1); @@ -201,17 +201,6 @@ public class ItemViewHolder { descrTextView.setVisibility(View.GONE); } - rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_remove_dark)); - rightImageButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - if (silentCancelDownload) { - context.getDownloadThread().cancelDownload(indexItem); - } else { - context.makeSureUserCancelDownload(indexItem); - } - } - }); } } @@ -249,17 +238,27 @@ public class ItemViewHolder { builder.show(); } - private boolean checkDisabledAndClickAction(final IndexItem indexItem) { - RightButtonAction clickAction = getClickAction(indexItem); + private boolean checkDisabledAndClickAction(final IndexItem item) { + RightButtonAction clickAction = getClickAction(item); boolean disabled = clickAction != RightButtonAction.DOWNLOAD; + OnClickListener action = getRightButtonAction(item, clickAction, null); if (clickAction != RightButtonAction.DOWNLOAD) { rightButton.setText(R.string.get_plugin); rightButton.setVisibility(View.VISIBLE); rightImageButton.setVisibility(View.GONE); - rightButton.setOnClickListener(getRightButtonAction(indexItem, clickAction, null)); + rightButton.setOnClickListener(action); } else { rightButton.setVisibility(View.GONE); rightImageButton.setVisibility(View.VISIBLE); + final boolean isDownloading = context.getDownloadThread().isDownloading(item); + if (isDownloading) { + rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_remove_dark)); + } else if(item.isDownloaded() && !item.isOutdated()) { + rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_overflow_menu_white)); + } else { + rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import)); + } + rightImageButton.setOnClickListener(action); } return disabled; @@ -328,6 +327,8 @@ public class ItemViewHolder { } else { context.makeSureUserCancelDownload(item); } + } else if(item.isDownloaded() && !item.isOutdated()){ + contextMenu(v, item, parentOptional); } else { download(item, parentOptional); } @@ -336,6 +337,61 @@ public class ItemViewHolder { } } + protected void contextMenu(View v, final IndexItem indexItem, final DownloadResourceGroup parentOptional) { + final PopupMenu optionsMenu = new PopupMenu(context, v); + MenuItem item; + + final File fl = indexItem.getTargetFile(context.getMyApplication()); + if (fl.exists()) { + item = optionsMenu.getMenu().add(R.string.shared_string_delete).setIcon( + context.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_remove_dark)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + LocalIndexType tp = LocalIndexType.MAP_DATA; + if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) { + tp = LocalIndexType.TILES_DATA; + } else if (indexItem.getType() == DownloadActivityType.ROADS_FILE) { + tp = LocalIndexType.MAP_DATA; + } else if (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { + tp = LocalIndexType.SRTM_DATA; + } else if (indexItem.getType() == DownloadActivityType.WIKIPEDIA_FILE) { + tp = LocalIndexType.MAP_DATA; + } else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) { + tp = indexItem.getBasename().contains("tts") ? LocalIndexType.TTS_VOICE_DATA + : LocalIndexType.VOICE_DATA; + } + final LocalIndexInfo info = new LocalIndexInfo(tp, fl, false); + Builder confirm = new Builder(context); + confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + new LocalIndexOperationTask(context, null, LocalIndexOperationTask.DELETE_OPERATION) + .execute(info); + } + }); + confirm.setNegativeButton(R.string.shared_string_no, null); + String fn = FileNameTranslationHelper.getFileName(context, context.getMyApplication().getRegions(), + indexItem.getVisibleName(context, context.getMyApplication().getRegions())); + confirm.setMessage(context.getString(R.string.delete_confirmation_msg, fn)); + confirm.show(); + return true; + } + }); + } + item = optionsMenu.getMenu().add(R.string.shared_string_download) + .setIcon(context.getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_import)); + item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { + @Override + public boolean onMenuItemClick(MenuItem item) { + download(indexItem, parentOptional); + return true; + } + }); + + optionsMenu.show(); + } + private Drawable getContentIcon(DownloadActivity context, int resourceId) { return context.getMyApplication().getIconsCache().getContentIcon(resourceId); } diff --git a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java index 43d0ebacf3..93d102359f 100644 --- a/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java +++ b/OsmAnd/src/net/osmand/plus/download/ui/LocalIndexesFragment.java @@ -1,5 +1,41 @@ package net.osmand.plus.download.ui; +import java.io.File; +import java.text.Collator; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import net.osmand.IndexConstants; +import net.osmand.access.AccessibleToast; +import net.osmand.plus.ContextMenuAdapter; +import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; +import net.osmand.plus.IconsCache; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.OsmandPlugin; +import net.osmand.plus.R; +import net.osmand.plus.activities.LocalIndexHelper; +import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; +import net.osmand.plus.activities.LocalIndexInfo; +import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; +import net.osmand.plus.activities.OsmandExpandableListFragment; +import net.osmand.plus.dialogs.DirectionsDialogs; +import net.osmand.plus.download.DownloadActivity; +import net.osmand.plus.download.DownloadActivityType; +import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; +import net.osmand.plus.download.IndexItem; +import net.osmand.plus.helpers.FileNameTranslationHelper; +import net.osmand.plus.resources.IncrementalChangesManager; +import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdate; +import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdateList; +import net.osmand.util.Algorithms; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; @@ -11,6 +47,7 @@ import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.Drawable; import android.os.AsyncTask; +import android.os.AsyncTask.Status; import android.os.Bundle; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.ActionBar; @@ -35,43 +72,6 @@ import android.widget.ImageButton; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; -import net.osmand.IProgress; -import net.osmand.IndexConstants; -import net.osmand.access.AccessibleToast; -import net.osmand.plus.ContextMenuAdapter; -import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick; -import net.osmand.plus.IconsCache; -import net.osmand.plus.OsmandApplication; -import net.osmand.plus.OsmandPlugin; -import net.osmand.plus.R; -import net.osmand.plus.activities.LocalIndexHelper; -import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType; -import net.osmand.plus.activities.LocalIndexInfo; -import net.osmand.plus.activities.OsmandBaseExpandableListAdapter; -import net.osmand.plus.activities.OsmandExpandableListFragment; -import net.osmand.plus.dialogs.DirectionsDialogs; -import net.osmand.plus.download.DownloadActivity; -import net.osmand.plus.download.DownloadActivityType; -import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; -import net.osmand.plus.download.IndexItem; -import net.osmand.plus.helpers.FileNameTranslationHelper; -import net.osmand.plus.resources.IncrementalChangesManager; -import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdate; -import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdateList; -import net.osmand.util.Algorithms; - -import java.io.File; -import java.text.Collator; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Set; public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents { @@ -83,9 +83,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement private boolean selectionMode = false; private Set selectedItems = new LinkedHashSet(); - protected static int DELETE_OPERATION = 1; - protected static int BACKUP_OPERATION = 2; - protected static int RESTORE_OPERATION = 3; MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US); private ContextMenuAdapter optionsMenuAdapter; @@ -118,8 +115,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement // getLastNonConfigurationInstance method should be in onCreate() method // (onResume() doesn't work) Object indexes = getActivity().getLastNonConfigurationInstance(); - asyncLoader = new LoadLocalIndexTask(); if (indexes instanceof List) { + asyncLoader = new LoadLocalIndexTask(); asyncLoader.setResult((List) indexes); } } @@ -160,8 +157,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } public void reloadData() { - asyncLoader = new LoadLocalIndexTask(); - asyncLoader.execute(getActivity()); + LoadLocalIndexTask current = asyncLoader; + if(current == null || current.getStatus() == Status.FINISHED || + current.isCancelled() || current.getResult() != null) { + asyncLoader = new LoadLocalIndexTask(); + asyncLoader.execute(getActivity()); + } } @@ -216,17 +217,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement @Override public void run() { - reloadIndexes(); + getDownloadActivity().reloadLocalIndexes(); } }); } else if (resId == R.string.local_index_mi_restore) { - new LocalIndexOperationTask(RESTORE_OPERATION).execute(info); + new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION).execute(info); } else if (resId == R.string.shared_string_delete) { Builder confirm = new Builder(getActivity()); confirm.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - new LocalIndexOperationTask(DELETE_OPERATION).execute(info); + new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.DELETE_OPERATION).execute(info); } }); confirm.setNegativeButton(R.string.shared_string_no, null); @@ -236,7 +237,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement confirm.setMessage(getString(R.string.delete_confirmation_msg, fn)); confirm.show(); } else if (resId == R.string.local_index_mi_backup) { - new LocalIndexOperationTask(BACKUP_OPERATION).execute(info); + new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.BACKUP_OPERATION).execute(info); } return true; } @@ -311,9 +312,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement public void setResult(List result) { this.result = result; - if (result == null) { - listAdapter.clear(); - } else { + listAdapter.clear(); + if (result != null) { for (LocalIndexInfo v : result) { listAdapter.addLocalIndexInfo(v); } @@ -339,52 +339,67 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } - private File getFileToRestore(LocalIndexInfo i) { - if (i.isBackupedData()) { - File parent = new File(i.getPathToData()).getParentFile(); - if (i.getType() == LocalIndexType.SRTM_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR); - } else if (i.getFileName().endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) { - parent = getMyApplication().getAppPath(IndexConstants.ROADS_INDEX_DIR); - } else if (i.getType() == LocalIndexType.WIKI_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR); - } else if (i.getType() == LocalIndexType.MAP_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH); - } else if (i.getType() == LocalIndexType.TILES_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR); - } else if (i.getType() == LocalIndexType.VOICE_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); - } else if (i.getType() == LocalIndexType.TTS_VOICE_DATA) { - parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); - } - return new File(parent, i.getFileName()); - } - return new File(i.getPathToData()); - } + - private File getFileToBackup(LocalIndexInfo i) { - if (!i.isBackupedData()) { - return new File(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR), i.getFileName()); - } - return new File(i.getPathToData()); - } + - private boolean move(File from, File to) { - if (!to.getParentFile().exists()) { - to.getParentFile().mkdirs(); - } - return from.renameTo(to); - } + - public class LocalIndexOperationTask extends AsyncTask { + public static class LocalIndexOperationTask extends AsyncTask { + protected static int DELETE_OPERATION = 1; + protected static int BACKUP_OPERATION = 2; + protected static int RESTORE_OPERATION = 3; private final int operation; + private DownloadActivity a; + private LocalIndexesAdapter listAdapter; - public LocalIndexOperationTask(int operation) { + public LocalIndexOperationTask(DownloadActivity a, LocalIndexesAdapter listAdapter, int operation) { + this.a = a; + this.listAdapter = listAdapter; this.operation = operation; } - + private boolean move(File from, File to) { + if (!to.getParentFile().exists()) { + to.getParentFile().mkdirs(); + } + return from.renameTo(to); + } + + private File getFileToBackup(LocalIndexInfo i) { + if (!i.isBackupedData()) { + return new File(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR), i.getFileName()); + } + return new File(i.getPathToData()); + } + private OsmandApplication getMyApplication() { + return (OsmandApplication) a.getApplication(); + } + + + private File getFileToRestore(LocalIndexInfo i) { + if (i.isBackupedData()) { + File parent = new File(i.getPathToData()).getParentFile(); + if (i.getType() == LocalIndexType.SRTM_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR); + } else if (i.getFileName().endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) { + parent = getMyApplication().getAppPath(IndexConstants.ROADS_INDEX_DIR); + } else if (i.getType() == LocalIndexType.WIKI_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR); + } else if (i.getType() == LocalIndexType.MAP_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH); + } else if (i.getType() == LocalIndexType.TILES_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR); + } else if (i.getType() == LocalIndexType.VOICE_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); + } else if (i.getType() == LocalIndexType.TTS_VOICE_DATA) { + parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); + } + return new File(parent, i.getFileName()); + } + return new File(i.getPathToData()); + } @Override protected String doInBackground(LocalIndexInfo... params) { int count = 0; @@ -395,6 +410,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement if (operation == DELETE_OPERATION) { File f = new File(info.getPathToData()); successfull = Algorithms.removeAllFiles(f); + if (successfull) { + getMyApplication().getResourceManager().closeFile(info.getFileName()); + } } else if (operation == RESTORE_OPERATION) { successfull = move(new File(info.getPathToData()), getFileToRestore(info)); if (successfull) { @@ -415,11 +433,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } } if (operation == DELETE_OPERATION) { - return getString(R.string.local_index_items_deleted, count, total); + a.getDownloadThread().updateLoadedFiles(); + } + if (operation == DELETE_OPERATION) { + return a.getString(R.string.local_index_items_deleted, count, total); } else if (operation == BACKUP_OPERATION) { - return getString(R.string.local_index_items_backuped, count, total); + return a.getString(R.string.local_index_items_backuped, count, total); } else if (operation == RESTORE_OPERATION) { - return getString(R.string.local_index_items_restored, count, total); + return a.getString(R.string.local_index_items_restored, count, total); } return ""; @@ -428,34 +449,38 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement @Override protected void onProgressUpdate(LocalIndexInfo... values) { - if (operation == DELETE_OPERATION) { - listAdapter.delete(values); - } else if (operation == BACKUP_OPERATION) { - listAdapter.move(values, false); - } else if (operation == RESTORE_OPERATION) { - listAdapter.move(values, true); + if (listAdapter != null) { + if (operation == DELETE_OPERATION) { + listAdapter.delete(values); + } else if (operation == BACKUP_OPERATION) { + listAdapter.move(values, false); + } else if (operation == RESTORE_OPERATION) { + listAdapter.move(values, true); + } } } @Override protected void onPreExecute() { - getDownloadActivity().setProgressBarIndeterminateVisibility(true); + a.setProgressBarIndeterminateVisibility(true); } @Override protected void onPostExecute(String result) { - getDownloadActivity().setProgressBarIndeterminateVisibility(false); - AccessibleToast.makeText(getDownloadActivity(), result, Toast.LENGTH_LONG).show(); + a.setProgressBarIndeterminateVisibility(false); + AccessibleToast.makeText(a, result, Toast.LENGTH_LONG).show(); if (operation == RESTORE_OPERATION || operation == BACKUP_OPERATION) { - listAdapter.clear(); - reloadIndexes(); + a.reloadLocalIndexes(); + } else { + a.newDownloadIndexes(); } } } @Override public void newDownloadIndexes() { + reloadData(); } @Override @@ -585,11 +610,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement public void doAction(int actionResId) { if (actionResId == R.string.local_index_mi_backup) { - operationTask = new LocalIndexOperationTask(BACKUP_OPERATION); + operationTask = new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.BACKUP_OPERATION); } else if (actionResId == R.string.shared_string_delete) { - operationTask = new LocalIndexOperationTask(DELETE_OPERATION); + operationTask = new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.DELETE_OPERATION); } else if (actionResId == R.string.local_index_mi_restore) { - operationTask = new LocalIndexOperationTask(RESTORE_OPERATION); + operationTask = new LocalIndexOperationTask(getDownloadActivity(), listAdapter, LocalIndexOperationTask.RESTORE_OPERATION); } else { operationTask = null; } @@ -676,7 +701,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement public void localOptionsMenu(final int itemId) { if (itemId == R.string.local_index_mi_reload) { - reloadIndexes(); + getDownloadActivity().reloadLocalIndexes(); } else if (itemId == R.string.shared_string_delete) { openSelectionMode(itemId, R.drawable.ic_action_delete_dark, new DialogInterface.OnClickListener() { @@ -720,50 +745,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement } - public void reloadIndexes() { - listAdapter.clear(); - asyncLoader = new LoadLocalIndexTask(); - AsyncTask> task = new AsyncTask>() { - @Override - protected void onPreExecute() { - super.onPreExecute(); - getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true); - } - - @Override - protected List doInBackground(Void... params) { - return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS, - new ArrayList() - ); - } - - @Override - protected void onPostExecute(List warnings) { - if (getDownloadActivity() == null) { - return; - } - getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false); - if (!warnings.isEmpty()) { - final StringBuilder b = new StringBuilder(); - boolean f = true; - for (String w : warnings) { - if (f) { - f = false; - } else { - b.append('\n'); - } - b.append(w); - } - AccessibleToast.makeText(getDownloadActivity(), b.toString(), Toast.LENGTH_LONG).show(); - } - if (asyncLoader.getStatus() == Status.PENDING) { - asyncLoader.execute(getDownloadActivity()); - } - } - }; - task.execute(); - - } + protected class LocalIndexesAdapter extends OsmandBaseExpandableListAdapter { diff --git a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java index c0c69d2ad3..f3ce3a6938 100644 --- a/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java +++ b/OsmAnd/src/net/osmand/plus/resources/ResourceManager.java @@ -10,12 +10,10 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import net.osmand.AndroidUtils; @@ -963,6 +961,7 @@ public class ResourceManager { log.error(e, e); } } + indexFileNames.remove(fileName); renderer.closeConnection(fileName); }