Search in sources :

Example 1 with ApplicationMode

use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.

the class DashboardOnMap method setDashboardVisibility.

public void setDashboardVisibility(boolean visible, DashboardType type, DashboardType prevItem, boolean animation, int[] animationCoordinates) {
    if (visible == this.visible && type == visibleType) {
        return;
    }
    mapActivity.getRoutingHelper().removeListener(this);
    nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
    this.previousVisibleType = prevItem;
    this.visible = visible;
    ApplicationMode currentAppMode = getMyApplication().getSettings().APPLICATION_MODE.get();
    boolean appModeChanged = currentAppMode != previousAppMode;
    boolean refresh = this.visibleType == type && !appModeChanged;
    previousAppMode = currentAppMode;
    this.visibleType = type;
    DashboardOnMap.staticVisible = visible;
    DashboardOnMap.staticVisibleType = type;
    mapActivity.enableDrawer();
    if (swipeDismissListener != null) {
        swipeDismissListener.discardUndo();
    }
    removeMapillaryFiltersFragment();
    if (visible) {
        mapActivity.dismissCardDialog();
        mapActivity.getContextMenu().hideMenues();
        mapViewLocation = mapActivity.getMapLocation();
        mapRotation = mapActivity.getMapRotate();
        mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
        myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
        mapActivity.getMapViewTrackingUtilities().setDashboard(this);
        mapActivity.disableDrawer();
        dashboardView.setVisibility(View.VISIBLE);
        if (isActionButtonVisible()) {
            setActionButton(visibleType);
            actionButton.setVisibility(View.VISIBLE);
        } else {
            hideActionButton();
            if (visibleType == DashboardType.CONFIGURE_MAP) {
                int btnSizePx = mapActivity.getResources().getDimensionPixelSize(R.dimen.map_small_button_size);
                compassButton = mapActivity.getMapLayers().getMapControlsLayer().moveCompassButton(dashboardView, getActionButtonLayoutParams(btnSizePx), nightMode);
            }
        }
        updateDownloadBtn();
        View listViewLayout = dashboardView.findViewById(R.id.dash_list_view_layout);
        ScrollView scrollView = (ScrollView) dashboardView.findViewById(R.id.main_scroll);
        if (visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.MAPILLARY) {
            if (visibleType == DashboardType.DASHBOARD) {
                addOrUpdateDashboardFragments();
            } else {
                mapActivity.getSupportFragmentManager().beginTransaction().replace(R.id.content, new MapillaryFiltersFragment(), MapillaryFiltersFragment.TAG).commit();
            }
            scrollView.setVisibility(View.VISIBLE);
            scrollView.scrollTo(0, 0);
            listViewLayout.setVisibility(View.GONE);
            onScrollChanged(scrollView.getScrollY(), false, false);
        } else {
            scrollView.setVisibility(View.GONE);
            listViewLayout.setVisibility(View.VISIBLE);
            if (refresh) {
                refreshContent(false);
            } else {
                listView.scrollTo(0, 0);
                listView.clearParams();
                onScrollChanged(listView.getScrollY(), false, false);
                updateListAdapter();
            }
            updateListBackgroundHeight();
            applyDayNightMode();
        }
        mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
        mapActivity.getMapLayers().getMapControlsLayer().hideMapControls();
        boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
        if (!portrait) {
            AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), true);
            mapActivity.getMapView().setMapPositionX(1);
            mapActivity.refreshMap();
        }
        updateToolbarActions();
        // fabButton.showFloatingActionButton();
        open(animation, animationCoordinates);
        updateLocation(true, true, false);
        // addOrUpdateDashboardFragments();
        mapActivity.getRoutingHelper().addListener(this);
    } else {
        mapActivity.getMapViewTrackingUtilities().setDashboard(null);
        hide(animation);
        if (!MapRouteInfoMenu.isVisible()) {
            AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), false);
            mapActivity.getMapView().setMapPositionX(0);
            mapActivity.getMapView().refreshMap();
        }
        mapActivity.getMapLayers().getMapControlsLayer().showMapControlsIfHidden();
        hideActionButton();
        for (WeakReference<DashBaseFragment> df : fragList) {
            if (df.get() != null) {
                df.get().onCloseDash();
            }
        }
        OsmandSettings settings = getMyApplication().getSettings();
        if (settings.SHOW_MAPILLARY.get() && !settings.MAPILLARY_FIRST_DIALOG_SHOWN.get()) {
            MapillaryFirstDialogFragment fragment = new MapillaryFirstDialogFragment();
            fragment.show(mapActivity.getSupportFragmentManager(), MapillaryFirstDialogFragment.TAG);
            settings.MAPILLARY_FIRST_DIALOG_SHOWN.set(true);
        }
    }
    mapActivity.updateStatusBarColor();
}
Also used : ScrollView(android.widget.ScrollView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) MapillaryFirstDialogFragment(net.osmand.plus.mapillary.MapillaryPlugin.MapillaryFirstDialogFragment) ApplicationMode(net.osmand.plus.ApplicationMode) MapillaryFiltersFragment(net.osmand.plus.mapillary.MapillaryFiltersFragment) ImageView(android.widget.ImageView) DynamicListView(net.osmand.plus.views.controls.DynamicListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) ScrollView(android.widget.ScrollView) ObservableScrollView(com.github.ksoichiro.android.observablescrollview.ObservableScrollView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TargetPoint(net.osmand.plus.TargetPointsHelper.TargetPoint) SuppressLint(android.annotation.SuppressLint) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 2 with ApplicationMode

use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.

the class SettingsDevelopmentActivity method availableProfileDialog.

protected void availableProfileDialog() {
    AlertDialog.Builder b = new AlertDialog.Builder(this);
    final List<ApplicationMode> modes = ApplicationMode.allPossibleValues();
    modes.remove(ApplicationMode.DEFAULT);
    final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>(ApplicationMode.values(settings));
    selected.remove(ApplicationMode.DEFAULT);
    View v = AppModeDialog.prepareAppModeView(this, modes, selected, null, false, true, false, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            StringBuilder vls = new StringBuilder(ApplicationMode.DEFAULT.getStringKey() + ",");
            for (ApplicationMode mode : modes) {
                if (selected.contains(mode)) {
                    vls.append(mode.getStringKey()).append(",");
                }
            }
            settings.AVAILABLE_APP_MODES.set(vls.toString());
        }
    });
    b.setTitle(R.string.profile_settings);
    b.setPositiveButton(R.string.shared_string_ok, null);
    b.setView(v);
    b.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) LinkedHashSet(java.util.LinkedHashSet) ApplicationMode(net.osmand.plus.ApplicationMode) View(android.view.View)

Example 3 with ApplicationMode

use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.

the class SRTMPlugin method init.

@Override
public boolean init(final OsmandApplication app, Activity activity) {
    OsmandSettings settings = app.getSettings();
    CommonPreference<String> pref = settings.getCustomRenderProperty("contourLines");
    if (pref.get().equals("")) {
        for (ApplicationMode m : ApplicationMode.allPossibleValues()) {
            if (pref.getModeValue(m).equals("")) {
                pref.setModeValue(m, "13");
            }
        }
    }
    return true;
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 4 with ApplicationMode

use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.

the class MapActivityActions method stopNavigationWithoutConfirm.

public void stopNavigationWithoutConfirm() {
    getMyApplication().stopNavigation();
    mapActivity.updateApplicationModeSettings();
    mapActivity.getDashboard().clearDeletedPoints();
    List<ApplicationMode> modes = ApplicationMode.values(settings);
    for (ApplicationMode mode : modes) {
        if (settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(mode)) {
            settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, false);
            settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false).setModeValue(mode, false);
        }
    }
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Example 5 with ApplicationMode

use of net.osmand.plus.ApplicationMode in project Osmand by osmandapp.

the class MapActivityActions method recalculateRoute.

public void recalculateRoute(boolean showDialog) {
    settings.USE_INTERMEDIATE_POINTS_NAVIGATION.set(true);
    OsmandApplication app = mapActivity.getMyApplication();
    TargetPointsHelper targets = app.getTargetPointsHelper();
    ApplicationMode mode = getRouteMode(null);
    // app.getSettings().APPLICATION_MODE.set(mode);
    app.getRoutingHelper().setAppMode(mode);
    // Test for #2810: No need to init player here?
    // app.initVoiceCommandPlayer(mapActivity, true, null, false, false);
    // save application mode controls
    settings.FOLLOW_THE_ROUTE.set(false);
    app.getRoutingHelper().setFollowingMode(false);
    app.getRoutingHelper().setRoutePlanningMode(true);
    // reset start point
    targets.setStartPoint(null, false, null);
    // then update start and destination point
    targets.updateRouteAndRefresh(true);
    mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
    mapActivity.getMapView().refreshMap(true);
    if (showDialog) {
        mapActivity.getMapLayers().getMapControlsLayer().showDialog();
    }
    if (targets.hasTooLongDistanceToNavigate()) {
        app.showToastMessage(R.string.route_is_too_long_v2);
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ApplicationMode(net.osmand.plus.ApplicationMode) TargetPointsHelper(net.osmand.plus.TargetPointsHelper)

Aggregations

ApplicationMode (net.osmand.plus.ApplicationMode)41 View (android.view.View)13 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 OsmandSettings (net.osmand.plus.OsmandSettings)7 AlertDialog (android.support.v7.app.AlertDialog)6 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 AdapterView (android.widget.AdapterView)5 LatLon (net.osmand.data.LatLon)5 Intent (android.content.Intent)4 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)4 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)4 File (java.io.File)3 OsmandPreference (net.osmand.plus.OsmandSettings.OsmandPreference)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 Uri (android.net.Uri)2 PreferenceCategory (android.preference.PreferenceCategory)2