Put waypoints/ configure map/screen in the list
This commit is contained in:
parent
53f0a7fba3
commit
111ad576eb
10 changed files with 290 additions and 436 deletions
|
@ -48,6 +48,35 @@
|
||||||
android:src="@drawable/ic_action_settings_dark" />
|
android:src="@drawable/ic_action_settings_dark" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toolbar_ok"
|
||||||
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:background="@drawable/dashboard_button_light"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_action_ok_dark" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toolbar_sort"
|
||||||
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:background="@drawable/dashboard_button_light"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/ic_sort_waypoint_dark" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/toolbar_flat"
|
||||||
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
|
android:layout_height="@dimen/dashListItemHeight"
|
||||||
|
android:layout_gravity="right"
|
||||||
|
android:background="@drawable/dashboard_button_light"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:src="@drawable/ic_flat_list_dark" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/toolbar_edit"
|
android:id="@+id/toolbar_edit"
|
||||||
android:layout_width="@dimen/dashListItemHeight"
|
android:layout_width="@dimen/dashListItemHeight"
|
||||||
|
@ -55,6 +84,7 @@
|
||||||
android:layout_gravity="right"
|
android:layout_gravity="right"
|
||||||
android:background="@drawable/dashboard_button_light"
|
android:background="@drawable/dashboard_button_light"
|
||||||
android:scaleType="center"
|
android:scaleType="center"
|
||||||
|
android:visibility="gone"
|
||||||
android:src="@drawable/ic_action_edit_dark" />
|
android:src="@drawable/ic_action_edit_dark" />
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,13 +84,10 @@ public class MapActivityActions implements DialogProvider {
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
private RoutingHelper routingHelper;
|
private RoutingHelper routingHelper;
|
||||||
|
|
||||||
private WaypointDialogHelper waypointDialogHelper;
|
|
||||||
|
|
||||||
public MapActivityActions(MapActivity mapActivity){
|
public MapActivityActions(MapActivity mapActivity){
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
settings = mapActivity.getMyApplication().getSettings();
|
settings = mapActivity.getMyApplication().getSettings();
|
||||||
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
routingHelper = mapActivity.getMyApplication().getRoutingHelper();
|
||||||
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -546,7 +543,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private ContextMenuAdapter createMainOptionsMenu() {
|
public ContextMenuAdapter createMainOptionsMenu() {
|
||||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||||
final OsmandApplication app = mapActivity.getMyApplication();
|
final OsmandApplication app = mapActivity.getMyApplication();
|
||||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
|
||||||
|
@ -631,7 +628,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
showWaypointsInDrawer(false);
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
@ -692,8 +689,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
mapActivity.getDashboard().setListAdapter(new ConfigureMapMenu().createListAdapter(mapActivity),
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||||
DashboardType.CONFIGURE_MAP);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
@ -702,8 +698,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
.listen(new OnContextMenuClick() {
|
.listen(new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||||
mapActivity.getDashboard().setListAdapter(cm, DashboardType.CONFIGURE_SCREEN);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
|
@ -767,24 +762,9 @@ public class MapActivityActions implements DialogProvider {
|
||||||
return optionsMenuHelper;
|
return optionsMenuHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showWaypointsInDrawer(boolean flat) {
|
|
||||||
final int[] running = new int[] { -1 };
|
|
||||||
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(mapActivity, running, flat);
|
|
||||||
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
|
|
||||||
listAdapter, null);
|
|
||||||
mapActivity.getDashboard().setListAdapter(listAdapter, listener, DashboardType.WAYPOINTS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showWaypointsDialog(boolean flat) {
|
|
||||||
if(flat) {
|
|
||||||
waypointDialogHelper.showWaypointsDialogFlat(mapActivity, false);
|
|
||||||
} else {
|
|
||||||
waypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void openIntermediatePointsDialog(){
|
public void openIntermediatePointsDialog(){
|
||||||
waypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetPointsHelper getTargets() {
|
private TargetPointsHelper getTargets() {
|
||||||
|
|
|
@ -168,7 +168,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
||||||
|
|
||||||
showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
|
showOnMapItem = menu.add(0, SHOW_ON_MAP, 0, R.string.shared_string_show_on_map);
|
||||||
MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
MenuItemCompat.setShowAsAction(showOnMapItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
showOnMapItem = showOnMapItem.setIcon(R.drawable.ic_action_marker2_dark);
|
showOnMapItem = showOnMapItem.setIcon(getMyApplication().getIconsCache().getActionBarIcon(
|
||||||
|
R.drawable.ic_action_map_marker_dark));
|
||||||
showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
showOnMapItem.setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemClick(MenuItem item) {
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
|
|
@ -168,7 +168,7 @@ public class SearchPoiFilterFragment extends ListFragment implements SearchActiv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageView editIcon = (ImageView) row.findViewById(R.id.folder_edit_icon);
|
ImageView editIcon = (ImageView) row.findViewById(R.id.folder_edit_icon);
|
||||||
editIcon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_filter_dark));
|
editIcon.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_edit_dark));
|
||||||
if (model.isStandardFilter()) {
|
if (model.isStandardFilter()) {
|
||||||
editIcon.setVisibility(View.GONE);
|
editIcon.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,12 +14,16 @@ import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.activities.IntermediatePointsDialog;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
|
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
|
||||||
import net.osmand.plus.development.DashSimulateFragment;
|
import net.osmand.plus.development.DashSimulateFragment;
|
||||||
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
import net.osmand.plus.development.OsmandDevelopmentPlugin;
|
||||||
|
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||||
import net.osmand.plus.download.DownloadActivity;
|
import net.osmand.plus.download.DownloadActivity;
|
||||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||||
|
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||||
|
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
import net.osmand.plus.monitoring.DashTrackFragment;
|
import net.osmand.plus.monitoring.DashTrackFragment;
|
||||||
import net.osmand.plus.osmedit.DashOsmEditsFragment;
|
import net.osmand.plus.osmedit.DashOsmEditsFragment;
|
||||||
import net.osmand.plus.osmo.DashOsMoFragment;
|
import net.osmand.plus.osmo.DashOsMoFragment;
|
||||||
|
@ -77,6 +82,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
|
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
private DashboardType visibleType;
|
private DashboardType visibleType;
|
||||||
|
private DashboardType previousVisibleType;
|
||||||
private boolean landscape;
|
private boolean landscape;
|
||||||
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>();
|
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>();
|
||||||
private net.osmand.Location myLocation;
|
private net.osmand.Location myLocation;
|
||||||
|
@ -91,10 +97,15 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
private View paddingView;
|
private View paddingView;
|
||||||
private int mFlexibleSpaceImageHeight;
|
private int mFlexibleSpaceImageHeight;
|
||||||
|
|
||||||
|
|
||||||
|
private WaypointDialogHelper waypointDialogHelper;
|
||||||
|
private final int[] running = new int[] { -1 };
|
||||||
|
private List<LocationPointWrapper> deletedPoints = new ArrayList<LocationPointWrapper>();
|
||||||
|
|
||||||
public enum DashboardType {
|
public enum DashboardType {
|
||||||
WAYPOINTS,
|
WAYPOINTS,
|
||||||
|
WAYPOINTS_FLAT,
|
||||||
WAYPOINTS_EDIT,
|
WAYPOINTS_EDIT,
|
||||||
WAYPOINTS_SORT,
|
|
||||||
CONFIGURE_SCREEN,
|
CONFIGURE_SCREEN,
|
||||||
CONFIGURE_MAP,
|
CONFIGURE_MAP,
|
||||||
LIST_MENU,
|
LIST_MENU,
|
||||||
|
@ -108,6 +119,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
|
|
||||||
|
|
||||||
public void createDashboardView() {
|
public void createDashboardView() {
|
||||||
|
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
|
||||||
landscape = !ScreenOrientationHelper.isOrientationPortrait(mapActivity);
|
landscape = !ScreenOrientationHelper.isOrientationPortrait(mapActivity);
|
||||||
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
|
dashboardView = (FrameLayout) mapActivity.findViewById(R.id.dashboard);
|
||||||
View.OnClickListener listener = new View.OnClickListener() {
|
View.OnClickListener listener = new View.OnClickListener() {
|
||||||
|
@ -137,20 +149,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
paddingView.setClickable(true);
|
paddingView.setClickable(true);
|
||||||
paddingView.setOnClickListener(listener);
|
paddingView.setOnClickListener(listener);
|
||||||
listView.addHeaderView(paddingView);
|
listView.addHeaderView(paddingView);
|
||||||
|
|
||||||
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
|
listBackgroundView = mapActivity.findViewById(R.id.dash_list_background);
|
||||||
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
|
|
||||||
contentView.post(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// mListBackgroundView's should fill its parent vertically
|
|
||||||
// but the height of the content view is 0 on 'onCreate'.
|
|
||||||
// So we should get it with post().
|
|
||||||
if(listBackgroundView != null) {
|
|
||||||
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
|
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
|
||||||
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
|
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
|
||||||
|
@ -160,49 +159,129 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initToolbarActions() {
|
private void updateListBackgroundHeight() {
|
||||||
|
final View contentView = mapActivity.getWindow().getDecorView().findViewById(android.R.id.content);
|
||||||
|
if(contentView.getHeight() > 0) {
|
||||||
|
if(listBackgroundView != null) {
|
||||||
|
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
contentView.post(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// mListBackgroundView's should fill its parent vertically
|
||||||
|
// but the height of the content view is 0 on 'onCreate'.
|
||||||
|
// So we should get it with post().
|
||||||
|
if (listBackgroundView != null) {
|
||||||
|
listBackgroundView.getLayoutParams().height = contentView.getHeight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void updateToolbarActions() {
|
||||||
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
|
TextView tv = (TextView) dashboardView.findViewById(R.id.toolbar_text);
|
||||||
|
tv.setText("");
|
||||||
|
boolean waypointsVisible = visibleType == DashboardType.WAYPOINTS || visibleType == DashboardType.WAYPOINTS_FLAT;
|
||||||
|
boolean waypointsEdit = visibleType == DashboardType.WAYPOINTS_EDIT;
|
||||||
|
if (waypointsVisible || waypointsEdit){
|
||||||
|
tv.setText(R.string.waypoints);
|
||||||
|
} else if(visibleType == DashboardType.CONFIGURE_MAP){
|
||||||
|
tv.setText(R.string.configure_map);
|
||||||
|
} else if(visibleType == DashboardType.CONFIGURE_SCREEN){
|
||||||
|
tv.setText(R.string.layer_map_appearance);
|
||||||
|
}
|
||||||
|
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
|
||||||
|
edit.setVisibility(View.GONE);
|
||||||
|
ImageView sort = (ImageView) dashboardView.findViewById(R.id.toolbar_sort);
|
||||||
|
sort.setVisibility(View.GONE);
|
||||||
|
ImageView ok = (ImageView) dashboardView.findViewById(R.id.toolbar_ok);
|
||||||
|
ok.setVisibility(View.GONE);
|
||||||
|
ImageView flat = (ImageView) dashboardView.findViewById(R.id.toolbar_flat);
|
||||||
|
flat.setVisibility(View.GONE);
|
||||||
|
ImageView settings = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
|
||||||
|
settings.setVisibility(View.GONE);
|
||||||
|
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
||||||
|
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
|
||||||
|
lst.setVisibility(View.GONE);
|
||||||
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
|
ImageView back = (ImageView) dashboardView.findViewById(R.id.toolbar_back);
|
||||||
back.setOnClickListener(new View.OnClickListener() {
|
back.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
hideDashboard();
|
backPressed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
|
|
||||||
edit.setVisibility(View.GONE);
|
if (waypointsVisible) {
|
||||||
|
edit.setVisibility(View.VISIBLE);
|
||||||
edit.setOnClickListener(new View.OnClickListener() {
|
edit.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
setDashboardVisibility(true, DashboardType.WAYPOINTS_EDIT);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ImageView settings = (ImageView) dashboardView.findViewById(R.id.toolbar_settings);
|
// TODO conditional
|
||||||
|
flat.setVisibility(View.VISIBLE);
|
||||||
|
final boolean flatNow = visibleType == DashboardType.WAYPOINTS_FLAT;
|
||||||
|
flat.setImageDrawable(iconsCache.getActionBarIcon(flatNow ?
|
||||||
|
R.drawable.ic_tree_list_dark : R.drawable.ic_flat_list_dark));
|
||||||
|
flat.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
setDashboardVisibility(true, flatNow ? DashboardType.WAYPOINTS :
|
||||||
|
DashboardType.WAYPOINTS_FLAT);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(waypointsEdit) {
|
||||||
|
ok.setVisibility(View.VISIBLE);
|
||||||
|
ok.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
mapActivity.getMyApplication().getWaypointHelper().removeVisibleLocationPoint(deletedPoints);
|
||||||
|
hideDashboard();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (mapActivity.getMyApplication().getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
||||||
|
sort.setVisibility(View.VISIBLE);
|
||||||
|
sort.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
hideDashboard();
|
||||||
|
IntermediatePointsDialog.openIntermediatePointsDialog(mapActivity, getMyApplication(), true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU) {
|
||||||
|
settings.setVisibility(View.VISIBLE);
|
||||||
settings.setOnClickListener(new View.OnClickListener() {
|
settings.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Class<? extends Activity> sta = mapActivity.getMyApplication().getAppCustomization().getSettingsActivity();
|
Class<? extends Activity> sta = mapActivity.getMyApplication().getAppCustomization()
|
||||||
|
.getSettingsActivity();
|
||||||
visible = false;
|
visible = false;
|
||||||
mapActivity.startActivity(new Intent(mapActivity, sta));
|
mapActivity.startActivity(new Intent(mapActivity, sta));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
|
|
||||||
|
|
||||||
ImageView lst = (ImageView) dashboardView.findViewById(R.id.toolbar_list);
|
|
||||||
lst.setVisibility(View.VISIBLE);
|
lst.setVisibility(View.VISIBLE);
|
||||||
if(visibleType == DashboardType.DASHBOARD) {
|
if (visibleType == DashboardType.DASHBOARD) {
|
||||||
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_navigation_drawer));
|
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_navigation_drawer_dark));
|
||||||
} else if(visibleType == DashboardType.LIST_MENU) {
|
} else if (visibleType == DashboardType.LIST_MENU) {
|
||||||
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_dashboard_dark));
|
lst.setImageDrawable(iconsCache.getActionBarIcon(R.drawable.ic_dashboard_dark));
|
||||||
} else {
|
|
||||||
lst.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
lst.setOnClickListener(new View.OnClickListener() {
|
lst.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
if(visibleType == DashboardType.DASHBOARD) {
|
if (visibleType == DashboardType.DASHBOARD) {
|
||||||
setDashboardVisibility(true, DashboardType.LIST_MENU);
|
setDashboardVisibility(true, DashboardType.LIST_MENU);
|
||||||
} else {
|
} else {
|
||||||
setDashboardVisibility(true, DashboardType.DASHBOARD);
|
setDashboardVisibility(true, DashboardType.DASHBOARD);
|
||||||
|
@ -210,6 +289,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void initActionButton() {
|
private void initActionButton() {
|
||||||
|
@ -276,14 +356,16 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideDashboard() {
|
public void hideDashboard() {
|
||||||
setDashboardVisibility(false, DashboardType.DASHBOARD);
|
setDashboardVisibility(false, visibleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashboardVisibility(boolean visible, DashboardType type) {
|
public void setDashboardVisibility(boolean visible, DashboardType type) {
|
||||||
if(visible == this.visible && type == visibleType) {
|
if(visible == this.visible && type == visibleType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.previousVisibleType = this.visible ? null : visibleType;
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
|
boolean refresh = this.visibleType == type;
|
||||||
this.visibleType = type;
|
this.visibleType = type;
|
||||||
DashboardOnMap.staticVisible = visible;
|
DashboardOnMap.staticVisible = visible;
|
||||||
DashboardOnMap.staticVisibleType = type;
|
DashboardOnMap.staticVisibleType = type;
|
||||||
|
@ -304,10 +386,16 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
} else {
|
} else {
|
||||||
scrollView.setVisibility(View.GONE);
|
scrollView.setVisibility(View.GONE);
|
||||||
listViewLayout.setVisibility(View.VISIBLE);
|
listViewLayout.setVisibility(View.VISIBLE);
|
||||||
|
if(refresh) {
|
||||||
|
refreshContent();
|
||||||
|
} else {
|
||||||
|
updateListAdapter();
|
||||||
|
updateListBackgroundHeight();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
|
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
initToolbarActions();
|
updateToolbarActions();
|
||||||
//fabButton.showFloatingActionButton();
|
//fabButton.showFloatingActionButton();
|
||||||
open(dashboardView.findViewById(R.id.animateContent));
|
open(dashboardView.findViewById(R.id.animateContent));
|
||||||
updateLocation(true, true, false);
|
updateLocation(true, true, false);
|
||||||
|
@ -326,6 +414,48 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateListAdapter() {
|
||||||
|
ContextMenuAdapter cm = null;
|
||||||
|
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
|
||||||
|
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running,
|
||||||
|
DashboardType.WAYPOINTS_FLAT == visibleType);
|
||||||
|
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
|
||||||
|
listAdapter, null);
|
||||||
|
updateListAdapter(listAdapter, listener);
|
||||||
|
} else if (DashboardType.WAYPOINTS_EDIT == visibleType) {
|
||||||
|
deletedPoints.clear();
|
||||||
|
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
|
||||||
|
DashboardType.WAYPOINTS_FLAT == visibleType);
|
||||||
|
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
|
||||||
|
listAdapter, null);
|
||||||
|
updateListAdapter(listAdapter, listener);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (DashboardType.CONFIGURE_SCREEN == visibleType) {
|
||||||
|
cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||||
|
} else if(DashboardType.CONFIGURE_MAP == visibleType) {
|
||||||
|
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
|
||||||
|
} else if(DashboardType.LIST_MENU == visibleType) {
|
||||||
|
cm = mapActivity.getMapActions().createMainOptionsMenu();
|
||||||
|
}
|
||||||
|
if (cm != null) {
|
||||||
|
updateListAdapter(cm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateListAdapter(ContextMenuAdapter cm) {
|
||||||
|
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings()
|
||||||
|
.isLightContent());
|
||||||
|
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
|
||||||
|
updateListAdapter(listAdapter, listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshContent() {
|
||||||
|
listAdapter.notifyDataSetChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
|
private OnItemClickListener getOptionsMenuOnClickListener(final ContextMenuAdapter cm,
|
||||||
final ArrayAdapter<?> listAdapter) {
|
final ArrayAdapter<?> listAdapter) {
|
||||||
return new AdapterView.OnItemClickListener() {
|
return new AdapterView.OnItemClickListener() {
|
||||||
|
@ -571,13 +701,23 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
|
|
||||||
public boolean onBackPressed() {
|
public boolean onBackPressed() {
|
||||||
if (isVisible()) {
|
if (isVisible()) {
|
||||||
hideDashboard();
|
backPressed();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void backPressed() {
|
||||||
|
if(previousVisibleType != visibleType && previousVisibleType != null) {
|
||||||
|
visibleType = null;
|
||||||
|
setDashboardVisibility(true, previousVisibleType);
|
||||||
|
} else {
|
||||||
|
hideDashboard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
|
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
|
||||||
// Translate list background
|
// Translate list background
|
||||||
|
@ -605,7 +745,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListAdapter(ArrayAdapter<?> listAdapter, OnItemClickListener listener, DashboardType type) {
|
private void updateListAdapter(ArrayAdapter<?> listAdapter, OnItemClickListener listener) {
|
||||||
this.listAdapter = listAdapter;
|
this.listAdapter = listAdapter;
|
||||||
this.listAdapterOnClickListener = listener;
|
this.listAdapterOnClickListener = listener;
|
||||||
if(this.listView != null) {
|
if(this.listView != null) {
|
||||||
|
@ -624,18 +764,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
listView.setOnItemClickListener(null);
|
listView.setOnItemClickListener(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setDashboardVisibility(true, type);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setListAdapter(ContextMenuAdapter cm, DashboardType type) {
|
|
||||||
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings()
|
|
||||||
.isLightContent());
|
|
||||||
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
|
|
||||||
setListAdapter(listAdapter, listener, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@SuppressLint("NewApi")
|
@SuppressLint("NewApi")
|
||||||
private void setTranslationY(View v, int y) {
|
private void setTranslationY(View v, int y) {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
|
||||||
|
@ -669,12 +799,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void refreshContent() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
// ?? This method might not be needed
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.SettingsActivity;
|
import net.osmand.plus.activities.SettingsActivity;
|
||||||
import net.osmand.plus.activities.TransportRouteHelper;
|
import net.osmand.plus.activities.TransportRouteHelper;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
|
||||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.render.RenderingRuleProperty;
|
import net.osmand.render.RenderingRuleProperty;
|
||||||
|
@ -45,20 +44,12 @@ public class ConfigureMapMenu {
|
||||||
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
public ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
||||||
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, allModes);
|
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, allModes);
|
||||||
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
|
adapter.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||||
adapter.item(R.string.configure_map).iconColor(R.drawable.ic_back_drawer_dark)
|
|
||||||
.listen(new OnContextMenuClick() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}).reg();
|
|
||||||
adapter.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
adapter.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||||
adapter.setChangeAppModeListener(new OnClickListener() {
|
adapter.setChangeAppModeListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean result) {
|
public void onClick(boolean result) {
|
||||||
allModes = true;
|
allModes = true;
|
||||||
ma.getDashboard().setListAdapter(createListAdapter(ma), DashboardType.CONFIGURE_MAP);
|
ma.getDashboard().updateListAdapter(createListAdapter(ma));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
createLayersItems(adapter, ma);
|
createLayersItems(adapter, ma);
|
||||||
|
|
|
@ -1,26 +1,7 @@
|
||||||
package net.osmand.plus.helpers;
|
package net.osmand.plus.helpers;
|
||||||
|
|
||||||
import android.app.Activity;
|
import java.util.ArrayList;
|
||||||
import android.app.AlertDialog;
|
import java.util.List;
|
||||||
import android.app.Dialog;
|
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.DialogInterface.OnClickListener;
|
|
||||||
import android.content.DialogInterface.OnDismissListener;
|
|
||||||
import android.os.AsyncTask;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.support.v4.app.DialogFragment;
|
|
||||||
import android.support.v4.app.FragmentActivity;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.AdapterView;
|
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.LocationPoint;
|
import net.osmand.data.LocationPoint;
|
||||||
|
@ -35,9 +16,24 @@ import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
import android.app.Activity;
|
||||||
import java.util.ArrayList;
|
import android.app.AlertDialog;
|
||||||
import java.util.List;
|
import android.content.DialogInterface;
|
||||||
|
import android.content.DialogInterface.OnClickListener;
|
||||||
|
import android.content.DialogInterface.OnDismissListener;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.support.v4.app.DialogFragment;
|
||||||
|
import android.support.v4.app.FragmentActivity;
|
||||||
|
import android.view.Gravity;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.AdapterView;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageButton;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
|
@ -62,7 +58,7 @@ public class WaypointDialogHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePointInfoView(final OsmandApplication app, final MapActivity activity,
|
public static void updatePointInfoView(final OsmandApplication app, final Activity activity,
|
||||||
View localView, final LocationPointWrapper ps, final DialogFragment dialog) {
|
View localView, final LocationPointWrapper ps, final DialogFragment dialog) {
|
||||||
WaypointHelper wh = app.getWaypointHelper();
|
WaypointHelper wh = app.getWaypointHelper();
|
||||||
final LocationPoint point = ps.getPoint();
|
final LocationPoint point = ps.getPoint();
|
||||||
|
@ -105,29 +101,13 @@ public class WaypointDialogHelper {
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showWaypointsDialogFlat(FragmentActivity fragmentActivity, boolean edit) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putBoolean(WaypointDialogFragment.FLAT_ARG, true);
|
|
||||||
args.putBoolean(WaypointDialogFragment.EDIT_ARG, edit);
|
|
||||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
|
||||||
wdf.setArguments(args);
|
|
||||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showWaypointsDialog(FragmentActivity fragmentActivity, boolean edit) {
|
public ArrayAdapter<Object> getWaypointsDrawerAdapter(
|
||||||
Bundle args = new Bundle();
|
final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
||||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
final MapActivity ctx, final int[] running, final boolean flat) {
|
||||||
args.putBoolean(WaypointDialogFragment.EDIT_ARG, edit);
|
|
||||||
wdf.setArguments(args);
|
|
||||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public ArrayAdapter<Object> getWaypointsDrawerAdapter(final MapActivity ctx, final int[] running, final boolean flat) {
|
|
||||||
final List<Object> points;
|
final List<Object> points;
|
||||||
if(flat) {
|
if(flat) {
|
||||||
points = new ArrayList<Object>(waypointHelper.getAllPoints());
|
points = new ArrayList<Object>(waypointHelper.getAllPoints());
|
||||||
points.add(0, new LocationPointWrapper());
|
|
||||||
} else {
|
} else {
|
||||||
points = getPoints();
|
points = getPoints();
|
||||||
}
|
}
|
||||||
|
@ -140,20 +120,14 @@ public class WaypointDialogHelper {
|
||||||
View v = convertView;
|
View v = convertView;
|
||||||
final ArrayAdapter<Object> thisAdapter = this;
|
final ArrayAdapter<Object> thisAdapter = this;
|
||||||
boolean labelView = (getItem(position) instanceof Integer);
|
boolean labelView = (getItem(position) instanceof Integer);
|
||||||
if (position == 0) {
|
if (getItem(position) instanceof RadiusItem) {
|
||||||
v = createDialogHeader(ctx, false, flat, null);
|
|
||||||
} else if (getItem(position) instanceof RadiusItem) {
|
|
||||||
final int type = ((RadiusItem) getItem(position)).type;
|
final int type = ((RadiusItem) getItem(position)).type;
|
||||||
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
||||||
} else if (labelView) {
|
} else if (labelView) {
|
||||||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
||||||
} else {
|
} else {
|
||||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
LocationPointWrapper point = (LocationPointWrapper) getItem(position);
|
||||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
v = updateWaypointItemView(edit, deletedPoints, ctx, null, v, point, this);
|
||||||
}
|
|
||||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), null);
|
|
||||||
View remove = v.findViewById(R.id.info_close);
|
|
||||||
remove.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
@ -162,31 +136,15 @@ public class WaypointDialogHelper {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayAdapter<Object> getWaypointsAdapter(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
|
||||||
final MapActivity ctx, final int[] running,
|
|
||||||
final AlertDialog[] srcDialog, final DialogFragment dialogFragment) {
|
|
||||||
final List<Object> points = getPoints();
|
|
||||||
return new ArrayAdapter<Object>(ctx,
|
|
||||||
R.layout.waypoint_reached, R.id.title, points) {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
private View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
|
||||||
// User super class to create the View
|
final Activity ctx, final DialogFragment dialogFragment, View v, final LocationPointWrapper point,
|
||||||
View v = convertView;
|
final ArrayAdapter adapter) {
|
||||||
final ArrayAdapter<Object> thisAdapter = this;
|
|
||||||
boolean labelView = (getItem(position) instanceof Integer);
|
|
||||||
if (position == 0) {
|
|
||||||
v = createDialogHeader(ctx, edit, false, srcDialog[0]);
|
|
||||||
} else if (getItem(position) instanceof RadiusItem) {
|
|
||||||
final int type = ((RadiusItem) getItem(position)).type;
|
|
||||||
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter);
|
|
||||||
} else if (labelView) {
|
|
||||||
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
|
|
||||||
} else {
|
|
||||||
if (v == null || v.findViewById(R.id.info_close) == null) {
|
if (v == null || v.findViewById(R.id.info_close) == null) {
|
||||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
||||||
}
|
}
|
||||||
updatePointInfoView(app, ctx, v, (LocationPointWrapper) getItem(position), dialogFragment);
|
updatePointInfoView(app, ctx, v, point, dialogFragment);
|
||||||
View remove = v.findViewById(R.id.info_close);
|
View remove = v.findViewById(R.id.info_close);
|
||||||
if (!edit) {
|
if (!edit) {
|
||||||
remove.setVisibility(View.GONE);
|
remove.setVisibility(View.GONE);
|
||||||
|
@ -197,104 +155,18 @@ public class WaypointDialogHelper {
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
LocationPointWrapper point = (LocationPointWrapper) points.get(position);
|
adapter.remove(point);
|
||||||
remove(point);
|
|
||||||
deletedPoints.add(point);
|
deletedPoints.add(point);
|
||||||
notifyDataSetChanged();
|
adapter.notifyDataSetChanged();
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected View createDialogHeader(final FragmentActivity a, final boolean editF, final boolean flat, final AlertDialog dlg) {
|
|
||||||
View v;
|
|
||||||
IconsCache iconsCache = app.getIconsCache();
|
|
||||||
v = a.getLayoutInflater().inflate(R.layout.waypoint_title, null);
|
|
||||||
ImageView iBack = (ImageView) v.findViewById(R.id.back);
|
|
||||||
if(dlg != null) {
|
|
||||||
iBack.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
iBack.setVisibility(View.VISIBLE);
|
|
||||||
iBack.setImageResource(app.getSettings().isLightContent() ? R.drawable.ic_back_drawer_white
|
|
||||||
: R.drawable.ic_back_drawer_dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
ImageButton edit = (ImageButton) v.findViewById(R.id.edit);
|
|
||||||
ImageButton sort = (ImageButton) v.findViewById(R.id.sort);
|
|
||||||
ImageButton all = (ImageButton) v.findViewById(R.id.all);
|
|
||||||
edit.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_action_gedit_dark));
|
|
||||||
edit.setVisibility(editF ? View.GONE : View.VISIBLE);
|
|
||||||
edit.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (flat) {
|
|
||||||
showWaypointsDialogFlat(a, true);
|
|
||||||
} else {
|
|
||||||
showWaypointsDialog(a, true);
|
|
||||||
}
|
|
||||||
if (dlg != null) {
|
|
||||||
dlg.dismiss();
|
|
||||||
} else if(a instanceof MapActivity){
|
|
||||||
((MapActivity) a).onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (app.getTargetPointsHelper().getIntermediatePoints().size() > 0) {
|
|
||||||
sort.setVisibility(View.VISIBLE);
|
|
||||||
sort.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_sort_waypoint_dark));
|
|
||||||
sort.setOnClickListener(new View.OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
IntermediatePointsDialog.openIntermediatePointsDialog(a, app, true);
|
|
||||||
if (dlg != null) {
|
|
||||||
dlg.dismiss();
|
|
||||||
} else if(a instanceof MapActivity){
|
|
||||||
// to close drawer
|
|
||||||
((MapActivity) a).onBackPressed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
sort.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
if (!waypointHelper.isRouteCalculated()) {
|
|
||||||
all.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
all.setVisibility(View.VISIBLE);
|
|
||||||
if(flat) {
|
|
||||||
all.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_tree_list_dark));
|
|
||||||
} else {
|
|
||||||
all.setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_flat_list_dark));
|
|
||||||
}
|
|
||||||
all.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (dlg != null) {
|
|
||||||
if (flat) {
|
|
||||||
showWaypointsDialog(a, editF);
|
|
||||||
} else {
|
|
||||||
showWaypointsDialogFlat(a, editF);
|
|
||||||
}
|
|
||||||
dlg.dismiss();
|
|
||||||
} else if(a instanceof MapActivity){
|
|
||||||
((MapActivity) a).getMapActions().showWaypointsInDrawer(!flat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
|
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
|
||||||
final int position, final ArrayAdapter<Object> thisAdapter) {
|
final int position, final ArrayAdapter<Object> thisAdapter) {
|
||||||
View v;
|
View v;
|
||||||
|
@ -518,7 +390,6 @@ public class WaypointDialogHelper {
|
||||||
protected List<Object> getPoints() {
|
protected List<Object> getPoints() {
|
||||||
final List<Object> points = new ArrayList<Object>();
|
final List<Object> points = new ArrayList<Object>();
|
||||||
boolean rc = waypointHelper.isRouteCalculated();
|
boolean rc = waypointHelper.isRouteCalculated();
|
||||||
points.add("");
|
|
||||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
||||||
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
List<LocationPointWrapper> tp = waypointHelper.getWaypoints(i);
|
||||||
if (!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
|
if (!rc && i != WaypointHelper.WAYPOINTS && i != WaypointHelper.TARGETS) {
|
||||||
|
@ -573,138 +444,4 @@ public class WaypointDialogHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WaypointDialogFragment extends DialogFragment {
|
|
||||||
|
|
||||||
WaypointHelper waypointHelper;
|
|
||||||
private OsmandApplication app;
|
|
||||||
|
|
||||||
public static final String FLAT_ARG = "FLAT_ARG";
|
|
||||||
public static final String EDIT_ARG = "EDIT_ARG";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAttach(Activity activity) {
|
|
||||||
super.onAttach(activity);
|
|
||||||
app = (OsmandApplication) activity.getApplication();
|
|
||||||
waypointHelper = app.getWaypointHelper();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
|
||||||
if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
|
||||||
return createWaypointsDialogFlat(waypointHelper.getAllPoints(), getArguments().getBoolean(EDIT_ARG));
|
|
||||||
}
|
|
||||||
return createWaypointsDialog(getArguments().getBoolean(EDIT_ARG));
|
|
||||||
}
|
|
||||||
|
|
||||||
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points, final boolean edit) {
|
|
||||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
|
||||||
final FragmentActivity ctx = getActivity();
|
|
||||||
final AlertDialog[] srcDialog = new AlertDialog[1];
|
|
||||||
points.add(0, new LocationPointWrapper());
|
|
||||||
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
|
||||||
points) {
|
|
||||||
@Override
|
|
||||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
|
||||||
// User super class to create the View
|
|
||||||
View v = convertView;
|
|
||||||
if (position == 0) {
|
|
||||||
return createDialogHeader(ctx, edit, true, srcDialog[0]);
|
|
||||||
}
|
|
||||||
if (v == null || v.findViewById(R.id.waypoint_icon) == null) {
|
|
||||||
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
|
|
||||||
}
|
|
||||||
updatePointInfoView(app, (MapActivity) ctx, v, getItem(position), WaypointDialogFragment.this);
|
|
||||||
View remove = v.findViewById(R.id.info_close);
|
|
||||||
if (!edit) {
|
|
||||||
remove.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
remove.setVisibility(View.VISIBLE);
|
|
||||||
((ImageButton) remove).setImageDrawable(
|
|
||||||
app.getIconsCache().getContentIcon(R.drawable.ic_action_gremove_dark));
|
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View view) {
|
|
||||||
LocationPointWrapper point = points.get(position);
|
|
||||||
remove(point);
|
|
||||||
deletedPoints.add(point);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
ListView listView = new ListView(ctx);
|
|
||||||
listView.setAdapter(listAdapter);
|
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
||||||
LocationPointWrapper ps = listAdapter.getItem(i);
|
|
||||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
|
||||||
builder.setView(listView);
|
|
||||||
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (edit) {
|
|
||||||
builder.setNegativeButton(ctx.getString(R.string.shared_string_cancel), null);
|
|
||||||
}
|
|
||||||
AlertDialog dlg = builder.create();
|
|
||||||
srcDialog[0] = dlg;
|
|
||||||
return dlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AlertDialog createWaypointsDialog(final boolean edit) {
|
|
||||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
|
||||||
final FragmentActivity ctx = getActivity();
|
|
||||||
final ListView listView = new ListView(ctx);
|
|
||||||
final int[] running = new int[]{-1};
|
|
||||||
final AlertDialog[] srcDialog = new AlertDialog[1];
|
|
||||||
final ArrayAdapter<Object> listAdapter = getWaypointsAdapter(edit, deletedPoints, (MapActivity) ctx,
|
|
||||||
running, srcDialog, WaypointDialogFragment.this);
|
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
|
||||||
listView.setOnItemClickListener( new AdapterView.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
|
||||||
if (listAdapter.getItem(item) instanceof LocationPointWrapper) {
|
|
||||||
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
|
||||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
|
||||||
} else if (new Integer(WaypointHelper.TARGETS).equals(listAdapter.getItem(item))) {
|
|
||||||
IntermediatePointsDialog.openIntermediatePointsDialog(ctx, app, true);
|
|
||||||
if (srcDialog[0] != null) {
|
|
||||||
srcDialog[0].dismiss();
|
|
||||||
}
|
|
||||||
} else if (listAdapter.getItem(item) instanceof RadiusItem) {
|
|
||||||
selectDifferentRadius(((RadiusItem) listAdapter.getItem(item)).type, running, item, listAdapter, ctx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
|
||||||
builder.setView(listView);
|
|
||||||
builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (edit) {
|
|
||||||
builder.setNegativeButton(ctx.getString(R.string.shared_string_cancel), null);
|
|
||||||
}
|
|
||||||
AlertDialog dlg = builder.create();
|
|
||||||
srcDialog[0] = dlg;
|
|
||||||
return dlg;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -176,8 +176,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
mapActivity.getDashboard().setListAdapter(new ConfigureMapMenu().createListAdapter(mapActivity),
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||||
DashboardType.CONFIGURE_MAP);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||||
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory;
|
||||||
|
@ -307,20 +306,12 @@ public class MapInfoLayer extends OsmandMapLayer {
|
||||||
public ContextMenuAdapter getViewConfigureMenuAdapter() {
|
public ContextMenuAdapter getViewConfigureMenuAdapter() {
|
||||||
ContextMenuAdapter cm = new ContextMenuAdapter(view.getContext());
|
ContextMenuAdapter cm = new ContextMenuAdapter(view.getContext());
|
||||||
cm.setDefaultLayoutId(R.layout.drawer_list_item);
|
cm.setDefaultLayoutId(R.layout.drawer_list_item);
|
||||||
cm.item(R.string.layer_map_appearance).iconColor(R.drawable.ic_back_drawer_dark)
|
|
||||||
.listen(new OnContextMenuClick() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}).reg();
|
|
||||||
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
cm.item(R.string.app_modes_choose).layout(R.layout.mode_toggles).reg();
|
||||||
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
cm.setChangeAppModeListener(new ConfigureMapMenu.OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(boolean allModes) {
|
public void onClick(boolean allModes) {
|
||||||
map.getDashboard().setListAdapter(getViewConfigureMenuAdapter(), DashboardType.CONFIGURE_MAP);
|
map.getDashboard().updateListAdapter(getViewConfigureMenuAdapter());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cm.item(R.string.map_widget_reset)
|
cm.item(R.string.map_widget_reset)
|
||||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.plus.R;
|
||||||
import net.osmand.plus.Version;
|
import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.actions.StartGPSStatus;
|
import net.osmand.plus.activities.actions.StartGPSStatus;
|
||||||
|
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||||
import net.osmand.plus.helpers.WaypointHelper;
|
import net.osmand.plus.helpers.WaypointHelper;
|
||||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
|
@ -407,7 +408,7 @@ public class MapInfoWidgetsFactory {
|
||||||
all.setOnClickListener(new View.OnClickListener() {
|
all.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
map.getMapActions().showWaypointsDialog(false);
|
map.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
btnN.setOnClickListener(new View.OnClickListener() {
|
btnN.setOnClickListener(new View.OnClickListener() {
|
||||||
|
|
Loading…
Reference in a new issue