use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class AudioVideoNoteRecordingMenu method applyViewfinderVisibility.
protected void applyViewfinderVisibility() {
MapActivity mapActivity = plugin.getMapActivity();
CurrentRecording recording = plugin.getCurrentRecording();
boolean show = showViewfinder && recording != null && recording.getType() != AVActionType.REC_AUDIO;
if (isLandscapeLayout() && mapActivity != null) {
int buttonsHeight = (int) view.getResources().getDimension(R.dimen.map_route_buttons_height);
int tileBoxHeight = mapActivity.getMapView().getCurrentRotatedTileBox().getPixHeight();
int h = show ? tileBoxHeight : buttonsHeight;
view.setLayoutParams(new LinearLayout.LayoutParams(AndroidUtils.dpToPx(mapActivity, 320f), h));
view.requestLayout();
}
viewfinder.setVisibility(show ? View.VISIBLE : View.GONE);
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class OsmandApplication method initVoiceCommandPlayer.
public void initVoiceCommandPlayer(final Activity uiContext, ApplicationMode applicationMode, boolean warningNoneProvider, Runnable run, boolean showDialog, boolean force) {
String voiceProvider = osmandSettings.VOICE_PROVIDER.get();
if (voiceProvider == null || OsmandSettings.VOICE_PROVIDER_NOT_USE.equals(voiceProvider)) {
if (warningNoneProvider && voiceProvider == null) {
final AlertDialog.Builder builder = new AlertDialog.Builder(uiContext);
View view = uiContext.getLayoutInflater().inflate(R.layout.select_voice_first, null);
((ImageView) view.findViewById(R.id.icon)).setImageDrawable(getIconsCache().getIcon(R.drawable.ic_action_volume_up, getSettings().isLightContent()));
view.findViewById(R.id.spinner).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
RoutePreferencesMenu.selectVoiceGuidance((MapActivity) uiContext, new CallbackWithObject<String>() {
@Override
public boolean processResult(String result) {
boolean acceptableValue = !RoutePreferencesMenu.MORE_VALUE.equals(firstSelectedVoiceProvider);
if (acceptableValue) {
((TextView) v.findViewById(R.id.selectText)).setText(RoutePreferencesMenu.getVoiceProviderName(uiContext, result));
firstSelectedVoiceProvider = result;
}
return acceptableValue;
}
});
}
});
((ImageView) view.findViewById(R.id.dropDownIcon)).setImageDrawable(getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, getSettings().isLightContent()));
builder.setCancelable(true);
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!Algorithms.isEmpty(firstSelectedVoiceProvider)) {
RoutePreferencesMenu.applyVoiceProvider((MapActivity) uiContext, firstSelectedVoiceProvider);
}
}
});
builder.setNeutralButton(R.string.shared_string_do_not_use, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
osmandSettings.VOICE_PROVIDER.set(OsmandSettings.VOICE_PROVIDER_NOT_USE);
}
});
builder.setView(view);
builder.show();
}
} else {
if (player == null || !Algorithms.objectEquals(voiceProvider, player.getCurrentVoice()) || force) {
appInitializer.initVoiceDataInDifferentThread(uiContext, applicationMode, voiceProvider, run, showDialog);
}
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class OsmandPlugin method enablePlugin.
public static boolean enablePlugin(Activity activity, OsmandApplication app, OsmandPlugin plugin, boolean enable) {
if (enable) {
if (!plugin.init(app, activity)) {
plugin.setActive(false);
return false;
} else {
plugin.setActive(true);
}
} else {
plugin.disable(app);
plugin.setActive(false);
}
app.getSettings().enablePlugin(plugin.getId(), enable);
if (activity instanceof MapActivity) {
final MapActivity mapActivity = (MapActivity) activity;
plugin.updateLayers(mapActivity.getMapView(), mapActivity);
mapActivity.getDashboard().refreshDashboardFragments();
if (!enable && plugin.getCardFragment() != null) {
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(plugin.getCardFragment().tag);
LOG.debug("fragment=" + fragment);
mapActivity.getSupportFragmentManager().beginTransaction().remove(fragment).commit();
}
}
return true;
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class DownloadedRegionsLayer method collectObjectsFromPoint.
// IContextMenuProvider
@Override
public void collectObjectsFromPoint(PointF point, RotatedTileBox tileBox, List<Object> objects, boolean unknownLocation) {
boolean isMenuVisible = false;
if (view.getContext() instanceof MapActivity) {
MapActivity mapActivity = (MapActivity) view.getContext();
MapContextMenu menu = mapActivity.getContextMenu();
MapMultiSelectionMenu multiMenu = menu.getMultiSelectionMenu();
isMenuVisible = menu.isVisible() || multiMenu.isVisible();
}
if (!isMenuVisible) {
getWorldRegionFromPoint(tileBox, point, objects);
}
}
use of net.osmand.plus.activities.MapActivity in project Osmand by osmandapp.
the class ParkingTypeBottomSheetDialogFragment method addParkingPosition.
private void addParkingPosition(boolean limited) {
ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
if (plugin != null) {
MapActivity mapActivity = (MapActivity) getActivity();
Bundle args = getArguments();
double latitude = args.getDouble(LAT_KEY);
double longitude = args.getDouble(LON_KEY);
if (plugin.isParkingEventAdded()) {
plugin.showDeleteEventWarning(mapActivity);
}
if (limited) {
plugin.setParkingPosition(mapActivity, latitude, longitude, true);
plugin.showSetTimeLimitDialog(mapActivity, new Dialog(getContext()));
mapActivity.refreshMap();
} else {
plugin.addOrRemoveParkingEvent(false);
plugin.setParkingPosition(mapActivity, latitude, longitude, false);
plugin.showContextMenuIfNeeded(mapActivity, true);
mapActivity.refreshMap();
}
}
dismiss();
}
Aggregations