Search in sources :

Example 91 with OsmandApplication

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

the class AddQuickActionDialog method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    OsmandApplication application = (OsmandApplication) getActivity().getApplication();
    boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
    return new Dialog(new ContextThemeWrapper(getActivity(), light ? R.style.Dialog90Light : R.style.Dialog90Dark), getTheme());
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) Dialog(android.app.Dialog) NonNull(android.support.annotation.NonNull)

Example 92 with OsmandApplication

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

the class EditPoiDialogFragment method showEditInstance.

public static void showEditInstance(final Amenity amenity, final AppCompatActivity activity) {
    final OsmandSettings settings = ((OsmandApplication) activity.getApplication()).getSettings();
    final OpenstreetmapUtil openstreetmapUtilToLoad;
    OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
    if (// settings.OFFLINE_EDITION.get() ||
    !settings.isInternetConnectionAvailable(true)) {
        openstreetmapUtilToLoad = plugin.getPoiModificationLocalUtil();
    } else {
        openstreetmapUtilToLoad = plugin.getPoiModificationRemoteUtil();
    }
    new AsyncTask<Void, Void, Node>() {

        @Override
        protected Node doInBackground(Void... params) {
            return openstreetmapUtilToLoad.loadNode(amenity);
        }

        protected void onPostExecute(Node n) {
            if (n != null) {
                EditPoiDialogFragment fragment = EditPoiDialogFragment.createInstance(n, false);
                fragment.show(activity.getSupportFragmentManager(), TAG);
            } else {
                Toast.makeText(activity, activity.getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show();
            }
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) Node(net.osmand.osm.edit.Node) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 93 with OsmandApplication

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

the class QuickActionsWidget method createPageView.

private View createPageView(ViewGroup container, int position) {
    OsmandApplication application = ((OsmandApplication) getContext().getApplicationContext());
    boolean light = application.getSettings().isLightContent() && !application.getDaynightHelper().isNightMode();
    LayoutInflater li = getLayoutInflater(light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
    View page = li.inflate(R.layout.quick_action_widget_page, container, false);
    GridLayout gridLayout = (GridLayout) page.findViewById(R.id.grid);
    final boolean land = !AndroidUiHelper.isOrientationPortrait((Activity) getContext());
    final int maxItems = actions.size() == 1 ? 1 : ELEMENT_PER_PAGE;
    for (int i = 0; i < maxItems; i++) {
        View view = li.inflate(R.layout.quick_action_widget_item, gridLayout, false);
        if (i + (position * ELEMENT_PER_PAGE) < actions.size()) {
            final QuickAction action = QuickActionFactory.produceAction(actions.get(i + (position * ELEMENT_PER_PAGE)));
            ((ImageView) view.findViewById(imageView)).setImageResource(action.getIconRes(getContext()));
            ((TextView) view.findViewById(R.id.title)).setText(action.getActionText(application));
            if (action.isActionWithSlash(application)) {
                ((ImageView) view.findViewById(R.id.imageSlash)).setImageResource(light ? R.drawable.ic_action_icon_hide_white : R.drawable.ic_action_icon_hide_dark);
            }
            view.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View view) {
                    if (selectionListener != null)
                        selectionListener.onActionSelected(action);
                }
            });
            if (action.isActionEditable()) {
                view.setOnLongClickListener(new OnLongClickListener() {

                    @Override
                    public boolean onLongClick(View v) {
                        CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.id);
                        dialog.show(((AppCompatActivity) getContext()).getSupportFragmentManager(), AddQuickActionDialog.TAG);
                        return true;
                    }
                });
            }
            if (!action.isActionEnable(application)) {
                view.setEnabled(false);
                view.setAlpha(0.5f);
            }
        }
        if (land) {
            view.findViewById(R.id.dividerBot).setVisibility(GONE);
            view.findViewById(R.id.dividerRight).setVisibility(VISIBLE);
        } else {
            view.findViewById(R.id.dividerBot).setVisibility(i < ELEMENT_PER_PAGE / 2 ? VISIBLE : GONE);
            view.findViewById(R.id.dividerRight).setVisibility(((i + 1) % 3) == 0 ? GONE : VISIBLE);
        }
        gridLayout.addView(view);
    }
    return gridLayout;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) AppCompatActivity(android.support.v7.app.AppCompatActivity) AppCompatActivity(android.support.v7.app.AppCompatActivity) Activity(android.app.Activity) ImageView(android.widget.ImageView) R.id.imageView(net.osmand.plus.R.id.imageView) View(android.view.View) TextView(android.widget.TextView) GridLayout(android.support.v7.widget.GridLayout) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) ImageView(android.widget.ImageView)

Example 94 with OsmandApplication

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

the class MapStyleAction method getOnAddBtnClickListener.

@Override
protected View.OnClickListener getOnAddBtnClickListener(final MapActivity activity, final Adapter adapter) {
    return new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            AlertDialog.Builder bld = new AlertDialog.Builder(activity);
            bld.setTitle(R.string.renderers);
            final OsmandApplication app = activity.getMyApplication();
            final List<String> visibleNamesList = new ArrayList<>();
            final ArrayList<String> items = new ArrayList<>(app.getRendererRegistry().getRendererNames());
            final boolean nauticalPluginDisabled = OsmandPlugin.getEnabledPlugin(NauticalMapsPlugin.class) == null;
            Iterator<String> iterator = items.iterator();
            while (iterator.hasNext()) {
                String item = iterator.next();
                if (nauticalPluginDisabled && item.equals(RendererRegistry.NAUTICAL_RENDER)) {
                    iterator.remove();
                } else {
                    String translation = RendererRegistry.getTranslatedRendererName(activity, item);
                    visibleNamesList.add(translation != null ? translation : item.replace('_', ' ').replace('-', ' '));
                }
            }
            final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(activity, R.layout.dialog_text_item);
            arrayAdapter.addAll(visibleNamesList);
            bld.setAdapter(arrayAdapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    String renderer = items.get(i);
                    RenderingRulesStorage loaded = app.getRendererRegistry().getRenderer(renderer);
                    if (loaded != null) {
                        adapter.addItem(renderer, activity);
                    }
                    dialogInterface.dismiss();
                }
            });
            bld.setNegativeButton(R.string.shared_string_dismiss, null);
            bld.show();
        }
    };
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) View(android.view.View) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) NauticalMapsPlugin(net.osmand.plus.openseamapsplugin.NauticalMapsPlugin) ArrayAdapter(android.widget.ArrayAdapter)

Example 95 with OsmandApplication

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

the class MapMarkersListAdapter method reloadData.

public void reloadData() {
    items.clear();
    OsmandApplication app = mapActivity.getMyApplication();
    myLoc = app.getLocationProvider().getLastStaleKnownLocation();
    showLocationItem = myLoc != null;
    inRoundTrip = app.getSettings().ROUTE_MAP_MARKERS_ROUND_TRIP.get();
    if (showLocationItem) {
        lookupLocationAddress(app);
        items.add(myLoc);
    }
    items.addAll(mapActivity.getMyApplication().getMapMarkersHelper().getMapMarkers());
    calculateStartAndFinishPos();
    showRoundTripItem = inRoundTrip && !inDragAndDrop && startPos != -1;
    if (showRoundTripItem) {
        items.add(finishPos, items.get(startPos));
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication)

Aggregations

OsmandApplication (net.osmand.plus.OsmandApplication)181 View (android.view.View)46 TextView (android.widget.TextView)39 ArrayList (java.util.ArrayList)33 AlertDialog (android.support.v7.app.AlertDialog)32 ImageView (android.widget.ImageView)31 DialogInterface (android.content.DialogInterface)27 OsmandSettings (net.osmand.plus.OsmandSettings)27 LatLon (net.osmand.data.LatLon)25 Intent (android.content.Intent)21 AdapterView (android.widget.AdapterView)19 File (java.io.File)17 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)15 Location (net.osmand.Location)13 EditText (android.widget.EditText)12 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)12 ArrayAdapter (android.widget.ArrayAdapter)11 ListView (android.widget.ListView)11 ContextMenuItem (net.osmand.plus.ContextMenuItem)11 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)11