Add gpx tracks selection
This commit is contained in:
parent
83619fde7d
commit
4a5ef45e58
3 changed files with 47 additions and 31 deletions
|
@ -12,18 +12,15 @@ import java.util.Map;
|
|||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||
import net.osmand.plus.activities.LocalIndexesActivity.LoadLocalIndexDescriptionTask;
|
||||
import net.osmand.plus.activities.LocalIndexesActivity.LocalIndexOperationTask;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.Activity;
|
||||
|
@ -37,19 +34,18 @@ import android.graphics.Typeface;
|
|||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.AsyncTask.Status;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.TextView;
|
||||
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
|
@ -57,7 +53,6 @@ import com.actionbarsherlock.view.ActionMode.Callback;
|
|||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuInflater;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
import com.actionbarsherlock.view.SubMenu;
|
||||
import com.actionbarsherlock.widget.SearchView;
|
||||
import com.actionbarsherlock.widget.SearchView.OnQueryTextListener;
|
||||
|
||||
|
@ -227,6 +222,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
@Override
|
||||
public void onContextMenuClick(final int itemId, int pos, boolean isChecked, DialogInterface dialog) {
|
||||
if (itemId == R.string.local_index_mi_reload) {
|
||||
asyncLoader = new LoadGpxTask();
|
||||
asyncLoader.execute(getActivity());
|
||||
} else if (itemId == R.string.local_index_mi_delete) {
|
||||
openSelectionMode(itemId, R.drawable.ic_action_delete_dark, R.drawable.ic_action_delete_light,
|
||||
|
@ -381,9 +377,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
|
|||
f.getParentFile().mkdirs();
|
||||
}
|
||||
if(f.renameTo(dest)){
|
||||
if(asyncLoader.getStatus() == Status.PENDING) {
|
||||
asyncLoader.execute(getActivity());
|
||||
}
|
||||
asyncLoader = new LoadGpxTask();
|
||||
asyncLoader.execute(getActivity());
|
||||
} else {
|
||||
AccessibleToast.makeText(getActivity(), R.string.file_can_not_be_renamed, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
package net.osmand.plus.activities;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -17,6 +18,7 @@ import android.support.v4.app.FragmentPagerAdapter;
|
|||
import android.support.v4.view.ViewPager;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabWidget;
|
||||
|
||||
|
@ -41,28 +43,44 @@ public class FavouritesActivity extends SherlockFragmentActivity {
|
|||
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
|
||||
getSherlock().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
|
||||
super.onCreate(icicle);
|
||||
|
||||
|
||||
setContentView(R.layout.tab_content);
|
||||
setSupportProgressBarIndeterminateVisibility(false);
|
||||
TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
|
||||
tabHost.setup();
|
||||
|
||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
Integer tab = settings.FAVORITES_TAB.get();
|
||||
ViewPager mViewPager = (ViewPager)findViewById(R.id.pager);
|
||||
mTabsAdapter = new TabsAdapter(this, tabHost, mViewPager, settings);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(FAVOURITES_INFO).setIndicator(getString(R.string.my_favorites)),
|
||||
FavouritesTreeFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(TRACKS).setIndicator(getString(R.string.my_tracks)),
|
||||
AvailableGPXFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
|
||||
SelectedGPXFragment.class, null);
|
||||
tabHost.setCurrentTab(tab);
|
||||
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
getSupportActionBar().setTitle("");
|
||||
// getSupportActionBar().setIcon(R.drawable.tab_search_favorites_icon);
|
||||
File[] lf = ((OsmandApplication) getApplication()).getAppPath(TRACKS).listFiles();
|
||||
boolean hasGpx = false;
|
||||
if(lf != null) {
|
||||
for(File t : lf) {
|
||||
if(t.isDirectory() || (t.getName().toLowerCase().endsWith(".gpx"))) {
|
||||
hasGpx = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasGpx) {
|
||||
FrameLayout fl = new FrameLayout(this);
|
||||
fl.setId(R.id.layout);
|
||||
setContentView(fl);
|
||||
getSupportFragmentManager().beginTransaction().add(R.id.layout, new FavouritesTreeFragment()).commit();
|
||||
} else {
|
||||
setContentView(R.layout.tab_content);
|
||||
TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost);
|
||||
tabHost.setup();
|
||||
|
||||
OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
|
||||
Integer tab = settings.FAVORITES_TAB.get();
|
||||
ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);
|
||||
mTabsAdapter = new TabsAdapter(this, tabHost, mViewPager, settings);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(FAVOURITES_INFO).setIndicator(getString(R.string.my_favorites)),
|
||||
FavouritesTreeFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(TRACKS).setIndicator(getString(R.string.my_tracks)),
|
||||
AvailableGPXFragment.class, null);
|
||||
mTabsAdapter.addTab(tabHost.newTabSpec(SELECTED_TRACK).setIndicator(getString(R.string.selected_track)),
|
||||
SelectedGPXFragment.class, null);
|
||||
tabHost.setCurrentTab(tab);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,6 @@ import android.app.AlertDialog;
|
|||
import android.app.AlertDialog.Builder;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.Spannable;
|
||||
|
@ -80,6 +79,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
private Comparator<FavouritePoint> favoritesComparator;
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
protected boolean hideActionBar;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
|
@ -299,6 +299,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
mi.setActionView(searchView);
|
||||
searchView.setOnQueryTextListener(new OnQueryTextListener() {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
favouritesAdapter.getFilter().filter(query);
|
||||
|
@ -311,6 +312,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
if(!searchView.isActivated()) {
|
||||
createMenuItem(menu, EXPORT_ID, R.string.export_fav, R.drawable.ic_action_gsave_light,
|
||||
R.drawable.ic_action_gsave_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
createMenuItem(menu, SHARE_ID, R.string.share_fav, R.drawable.ic_action_gshare_light,
|
||||
|
@ -319,6 +321,7 @@ public class FavouritesTreeFragment extends OsmandExpandableListFragment {
|
|||
R.drawable.ic_action_grefresh_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
|
||||
createMenuItem(menu, DELETE_ID, R.string.default_buttons_delete, R.drawable.ic_action_delete_light,
|
||||
R.drawable.ic_action_delete_dark, MenuItem.SHOW_AS_ACTION_IF_ROOM);
|
||||
}
|
||||
}
|
||||
|
||||
public void showProgressBar() {
|
||||
|
|
Loading…
Reference in a new issue