Update UI
This commit is contained in:
parent
6422a8aa56
commit
1142ad4130
8 changed files with 179 additions and 73 deletions
|
@ -622,6 +622,8 @@ public class OsmandSettings {
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final CommonPreference<Boolean> USE_DASHBOARD_INSTEAD_OF_DRAWER = new BooleanPreference("use_dashboard_instead_of_drawer", true).makeGlobal().cache();
|
||||||
|
|
||||||
// this value string is synchronized with settings_pref.xml preference name
|
// this value string is synchronized with settings_pref.xml preference name
|
||||||
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
|
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
private WakeLockHelper wakeLockHelper;
|
private WakeLockHelper wakeLockHelper;
|
||||||
private boolean intentLocation = false;
|
private boolean intentLocation = false;
|
||||||
|
|
||||||
private DashboardOnMap dashboardOnMap;
|
private DashboardOnMap dashboardOnMap = new DashboardOnMap(this);
|
||||||
private AppInitializeListener initListener;
|
private AppInitializeListener initListener;
|
||||||
|
|
||||||
private Notification getNotification() {
|
private Notification getNotification() {
|
||||||
|
@ -143,7 +143,6 @@ public class MapActivity extends AccessibleActivity {
|
||||||
mapActions = new MapActivityActions(this);
|
mapActions = new MapActivityActions(this);
|
||||||
mapLayers = new MapActivityLayers(this);
|
mapLayers = new MapActivityLayers(this);
|
||||||
|
|
||||||
dashboardOnMap = new DashboardOnMap(this);
|
|
||||||
dashboardOnMap.createDashboardView();
|
dashboardOnMap.createDashboardView();
|
||||||
if (app.isApplicationInitializing()) {
|
if (app.isApplicationInitializing()) {
|
||||||
dashboardOnMap.setDashboardVisibility(true);
|
dashboardOnMap.setDashboardVisibility(true);
|
||||||
|
@ -484,17 +483,23 @@ public class MapActivity extends AccessibleActivity {
|
||||||
loc.setLatitude(mapView.getLatitude());
|
loc.setLatitude(mapView.getLatitude());
|
||||||
loc.setLongitude(mapView.getLongitude());
|
loc.setLongitude(mapView.getLongitude());
|
||||||
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
|
getMapActions().enterRoutePlanningMode(null, null, status == OsmandSettings.NAVIGATE_CURRENT_GPX);
|
||||||
}
|
if(dashboardOnMap.isVisible()) {
|
||||||
if (mapLabelToShow != null && latLonToShow != null) {
|
dashboardOnMap.setDashboardVisibility(false);
|
||||||
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
|
}
|
||||||
mapLayers.getContextMenuLayer().setLocation(latLonToShow,
|
|
||||||
mapLabelToShow.getFullPlainName(this, latLonToShow.getLatitude(), latLonToShow.getLongitude()));
|
|
||||||
}
|
|
||||||
if (latLonToShow != null && !latLonToShow.equals(cur)) {
|
|
||||||
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(), latLonToShow.getLongitude(),
|
|
||||||
settings.getMapZoomToShow(), true);
|
|
||||||
}
|
}
|
||||||
if (latLonToShow != null) {
|
if (latLonToShow != null) {
|
||||||
|
if(dashboardOnMap.isVisible()) {
|
||||||
|
dashboardOnMap.setDashboardVisibility(false);
|
||||||
|
}
|
||||||
|
if (mapLabelToShow != null) {
|
||||||
|
mapLayers.getContextMenuLayer().setSelectedObject(toShow);
|
||||||
|
mapLayers.getContextMenuLayer().setLocation(latLonToShow,
|
||||||
|
mapLabelToShow.getFullPlainName(this, latLonToShow.getLatitude(), latLonToShow.getLongitude()));
|
||||||
|
}
|
||||||
|
if (!latLonToShow.equals(cur)) {
|
||||||
|
mapView.getAnimatedDraggingThread().startMoving(latLonToShow.getLatitude(),
|
||||||
|
latLonToShow.getLongitude(), settings.getMapZoomToShow(), true);
|
||||||
|
}
|
||||||
// remember if map should come back to isMapLinkedToLocation=true
|
// remember if map should come back to isMapLinkedToLocation=true
|
||||||
mapViewTrackingUtilities.setMapLinkedToLocation(false);
|
mapViewTrackingUtilities.setMapLinkedToLocation(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,9 +701,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) {
|
||||||
// Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(true);
|
||||||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
// mapActivity.startActivity(newIntent);
|
|
||||||
mapActivity.getDashboard().setDashboardVisibility(true);
|
mapActivity.getDashboard().setDashboardVisibility(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -754,7 +752,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
@Override
|
@Override
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||||
enterRoutePlanningMode(null, null, false);
|
enterRoutePlanningMode(null, null, false);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}).reg();
|
}).reg();
|
||||||
} else if(routingHelper.isRouteCalculated()) {
|
} else if(routingHelper.isRouteCalculated()) {
|
||||||
|
@ -934,7 +932,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
return optionsMenuHelper;
|
return optionsMenuHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareConfigureScreen() {
|
public void prepareConfigureScreen() {
|
||||||
currentDrawer = DrawerType.CONFIGURE_SCREEN;
|
currentDrawer = DrawerType.CONFIGURE_SCREEN;
|
||||||
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
ContextMenuAdapter cm = mapActivity.getMapLayers().getMapInfoLayer().getViewConfigureMenuAdapter();
|
||||||
prepareOptionsMenu(cm);
|
prepareOptionsMenu(cm);
|
||||||
|
@ -1017,7 +1015,7 @@ public class MapActivityActions implements DialogProvider {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void whereAmIDialog() {
|
public void whereAmIDialog() {
|
||||||
final List<String> items = new ArrayList<String>();
|
final List<String> items = new ArrayList<String>();
|
||||||
items.add(getString(R.string.show_location));
|
items.add(getString(R.string.show_location));
|
||||||
items.add(getString(R.string.show_details));
|
items.add(getString(R.string.show_details));
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import net.osmand.plus.OsmandApplication;
|
import net.osmand.plus.OsmandApplication;
|
||||||
|
import net.osmand.plus.activities.MapActivity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Denis on 24.11.2014.
|
* Created by Denis on 24.11.2014.
|
||||||
*/
|
*/
|
||||||
public class DashBaseFragment extends Fragment {
|
public class DashBaseFragment extends Fragment {
|
||||||
|
|
||||||
|
private DashboardOnMap dashboard;
|
||||||
|
|
||||||
public OsmandApplication getMyApplication(){
|
public OsmandApplication getMyApplication(){
|
||||||
if (getActivity() == null){
|
if (getActivity() == null){
|
||||||
return null;
|
return null;
|
||||||
|
@ -15,4 +19,21 @@ public class DashBaseFragment extends Fragment {
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttach(Activity activity) {
|
||||||
|
super.onAttach(activity);
|
||||||
|
if(activity instanceof MapActivity) {
|
||||||
|
dashboard = ((MapActivity) activity).getDashboard();
|
||||||
|
dashboard.onAttach(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetach() {
|
||||||
|
super.onDetach();
|
||||||
|
if(dashboard != null) {
|
||||||
|
dashboard.onDetach(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,6 +105,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
||||||
private void updatePluginState(View pluginView, OsmandPlugin plugin) {
|
private void updatePluginState(View pluginView, OsmandPlugin plugin) {
|
||||||
CompoundButton enableDisableButton = (CompoundButton) pluginView.findViewById(R.id.plugin_enable_disable);
|
CompoundButton enableDisableButton = (CompoundButton) pluginView.findViewById(R.id.plugin_enable_disable);
|
||||||
Button getButton = (Button) pluginView.findViewById(R.id.get_plugin);
|
Button getButton = (Button) pluginView.findViewById(R.id.get_plugin);
|
||||||
|
enableDisableButton.setOnCheckedChangeListener(null);
|
||||||
if (plugin.needsInstallation()) {
|
if (plugin.needsInstallation()) {
|
||||||
getButton.setVisibility(View.VISIBLE);
|
getButton.setVisibility(View.VISIBLE);
|
||||||
enableDisableButton.setVisibility(View.GONE);
|
enableDisableButton.setVisibility(View.GONE);
|
||||||
|
@ -113,6 +114,7 @@ public class DashPluginsFragment extends DashBaseFragment {
|
||||||
enableDisableButton.setVisibility(View.VISIBLE);
|
enableDisableButton.setVisibility(View.VISIBLE);
|
||||||
enableDisableButton.setChecked(plugin.isActive());
|
enableDisableButton.setChecked(plugin.isActive());
|
||||||
}
|
}
|
||||||
|
setListener(plugin, enableDisableButton, pluginView);
|
||||||
|
|
||||||
ImageButton logoView = (ImageButton) pluginView.findViewById(R.id.plugin_logo);
|
ImageButton logoView = (ImageButton) pluginView.findViewById(R.id.plugin_logo);
|
||||||
if (plugin.isActive()) {
|
if (plugin.isActive()) {
|
||||||
|
@ -141,6 +143,11 @@ public class DashPluginsFragment extends DashBaseFragment {
|
||||||
enableDisableButton.setOnCheckedChangeListener(null);
|
enableDisableButton.setOnCheckedChangeListener(null);
|
||||||
updatePluginState(view, plugin);
|
updatePluginState(view, plugin);
|
||||||
final View pluginView = view;
|
final View pluginView = view;
|
||||||
|
setListener(plugin, enableDisableButton, pluginView);
|
||||||
|
container.addView(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setListener(final OsmandPlugin plugin, CompoundButton enableDisableButton, final View pluginView) {
|
||||||
enableDisableButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
enableDisableButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
@ -152,6 +159,5 @@ public class DashPluginsFragment extends DashBaseFragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
container.addView(view);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,22 @@
|
||||||
package net.osmand.plus.dashboard;
|
package net.osmand.plus.dashboard;
|
||||||
|
|
||||||
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.osmand.plus.OsmandApplication;
|
||||||
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.audionotes.DashAudioVideoNotesFragment;
|
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
|
||||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||||
import net.osmand.plus.monitoring.DashTrackFragment;
|
import net.osmand.plus.monitoring.DashTrackFragment;
|
||||||
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.views.controls.FloatingActionButton;
|
import net.osmand.plus.views.controls.FloatingActionButton;
|
||||||
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
|
@ -30,23 +40,26 @@ public class DashboardOnMap {
|
||||||
|
|
||||||
|
|
||||||
private static final int LIST_ID = 1;
|
private static final int LIST_ID = 1;
|
||||||
private static final int WAYPOINTS_ID = 2;
|
private static final int DIRECTIONS_ID = 2;
|
||||||
private static final int CONFIGURE_SCREEN_ID = 3;
|
private static final int CONFIGURE_SCREEN_ID = 3;
|
||||||
private static final int SETTINGS_ID = 4;
|
private static final int SETTINGS_ID = 4;
|
||||||
private MapActivity ma;
|
private MapActivity mapActivity;
|
||||||
FloatingActionButton fabButton;
|
FloatingActionButton fabButton;
|
||||||
boolean floatingButtonVisible = true;
|
boolean floatingButtonVisible = true;
|
||||||
private FrameLayout dashboardView;
|
private FrameLayout dashboardView;
|
||||||
private boolean visible = false;
|
private boolean visible = false;
|
||||||
|
private boolean landscape;
|
||||||
|
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>();
|
||||||
|
|
||||||
|
|
||||||
public DashboardOnMap(MapActivity ma) {
|
public DashboardOnMap(MapActivity ma) {
|
||||||
this.ma = ma;
|
this.mapActivity = ma;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void createDashboardView() {
|
public void createDashboardView() {
|
||||||
dashboardView = (FrameLayout) ma.getLayoutInflater().inflate(R.layout.dashboard_over_map, null, false);
|
landscape = !ScreenOrientationHelper.isOrientationPortrait(mapActivity);
|
||||||
|
dashboardView = (FrameLayout) mapActivity.getLayoutInflater().inflate(R.layout.dashboard_over_map, null, false);
|
||||||
dashboardView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
dashboardView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
|
||||||
ViewGroup.LayoutParams.MATCH_PARENT));
|
ViewGroup.LayoutParams.MATCH_PARENT));
|
||||||
View.OnClickListener listener = new View.OnClickListener() {
|
View.OnClickListener listener = new View.OnClickListener() {
|
||||||
|
@ -57,23 +70,29 @@ public class DashboardOnMap {
|
||||||
};
|
};
|
||||||
dashboardView.findViewById(R.id.content).setOnClickListener(listener);
|
dashboardView.findViewById(R.id.content).setOnClickListener(listener);
|
||||||
dashboardView.setOnClickListener(listener);
|
dashboardView.setOnClickListener(listener);
|
||||||
((FrameLayout) ma.findViewById(R.id.ParentLayout)).addView(dashboardView);
|
((FrameLayout) mapActivity.findViewById(R.id.ParentLayout)).addView(dashboardView);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||||
fabButton = new FloatingActionButton.Builder(ma)
|
fabButton = new FloatingActionButton.Builder(mapActivity)
|
||||||
.withDrawable(ma.getResources().getDrawable(R.drawable.ic_action_map))
|
.withDrawable(mapActivity.getResources().getDrawable(R.drawable.ic_action_map))
|
||||||
.withButtonColor(ma.getResources().getColor(R.color.color_myloc_distance)).withGravity(Gravity.TOP | Gravity.RIGHT)
|
.withButtonColor(mapActivity.getResources().getColor(R.color.color_myloc_distance))
|
||||||
.withMargins(0, 160, 16, 0).create();
|
.withGravity(landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT)
|
||||||
|
.withMargins(0, landscape ? 0 : 160, 16, landscape ? 16 : 0).create();
|
||||||
fabButton.setOnClickListener(new View.OnClickListener() {
|
fabButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
|
if (getMyApplication().accessibilityEnabled()) {
|
||||||
|
mapActivity.getMapActions().whereAmIDialog();
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||||
|
}
|
||||||
setDashboardVisibility(false);
|
setDashboardVisibility(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fabButton.hideFloatingActionButton();
|
fabButton.hideFloatingActionButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ScreenOrientationHelper.isOrientationPortrait(ma)) {
|
if (ScreenOrientationHelper.isOrientationPortrait(mapActivity)) {
|
||||||
((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll))
|
((NotifyingScrollView) dashboardView.findViewById(R.id.main_scroll))
|
||||||
.setOnScrollChangedListener(onScrollChangedListener);
|
.setOnScrollChangedListener(onScrollChangedListener);
|
||||||
}
|
}
|
||||||
|
@ -81,35 +100,40 @@ public class DashboardOnMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected OsmandApplication getMyApplication() {
|
||||||
|
return mapActivity.getMyApplication();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setDashboardVisibility(boolean visible) {
|
public void setDashboardVisibility(boolean visible) {
|
||||||
this.visible = visible;
|
this.visible = visible;
|
||||||
if (visible) {
|
if (visible) {
|
||||||
addDashboardFragments();
|
addOrUpdateDashboardFragments();
|
||||||
setupActionBar();
|
setupActionBar();
|
||||||
dashboardView.setVisibility(View.VISIBLE);
|
dashboardView.setVisibility(View.VISIBLE);
|
||||||
fabButton.showFloatingActionButton();
|
fabButton.showFloatingActionButton();
|
||||||
open(dashboardView.findViewById(R.id.animateContent));
|
open(dashboardView.findViewById(R.id.animateContent));
|
||||||
ma.getMapActions().disableDrawer();
|
mapActivity.getMapActions().disableDrawer();
|
||||||
ma.findViewById(R.id.MapInfoControls).setVisibility(View.GONE);
|
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.GONE);
|
||||||
ma.findViewById(R.id.MapButtons).setVisibility(View.GONE);
|
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ma.getMapActions().enableDrawer();
|
mapActivity.getMapActions().enableDrawer();
|
||||||
hide(dashboardView.findViewById(R.id.animateContent));
|
hide(dashboardView.findViewById(R.id.animateContent));
|
||||||
ma.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
|
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
|
||||||
ma.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
|
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
|
||||||
fabButton.hideFloatingActionButton();
|
fabButton.hideFloatingActionButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupActionBar() {
|
private void setupActionBar() {
|
||||||
final Toolbar tb = (Toolbar) ma.findViewById(R.id.bottomControls);
|
final Toolbar tb = (Toolbar) mapActivity.findViewById(R.id.bottomControls);
|
||||||
tb.setTitle(null);
|
tb.setTitle(null);
|
||||||
tb.getMenu().clear();
|
tb.getMenu().clear();
|
||||||
Menu menu = tb.getMenu();
|
Menu menu = tb.getMenu();
|
||||||
createMenuItem(menu, LIST_ID, R.string.drawer,
|
createMenuItem(menu, LIST_ID, R.string.drawer,
|
||||||
R.drawable.ic_flat_list_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
R.drawable.ic_dashboard_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
createMenuItem(menu, WAYPOINTS_ID, R.string.waypoints,
|
createMenuItem(menu, DIRECTIONS_ID, R.string.get_directions,
|
||||||
R.drawable.ic_action_flage_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
R.drawable.ic_action_gdirections_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
createMenuItem(menu, CONFIGURE_SCREEN_ID, R.string.layer_map_appearance,
|
createMenuItem(menu, CONFIGURE_SCREEN_ID, R.string.layer_map_appearance,
|
||||||
R.drawable.ic_configure_screen_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
R.drawable.ic_configure_screen_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||||
createMenuItem(menu, SETTINGS_ID, R.string.settings_activity,
|
createMenuItem(menu, SETTINGS_ID, R.string.settings_activity,
|
||||||
|
@ -134,13 +158,35 @@ public class DashboardOnMap {
|
||||||
|
|
||||||
|
|
||||||
protected boolean onOptionsItemSelected(MenuItem item) {
|
protected boolean onOptionsItemSelected(MenuItem item) {
|
||||||
return false;
|
setDashboardVisibility(false);
|
||||||
|
if(item.getItemId() == LIST_ID) {
|
||||||
|
getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.set(false);
|
||||||
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
|
} else if(item.getItemId() == DIRECTIONS_ID) {
|
||||||
|
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
|
||||||
|
if(!routingHelper.isFollowingMode() && !routingHelper.isRoutePlanningMode()) {
|
||||||
|
mapActivity.getMapActions().enterRoutePlanningMode(null, null, false);
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||||
|
mapActivity.refreshMap();
|
||||||
|
}
|
||||||
|
} else if(item.getItemId() == CONFIGURE_SCREEN_ID) {
|
||||||
|
mapActivity.getMapActions().prepareConfigureScreen();
|
||||||
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
|
return false;
|
||||||
|
} else if(item.getItemId() == SETTINGS_ID) {
|
||||||
|
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization().getSettingsActivity());
|
||||||
|
mapActivity.startActivity(settings);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// To animate view slide out from right to left
|
// To animate view slide out from right to left
|
||||||
private void open(View view){
|
private void open(View view){
|
||||||
TranslateAnimation animate = new TranslateAnimation(-ma.findViewById(R.id.ParentLayout).getWidth(),0,0,0);
|
TranslateAnimation animate = new TranslateAnimation(-mapActivity.findViewById(R.id.ParentLayout).getWidth(),0,0,0);
|
||||||
animate.setDuration(500);
|
animate.setDuration(500);
|
||||||
animate.setFillAfter(true);
|
animate.setFillAfter(true);
|
||||||
view.startAnimation(animate);
|
view.startAnimation(animate);
|
||||||
|
@ -148,7 +194,7 @@ public class DashboardOnMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void hide(View view) {
|
private void hide(View view) {
|
||||||
TranslateAnimation animate = new TranslateAnimation(0, -ma.findViewById(R.id.ParentLayout).getWidth(), 0, 0);
|
TranslateAnimation animate = new TranslateAnimation(0, -mapActivity.findViewById(R.id.ParentLayout).getWidth(), 0, 0);
|
||||||
animate.setDuration(500);
|
animate.setDuration(500);
|
||||||
animate.setFillAfter(true);
|
animate.setFillAfter(true);
|
||||||
animate.setAnimationListener(new AnimationListener() {
|
animate.setAnimationListener(new AnimationListener() {
|
||||||
|
@ -173,38 +219,43 @@ public class DashboardOnMap {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void addDashboardFragments() {
|
private void addOrUpdateDashboardFragments() {
|
||||||
FragmentManager manager = ma.getSupportFragmentManager();
|
FragmentManager manager = mapActivity.getSupportFragmentManager();
|
||||||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||||
if (manager.findFragmentByTag(DashErrorFragment.TAG) == null &&
|
showFragment(manager, fragmentTransaction, DashErrorFragment.TAG, DashErrorFragment.class,
|
||||||
ma.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(ma)) {
|
mapActivity.getMyApplication().getAppInitializer().checkPreviousRunsForExceptions(mapActivity));
|
||||||
DashErrorFragment errorFragment = new DashErrorFragment();
|
showFragment(manager, fragmentTransaction, DashSearchFragment.TAG, DashSearchFragment.class);
|
||||||
fragmentTransaction.add(R.id.content, errorFragment, DashErrorFragment.TAG);
|
showFragment(manager, fragmentTransaction, DashRecentsFragment.TAG, DashRecentsFragment.class);
|
||||||
}
|
showFragment(manager, fragmentTransaction, DashFavoritesFragment.TAG, DashFavoritesFragment.class);
|
||||||
if (manager.findFragmentByTag(DashSearchFragment.TAG) == null) {
|
showFragment(manager, fragmentTransaction, DashAudioVideoNotesFragment.TAG, DashAudioVideoNotesFragment.class);
|
||||||
fragmentTransaction.add(R.id.content, new DashSearchFragment(), DashSearchFragment.TAG);
|
showFragment(manager, fragmentTransaction, DashTrackFragment.TAG, DashTrackFragment.class);
|
||||||
}
|
// showFragment(manager, fragmentTransaction, DashUpdatesFragment.TAG, DashUpdatesFragment.class);
|
||||||
if (manager.findFragmentByTag(DashRecentsFragment.TAG) == null) {
|
showFragment(manager, fragmentTransaction, DashPluginsFragment.TAG, DashPluginsFragment.class);
|
||||||
fragmentTransaction.add(R.id.content, new DashRecentsFragment(), DashRecentsFragment.TAG);
|
|
||||||
}
|
|
||||||
if (manager.findFragmentByTag(DashFavoritesFragment.TAG) == null) {
|
|
||||||
fragmentTransaction.add(R.id.content, new DashFavoritesFragment(), DashFavoritesFragment.TAG);
|
|
||||||
}
|
|
||||||
if (manager.findFragmentByTag(DashAudioVideoNotesFragment.TAG) == null) {
|
|
||||||
fragmentTransaction.add(R.id.content, new DashAudioVideoNotesFragment(), DashAudioVideoNotesFragment.TAG);
|
|
||||||
}
|
|
||||||
if (manager.findFragmentByTag(DashTrackFragment.TAG) == null) {
|
|
||||||
fragmentTransaction.add(R.id.content, new DashTrackFragment(), DashTrackFragment.TAG);
|
|
||||||
}
|
|
||||||
// fragmentTransaction.add(R.id.content, new DashUpdatesFragment(), DashUpdatesFragment.TAG);
|
|
||||||
if (manager.findFragmentByTag(DashPluginsFragment.TAG) == null) {
|
|
||||||
fragmentTransaction.add(R.id.content, new DashPluginsFragment(), DashPluginsFragment.TAG);
|
|
||||||
}
|
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private <T extends Fragment> void showFragment(FragmentManager manager, FragmentTransaction fragmentTransaction,
|
||||||
|
String tag, Class<T> cl) {
|
||||||
|
showFragment(manager, fragmentTransaction, tag, cl, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T extends Fragment> void showFragment(FragmentManager manager, FragmentTransaction fragmentTransaction,
|
||||||
|
String tag, Class<T> cl, boolean cond) {
|
||||||
|
try {
|
||||||
|
if (manager.findFragmentByTag(tag) == null && cond) {
|
||||||
|
T ni = cl.newInstance();
|
||||||
|
fragmentTransaction.add(R.id.content, ni, tag);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
getMyApplication().showToastMessage("Error showing dashboard");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {
|
private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {
|
||||||
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
|
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
|
||||||
|
@ -213,11 +264,26 @@ public class DashboardOnMap {
|
||||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) fabButton.getLayoutParams();
|
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) fabButton.getLayoutParams();
|
||||||
lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy);
|
lp.topMargin = (int) Math.max(30 * scale, 160 * scale - sy);
|
||||||
((FrameLayout) fabButton.getParent()).updateViewLayout(fabButton, lp);
|
((FrameLayout) fabButton.getParent()).updateViewLayout(fabButton, lp);
|
||||||
// TODO
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
return visible;
|
return visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onDetach(DashBaseFragment dashBaseFragment) {
|
||||||
|
Iterator<WeakReference<DashBaseFragment>> it = fragList.iterator();
|
||||||
|
while(it.hasNext()) {
|
||||||
|
WeakReference<DashBaseFragment> wr = it.next();
|
||||||
|
if(wr.get() == dashBaseFragment) {
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void onAttach(DashBaseFragment dashBaseFragment) {
|
||||||
|
fragList.add(new WeakReference<DashBaseFragment>(dashBaseFragment));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,13 @@ public class MapMenuControls extends MapControls {
|
||||||
// double lat = activity.getMapView().getLatitude();
|
// double lat = activity.getMapView().getLatitude();
|
||||||
// double lon = activity.getMapView().getLongitude();
|
// double lon = activity.getMapView().getLongitude();
|
||||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||||
mapActivity.getMapActions().onDrawerBack();
|
|
||||||
mapActivity.getMapActions().toggleDrawer();
|
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
|
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
|
||||||
|
mapActivity.getDashboard().setDashboardVisibility(true);
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapActions().onDrawerBack();
|
||||||
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,12 @@ public class SmallMapMenuControls extends MapControls {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
mapActivity.getMapActions().onDrawerBack();
|
if(mapActivity.getMyApplication().getSettings().USE_DASHBOARD_INSTEAD_OF_DRAWER.get()) {
|
||||||
mapActivity.getMapActions().toggleDrawer();
|
mapActivity.getDashboard().setDashboardVisibility(true);
|
||||||
|
} else {
|
||||||
|
mapActivity.getMapActions().onDrawerBack();
|
||||||
|
mapActivity.getMapActions().toggleDrawer();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue