Merge pull request #1122 from Bars107/master
Added select all for poi type.
This commit is contained in:
commit
a655b8a0f8
2 changed files with 92 additions and 36 deletions
|
@ -4,25 +4,6 @@
|
||||||
package net.osmand.plus.activities;
|
package net.osmand.plus.activities;
|
||||||
|
|
||||||
|
|
||||||
import java.text.Collator;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
|
||||||
import net.osmand.osm.PoiCategory;
|
|
||||||
import net.osmand.osm.PoiType;
|
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
|
||||||
import net.osmand.plus.activities.search.SearchActivity;
|
|
||||||
import net.osmand.plus.activities.search.SearchPOIActivity;
|
|
||||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
|
||||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
|
||||||
import net.osmand.util.Algorithms;
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.AlertDialog.Builder;
|
import android.app.AlertDialog.Builder;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -42,6 +23,26 @@ import android.widget.ListView;
|
||||||
import android.widget.ScrollView;
|
import android.widget.ScrollView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
|
import net.osmand.osm.PoiCategory;
|
||||||
|
import net.osmand.osm.PoiType;
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.search.SearchActivity;
|
||||||
|
import net.osmand.plus.activities.search.SearchPOIActivity;
|
||||||
|
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||||
|
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||||
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
|
import java.text.Collator;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -63,9 +64,20 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
filter = helper.getFilterById(filterId);
|
filter = helper.getFilterById(filterId);
|
||||||
super.onCreate(icicle);
|
super.onCreate(icicle);
|
||||||
|
|
||||||
setContentView(R.layout.editing_poi_filter);
|
setContentView(R.layout.update_index);
|
||||||
|
((TextView)findViewById(R.id.header)).setText(R.string.shared_string_select_all);
|
||||||
|
final CheckBox selectAll = (CheckBox) findViewById(R.id.select_all);
|
||||||
|
selectAll.setOnClickListener(new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (selectAll.isChecked()) {
|
||||||
|
selectAll();
|
||||||
|
} else {
|
||||||
|
deselectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
getSupportActionBar().setTitle(R.string.filterpoi_activity);
|
getSupportActionBar().setTitle(R.string.filterpoi_activity);
|
||||||
// getSupportActionBar().setIcon(R.drawable.tab_search_poi_icon);
|
|
||||||
|
|
||||||
if (filter != null) {
|
if (filter != null) {
|
||||||
getSupportActionBar().setSubtitle(filter.getName());
|
getSupportActionBar().setSubtitle(filter.getName());
|
||||||
|
@ -204,11 +216,7 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
builder.setPositiveButton(EditPOIFilterActivity.this.getText(R.string.shared_string_select_all), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(EditPOIFilterActivity.this.getText(R.string.shared_string_select_all), new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
filter.selectSubTypesToAccept(poiCategory, null);
|
ListView lv = selectAllFromCategory(poiCategory);
|
||||||
helper.editPoiFilter(filter);
|
|
||||||
ListView lv = EditPOIFilterActivity.this.getListView();
|
|
||||||
AmenityAdapter la = (AmenityAdapter) EditPOIFilterActivity.this.getListAdapter();
|
|
||||||
la.notifyDataSetInvalidated();
|
|
||||||
lv.setSelectionFromTop(index, top);
|
lv.setSelectionFromTop(index, top);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -223,8 +231,39 @@ public class EditPOIFilterActivity extends OsmandListActivity {
|
||||||
builder.show();
|
builder.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ListView selectAllFromCategory(PoiCategory poiCategory) {
|
||||||
|
filter.selectSubTypesToAccept(poiCategory, null);
|
||||||
|
helper.editPoiFilter(filter);
|
||||||
|
ListView lv = this.getListView();
|
||||||
|
AmenityAdapter la = this.getListAdapter();
|
||||||
|
la.notifyDataSetInvalidated();
|
||||||
|
return lv;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectAll(){
|
||||||
|
AmenityAdapter adapter = getListAdapter();
|
||||||
|
int count = adapter.getCount();
|
||||||
|
for (int i =0; i< count; i++) {
|
||||||
|
selectAllFromCategory(adapter.getItem(i));
|
||||||
|
ListView lv = EditPOIFilterActivity.this.getListView();
|
||||||
|
final int index = lv.getFirstVisiblePosition();
|
||||||
|
View v = lv.getChildAt(0);
|
||||||
|
final int top = (v == null) ? 0 : v.getTop();
|
||||||
|
lv.setSelectionFromTop(index, top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void deselectAll(){
|
||||||
|
AmenityAdapter adapter = getListAdapter();
|
||||||
|
int count = adapter.getCount();
|
||||||
|
for (int i =0; i< count; i++) {
|
||||||
|
filter.setTypeToAccept(adapter.getItem(i), false);
|
||||||
|
}
|
||||||
|
ListView lv = EditPOIFilterActivity.this.getListView();
|
||||||
|
lv.deferNotifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AmenityAdapter getListAdapter() {
|
public AmenityAdapter getListAdapter() {
|
||||||
return (AmenityAdapter) super.getListAdapter();
|
return (AmenityAdapter) super.getListAdapter();
|
||||||
|
|
|
@ -435,6 +435,19 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
private OsMoGroup group;
|
private OsMoGroup group;
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
|
||||||
|
private MenuItem createActionModeMenuItem(final ActionMode actionMode, Menu m, int id, int titleRes, int icon, int menuItemType){
|
||||||
|
final MenuItem menuItem = createMenuItem(m, id, titleRes, icon,
|
||||||
|
menuItemType);
|
||||||
|
menuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
onActionItemClicked(actionMode, menuItem);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return menuItem;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
|
||||||
selectedObject = o;
|
selectedObject = o;
|
||||||
|
@ -449,34 +462,37 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
group = (OsMoGroup) (o instanceof OsMoGroup ? o : null);
|
group = (OsMoGroup) (o instanceof OsMoGroup ? o : null);
|
||||||
MenuItem mi = null;
|
MenuItem mi = null;
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
mi = createMenuItem(menu, ON_OFF_ACTION_ID, R.string.shared_string_ok, 0, 0,
|
mi = createActionModeMenuItem(actionMode, menu, ON_OFF_ACTION_ID, R.string.shared_string_ok, 0,
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
mode.setTitle(device.getVisibleName());
|
||||||
}
|
}
|
||||||
if (device != null && device.getLastLocation() != null) {
|
if (device != null && device.getLastLocation() != null) {
|
||||||
createMenuItem(menu, SHOW_ON_MAP_ID, R.string.shared_string_show_on_map, R.drawable.ic_action_marker_dark,
|
createActionModeMenuItem(actionMode, menu, SHOW_ON_MAP_ID, R.string.shared_string_show_on_map, R.drawable.ic_action_marker_dark,
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
|
|
||||||
}
|
}
|
||||||
createMenuItem(menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
createActionModeMenuItem(actionMode, menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
||||||
// there is a bug in Android 4.2 layout
|
// there is a bug in Android 4.2 layout
|
||||||
device != null && device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
device != null && device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
///
|
///
|
||||||
if (device != null) {
|
if (device != null) {
|
||||||
createMenuItem(menu, SETTINGS_DEV_ID, R.string.shared_string_settings, R.drawable.ic_action_settings_enabled_dark,
|
createActionModeMenuItem(actionMode, menu, SETTINGS_DEV_ID, R.string.shared_string_settings, R.drawable.ic_action_settings_enabled_dark,
|
||||||
// there is a bug in Android 4.2 layout
|
// there is a bug in Android 4.2 layout
|
||||||
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
}
|
}
|
||||||
if (device != null && device.getLastLocation() != null) {
|
if (device != null && device.getLastLocation() != null) {
|
||||||
MenuItem menuItem = createMenuItem(menu, TRACK_DEV_ID, R.string.osmo_set_moving_target, R.drawable.ic_action_flage_dark,
|
MenuItem menuItem = createActionModeMenuItem(actionMode, menu, TRACK_DEV_ID, R.string.osmo_set_moving_target, R.drawable.ic_action_flage_dark,
|
||||||
// there is a bug in Android 4.2 layout
|
// there is a bug in Android 4.2 layout
|
||||||
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER : MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
menuItem.setTitleCondensed(getString(R.string.osmo_follow));
|
menuItem.setTitleCondensed(getString(R.string.osmo_follow));
|
||||||
}
|
}
|
||||||
if (group != null) {
|
if (group != null) {
|
||||||
createMenuItem(menu, GROUP_INFO, R.string.osmo_group_info, R.drawable.ic_action_gabout_dark,
|
mode.setTitle(group.getVisibleName(OsMoGroupsActivity.this));
|
||||||
|
createActionModeMenuItem(actionMode, menu, GROUP_INFO, R.string.osmo_group_info, R.drawable.ic_action_gabout_dark,
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
}
|
}
|
||||||
if ((group != null && !group.isMainGroup()) || (device != null && device.getGroup().isMainGroup())) {
|
if ((group != null && !group.isMainGroup()) || (device != null && device.getGroup().isMainGroup())) {
|
||||||
createMenuItem(menu, DELETE_ACTION_ID, R.string.shared_string_delete,
|
createActionModeMenuItem(actionMode, menu, DELETE_ACTION_ID, R.string.shared_string_delete,
|
||||||
R.drawable.ic_action_delete_dark,
|
R.drawable.ic_action_delete_dark,
|
||||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
}
|
}
|
||||||
|
@ -981,7 +997,8 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
final String nameUser = name.getText().toString();
|
final String nameUser = name.getText().toString();
|
||||||
final String id = tracker.getText().toString();
|
final String id = tracker.getText().toString();
|
||||||
final String nick = nickname.getText().toString();
|
String nick = nickname.getText().toString().isEmpty() ? "user" : nickname.getText().toString();
|
||||||
|
|
||||||
if(id.length() == 0) {
|
if(id.length() == 0) {
|
||||||
app.showToastMessage(R.string.osmo_specify_tracker_id);
|
app.showToastMessage(R.string.osmo_specify_tracker_id);
|
||||||
connectToDevice();
|
connectToDevice();
|
||||||
|
|
Loading…
Reference in a new issue