Search in sources :

Example 81 with MapActivity

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);
}
Also used : CurrentRecording(net.osmand.plus.audionotes.AudioVideoNotesPlugin.CurrentRecording) LinearLayout(android.widget.LinearLayout) MapActivity(net.osmand.plus.activities.MapActivity)

Example 82 with MapActivity

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);
        }
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) CallbackWithObject(net.osmand.CallbackWithObject) TextView(android.widget.TextView) ImageView(android.widget.ImageView) MapActivity(net.osmand.plus.activities.MapActivity)

Example 83 with MapActivity

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;
}
Also used : Fragment(android.support.v4.app.Fragment) MapActivity(net.osmand.plus.activities.MapActivity)

Example 84 with MapActivity

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);
    }
}
Also used : MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) MapMultiSelectionMenu(net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu) MapActivity(net.osmand.plus.activities.MapActivity)

Example 85 with MapActivity

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();
}
Also used : Bundle(android.os.Bundle) Dialog(android.app.Dialog) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

MapActivity (net.osmand.plus.activities.MapActivity)85 View (android.view.View)39 ImageView (android.widget.ImageView)28 TextView (android.widget.TextView)28 RecyclerView (android.support.v7.widget.RecyclerView)15 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)14 AlertDialog (android.support.v7.app.AlertDialog)12 Nullable (android.support.annotation.Nullable)11 DialogInterface (android.content.DialogInterface)10 AdapterView (android.widget.AdapterView)9 LatLon (net.osmand.data.LatLon)9 OsmandApplication (net.osmand.plus.OsmandApplication)9 Bundle (android.os.Bundle)7 Button (android.widget.Button)7 EditText (android.widget.EditText)7 ImageButton (android.widget.ImageButton)7 FavouritePoint (net.osmand.data.FavouritePoint)7 Fragment (android.support.v4.app.Fragment)6 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)6 ViewTreeObserver (android.view.ViewTreeObserver)6