Search in sources :

Example 16 with ApplicationMode

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

the class RoutePreferencesMenu method updateParameters.

private void updateParameters() {
    // ApplicationMode am = settings.APPLICATION_MODE.get();
    ApplicationMode am = routingHelper.getAppMode();
    listAdapter.setNotifyOnChange(false);
    listAdapter.clear();
    for (LocalRoutingParameter r : getRoutingParameters(am)) {
        listAdapter.add(r);
    }
    listAdapter.notifyDataSetChanged();
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Example 17 with ApplicationMode

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

the class SnapToRoadBottomSheetDialogFragment method setupDialog.

@Override
public void setupDialog(Dialog dialog, int style) {
    super.setupDialog(dialog, style);
    if (getMyApplication().getSettings().DO_NOT_USE_ANIMATIONS.get()) {
        dialog.getWindow().setWindowAnimations(R.style.Animations_NoAnimation);
    }
    nightMode = getMyApplication().getDaynightHelper().isNightModeForMapControls();
    portrait = AndroidUiHelper.isOrientationPortrait(getActivity());
    final OsmandSettings settings = getMyApplication().getSettings();
    final int themeRes = nightMode ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
    final View mainView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_snap_to_road_bottom_sheet_dialog, null);
    AndroidUtils.setBackground(getActivity(), mainView, nightMode, portrait ? R.drawable.bg_bottom_menu_light : R.drawable.bg_bottom_sheet_topsides_landscape_light, portrait ? R.drawable.bg_bottom_menu_dark : R.drawable.bg_bottom_sheet_topsides_landscape_dark);
    mainView.findViewById(R.id.cancel_row).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            dismiss();
        }
    });
    if (nightMode) {
        ((TextView) mainView.findViewById(R.id.choose_navigation_title)).setTextColor(ContextCompat.getColor(getActivity(), R.color.ctx_menu_info_text_dark));
    }
    LinearLayout container = (LinearLayout) mainView.findViewById(R.id.navigation_types_container);
    final List<ApplicationMode> modes = new ArrayList<>(ApplicationMode.values(settings));
    if (removeDefaultMode) {
        modes.remove(ApplicationMode.DEFAULT);
    }
    View.OnClickListener onClickListener = new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            snapToRoadEnabled = true;
            if (listener != null) {
                listener.onApplicationModeItemClick(modes.get((int) view.getTag()));
            }
            dismiss();
        }
    };
    for (int i = 0; i < modes.size(); i++) {
        ApplicationMode mode = modes.get(i);
        View row = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.list_item_icon_and_title, null);
        ((ImageView) row.findViewById(R.id.icon)).setImageDrawable(getContentIcon(mode.getSmallIconDark()));
        ((TextView) row.findViewById(R.id.title)).setText(mode.toHumanString(getContext()));
        row.setOnClickListener(onClickListener);
        row.setTag(i);
        container.addView(row);
    }
    if (!portrait) {
        dialog.setOnShowListener(new DialogInterface.OnShowListener() {

            @Override
            public void onShow(DialogInterface dialogInterface) {
                BottomSheetDialog dialog = (BottomSheetDialog) dialogInterface;
                FrameLayout bottomSheet = (FrameLayout) dialog.findViewById(android.support.design.R.id.design_bottom_sheet);
                BottomSheetBehavior.from(bottomSheet).setState(BottomSheetBehavior.STATE_EXPANDED);
            }
        });
    }
    dialog.setContentView(mainView);
    ((View) mainView.getParent()).setBackgroundResource(0);
}
Also used : DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) ApplicationMode(net.osmand.plus.ApplicationMode) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings) BottomSheetDialog(android.support.design.widget.BottomSheetDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) TextView(android.widget.TextView) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 18 with ApplicationMode

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

the class OsmandAidlApi method registerNavigateReceiver.

private void registerNavigateReceiver(final MapActivity mapActivity) {
    navigateReceiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            String profileStr = intent.getStringExtra(AIDL_PROFILE);
            final ApplicationMode profile = ApplicationMode.valueOfStringKey(profileStr, DEFAULT_PROFILE);
            boolean validProfile = false;
            for (ApplicationMode mode : VALID_PROFILES) {
                if (mode == profile) {
                    validProfile = true;
                    break;
                }
            }
            if (validProfile) {
                String startName = intent.getStringExtra(AIDL_START_NAME);
                if (Algorithms.isEmpty(startName)) {
                    startName = "";
                }
                String destName = intent.getStringExtra(AIDL_DEST_NAME);
                if (Algorithms.isEmpty(destName)) {
                    destName = "";
                }
                final LatLon start;
                final PointDescription startDesc;
                double startLat = intent.getDoubleExtra(AIDL_START_LAT, 0);
                double startLon = intent.getDoubleExtra(AIDL_START_LON, 0);
                if (startLat != 0 && startLon != 0) {
                    start = new LatLon(startLat, startLon);
                    startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
                } else {
                    start = null;
                    startDesc = null;
                }
                double destLat = intent.getDoubleExtra(AIDL_DEST_LAT, 0);
                double destLon = intent.getDoubleExtra(AIDL_DEST_LON, 0);
                final LatLon dest = new LatLon(destLat, destLon);
                final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName);
                final RoutingHelper routingHelper = app.getRoutingHelper();
                boolean force = intent.getBooleanExtra(AIDL_FORCE, true);
                if (routingHelper.isFollowingMode() && !force) {
                    AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
                    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {

                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            if (!routingHelper.isFollowingMode()) {
                                startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile);
                            }
                        }
                    });
                } else {
                    startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile);
                }
            }
        }
    };
    mapActivity.registerReceiver(navigateReceiver, new IntentFilter(AIDL_NAVIGATE));
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) IntentFilter(android.content.IntentFilter) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ApplicationMode(net.osmand.plus.ApplicationMode) RoutingHelper(net.osmand.plus.routing.RoutingHelper) BroadcastReceiver(android.content.BroadcastReceiver) LatLon(net.osmand.data.LatLon) PointDescription(net.osmand.data.PointDescription)

Example 19 with ApplicationMode

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

the class MeasurementToolFragment method createSnapToRoadFragmentListener.

private SnapToRoadFragmentListener createSnapToRoadFragmentListener() {
    return new SnapToRoadFragmentListener() {

        @Override
        public void onDestroyView(boolean snapToRoadEnabled) {
            if (!snapToRoadEnabled && !editingCtx.isInSnapToRoadMode()) {
                toolBarController.setTitle(previousToolBarTitle);
                MapActivity mapActivity = getMapActivity();
                if (mapActivity != null) {
                    mapActivity.refreshMap();
                }
            }
        }

        @Override
        public void onApplicationModeItemClick(ApplicationMode mode) {
            enableSnapToRoadMode(mode);
        }
    };
}
Also used : SnapToRoadFragmentListener(net.osmand.plus.measurementtool.SnapToRoadBottomSheetDialogFragment.SnapToRoadFragmentListener) ApplicationMode(net.osmand.plus.ApplicationMode) MapActivity(net.osmand.plus.activities.MapActivity)

Example 20 with ApplicationMode

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

the class MeasurementToolFragment method showSnapToRoadControls.

private void showSnapToRoadControls() {
    final MapActivity mapActivity = getMapActivity();
    final ApplicationMode appMode = editingCtx.getSnapToRoadAppMode();
    if (mapActivity != null && appMode != null) {
        toolBarController.setTopBarSwitchVisible(true);
        toolBarController.setTopBarSwitchChecked(true);
        mainIcon.setImageDrawable(getActiveIcon(R.drawable.ic_action_snap_to_road));
        ImageButton snapToRoadBtn = (ImageButton) mapActivity.findViewById(R.id.snap_to_road_image_button);
        snapToRoadBtn.setBackgroundResource(nightMode ? R.drawable.btn_circle_night : R.drawable.btn_circle);
        snapToRoadBtn.setImageDrawable(getActiveIcon(appMode.getMapIconId()));
        snapToRoadBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View view) {
                showSnapToRoadMenu(false);
            }
        });
        snapToRoadBtn.setVisibility(View.VISIBLE);
        mapActivity.refreshMap();
    }
}
Also used : ImageButton(android.widget.ImageButton) ApplicationMode(net.osmand.plus.ApplicationMode) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RecyclerView(android.support.v7.widget.RecyclerView) MapActivity(net.osmand.plus.activities.MapActivity)

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