Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-10-28 04:48:51 +01:00
commit b88f7c3c55
5 changed files with 91 additions and 87 deletions

View file

@ -98,7 +98,7 @@ public class LocalIndexHelper {
loadTilesData(app.getAppPath(IndexConstants.TILES_INDEX_DIR), result, false, loadTask); loadTilesData(app.getAppPath(IndexConstants.TILES_INDEX_DIR), result, false, loadTask);
loadSrtmData(app.getAppPath(IndexConstants.SRTM_INDEX_DIR), result, loadTask); loadSrtmData(app.getAppPath(IndexConstants.SRTM_INDEX_DIR), result, loadTask);
loadWikiData(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), result, loadTask); loadWikiData(app.getAppPath(IndexConstants.WIKI_INDEX_DIR), result, loadTask);
loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask); //loadVoiceData(app.getAppPath(IndexConstants.TTSVOICE_INDEX_EXT_ZIP), result, true, loadTask);
loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask); loadVoiceData(app.getAppPath(IndexConstants.VOICE_INDEX_DIR), result, false, loadTask);
return result; return result;
@ -213,7 +213,8 @@ public class LocalIndexHelper {
SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm), SRTM_DATA(R.string.local_indexes_cat_srtm, R.drawable.ic_plugin_srtm),
WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia), WIKI_DATA(R.string.local_indexes_cat_wiki, R.drawable.ic_plugin_wikipedia),
TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up), TTS_VOICE_DATA(R.string.local_indexes_cat_tts, R.drawable.ic_action_volume_up),
VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up); VOICE_DATA(R.string.local_indexes_cat_voice, R.drawable.ic_action_volume_up),
DEACTIVATED(R.string.local_indexes_cat_backup, R.drawable.ic_type_archive);
// AV_DATA(R.string.local_indexes_cat_av);; // AV_DATA(R.string.local_indexes_cat_av);;
@StringRes @StringRes

View file

@ -120,6 +120,10 @@ public class LocalIndexInfo {
} }
public LocalIndexType getType() { public LocalIndexType getType() {
return backupedData ? LocalIndexType.DEACTIVATED : type;
}
public LocalIndexType getOriginalType() {
return type; return type;
} }

View file

@ -60,6 +60,7 @@ public class ItemViewHolder {
boolean showTypeInDesc; boolean showTypeInDesc;
boolean showTypeInName; boolean showTypeInName;
boolean showParentRegionName;
boolean showRemoteDate; boolean showRemoteDate;
boolean silentCancelDownload; boolean silentCancelDownload;
boolean showProgressInDesc; boolean showProgressInDesc;
@ -99,6 +100,11 @@ public class ItemViewHolder {
this.showRemoteDate = showRemoteDate; this.showRemoteDate = showRemoteDate;
} }
public void setShowParentRegionName(boolean showParentRegionName) {
this.showParentRegionName = showParentRegionName;
}
public void setShowProgressInDescr(boolean b) { public void setShowProgressInDescr(boolean b) {
showProgressInDesc = b; showProgressInDesc = b;
} }
@ -137,7 +143,7 @@ public class ItemViewHolder {
if(showTypeInName) { if(showTypeInName) {
nameTextView.setText(indexItem.getType().getString(context)); nameTextView.setText(indexItem.getType().getString(context));
} else { } else {
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), false)); nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), showParentRegionName));
} }
if(!disabled) { if(!disabled) {
nameTextView.setTextColor(textColorPrimary); nameTextView.setTextColor(textColorPrimary);

View file

@ -1,5 +1,45 @@
package net.osmand.plus.download.ui; package net.osmand.plus.download.ui;
import java.io.File;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
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 org.apache.commons.logging.Log;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog; import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
@ -34,51 +74,10 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import net.osmand.IProgress;
import net.osmand.IndexConstants;
import net.osmand.PlatformUtil;
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 org.apache.commons.logging.Log;
import java.io.File;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents { public class LocalIndexesFragment extends OsmandExpandableListFragment implements DownloadEvents {
private static final Log LOG = PlatformUtil.getLog(LocalIndexesFragment.class);
private LoadLocalIndexTask asyncLoader; private LoadLocalIndexTask asyncLoader;
private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>(); private Map<String, IndexItem> filesToUpdate = new HashMap<String, IndexItem>();
private LocalIndexesAdapter listAdapter; private LocalIndexesAdapter listAdapter;
@ -94,7 +93,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private ContextMenuAdapter optionsMenuAdapter; private ContextMenuAdapter optionsMenuAdapter;
private ActionMode actionMode; private ActionMode actionMode;
Drawable backup;
Drawable sdcard; Drawable sdcard;
Drawable planet; Drawable planet;
@ -131,11 +129,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private void colorDrawables() { private void colorDrawables() {
boolean light = getMyApplication().getSettings().isLightContent(); boolean light = getMyApplication().getSettings().isLightContent();
backup = getActivity().getResources().getDrawable(R.drawable.ic_type_archive);
backup.mutate();
if (light) {
backup.setColorFilter(getResources().getColor(R.color.icon_color), PorterDuff.Mode.MULTIPLY);
}
sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard); sdcard = getActivity().getResources().getDrawable(R.drawable.ic_sdcard);
sdcard.mutate(); sdcard.mutate();
sdcard.setColorFilter(getActivity().getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY); sdcard.setColorFilter(getActivity().getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
@ -388,19 +381,21 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
private File getFileToRestore(LocalIndexInfo i) { private File getFileToRestore(LocalIndexInfo i) {
if (i.isBackupedData()) { if (i.isBackupedData()) {
File parent = new File(i.getPathToData()).getParentFile(); File parent = new File(i.getPathToData()).getParentFile();
if (i.getType() == LocalIndexType.MAP_DATA) { if (i.getOriginalType() == LocalIndexType.MAP_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH); if (i.getFileName().endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) {
} else if (i.getFileName().endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) {
parent = getMyApplication().getAppPath(IndexConstants.ROADS_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.ROADS_INDEX_DIR);
} else if (i.getType() == LocalIndexType.TILES_DATA) { } else {
parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH);
}
} else if (i.getOriginalType() == LocalIndexType.TILES_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR);
} else if (i.getType() == LocalIndexType.SRTM_DATA) { } else if (i.getOriginalType() == LocalIndexType.SRTM_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR);
} else if (i.getType() == LocalIndexType.WIKI_DATA) { } else if (i.getOriginalType() == LocalIndexType.WIKI_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR);
} else if (i.getType() == LocalIndexType.TTS_VOICE_DATA) { } else if (i.getOriginalType() == LocalIndexType.TTS_VOICE_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
} else if (i.getType() == LocalIndexType.VOICE_DATA) { } else if (i.getOriginalType() == LocalIndexType.VOICE_DATA) {
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR); parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
} }
return new File(parent, i.getFileName()); return new File(parent, i.getFileName());
@ -716,7 +711,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
doAction(itemId); doAction(itemId);
} }
}, null, null); }, null);
} else if (itemId == R.string.local_index_mi_backup) { } else if (itemId == R.string.local_index_mi_backup) {
openSelectionMode(itemId, R.drawable.ic_type_archive, openSelectionMode(itemId, R.drawable.ic_type_archive,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@ -725,7 +720,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
doAction(itemId); doAction(itemId);
} }
}, Boolean.FALSE, LocalIndexType.MAP_DATA); }, EnumSet.of(LocalIndexType.MAP_DATA, LocalIndexType.WIKI_DATA, LocalIndexType.SRTM_DATA));
} else if (itemId == R.string.local_index_mi_restore) { } else if (itemId == R.string.local_index_mi_restore) {
openSelectionMode(itemId, R.drawable.ic_type_archive, openSelectionMode(itemId, R.drawable.ic_type_archive,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@ -734,16 +729,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
doAction(itemId); doAction(itemId);
} }
}, Boolean.TRUE, LocalIndexType.MAP_DATA); }, EnumSet.of(LocalIndexType.DEACTIVATED));
listAdapter.filterCategories(true);
} }
} }
public void openSelectionMode(int stringRes, int darkIcon, DialogInterface.OnClickListener listener, Boolean backup, public void openSelectionMode(int stringRes, int darkIcon, DialogInterface.OnClickListener listener,
LocalIndexType filter) { EnumSet<LocalIndexType> filter) {
if (backup != null) {
listAdapter.filterCategories(backup);
}
if (filter != null) { if (filter != null) {
listAdapter.filterCategories(filter); listAdapter.filterCategories(filter);
} }
@ -838,16 +829,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void filterCategories(LocalIndexType... types) { public void filterCategories(EnumSet<LocalIndexType> types) {
List<LocalIndexInfo> filter = new ArrayList<LocalIndexInfo>(); List<LocalIndexInfo> filter = new ArrayList<LocalIndexInfo>();
List<LocalIndexInfo> source = filterCategory == null ? category : filterCategory; List<LocalIndexInfo> source = filterCategory == null ? category : filterCategory;
for (LocalIndexInfo info : source) { for (LocalIndexInfo info : source) {
for (LocalIndexType ts : types) { if(types.contains(info.getType())) {
if (info.getType() == ts) {
filter.add(info); filter.add(info);
} }
} }
}
filterCategory = filter; filterCategory = filter;
notifyDataSetChanged(); notifyDataSetChanged();
} }
@ -934,7 +923,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
name.append(" ").append(group.getSubfolder()); name.append(" ").append(group.getSubfolder());
} }
if (group.isBackupedData()) { if (group.isBackupedData()) {
name.append(" - ").append(ctx.getString(R.string.local_indexes_cat_backup)); ctx.getString(R.string.local_indexes_cat_backup);
} }
TextView nameView = ((TextView) v.findViewById(R.id.section_name)); TextView nameView = ((TextView) v.findViewById(R.id.section_name));
TextView sizeView = ((TextView) v.findViewById(R.id.section_description)); TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
@ -1035,12 +1024,8 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
openPopUpMenu(v, child); openPopUpMenu(v, child);
} }
}); });
if (child.isBackupedData()) {
icon.setImageDrawable(backup);
} else {
int colorId = filesToUpdate.containsKey(child.getFileName()) ? R.color.color_distance : R.color.color_ok; int colorId = filesToUpdate.containsKey(child.getFileName()) ? R.color.color_distance : R.color.color_ok;
icon.setImageDrawable(getContentIcon(ctx, child.getType().getIconResource(), colorId)); icon.setImageDrawable(getContentIcon(ctx, child.getType().getIconResource(), colorId));
}
nameTextView.setText(getNameToDisplay(child)); nameTextView.setText(getNameToDisplay(child));
if (child.isNotSupported()) { if (child.isNotSupported()) {
@ -1120,7 +1105,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
MenuItem item; MenuItem item;
if (info.getType() == LocalIndexType.MAP_DATA) { if (info.getType() == LocalIndexType.MAP_DATA) {
item = optionsMenu.getMenu().add(restore ? R.string.local_index_mi_restore : R.string.local_index_mi_backup) item = optionsMenu.getMenu().add(restore ? R.string.local_index_mi_restore : R.string.local_index_mi_backup)
.setIcon(backup); .setIcon(iconsCache.getContentIcon(R.drawable.ic_type_archive));
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() { item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {

View file

@ -11,6 +11,7 @@ import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents; import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.download.DownloadResources; import net.osmand.plus.download.DownloadResources;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
@ -33,10 +34,10 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
invalidateListView();
setHasOptionsMenu(true); setHasOptionsMenu(true);
} }
@Override @Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.update_index_frament, container, false); return inflater.inflate(R.layout.update_index_frament, container, false);
@ -48,6 +49,12 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
updateErrorMessage(); updateErrorMessage();
} }
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
invalidateListView(activity);
}
@Override @Override
public ArrayAdapter<?> getAdapter() { public ArrayAdapter<?> getAdapter() {
return listAdapter; return listAdapter;
@ -55,7 +62,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override @Override
public void downloadHasFinished() { public void downloadHasFinished() {
invalidateListView(); invalidateListView(getMyActivity());
updateUpdateAllButton(); updateUpdateAllButton();
} }
@ -66,17 +73,17 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
@Override @Override
public void newDownloadIndexes() { public void newDownloadIndexes() {
invalidateListView(); invalidateListView(getMyActivity());
updateUpdateAllButton(); updateUpdateAllButton();
} }
public void invalidateListView() { public void invalidateListView(Activity a) {
DownloadResources indexes = getMyActivity().getDownloadThread().getIndexes(); DownloadResources indexes = getMyApplication().getDownloadThread().getIndexes();
List<IndexItem> indexItems = indexes.getItemsToUpdate(); List<IndexItem> indexItems = indexes.getItemsToUpdate();
final OsmandRegions osmandRegions = final OsmandRegions osmandRegions =
getMyApplication().getResourceManager().getOsmandRegions(); getMyApplication().getResourceManager().getOsmandRegions();
listAdapter = new UpdateIndexAdapter(getMyActivity(), R.layout.download_index_list_item, indexItems); listAdapter = new UpdateIndexAdapter(a, R.layout.download_index_list_item, indexItems);
listAdapter.sort(new Comparator<IndexItem>() { listAdapter.sort(new Comparator<IndexItem>() {
@Override @Override
public int compare(IndexItem indexItem, IndexItem indexItem2) { public int compare(IndexItem indexItem, IndexItem indexItem2) {
@ -198,6 +205,7 @@ public class UpdatesIndexFragment extends OsmAndListFragment implements Download
ItemViewHolder holder = (ItemViewHolder) v.getTag(); ItemViewHolder holder = (ItemViewHolder) v.getTag();
holder.setShowRemoteDate(true); holder.setShowRemoteDate(true);
holder.setShowTypeInDesc(true); holder.setShowTypeInDesc(true);
holder.setShowParentRegionName(true);
holder.bindIndexItem(items.get(position), null); holder.bindIndexItem(items.get(position), null);
return v; return v;
} }