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();
}
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);
}
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));
}
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);
}
};
}
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();
}
}
Aggregations