Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8f54a2a358
11 changed files with 404 additions and 321 deletions
|
@ -12,14 +12,10 @@ import android.os.StatFs;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentActivity;
|
import android.support.v4.app.FragmentActivity;
|
||||||
import android.support.v4.app.ListFragment;
|
|
||||||
import android.support.v4.view.ViewPager;
|
import android.support.v4.view.ViewPager;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.BaseAdapter;
|
|
||||||
import android.widget.ExpandableListAdapter;
|
|
||||||
import android.widget.ListAdapter;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
@ -30,12 +26,11 @@ import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.LocalIndexInfo;
|
import net.osmand.plus.activities.LocalIndexInfo;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
|
||||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
|
||||||
import net.osmand.plus.activities.TabActivity;
|
import net.osmand.plus.activities.TabActivity;
|
||||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
import net.osmand.plus.download.items.ActiveDownloadsDialogFragment;
|
import net.osmand.plus.download.items.ActiveDownloadsDialogFragment;
|
||||||
import net.osmand.plus.download.items.DialogDismissListener;
|
import net.osmand.plus.download.items.DialogDismissListener;
|
||||||
|
import net.osmand.plus.download.items.ProgressAdapter;
|
||||||
import net.osmand.plus.download.items.SearchDialogFragment;
|
import net.osmand.plus.download.items.SearchDialogFragment;
|
||||||
import net.osmand.plus.download.items.WorldItemsFragment;
|
import net.osmand.plus.download.items.WorldItemsFragment;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
|
@ -73,7 +68,7 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
|
||||||
|
|
||||||
private List<DownloadActivityType> downloadTypes = new ArrayList<DownloadActivityType>();
|
private List<DownloadActivityType> downloadTypes = new ArrayList<DownloadActivityType>();
|
||||||
private BannerAndDownloadFreeVersion visibleBanner;
|
private BannerAndDownloadFreeVersion visibleBanner;
|
||||||
private ActiveDownloadsDialogFragment.DownloadEntryAdapter progressAdapter;
|
private ProgressAdapter progressAdapter;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -365,17 +360,8 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
|
||||||
Fragment f = ref.get();
|
Fragment f = ref.get();
|
||||||
if (f != null)
|
if (f != null)
|
||||||
if (f.isAdded()) {
|
if (f.isAdded()) {
|
||||||
if (f instanceof OsmandExpandableListFragment) {
|
if (f instanceof DataSetChangedListener) {
|
||||||
ExpandableListAdapter ad = ((OsmandExpandableListFragment) f).getExpandableListView()
|
((DataSetChangedListener) f).notifyDataSetChanged();
|
||||||
.getExpandableListAdapter();
|
|
||||||
if (ad instanceof OsmandBaseExpandableListAdapter) {
|
|
||||||
((OsmandBaseExpandableListAdapter) ad).notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
} else if (f instanceof ListFragment) {
|
|
||||||
ListAdapter la = ((ListFragment) f).getListAdapter();
|
|
||||||
if (la instanceof BaseAdapter) {
|
|
||||||
((BaseAdapter) la).notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,7 +491,7 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
|
||||||
updateProgress(true, null);
|
updateProgress(true, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerUpdateListener(ActiveDownloadsDialogFragment.DownloadEntryAdapter adapter) {
|
public void registerUpdateListener(ProgressAdapter adapter) {
|
||||||
progressAdapter = adapter;
|
progressAdapter = adapter;
|
||||||
updateProgress(true, null);
|
updateProgress(true, null);
|
||||||
}
|
}
|
||||||
|
@ -704,4 +690,8 @@ public class DownloadActivity extends BaseDownloadActivity implements DialogDism
|
||||||
descriptionText.setText(text);
|
descriptionText.setText(text);
|
||||||
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
descriptionText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface DataSetChangedListener {
|
||||||
|
void notifyDataSetChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,38 @@
|
||||||
package net.osmand.plus.download;
|
package net.osmand.plus.download;
|
||||||
|
|
||||||
import java.io.File;
|
import android.app.Activity;
|
||||||
import java.text.Collator;
|
import android.app.AlertDialog;
|
||||||
import java.text.MessageFormat;
|
import android.app.AlertDialog.Builder;
|
||||||
import java.util.ArrayList;
|
import android.content.Context;
|
||||||
import java.util.Collections;
|
import android.content.DialogInterface;
|
||||||
import java.util.Comparator;
|
import android.content.res.TypedArray;
|
||||||
import java.util.LinkedHashMap;
|
import android.graphics.PorterDuff;
|
||||||
import java.util.LinkedHashSet;
|
import android.graphics.Typeface;
|
||||||
import java.util.List;
|
import android.graphics.drawable.Drawable;
|
||||||
import java.util.Locale;
|
import android.os.AsyncTask;
|
||||||
import java.util.Map;
|
import android.os.Bundle;
|
||||||
import java.util.Set;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
import android.support.v7.app.ActionBar;
|
||||||
|
import android.support.v7.view.ActionMode;
|
||||||
|
import android.support.v7.widget.PopupMenu;
|
||||||
|
import android.view.ContextMenu;
|
||||||
|
import android.view.ContextMenu.ContextMenuInfo;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.SubMenu;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ExpandableListView;
|
||||||
|
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.IProgress;
|
import net.osmand.IProgress;
|
||||||
import net.osmand.IndexConstants;
|
import net.osmand.IndexConstants;
|
||||||
|
@ -33,45 +54,23 @@ import net.osmand.plus.resources.IncrementalChangesManager;
|
||||||
import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdate;
|
import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdate;
|
||||||
import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdateList;
|
import net.osmand.plus.resources.IncrementalChangesManager.IncrementalUpdateList;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
import android.app.Activity;
|
|
||||||
import android.app.AlertDialog;
|
import java.io.File;
|
||||||
import android.app.AlertDialog.Builder;
|
import java.text.Collator;
|
||||||
import android.content.Context;
|
import java.text.MessageFormat;
|
||||||
import android.content.DialogInterface;
|
import java.util.ArrayList;
|
||||||
import android.content.res.TypedArray;
|
import java.util.Collections;
|
||||||
import android.graphics.PorterDuff;
|
import java.util.Comparator;
|
||||||
import android.graphics.Typeface;
|
import java.util.LinkedHashMap;
|
||||||
import android.graphics.drawable.Drawable;
|
import java.util.LinkedHashSet;
|
||||||
import android.os.AsyncTask;
|
import java.util.List;
|
||||||
import android.os.Bundle;
|
import java.util.Locale;
|
||||||
import android.os.StatFs;
|
import java.util.Map;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import java.util.Set;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.view.ActionMode;
|
|
||||||
import android.support.v7.widget.PopupMenu;
|
|
||||||
import android.text.method.LinkMovementMethod;
|
|
||||||
import android.view.ContextMenu;
|
|
||||||
import android.view.ContextMenu.ContextMenuInfo;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.Menu;
|
|
||||||
import android.view.MenuInflater;
|
|
||||||
import android.view.MenuItem;
|
|
||||||
import android.view.SubMenu;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.EditText;
|
|
||||||
import android.widget.ExpandableListView;
|
|
||||||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
|
|
||||||
public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
public class LocalIndexesFragment extends OsmandExpandableListFragment
|
||||||
|
implements DownloadActivity.DataSetChangedListener {
|
||||||
|
|
||||||
private LoadLocalIndexTask asyncLoader;
|
private LoadLocalIndexTask asyncLoader;
|
||||||
private LocalIndexesAdapter listAdapter;
|
private LocalIndexesAdapter listAdapter;
|
||||||
|
@ -79,11 +78,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
private boolean selectionMode = false;
|
private boolean selectionMode = false;
|
||||||
private Set<LocalIndexInfo> selectedItems = new LinkedHashSet<LocalIndexInfo>();
|
private Set<LocalIndexInfo> selectedItems = new LinkedHashSet<LocalIndexInfo>();
|
||||||
|
|
||||||
protected static int DELETE_OPERATION = 1;
|
protected static int DELETE_OPERATION = 1;
|
||||||
protected static int BACKUP_OPERATION = 2;
|
protected static int BACKUP_OPERATION = 2;
|
||||||
protected static int RESTORE_OPERATION = 3;
|
protected static int RESTORE_OPERATION = 3;
|
||||||
|
|
||||||
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
MessageFormat formatMb = new MessageFormat("{0, number,##.#} MB", Locale.US);
|
||||||
private ContextMenuAdapter optionsMenuAdapter;
|
private ContextMenuAdapter optionsMenuAdapter;
|
||||||
private ActionMode actionMode;
|
private ActionMode actionMode;
|
||||||
|
@ -98,17 +97,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||||
|
|
||||||
ExpandableListView listView = (ExpandableListView)view.findViewById(android.R.id.list);
|
ExpandableListView listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||||
listAdapter = new LocalIndexesAdapter(getActivity());
|
listAdapter = new LocalIndexesAdapter(getActivity());
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
setListView(listView);
|
setListView(listView);
|
||||||
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(view);
|
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(view);
|
||||||
colorDrawables();
|
colorDrawables();
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked","deprecation"})
|
@SuppressWarnings({"unchecked", "deprecation"})
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -124,7 +123,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
setHasOptionsMenu(true);
|
setHasOptionsMenu(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = getActivity().getResources().getDrawable(R.drawable.ic_type_archive);
|
||||||
backup.mutate();
|
backup.mutate();
|
||||||
|
@ -183,7 +182,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) {
|
private void basicFileOperation(final LocalIndexInfo info, ContextMenuAdapter adapter) {
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -191,16 +190,16 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
return performBasicOperation(resId, info);
|
return performBasicOperation(resId, info);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA ||
|
if (info.getType() == LocalIndexType.MAP_DATA || info.getType() == LocalIndexType.SRTM_DATA ||
|
||||||
info.getType() == LocalIndexType.WIKI_DATA){
|
info.getType() == LocalIndexType.WIKI_DATA) {
|
||||||
if(!info.isBackupedData()){
|
if (!info.isBackupedData()) {
|
||||||
adapter.item(R.string.local_index_mi_backup).listen(listener).position( 1).reg();
|
adapter.item(R.string.local_index_mi_backup).listen(listener).position(1).reg();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(info.isBackupedData()){
|
if (info.isBackupedData()) {
|
||||||
adapter.item(R.string.local_index_mi_restore).listen(listener).position(2).reg();
|
adapter.item(R.string.local_index_mi_restore).listen(listener).position(2).reg();
|
||||||
}
|
}
|
||||||
if(info.getType() != LocalIndexType.TTS_VOICE_DATA && info.getType() != LocalIndexType.VOICE_DATA){
|
if (info.getType() != LocalIndexType.TTS_VOICE_DATA && info.getType() != LocalIndexType.VOICE_DATA) {
|
||||||
adapter.item(R.string.shared_string_rename).listen(listener).position(3).reg();
|
adapter.item(R.string.shared_string_rename).listen(listener).position(3).reg();
|
||||||
}
|
}
|
||||||
adapter.item(R.string.shared_string_delete).listen(listener).position(4).reg();
|
adapter.item(R.string.shared_string_delete).listen(listener).position(4).reg();
|
||||||
|
@ -209,7 +208,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
private boolean performBasicOperation(int resId, final LocalIndexInfo info) {
|
private boolean performBasicOperation(int resId, final LocalIndexInfo info) {
|
||||||
if (resId == R.string.shared_string_rename) {
|
if (resId == R.string.shared_string_rename) {
|
||||||
renameFile(getActivity(), new File(info.getPathToData()), new Runnable() {
|
renameFile(getActivity(), new File(info.getPathToData()), new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
reloadIndexes();
|
reloadIndexes();
|
||||||
|
@ -239,7 +238,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
public static void renameFile(final Activity a, final File f, final Runnable callback) {
|
public static void renameFile(final Activity a, final File f, final Runnable callback) {
|
||||||
Builder b = new AlertDialog.Builder(a);
|
Builder b = new AlertDialog.Builder(a);
|
||||||
if(f.exists()){
|
if (f.exists()) {
|
||||||
int xt = f.getName().lastIndexOf('.');
|
int xt = f.getName().lastIndexOf('.');
|
||||||
final String ext = xt == -1 ? "" : f.getName().substring(xt);
|
final String ext = xt == -1 ? "" : f.getName().substring(xt);
|
||||||
final String originalName = xt == -1 ? f.getName() : f.getName().substring(0, xt);
|
final String originalName = xt == -1 ? f.getName() : f.getName().substring(0, xt);
|
||||||
|
@ -247,7 +246,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
editText.setText(originalName);
|
editText.setText(originalName);
|
||||||
b.setView(editText);
|
b.setView(editText);
|
||||||
b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
b.setPositiveButton(R.string.shared_string_save, new DialogInterface.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
String newName = editText.getText().toString() + ext;
|
String newName = editText.getText().toString() + ext;
|
||||||
|
@ -255,18 +254,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
if (dest.exists()) {
|
if (dest.exists()) {
|
||||||
AccessibleToast.makeText(a, R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(a, R.string.file_with_name_already_exists, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
if(!dest.getParentFile().exists()) {
|
if (!dest.getParentFile().exists()) {
|
||||||
dest.getParentFile().mkdirs();
|
dest.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
if(f.renameTo(dest)){
|
if (f.renameTo(dest)) {
|
||||||
if(callback != null) {
|
if (callback != null) {
|
||||||
callback.run();
|
callback.run();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
AccessibleToast.makeText(a, R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(a, R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
b.setNegativeButton(R.string.shared_string_cancel, null);
|
b.setNegativeButton(R.string.shared_string_cancel, null);
|
||||||
|
@ -274,6 +273,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
|
||||||
|
}
|
||||||
|
|
||||||
public class LoadLocalIndexTask extends AsyncTask<Activity, LocalIndexInfo, List<LocalIndexInfo>> {
|
public class LoadLocalIndexTask extends AsyncTask<Activity, LocalIndexInfo, List<LocalIndexInfo>> {
|
||||||
|
|
||||||
private List<LocalIndexInfo> result;
|
private List<LocalIndexInfo> result;
|
||||||
|
@ -305,7 +310,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
public void setResult(List<LocalIndexInfo> result) {
|
public void setResult(List<LocalIndexInfo> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
if(result == null){
|
if (result == null) {
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
} else {
|
} else {
|
||||||
for (LocalIndexInfo v : result) {
|
for (LocalIndexInfo v : result) {
|
||||||
|
@ -321,7 +326,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
protected void onPostExecute(List<LocalIndexInfo> result) {
|
protected void onPostExecute(List<LocalIndexInfo> result) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
listAdapter.sortData();
|
listAdapter.sortData();
|
||||||
if (getDownloadActivity() != null){
|
if (getDownloadActivity() != null) {
|
||||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||||
getDownloadActivity().setLocalIndexInfos(result);
|
getDownloadActivity().setLocalIndexInfos(result);
|
||||||
}
|
}
|
||||||
|
@ -333,105 +338,105 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.SRTM_DATA){
|
if (i.getType() == LocalIndexType.SRTM_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.SRTM_INDEX_DIR);
|
||||||
} else 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.WIKI_DATA){
|
} else if (i.getType() == LocalIndexType.WIKI_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.WIKI_INDEX_DIR);
|
||||||
} else if(i.getType() == LocalIndexType.MAP_DATA){
|
} else if (i.getType() == LocalIndexType.MAP_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH);
|
parent = getMyApplication().getAppPath(IndexConstants.MAPS_PATH);
|
||||||
} else if(i.getType() == LocalIndexType.TILES_DATA){
|
} else if (i.getType() == LocalIndexType.TILES_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.TILES_INDEX_DIR);
|
||||||
} else if(i.getType() == LocalIndexType.VOICE_DATA){
|
} else if (i.getType() == LocalIndexType.VOICE_DATA) {
|
||||||
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
parent = getMyApplication().getAppPath(IndexConstants.VOICE_INDEX_DIR);
|
||||||
} else if(i.getType() == LocalIndexType.TTS_VOICE_DATA){
|
} else if (i.getType() == LocalIndexType.TTS_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());
|
||||||
}
|
}
|
||||||
return new File(i.getPathToData());
|
return new File(i.getPathToData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private File getFileToBackup(LocalIndexInfo i) {
|
private File getFileToBackup(LocalIndexInfo i) {
|
||||||
if(!i.isBackupedData()){
|
if (!i.isBackupedData()) {
|
||||||
return new File(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR), i.getFileName());
|
return new File(getMyApplication().getAppPath(IndexConstants.BACKUP_INDEX_DIR), i.getFileName());
|
||||||
}
|
}
|
||||||
return new File(i.getPathToData());
|
return new File(i.getPathToData());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean move(File from, File to){
|
private boolean move(File from, File to) {
|
||||||
if(!to.getParentFile().exists()){
|
if (!to.getParentFile().exists()) {
|
||||||
to.getParentFile().mkdirs();
|
to.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
return from.renameTo(to);
|
return from.renameTo(to);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LocalIndexOperationTask extends AsyncTask<LocalIndexInfo, LocalIndexInfo, String> {
|
public class LocalIndexOperationTask extends AsyncTask<LocalIndexInfo, LocalIndexInfo, String> {
|
||||||
|
|
||||||
private final int operation;
|
private final int operation;
|
||||||
|
|
||||||
public LocalIndexOperationTask(int operation){
|
public LocalIndexOperationTask(int operation) {
|
||||||
this.operation = operation;
|
this.operation = operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(LocalIndexInfo... params) {
|
protected String doInBackground(LocalIndexInfo... params) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
for(LocalIndexInfo info : params) {
|
for (LocalIndexInfo info : params) {
|
||||||
if(!isCancelled()){
|
if (!isCancelled()) {
|
||||||
boolean successfull = false;
|
boolean successfull = false;
|
||||||
if(operation == DELETE_OPERATION){
|
if (operation == DELETE_OPERATION) {
|
||||||
File f = new File(info.getPathToData());
|
File f = new File(info.getPathToData());
|
||||||
successfull = Algorithms.removeAllFiles(f);
|
successfull = Algorithms.removeAllFiles(f);
|
||||||
} else if(operation == RESTORE_OPERATION){
|
} else if (operation == RESTORE_OPERATION) {
|
||||||
successfull = move(new File(info.getPathToData()), getFileToRestore(info));
|
successfull = move(new File(info.getPathToData()), getFileToRestore(info));
|
||||||
if(successfull){
|
if (successfull) {
|
||||||
info.setBackupedData(false);
|
info.setBackupedData(false);
|
||||||
}
|
}
|
||||||
} else if(operation == BACKUP_OPERATION){
|
} else if (operation == BACKUP_OPERATION) {
|
||||||
successfull = move(new File(info.getPathToData()), getFileToBackup(info));
|
successfull = move(new File(info.getPathToData()), getFileToBackup(info));
|
||||||
if(successfull){
|
if (successfull) {
|
||||||
info.setBackupedData(true);
|
info.setBackupedData(true);
|
||||||
getMyApplication().getResourceManager().closeFile(info.getFileName());
|
getMyApplication().getResourceManager().closeFile(info.getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
total ++;
|
total++;
|
||||||
if(successfull){
|
if (successfull) {
|
||||||
count++;
|
count++;
|
||||||
publishProgress(info);
|
publishProgress(info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(operation == DELETE_OPERATION){
|
if (operation == DELETE_OPERATION) {
|
||||||
return getString(R.string.local_index_items_deleted, count, total);
|
return getString(R.string.local_index_items_deleted, count, total);
|
||||||
} else if(operation == BACKUP_OPERATION){
|
} else if (operation == BACKUP_OPERATION) {
|
||||||
return getString(R.string.local_index_items_backuped, count, total);
|
return getString(R.string.local_index_items_backuped, count, total);
|
||||||
} else if(operation == RESTORE_OPERATION){
|
} else if (operation == RESTORE_OPERATION) {
|
||||||
return getString(R.string.local_index_items_restored, count, total);
|
return getString(R.string.local_index_items_restored, count, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onProgressUpdate(LocalIndexInfo... values) {
|
protected void onProgressUpdate(LocalIndexInfo... values) {
|
||||||
if(operation == DELETE_OPERATION){
|
if (operation == DELETE_OPERATION) {
|
||||||
listAdapter.delete(values);
|
listAdapter.delete(values);
|
||||||
} else if(operation == BACKUP_OPERATION){
|
} else if (operation == BACKUP_OPERATION) {
|
||||||
listAdapter.move(values, false);
|
listAdapter.move(values, false);
|
||||||
} else if(operation == RESTORE_OPERATION){
|
} else if (operation == RESTORE_OPERATION) {
|
||||||
listAdapter.move(values, true);
|
listAdapter.move(values, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
getDownloadActivity().setProgressBarIndeterminateVisibility(true);
|
getDownloadActivity().setProgressBarIndeterminateVisibility(true);
|
||||||
|
@ -441,20 +446,18 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
protected void onPostExecute(String result) {
|
protected void onPostExecute(String result) {
|
||||||
getDownloadActivity().setProgressBarIndeterminateVisibility(false);
|
getDownloadActivity().setProgressBarIndeterminateVisibility(false);
|
||||||
AccessibleToast.makeText(getDownloadActivity(), result, Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getDownloadActivity(), result, Toast.LENGTH_LONG).show();
|
||||||
if (operation == RESTORE_OPERATION || operation == BACKUP_OPERATION){
|
if (operation == RESTORE_OPERATION || operation == BACKUP_OPERATION) {
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
reloadIndexes();
|
reloadIndexes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||||
LocalIndexInfo child = listAdapter.getChild(groupPosition, childPosition);
|
LocalIndexInfo child = listAdapter.getChild(groupPosition, childPosition);
|
||||||
if (!selectionMode){
|
if (!selectionMode) {
|
||||||
openPopUpMenu(v, child);
|
openPopUpMenu(v, child);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -462,18 +465,16 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<LocalIndexInfo> getSelectedItems() {
|
public Set<LocalIndexInfo> getSelectedItems() {
|
||||||
return selectedItems;
|
return selectedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
super.onPause();
|
super.onPause();
|
||||||
if(operationTask != null){
|
if (operationTask != null) {
|
||||||
operationTask.cancel(true);
|
operationTask.cancel(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -483,7 +484,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
asyncLoader.cancel(true);
|
asyncLoader.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@Override
|
@Override
|
||||||
|
@ -495,7 +496,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
//fixes issue when local files not shown after switching tabs
|
//fixes issue when local files not shown after switching tabs
|
||||||
//Next line throws NPE in some circumstances when called from dashboard and listAdpater=null is not checked for. (Checking !this.isAdded above is not sufficient!)
|
//Next line throws NPE in some circumstances when called from dashboard and listAdpater=null is not checked for. (Checking !this.isAdded above is not sufficient!)
|
||||||
if (listAdapter != null && listAdapter.getGroupCount() == 0 && getDownloadActivity().getLocalIndexInfos().size() > 0) {
|
if (listAdapter != null && listAdapter.getGroupCount() == 0 && getDownloadActivity().getLocalIndexInfos().size() > 0) {
|
||||||
for(LocalIndexInfo info : getDownloadActivity().getLocalIndexInfos()) {
|
for (LocalIndexInfo info : getDownloadActivity().getLocalIndexInfos()) {
|
||||||
listAdapter.addLocalIndexInfo(info);
|
listAdapter.addLocalIndexInfo(info);
|
||||||
}
|
}
|
||||||
listAdapter.sortData();
|
listAdapter.sortData();
|
||||||
|
@ -534,28 +535,28 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
split = menu.addSubMenu(0, 1, j + 1, R.string.shared_string_more_actions);
|
split = menu.addSubMenu(0, 1, j + 1, R.string.shared_string_more_actions);
|
||||||
split.setIcon(R.drawable.ic_overflow_menu_white);
|
split.setIcon(R.drawable.ic_overflow_menu_white);
|
||||||
split.getItem();
|
split.getItem();
|
||||||
MenuItemCompat.setShowAsAction(split.getItem(),MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.setShowAsAction(split.getItem(), MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
}
|
}
|
||||||
item = split.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
|
item = split.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
|
||||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS );
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
} else {
|
} else {
|
||||||
item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
|
item = menu.add(0, optionsMenuAdapter.getElementId(j), j + 1, optionsMenuAdapter.getItemName(j));
|
||||||
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS );
|
MenuItemCompat.setShowAsAction(item, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
}
|
}
|
||||||
OsmandApplication app = getMyApplication();
|
OsmandApplication app = getMyApplication();
|
||||||
if (optionsMenuAdapter.getImage(app, j, isLightActionBar()) != null) {
|
if (optionsMenuAdapter.getImage(app, j, isLightActionBar()) != null) {
|
||||||
item.setIcon(optionsMenuAdapter.getImage(app, j, isLightActionBar()));
|
item.setIcon(optionsMenuAdapter.getImage(app, j, isLightActionBar()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(operationTask == null || operationTask.getStatus() == AsyncTask.Status.FINISHED){
|
if (operationTask == null || operationTask.getStatus() == AsyncTask.Status.FINISHED) {
|
||||||
menu.setGroupVisible(0, true);
|
menu.setGroupVisible(0, true);
|
||||||
} else {
|
} else {
|
||||||
menu.setGroupVisible(0, false);
|
menu.setGroupVisible(0, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(MenuItem item) {
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
int itemId = item.getItemId();
|
int itemId = item.getItemId();
|
||||||
|
@ -567,40 +568,40 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doAction(int actionResId){
|
public void doAction(int actionResId) {
|
||||||
if(actionResId == R.string.local_index_mi_backup){
|
if (actionResId == R.string.local_index_mi_backup) {
|
||||||
operationTask = new LocalIndexOperationTask(BACKUP_OPERATION);
|
operationTask = new LocalIndexOperationTask(BACKUP_OPERATION);
|
||||||
} else if(actionResId == R.string.shared_string_delete){
|
} else if (actionResId == R.string.shared_string_delete) {
|
||||||
operationTask = new LocalIndexOperationTask(DELETE_OPERATION);
|
operationTask = new LocalIndexOperationTask(DELETE_OPERATION);
|
||||||
} else if(actionResId == R.string.local_index_mi_restore){
|
} else if (actionResId == R.string.local_index_mi_restore) {
|
||||||
operationTask = new LocalIndexOperationTask(RESTORE_OPERATION);
|
operationTask = new LocalIndexOperationTask(RESTORE_OPERATION);
|
||||||
} else {
|
} else {
|
||||||
operationTask = null;
|
operationTask = null;
|
||||||
}
|
}
|
||||||
if(operationTask != null){
|
if (operationTask != null) {
|
||||||
operationTask.execute(selectedItems.toArray(new LocalIndexInfo[selectedItems.size()]));
|
operationTask.execute(selectedItems.toArray(new LocalIndexInfo[selectedItems.size()]));
|
||||||
}
|
}
|
||||||
if(actionMode != null) {
|
if (actionMode != null) {
|
||||||
actionMode.finish();
|
actionMode.finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void expandAllGroups() {
|
private void expandAllGroups() {
|
||||||
for (int i = 0; i < listAdapter.getGroupCount(); i++) {
|
for (int i = 0; i < listAdapter.getGroupCount(); i++) {
|
||||||
getExpandableListView().expandGroup(i);
|
getExpandableListView().expandGroup(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openSelectionMode(final int actionResId, final int actionIconId,
|
private void openSelectionMode(final int actionResId, final int actionIconId,
|
||||||
final DialogInterface.OnClickListener listener){
|
final DialogInterface.OnClickListener listener) {
|
||||||
String value = getString(actionResId);
|
String value = getString(actionResId);
|
||||||
if (value.endsWith("...")) {
|
if (value.endsWith("...")) {
|
||||||
value = value.substring(0, value.length() - 3);
|
value = value.substring(0, value.length() - 3);
|
||||||
}
|
}
|
||||||
final String actionButton = value;
|
final String actionButton = value;
|
||||||
if(listAdapter.getGroupCount() == 0){
|
if (listAdapter.getGroupCount() == 0) {
|
||||||
listAdapter.cancelFilter();
|
listAdapter.cancelFilter();
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
|
@ -608,7 +609,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
|
|
||||||
selectionMode = true;
|
selectionMode = true;
|
||||||
selectedItems.clear();
|
selectedItems.clear();
|
||||||
actionMode = getDownloadActivity().startSupportActionMode(new ActionMode.Callback() {
|
actionMode = getDownloadActivity().startSupportActionMode(new ActionMode.Callback() {
|
||||||
|
@ -693,9 +694,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
listAdapter.filterCategories(true);
|
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, Boolean backup,
|
||||||
LocalIndexType filter) {
|
LocalIndexType filter) {
|
||||||
if (backup != null) {
|
if (backup != null) {
|
||||||
listAdapter.filterCategories(backup);
|
listAdapter.filterCategories(backup);
|
||||||
}
|
}
|
||||||
|
@ -704,16 +705,28 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
openSelectionMode(stringRes, darkIcon, listener);
|
openSelectionMode(stringRes, darkIcon, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reloadIndexes() {
|
public void reloadIndexes() {
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
asyncLoader = new LoadLocalIndexTask();
|
asyncLoader = new LoadLocalIndexTask();
|
||||||
AsyncTask<Void, String, List<String>> task = new AsyncTask<Void, String, List<String>>(){
|
AsyncTask<Void, String, List<String>> task = new AsyncTask<Void, String, List<String>>() {
|
||||||
|
@Override
|
||||||
|
protected void onPreExecute() {
|
||||||
|
super.onPreExecute();
|
||||||
|
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> doInBackground(Void... params) {
|
||||||
|
return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS,
|
||||||
|
new ArrayList<String>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(List<String> warnings) {
|
protected void onPostExecute(List<String> warnings) {
|
||||||
if ( getDownloadActivity() == null) {
|
if (getDownloadActivity() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(false);
|
||||||
|
@ -730,30 +743,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
AccessibleToast.makeText(getDownloadActivity(), b.toString(), Toast.LENGTH_LONG).show();
|
AccessibleToast.makeText(getDownloadActivity(), b.toString(), Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
if(asyncLoader.getStatus() == Status.PENDING) {
|
if (asyncLoader.getStatus() == Status.PENDING) {
|
||||||
asyncLoader.execute(getDownloadActivity());
|
asyncLoader.execute(getDownloadActivity());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPreExecute() {
|
|
||||||
super.onPreExecute();
|
|
||||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
protected List<String> doInBackground(Void... params) {
|
|
||||||
return getMyApplication().getResourceManager().reloadIndexes(IProgress.EMPTY_PROGRESS,
|
|
||||||
new ArrayList<String>()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
task.execute();
|
task.execute();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class LocalIndexesAdapter extends OsmandBaseExpandableListAdapter {
|
protected class LocalIndexesAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
Map<LocalIndexInfo, List<LocalIndexInfo>> data = new LinkedHashMap<LocalIndexInfo, List<LocalIndexInfo>>();
|
Map<LocalIndexInfo, List<LocalIndexInfo>> data = new LinkedHashMap<LocalIndexInfo, List<LocalIndexInfo>>();
|
||||||
List<LocalIndexInfo> category = new ArrayList<LocalIndexInfo>();
|
List<LocalIndexInfo> category = new ArrayList<LocalIndexInfo>();
|
||||||
List<LocalIndexInfo> filterCategory = null;
|
List<LocalIndexInfo> filterCategory = null;
|
||||||
|
@ -770,17 +770,17 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
ta.recycle();
|
ta.recycle();
|
||||||
corruptedColor = ctx.getResources().getColor(R.color.color_invalid);
|
corruptedColor = ctx.getResources().getColor(R.color.color_invalid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
data.clear();
|
data.clear();
|
||||||
category.clear();
|
category.clear();
|
||||||
filterCategory = null;
|
filterCategory = null;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sortData() {
|
public void sortData() {
|
||||||
final Collator cl = Collator.getInstance();
|
final Collator cl = Collator.getInstance();
|
||||||
for(List<LocalIndexInfo> i : data.values()) {
|
for (List<LocalIndexInfo> i : data.values()) {
|
||||||
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
Collections.sort(i, new Comparator<LocalIndexInfo>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
public int compare(LocalIndexInfo lhs, LocalIndexInfo rhs) {
|
||||||
|
@ -790,10 +790,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalIndexInfo findCategory(LocalIndexInfo val, boolean backuped){
|
public LocalIndexInfo findCategory(LocalIndexInfo val, boolean backuped) {
|
||||||
for(LocalIndexInfo i : category){
|
for (LocalIndexInfo i : category) {
|
||||||
if(i.isBackupedData() == backuped && val.getType() == i.getType() &&
|
if (i.isBackupedData() == backuped && val.getType() == i.getType() &&
|
||||||
Algorithms.objectEquals(i.getSubfolder(), val.getSubfolder())){
|
Algorithms.objectEquals(i.getSubfolder(), val.getSubfolder())) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -802,13 +802,13 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
data.put(newCat, new ArrayList<LocalIndexInfo>());
|
data.put(newCat, new ArrayList<LocalIndexInfo>());
|
||||||
return newCat;
|
return newCat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(LocalIndexInfo[] values) {
|
public void delete(LocalIndexInfo[] values) {
|
||||||
for(LocalIndexInfo i : values){
|
for (LocalIndexInfo i : values) {
|
||||||
LocalIndexInfo c = findCategory(i, i.isBackupedData());
|
LocalIndexInfo c = findCategory(i, i.isBackupedData());
|
||||||
if(c != null){
|
if (c != null) {
|
||||||
data.get(c).remove(i);
|
data.get(c).remove(i);
|
||||||
if (data.get(c).size() == 0){
|
if (data.get(c).size() == 0) {
|
||||||
data.remove(c);
|
data.remove(c);
|
||||||
category.remove(c);
|
category.remove(c);
|
||||||
}
|
}
|
||||||
|
@ -816,15 +816,15 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void move(LocalIndexInfo[] values, boolean oldBackupState) {
|
public void move(LocalIndexInfo[] values, boolean oldBackupState) {
|
||||||
for(LocalIndexInfo i : values){
|
for (LocalIndexInfo i : values) {
|
||||||
LocalIndexInfo c = findCategory(i, oldBackupState);
|
LocalIndexInfo c = findCategory(i, oldBackupState);
|
||||||
if(c != null){
|
if (c != null) {
|
||||||
data.get(c).remove(i);
|
data.get(c).remove(i);
|
||||||
}
|
}
|
||||||
c = findCategory(i, !oldBackupState);
|
c = findCategory(i, !oldBackupState);
|
||||||
if(c != null){
|
if (c != null) {
|
||||||
data.get(c).add(i);
|
data.get(c).add(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -832,11 +832,11 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelFilter(){
|
public void cancelFilter() {
|
||||||
filterCategory = null;
|
filterCategory = null;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filterCategories(LocalIndexType... types) {
|
public void filterCategories(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;
|
||||||
|
@ -850,7 +850,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
filterCategory = filter;
|
filterCategory = filter;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void filterCategories(boolean backup) {
|
public void filterCategories(boolean backup) {
|
||||||
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;
|
||||||
|
@ -900,7 +900,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
public View getChildView(final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
final LocalIndexInfo child = getChild(groupPosition, childPosition);
|
final LocalIndexInfo child = getChild(groupPosition, childPosition);
|
||||||
if (v == null ) {
|
if (v == null) {
|
||||||
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater inflater = (LayoutInflater) getDownloadActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
v = inflater.inflate(net.osmand.plus.R.layout.local_index_list_item, parent, false);
|
||||||
}
|
}
|
||||||
|
@ -938,7 +938,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
if (child.getSize() >= 0) {
|
if (child.getSize() >= 0) {
|
||||||
String size;
|
String size;
|
||||||
if (child.getSize() > 100) {
|
if (child.getSize() > 100) {
|
||||||
size = formatMb.format(new Object[] { (float) child.getSize() / (1 << 10) });
|
size = formatMb.format(new Object[]{(float) child.getSize() / (1 << 10)});
|
||||||
} else {
|
} else {
|
||||||
size = child.getSize() + " kB";
|
size = child.getSize() + " kB";
|
||||||
}
|
}
|
||||||
|
@ -957,7 +957,6 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
final CheckBox checkbox = (CheckBox) v.findViewById(R.id.check_local_index);
|
||||||
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
checkbox.setVisibility(selectionMode ? View.VISIBLE : View.GONE);
|
||||||
if (selectionMode) {
|
if (selectionMode) {
|
||||||
|
@ -965,10 +964,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
options.setVisibility(View.GONE);
|
options.setVisibility(View.GONE);
|
||||||
checkbox.setChecked(selectedItems.contains(child));
|
checkbox.setChecked(selectedItems.contains(child));
|
||||||
checkbox.setOnClickListener(new View.OnClickListener() {
|
checkbox.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(checkbox.isChecked()){
|
if (checkbox.isChecked()) {
|
||||||
selectedItems.add(child);
|
selectedItems.add(child);
|
||||||
} else {
|
} else {
|
||||||
selectedItems.remove(child);
|
selectedItems.remove(child);
|
||||||
|
@ -990,7 +989,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getNameToDisplay(LocalIndexInfo child) {
|
private String getNameToDisplay(LocalIndexInfo child) {
|
||||||
String mapDescr = getMapDescription(child.getFileName());
|
String mapDescr = getMapDescription(child.getFileName());
|
||||||
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
String mapName = FileNameTranslationHelper.getFileName(ctx,
|
||||||
|
@ -1012,7 +1011,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
v = inflater.inflate(R.layout.local_index_list_category, parent, false);
|
v = inflater.inflate(R.layout.local_index_list_category, parent, false);
|
||||||
}
|
}
|
||||||
StringBuilder name = new StringBuilder(group.getType().getHumanString(getDownloadActivity()));
|
StringBuilder name = new StringBuilder(group.getType().getHumanString(getDownloadActivity()));
|
||||||
if(group.getSubfolder() != null) {
|
if (group.getSubfolder() != null) {
|
||||||
name.append(" ").append(group.getSubfolder());
|
name.append(" ").append(group.getSubfolder());
|
||||||
}
|
}
|
||||||
if (group.isBackupedData()) {
|
if (group.isBackupedData()) {
|
||||||
|
@ -1034,9 +1033,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
String sz = "";
|
String sz = "";
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
if (size > 1 << 20) {
|
if (size > 1 << 20) {
|
||||||
sz = DownloadActivity.formatGb.format(new Object[] { (float) size / (1 << 20) });
|
sz = DownloadActivity.formatGb.format(new Object[]{(float) size / (1 << 20)});
|
||||||
} else {
|
} else {
|
||||||
sz = formatMb.format(new Object[] { (float) size / (1 << 10) });
|
sz = formatMb.format(new Object[]{(float) size / (1 << 10)});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1060,12 +1059,12 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocalIndexInfo getGroup(int groupPosition) {
|
public LocalIndexInfo getGroup(int groupPosition) {
|
||||||
return filterCategory == null ? category.get(groupPosition) : filterCategory.get(groupPosition);
|
return filterCategory == null ? category.get(groupPosition) : filterCategory.get(groupPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getGroupCount() {
|
public int getGroupCount() {
|
||||||
return filterCategory == null ? category.size() : filterCategory.size();
|
return filterCategory == null ? category.size() : filterCategory.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1084,15 +1083,14 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String getMapDescription(String fileName) {
|
||||||
private String getMapDescription(String fileName){
|
|
||||||
if (fileName.endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) {
|
if (fileName.endsWith(IndexConstants.BINARY_ROAD_MAP_INDEX_EXT)) {
|
||||||
return ctx.getString(R.string.download_roads_only_item);
|
return ctx.getString(R.string.download_roads_only_item);
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openPopUpMenu(View v, final LocalIndexInfo info) {
|
private void openPopUpMenu(View v, final LocalIndexInfo info) {
|
||||||
IconsCache iconsCache = getMyApplication().getIconsCache();
|
IconsCache iconsCache = getMyApplication().getIconsCache();
|
||||||
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
final PopupMenu optionsMenu = new PopupMenu(getActivity(), v);
|
||||||
|
@ -1100,7 +1098,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
final boolean restore = info.isBackupedData();
|
final boolean restore = info.isBackupedData();
|
||||||
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(backup);
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1130,7 +1128,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
if (getMyApplication().getSettings().BETA_TESTING_LIVE_UPDATES.get()) {
|
||||||
item = optionsMenu.getMenu().add("Live updates")
|
item = optionsMenu.getMenu().add("Live updates")
|
||||||
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
.setIcon(iconsCache.getContentIcon(R.drawable.ic_action_refresh_dark));
|
||||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@ -1141,10 +1139,10 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
optionsMenu.show();
|
optionsMenu.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runLiveUpdate(final LocalIndexInfo info) {
|
private void runLiveUpdate(final LocalIndexInfo info) {
|
||||||
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName()));
|
final String fnExt = Algorithms.getFileNameWithoutExtension(new File(info.getFileName()));
|
||||||
new AsyncTask<Object, Object, IncrementalUpdateList>() {
|
new AsyncTask<Object, Object, IncrementalUpdateList>() {
|
||||||
|
@ -1152,7 +1150,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
|
getDownloadActivity().setSupportProgressBarIndeterminateVisibility(true);
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected IncrementalUpdateList doInBackground(Object... params) {
|
protected IncrementalUpdateList doInBackground(Object... params) {
|
||||||
|
@ -1166,7 +1164,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
Toast.makeText(getDownloadActivity(), result.errorMessage, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getDownloadActivity(), result.errorMessage, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
List<IncrementalUpdate> ll = result.getItemsForUpdate();
|
List<IncrementalUpdate> ll = result.getItemsForUpdate();
|
||||||
if(ll.isEmpty()) {
|
if (ll.isEmpty()) {
|
||||||
Toast.makeText(getDownloadActivity(), R.string.no_updates_available, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getDownloadActivity(), R.string.no_updates_available, Toast.LENGTH_SHORT).show();
|
||||||
} else {
|
} else {
|
||||||
for (IncrementalUpdate iu : ll) {
|
for (IncrementalUpdate iu : ll) {
|
||||||
|
@ -1178,9 +1176,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
}.execute(new Object[] { fnExt });
|
}.execute(new Object[]{fnExt});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import net.osmand.map.OsmandRegions;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.OsmAndListFragment;
|
import net.osmand.plus.activities.OsmAndListFragment;
|
||||||
|
import net.osmand.plus.download.items.TwoLineWithImagesViewHolder;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
|
@ -36,7 +37,8 @@ import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class UpdatesIndexFragment extends OsmAndListFragment {
|
public class UpdatesIndexFragment extends OsmAndListFragment
|
||||||
|
implements DownloadActivity.DataSetChangedListener {
|
||||||
private static final Log LOG = PlatformUtil.getLog(UpdateIndexAdapter.class);
|
private static final Log LOG = PlatformUtil.getLog(UpdateIndexAdapter.class);
|
||||||
private UpdateIndexAdapter listAdapter;
|
private UpdateIndexAdapter listAdapter;
|
||||||
List<IndexItem> indexItems = new ArrayList<>();
|
List<IndexItem> indexItems = new ArrayList<>();
|
||||||
|
@ -202,6 +204,11 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
private class UpdateIndexAdapter extends ArrayAdapter<IndexItem> {
|
private class UpdateIndexAdapter extends ArrayAdapter<IndexItem> {
|
||||||
List<IndexItem> items;
|
List<IndexItem> items;
|
||||||
|
|
||||||
|
@ -243,28 +250,12 @@ public class UpdatesIndexFragment extends OsmAndListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 10/13/15 Extract viewholder parent
|
private static class UpdateViewHolder extends TwoLineWithImagesViewHolder {
|
||||||
private static class UpdateViewHolder {
|
|
||||||
private final TextView nameTextView;
|
|
||||||
private final TextView descrTextView;
|
|
||||||
private final ImageView leftImageView;
|
|
||||||
private final ImageView rightImageButton;
|
|
||||||
private final Button rightButton;
|
|
||||||
private final ProgressBar progressBar;
|
|
||||||
private final TextView mapDateTextView;
|
|
||||||
private final DownloadActivity context;
|
|
||||||
private final java.text.DateFormat format;
|
private final java.text.DateFormat format;
|
||||||
|
|
||||||
private UpdateViewHolder(View convertView,
|
private UpdateViewHolder(View convertView,
|
||||||
final DownloadActivity context) {
|
final DownloadActivity context) {
|
||||||
nameTextView = (TextView) convertView.findViewById(R.id.name);
|
super(convertView, context);
|
||||||
descrTextView = (TextView) convertView.findViewById(R.id.description);
|
|
||||||
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
|
|
||||||
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
|
|
||||||
rightButton = (Button) convertView.findViewById(R.id.rightButton);
|
|
||||||
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
|
|
||||||
mapDateTextView = (TextView) convertView.findViewById(R.id.mapDateTextView);
|
|
||||||
this.context = context;
|
|
||||||
format = context.getMyApplication().getResourceManager().getDateFormat();
|
format = context.getMyApplication().getResourceManager().getDateFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,8 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DownloadEntryAdapter extends ArrayAdapter<DownloadEntry> {
|
public static class DownloadEntryAdapter extends ArrayAdapter<DownloadEntry>
|
||||||
|
implements ProgressAdapter {
|
||||||
private final Drawable deleteDrawable;
|
private final Drawable deleteDrawable;
|
||||||
private final DownloadActivity context;
|
private final DownloadActivity context;
|
||||||
private int itemInProgressPosition = -1;
|
private int itemInProgressPosition = -1;
|
||||||
|
@ -83,6 +84,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setProgress(BasicProgressAsyncTask<?, ?, ?> task, Object tag) {
|
public void setProgress(BasicProgressAsyncTask<?, ?, ?> task, Object tag) {
|
||||||
isFinished = task == null
|
isFinished = task == null
|
||||||
|| task.getStatus() == AsyncTask.Status.FINISHED;
|
|| task.getStatus() == AsyncTask.Status.FINISHED;
|
||||||
|
@ -96,6 +98,7 @@ public class ActiveDownloadsDialogFragment extends DialogFragment {
|
||||||
itemInProgressPosition = i;
|
itemInProgressPosition = i;
|
||||||
downloadedItems.add(i);
|
downloadedItems.add(i);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
|
|
|
@ -6,10 +6,6 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.access.AccessibleToast;
|
import net.osmand.access.AccessibleToast;
|
||||||
|
@ -25,14 +21,7 @@ import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class ItemViewHolder {
|
public class ItemViewHolder extends TwoLineWithImagesViewHolder {
|
||||||
private final TextView nameTextView;
|
|
||||||
private final TextView descrTextView;
|
|
||||||
private final ImageView leftImageView;
|
|
||||||
private final ImageView rightImageButton;
|
|
||||||
private final Button rightButton;
|
|
||||||
private final ProgressBar progressBar;
|
|
||||||
private final TextView mapDateTextView;
|
|
||||||
|
|
||||||
private final Map<String, String> indexFileNames;
|
private final Map<String, String> indexFileNames;
|
||||||
private final Map<String, String> indexActivatedFileNames;
|
private final Map<String, String> indexActivatedFileNames;
|
||||||
|
@ -54,22 +43,17 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemViewHolder(View convertView,
|
public ItemViewHolder(View convertView,
|
||||||
|
DownloadActivity context,
|
||||||
DateFormat dateFormat,
|
DateFormat dateFormat,
|
||||||
Map<String, String> indexFileNames,
|
Map<String, String> indexFileNames,
|
||||||
Map<String, String> indexActivatedFileNames) {
|
Map<String, String> indexActivatedFileNames) {
|
||||||
|
super(convertView, context);
|
||||||
this.indexFileNames = indexFileNames;
|
this.indexFileNames = indexFileNames;
|
||||||
this.indexActivatedFileNames = indexActivatedFileNames;
|
this.indexActivatedFileNames = indexActivatedFileNames;
|
||||||
this.dateFormat = dateFormat;
|
this.dateFormat = dateFormat;
|
||||||
nameTextView = (TextView) convertView.findViewById(R.id.name);
|
|
||||||
descrTextView = (TextView) convertView.findViewById(R.id.description);
|
|
||||||
leftImageView = (ImageView) convertView.findViewById(R.id.leftImageView);
|
|
||||||
rightImageButton = (ImageView) convertView.findViewById(R.id.rightImageButton);
|
|
||||||
rightButton = (Button) convertView.findViewById(R.id.rightButton);
|
|
||||||
progressBar = (ProgressBar) convertView.findViewById(R.id.progressBar);
|
|
||||||
mapDateTextView = (TextView) convertView.findViewById(R.id.mapDateTextView);
|
|
||||||
|
|
||||||
TypedValue typedValue = new TypedValue();
|
TypedValue typedValue = new TypedValue();
|
||||||
Resources.Theme theme = convertView.getContext().getTheme();
|
Resources.Theme theme = context.getTheme();
|
||||||
theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
|
theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
|
||||||
textColorPrimary = typedValue.data;
|
textColorPrimary = typedValue.data;
|
||||||
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
|
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
|
||||||
|
@ -88,13 +72,20 @@ public class ItemViewHolder {
|
||||||
this.freeVersion = freeVersion;
|
this.freeVersion = freeVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindIndexItem(final IndexItem indexItem, final DownloadActivity context,
|
public void bindIndexItem(final IndexItem indexItem,
|
||||||
boolean showTypeInTitle, boolean showTypeInDesc) {
|
boolean showTypeInTitle, boolean showTypeInDesc, int progress) {
|
||||||
boolean disabled = false;
|
boolean disabled = false;
|
||||||
String textButtonCaption = "GET";
|
|
||||||
rightButtonAction = RightButtonAction.UNKNOWN;
|
rightButtonAction = RightButtonAction.UNKNOWN;
|
||||||
|
rightImageButton.setClickable(false);
|
||||||
if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
|
if (progress != -1) {
|
||||||
|
rightImageButton.setClickable(true);
|
||||||
|
rightImageButton.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
context.makeSureUserCancelDownload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (indexItem.getType() == DownloadActivityType.VOICE_FILE) {
|
||||||
nameTextView.setText(indexItem.getVisibleName(context,
|
nameTextView.setText(indexItem.getVisibleName(context,
|
||||||
context.getMyApplication().getRegions(), false));
|
context.getMyApplication().getRegions(), false));
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,22 +114,60 @@ public class ItemViewHolder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
descrTextView.setVisibility(View.VISIBLE);
|
if (progress == -1) {
|
||||||
if (!showTypeInTitle && (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
descrTextView.setVisibility(View.VISIBLE);
|
||||||
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
if (!showTypeInTitle && (indexItem.getType() == DownloadActivityType.SRTM_COUNTRY_FILE ||
|
||||||
descrTextView.setText(indexItem.getType().getString(context));
|
indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) && srtmDisabled) {
|
||||||
} else if (showTypeInDesc) {
|
descrTextView.setText(indexItem.getType().getString(context));
|
||||||
descrTextView.setText(indexItem.getType().getString(context) + " • " + indexItem.getSizeDescription(context));
|
} else if (showTypeInDesc) {
|
||||||
|
descrTextView.setText(indexItem.getType().getString(context) + " • " + indexItem.getSizeDescription(context));
|
||||||
|
} else {
|
||||||
|
descrTextView.setText(indexItem.getSizeDescription(context));
|
||||||
|
}
|
||||||
|
rightImageButton.setVisibility(View.VISIBLE);
|
||||||
|
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
|
||||||
|
progressBar.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (indexFileNames != null && indexItem.isAlreadyDownloaded(indexFileNames)) {
|
||||||
|
boolean outdated = false;
|
||||||
|
String date;
|
||||||
|
if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) {
|
||||||
|
date = indexItem.getDate(dateFormat);
|
||||||
|
} else {
|
||||||
|
String sfName = indexItem.getTargetFileName();
|
||||||
|
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
|
||||||
|
date = updatableResource ? indexActivatedFileNames.get(sfName) : indexFileNames.get(sfName);
|
||||||
|
outdated = DownloadActivity.downloadListIndexThread.checkIfItemOutdated(indexItem);
|
||||||
|
}
|
||||||
|
String updateDescr = context.getResources().getString(R.string.local_index_installed) + ": "
|
||||||
|
+ date;
|
||||||
|
mapDateTextView.setText(updateDescr);
|
||||||
|
int colorId = outdated ? R.color.color_distance : R.color.color_ok;
|
||||||
|
final int color = context.getResources().getColor(colorId);
|
||||||
|
mapDateTextView.setTextColor(color);
|
||||||
|
leftImageView.setImageDrawable(getContentIcon(context,
|
||||||
|
indexItem.getType().getIconResource(), color));
|
||||||
|
nameTextView.setTextColor(textColorPrimary);
|
||||||
|
} else if (disabled) {
|
||||||
|
leftImageView.setImageDrawable(getContentIcon(context,
|
||||||
|
indexItem.getType().getIconResource(), textColorSecondary));
|
||||||
|
nameTextView.setTextColor(textColorSecondary);
|
||||||
|
} else {
|
||||||
|
leftImageView.setImageDrawable(getContentIcon(context,
|
||||||
|
indexItem.getType().getIconResource()));
|
||||||
|
nameTextView.setTextColor(textColorPrimary);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
descrTextView.setText(indexItem.getSizeDescription(context));
|
progressBar.setVisibility(View.VISIBLE);
|
||||||
|
progressBar.setProgress(progress);
|
||||||
|
rightImageButton.setImageDrawable(
|
||||||
|
getContentIcon(context, R.drawable.ic_action_remove_dark));
|
||||||
}
|
}
|
||||||
rightImageButton.setVisibility(View.VISIBLE);
|
|
||||||
rightImageButton.setImageDrawable(getContentIcon(context, R.drawable.ic_action_import));
|
|
||||||
progressBar.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
if (rightButtonAction != RightButtonAction.UNKNOWN) {
|
if (rightButtonAction != RightButtonAction.UNKNOWN) {
|
||||||
rightButton.setText(textButtonCaption);
|
rightButton.setText(R.string.get_plugin);
|
||||||
rightButton.setVisibility(View.VISIBLE);
|
rightButton.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
rightImageButton.setVisibility(View.GONE);
|
rightImageButton.setVisibility(View.GONE);
|
||||||
|
|
||||||
final RightButtonAction action = rightButtonAction;
|
final RightButtonAction action = rightButtonAction;
|
||||||
|
@ -177,39 +206,14 @@ public class ItemViewHolder {
|
||||||
rightButton.setVisibility(View.GONE);
|
rightButton.setVisibility(View.GONE);
|
||||||
rightImageButton.setVisibility(View.VISIBLE);
|
rightImageButton.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indexFileNames != null && indexItem.isAlreadyDownloaded(indexFileNames)) {
|
|
||||||
boolean outdated = false;
|
|
||||||
String date;
|
|
||||||
if (indexItem.getType() == DownloadActivityType.HILLSHADE_FILE) {
|
|
||||||
date = indexItem.getDate(dateFormat);
|
|
||||||
} else {
|
|
||||||
String sfName = indexItem.getTargetFileName();
|
|
||||||
final boolean updatableResource = indexActivatedFileNames.containsKey(sfName);
|
|
||||||
date = updatableResource ? indexActivatedFileNames.get(sfName) : indexFileNames.get(sfName);
|
|
||||||
outdated = DownloadActivity.downloadListIndexThread.checkIfItemOutdated(indexItem);
|
|
||||||
}
|
|
||||||
String updateDescr = context.getResources().getString(R.string.local_index_installed) + ": "
|
|
||||||
+ date;
|
|
||||||
mapDateTextView.setText(updateDescr);
|
|
||||||
int colorId = outdated ? R.color.color_distance : R.color.color_ok;
|
|
||||||
final int color = context.getResources().getColor(colorId);
|
|
||||||
mapDateTextView.setTextColor(color);
|
|
||||||
leftImageView.setImageDrawable(getContentIcon(context,
|
|
||||||
indexItem.getType().getIconResource(), color));
|
|
||||||
nameTextView.setTextColor(textColorPrimary);
|
|
||||||
} else if (disabled) {
|
|
||||||
leftImageView.setImageDrawable(getContentIcon(context,
|
|
||||||
indexItem.getType().getIconResource(), textColorSecondary));
|
|
||||||
nameTextView.setTextColor(textColorSecondary);
|
|
||||||
} else {
|
|
||||||
leftImageView.setImageDrawable(getContentIcon(context,
|
|
||||||
indexItem.getType().getIconResource()));
|
|
||||||
nameTextView.setTextColor(textColorPrimary);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void bindRegion(WorldRegion region, DownloadActivity context) {
|
public void bindIndexItem(final IndexItem indexItem,
|
||||||
|
boolean showTypeInTitle, boolean showTypeInDesc) {
|
||||||
|
bindIndexItem(indexItem, showTypeInTitle, showTypeInDesc, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void bindRegion(WorldRegion region) {
|
||||||
nameTextView.setText(region.getName());
|
nameTextView.setText(region.getName());
|
||||||
nameTextView.setTextColor(textColorPrimary);
|
nameTextView.setTextColor(textColorPrimary);
|
||||||
if (region.getResourceTypes().size() > 0) {
|
if (region.getResourceTypes().size() > 0) {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package net.osmand.plus.download.items;
|
||||||
|
|
||||||
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by GaidamakUA on 10/16/15.
|
||||||
|
*/
|
||||||
|
public interface ProgressAdapter {
|
||||||
|
void setProgress(BasicProgressAsyncTask<?, ?, ?> task, Object tag);
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.download.items;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
|
@ -22,8 +23,10 @@ import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.WorldRegion;
|
import net.osmand.plus.WorldRegion;
|
||||||
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
import net.osmand.plus.activities.OsmandBaseExpandableListAdapter;
|
||||||
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
import net.osmand.plus.activities.OsmandExpandableListFragment;
|
||||||
|
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.download.DownloadActivityType;
|
import net.osmand.plus.download.DownloadActivityType;
|
||||||
|
import net.osmand.plus.download.DownloadEntry;
|
||||||
import net.osmand.plus.download.IndexItem;
|
import net.osmand.plus.download.IndexItem;
|
||||||
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
|
||||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||||
|
@ -80,6 +83,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
expandAllGroups();
|
expandAllGroups();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getMyActivity().registerUpdateListener(listAdapter);
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
@ -168,7 +172,8 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RegionsItemsAdapter extends OsmandBaseExpandableListAdapter {
|
private class RegionsItemsAdapter extends OsmandBaseExpandableListAdapter
|
||||||
|
implements ProgressAdapter {
|
||||||
|
|
||||||
private Map<String, List<Object>> data = new LinkedHashMap<>();
|
private Map<String, List<Object>> data = new LinkedHashMap<>();
|
||||||
private List<String> sections = new LinkedList<>();
|
private List<String> sections = new LinkedList<>();
|
||||||
|
@ -176,6 +181,11 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
private boolean nauticalPluginDisabled;
|
private boolean nauticalPluginDisabled;
|
||||||
private boolean freeVersion;
|
private boolean freeVersion;
|
||||||
|
|
||||||
|
private int groupInProgressPosition = -1;
|
||||||
|
private int childInProgressPosition = -1;
|
||||||
|
private int progress = -1;
|
||||||
|
private boolean isFinished;
|
||||||
|
|
||||||
public RegionsItemsAdapter() {
|
public RegionsItemsAdapter() {
|
||||||
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null;
|
srtmDisabled = OsmandPlugin.getEnabledPlugin(SRTMPlugin.class) == null;
|
||||||
nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
|
nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
|
||||||
|
@ -217,7 +227,7 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
if (convertView == null) {
|
if (convertView == null) {
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
convertView = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||||
viewHolder = new ItemViewHolder(convertView,
|
viewHolder = new ItemViewHolder(convertView, getMyActivity(),
|
||||||
getMyApplication().getResourceManager().getDateFormat(),
|
getMyApplication().getResourceManager().getDateFormat(),
|
||||||
getMyActivity().getIndexActivatedFileNames(),
|
getMyActivity().getIndexActivatedFileNames(),
|
||||||
getMyActivity().getIndexFileNames());
|
getMyActivity().getIndexFileNames());
|
||||||
|
@ -230,18 +240,16 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
viewHolder.setFreeVersion(freeVersion);
|
viewHolder.setFreeVersion(freeVersion);
|
||||||
final Object child = getChild(groupPosition, childPosition);
|
final Object child = getChild(groupPosition, childPosition);
|
||||||
|
|
||||||
if (child instanceof ItemsListBuilder.ResourceItem
|
if (child instanceof WorldRegion) {
|
||||||
&& groupPosition == regionMapsGroupPos) {
|
viewHolder.bindRegion((WorldRegion) child);
|
||||||
ItemsListBuilder.ResourceItem item = (ItemsListBuilder.ResourceItem) child;
|
|
||||||
viewHolder.bindIndexItem(item.getIndexItem(), getDownloadActivity(), true, false);
|
|
||||||
} else if (child instanceof WorldRegion) {
|
|
||||||
viewHolder.bindRegion((WorldRegion) child, getDownloadActivity());
|
|
||||||
} else if (child instanceof ItemsListBuilder.ResourceItem) {
|
} else if (child instanceof ItemsListBuilder.ResourceItem) {
|
||||||
|
final int localProgress = groupPosition == groupInProgressPosition
|
||||||
|
&& childPosition == childInProgressPosition ? progress : -1;
|
||||||
viewHolder.bindIndexItem(((ItemsListBuilder.ResourceItem) child).getIndexItem(),
|
viewHolder.bindIndexItem(((ItemsListBuilder.ResourceItem) child).getIndexItem(),
|
||||||
getDownloadActivity(), false, true);
|
false, true, localProgress);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
|
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
|
||||||
"IndexItem but is of type:" + child.getClass());
|
"ResourceItem but is of type:" + child.getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
|
@ -300,6 +308,39 @@ public class RegionItemsFragment extends OsmandExpandableListFragment {
|
||||||
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
public boolean isChildSelectable(int groupPosition, int childPosition) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setProgress(BasicProgressAsyncTask<?, ?, ?> task, Object tag) {
|
||||||
|
LOG.debug("setProgress()");
|
||||||
|
isFinished = task == null
|
||||||
|
|| task.getStatus() == AsyncTask.Status.FINISHED;
|
||||||
|
groupInProgressPosition = -1;
|
||||||
|
childInProgressPosition = -1;
|
||||||
|
progress = -1;
|
||||||
|
if (isFinished) return;
|
||||||
|
if (tag instanceof DownloadEntry) {
|
||||||
|
progress = task.getProgressPercentage();
|
||||||
|
outer_loop:
|
||||||
|
for (int i = 0; i < getGroupCount(); i++) {
|
||||||
|
for (int j = 0; j < getChildrenCount(i); j++) {
|
||||||
|
final IndexItem child =
|
||||||
|
((ItemsListBuilder.ResourceItem) getChild(i, j)).getIndexItem();
|
||||||
|
LOG.debug("chield=" + child.getBasename());
|
||||||
|
LOG.debug("tag=" + ((DownloadEntry) tag).baseName);
|
||||||
|
if (child.getBasename().equals(((DownloadEntry) tag).baseName)) {
|
||||||
|
groupInProgressPosition = i;
|
||||||
|
childInProgressPosition = j;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
LOG.debug("groupInProgressPosition=" + groupInProgressPosition
|
||||||
|
+ "; childInProgressPosition" + childInProgressPosition);
|
||||||
|
break outer_loop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
LOG.debug("groupInProgressPosition=" + groupInProgressPosition
|
||||||
|
+ "; childInProgressPosition" + childInProgressPosition);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ConfirmDownloadUnneededMapDialogFragment extends DialogFragment {
|
public static class ConfirmDownloadUnneededMapDialogFragment extends DialogFragment {
|
||||||
|
|
|
@ -218,6 +218,7 @@ public class SearchItemsFragment extends Fragment {
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
convertView = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||||
viewHolder = new ItemViewHolder(convertView,
|
viewHolder = new ItemViewHolder(convertView,
|
||||||
|
getMyActivity(),
|
||||||
getMyApplication().getResourceManager().getDateFormat(),
|
getMyApplication().getResourceManager().getDateFormat(),
|
||||||
getMyActivity().getIndexActivatedFileNames(),
|
getMyActivity().getIndexActivatedFileNames(),
|
||||||
getMyActivity().getIndexFileNames());
|
getMyActivity().getIndexFileNames());
|
||||||
|
@ -230,9 +231,9 @@ public class SearchItemsFragment extends Fragment {
|
||||||
viewHolder.setFreeVersion(freeVersion);
|
viewHolder.setFreeVersion(freeVersion);
|
||||||
|
|
||||||
if (item instanceof WorldRegion) {
|
if (item instanceof WorldRegion) {
|
||||||
viewHolder.bindRegion((WorldRegion) item, getDownloadActivity());
|
viewHolder.bindRegion((WorldRegion) item);
|
||||||
} else if (item instanceof IndexItem) {
|
} else if (item instanceof IndexItem) {
|
||||||
viewHolder.bindIndexItem((IndexItem) item, getDownloadActivity(), false, true);
|
viewHolder.bindIndexItem((IndexItem) item, false, true);
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
|
throw new IllegalArgumentException("Item must be of type WorldRegion or " +
|
||||||
"IndexItem but is of type:" + item.getClass());
|
"IndexItem but is of type:" + item.getClass());
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package net.osmand.plus.download.items;
|
||||||
|
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by GaidamakUA on 10/15/15.
|
||||||
|
*/
|
||||||
|
public class TwoLineWithImagesViewHolder {
|
||||||
|
protected final TextView nameTextView;
|
||||||
|
protected final TextView descrTextView;
|
||||||
|
protected final ImageView leftImageView;
|
||||||
|
protected final ImageView rightImageButton;
|
||||||
|
protected final Button rightButton;
|
||||||
|
protected final ProgressBar progressBar;
|
||||||
|
protected final TextView mapDateTextView;
|
||||||
|
protected final DownloadActivity context;
|
||||||
|
|
||||||
|
public TwoLineWithImagesViewHolder(View view, DownloadActivity context) {
|
||||||
|
this.context = context;
|
||||||
|
progressBar = (ProgressBar) view.findViewById(R.id.progressBar);
|
||||||
|
mapDateTextView = (TextView) view.findViewById(R.id.mapDateTextView);
|
||||||
|
rightButton = (Button) view.findViewById(R.id.rightButton);
|
||||||
|
leftImageView = (ImageView) view.findViewById(R.id.leftImageView);
|
||||||
|
descrTextView = (TextView) view.findViewById(R.id.description);
|
||||||
|
rightImageButton = (ImageView) view.findViewById(R.id.rightImageButton);
|
||||||
|
nameTextView = (TextView) view.findViewById(R.id.name);
|
||||||
|
}
|
||||||
|
}
|
|
@ -185,6 +185,7 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
convertView = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||||
viewHolder = new ItemViewHolder(convertView,
|
viewHolder = new ItemViewHolder(convertView,
|
||||||
|
getMyActivity(),
|
||||||
getMyApplication().getResourceManager().getDateFormat(),
|
getMyApplication().getResourceManager().getDateFormat(),
|
||||||
getMyActivity().getIndexFileNames(),
|
getMyActivity().getIndexFileNames(),
|
||||||
getMyActivity().getIndexActivatedFileNames());
|
getMyActivity().getIndexActivatedFileNames());
|
||||||
|
@ -194,7 +195,7 @@ public class VoiceItemsFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
IndexItem item = (IndexItem) child;
|
IndexItem item = (IndexItem) child;
|
||||||
viewHolder.bindIndexItem(item, getDownloadActivity(), true, false);
|
viewHolder.bindIndexItem(item, true, false);
|
||||||
|
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,8 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WorldItemsFragment extends OsmandExpandableListFragment {
|
public class WorldItemsFragment extends OsmandExpandableListFragment
|
||||||
|
implements DownloadActivity.DataSetChangedListener {
|
||||||
public static final String TAG = "WorldItemsFragment";
|
public static final String TAG = "WorldItemsFragment";
|
||||||
private static final Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
|
private static final Log LOG = PlatformUtil.getLog(WorldItemsFragment.class);
|
||||||
|
|
||||||
|
@ -199,6 +200,12 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void notifyDataSetChanged() {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
((DownloadActivity) getActivity()).updateDescriptionTextWithSize(getView());
|
||||||
|
}
|
||||||
|
|
||||||
private class WorldItemsAdapter extends OsmandBaseExpandableListAdapter {
|
private class WorldItemsAdapter extends OsmandBaseExpandableListAdapter {
|
||||||
|
|
||||||
private Map<String, List<Object>> data = new LinkedHashMap<>();
|
private Map<String, List<Object>> data = new LinkedHashMap<>();
|
||||||
|
@ -289,6 +296,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
||||||
convertView = LayoutInflater.from(parent.getContext())
|
convertView = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
.inflate(R.layout.two_line_with_images_list_item, parent, false);
|
||||||
viewHolder = new ItemViewHolder(convertView,
|
viewHolder = new ItemViewHolder(convertView,
|
||||||
|
getMyActivity(),
|
||||||
getMyApplication().getResourceManager().getDateFormat(),
|
getMyApplication().getResourceManager().getDateFormat(),
|
||||||
getMyActivity().getIndexActivatedFileNames(),
|
getMyActivity().getIndexActivatedFileNames(),
|
||||||
getMyActivity().getIndexFileNames());
|
getMyActivity().getIndexFileNames());
|
||||||
|
@ -299,7 +307,7 @@ public class WorldItemsFragment extends OsmandExpandableListFragment {
|
||||||
viewHolder.setSrtmDisabled(srtmDisabled);
|
viewHolder.setSrtmDisabled(srtmDisabled);
|
||||||
viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled);
|
viewHolder.setNauticalPluginDisabled(nauticalPluginDisabled);
|
||||||
viewHolder.setFreeVersion(freeVersion);
|
viewHolder.setFreeVersion(freeVersion);
|
||||||
viewHolder.bindIndexItem(item.getIndexItem(), getDownloadActivity(), false, false);
|
viewHolder.bindIndexItem(item.getIndexItem(), false, false);
|
||||||
} else if (groupPosition == voicePromptsIndex) {
|
} else if (groupPosition == voicePromptsIndex) {
|
||||||
String item = (String)child;
|
String item = (String)child;
|
||||||
SimpleViewHolder viewHolder;
|
SimpleViewHolder viewHolder;
|
||||||
|
|
Loading…
Reference in a new issue