Search in sources :

Example 36 with OsmandApplication

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

the class AppModeDialog method prepareAppModeView.

public static View prepareAppModeView(Activity a, final List<ApplicationMode> values, final Set<ApplicationMode> selected, ViewGroup parent, final boolean singleSelection, boolean useListBg, boolean useMapTheme, final View.OnClickListener onClickListener) {
    View ll = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
    boolean nightMode = isNightMode(((OsmandApplication) a.getApplication()), useMapTheme);
    if (useListBg) {
        AndroidUtils.setListItemBackground(a, ll, nightMode);
    } else {
        ll.setBackgroundColor(ContextCompat.getColor(a, nightMode ? R.color.route_info_bg_dark : R.color.route_info_bg_light));
    }
    final View[] buttons = new View[values.size()];
    int k = 0;
    for (ApplicationMode ma : values) {
        buttons[k++] = createToggle(a.getLayoutInflater(), (OsmandApplication) a.getApplication(), (LinearLayout) ll.findViewById(R.id.app_modes_content), ma, useMapTheme);
    }
    for (int i = 0; i < buttons.length; i++) {
        updateButtonState((OsmandApplication) a.getApplication(), values, selected, onClickListener, buttons, i, singleSelection, useMapTheme);
    }
    return ll;
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ApplicationMode(net.osmand.plus.ApplicationMode) ImageView(android.widget.ImageView) View(android.view.View) LinearLayout(android.widget.LinearLayout)

Example 37 with OsmandApplication

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

the class MapActivityLayers method showMultichoicePoiFilterDialog.

public void showMultichoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
    final OsmandApplication app = getApplication();
    final PoiFiltersHelper poiFilters = app.getPoiFilters();
    final ContextMenuAdapter adapter = new ContextMenuAdapter();
    final List<PoiUIFilter> list = new ArrayList<>();
    for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
        addFilterToList(adapter, list, f, true);
    }
    for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
        addFilterToList(adapter, list, f, true);
    }
    list.add(poiFilters.getCustomPOIFilter());
    final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final ListView listView = new ListView(activity);
    listView.setDivider(null);
    listView.setClickable(true);
    listView.setAdapter(listAdapter);
    listView.setOnItemClickListener(new ListView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            ContextMenuItem item = listAdapter.getItem(position);
            item.setSelected(!item.getSelected());
            item.getItemClickListener().onContextMenuClick(listAdapter, position, position, item.getSelected(), null);
            listAdapter.notifyDataSetChanged();
        }
    });
    builder.setView(listView).setTitle(R.string.show_poi_over_map).setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            for (int i = 0; i < listAdapter.getCount(); i++) {
                ContextMenuItem item = listAdapter.getItem(i);
                PoiUIFilter filter = list.get(i);
                if (item.getSelected()) {
                    getApplication().getPoiFilters().addSelectedPoiFilter(filter);
                } else {
                    getApplication().getPoiFilters().removeSelectedPoiFilter(filter);
                }
            }
            mapView.refreshMap();
        }
    }).setNegativeButton(R.string.shared_string_cancel, null).setNeutralButton(" ", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            showSingleChoicePoiFilterDialog(mapView, listener);
        }
    });
    final AlertDialog alertDialog = builder.create();
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
            Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_singleselect);
            neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
            neutralButton.setContentDescription(app.getString(R.string.shared_string_filters));
        }
    });
    alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            listener.dismiss();
        }
    });
    alertDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ListView(android.widget.ListView) Button(android.widget.Button)

Example 38 with OsmandApplication

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

the class MapActivityLayers method showSingleChoicePoiFilterDialog.

public void showSingleChoicePoiFilterDialog(final OsmandMapTileView mapView, final DismissListener listener) {
    final OsmandApplication app = getApplication();
    final PoiFiltersHelper poiFilters = app.getPoiFilters();
    final ContextMenuAdapter adapter = new ContextMenuAdapter();
    adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_search, app).setIcon(R.drawable.ic_action_search_dark).createItem());
    final List<PoiUIFilter> list = new ArrayList<>();
    list.add(poiFilters.getCustomPOIFilter());
    for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
        addFilterToList(adapter, list, f, false);
    }
    for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
        addFilterToList(adapter, list, f, false);
    }
    final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, app.getSettings().isLightContent());
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            PoiUIFilter pf = list.get(which);
            String filterId = pf.getFilterId();
            if (filterId.equals(PoiUIFilter.CUSTOM_FILTER_ID)) {
                if (activity.getDashboard().isVisible()) {
                    activity.getDashboard().hideDashboard();
                }
                activity.showQuickSearch(ShowQuickSearchMode.NEW, true);
            } else {
                getApplication().getPoiFilters().clearSelectedPoiFilters();
                getApplication().getPoiFilters().addSelectedPoiFilter(pf);
                mapView.refreshMap();
            }
        }
    });
    builder.setTitle(R.string.show_poi_over_map);
    builder.setNegativeButton(R.string.shared_string_dismiss, null);
    builder.setNeutralButton(" ", new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            showMultichoicePoiFilterDialog(mapView, listener);
        }
    });
    final AlertDialog alertDialog = builder.create();
    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
            Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
            neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
            neutralButton.setContentDescription(app.getString(R.string.apply_filters));
        }
    });
    alertDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            listener.dismiss();
        }
    });
    alertDialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) ContextMenuItem(net.osmand.plus.ContextMenuItem) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) Button(android.widget.Button)

Example 39 with OsmandApplication

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

the class NavigatePointFragment method onResume.

@Override
public void onResume() {
    super.onResume();
    OsmandApplication app = (OsmandApplication) getActivity().getApplication();
    LatLon loc = null;
    if (getActivity() instanceof SearchActivity) {
        loc = ((SearchActivity) getActivity()).getSearchPoint();
    }
    if (loc == null) {
        loc = app.getSettings().getLastKnownMapLocation();
    }
    if (!Algorithms.objectEquals(loc, location)) {
        location = loc;
        locationUpdate(location);
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) SearchActivity(net.osmand.plus.activities.search.SearchActivity)

Example 40 with OsmandApplication

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

the class ActionBarPreferenceActivity method onCreate.

@Override
protected void onCreate(final Bundle savedInstanceState) {
    // settings needed it's own theme because of check boxes not styled properly
    OsmandSettings settings = ((OsmandApplication) getApplication()).getSettings();
    int t = R.style.OsmandLightTheme_NoActionbar_Preferences;
    if (settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_DARK_THEME) {
        t = R.style.OsmandDarkTheme_NoActionbar_Preferences;
    } else if (settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME) {
        t = R.style.OsmandLightTheme_NoActionbar_Preferences;
    }
    setTheme(t);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.preference_activity);
    tb = (Toolbar) findViewById(R.id.toolbar);
    if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        shadowView = findViewById(R.id.shadowView);
        final ViewGroup parent = (ViewGroup) shadowView.getParent();
        parent.removeView(shadowView);
        shadowView = null;
    }
    tb.setClickable(true);
    tb.setNavigationIcon(((OsmandApplication) getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back));
    tb.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
    tb.setBackgroundColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTabBackground)));
    tb.setTitleTextColor(getResources().getColor(getResIdFromAttribute(this, R.attr.pstsTextColor)));
    tb.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(final View v) {
            finish();
        }
    });
    getSpinner().setVisibility(View.GONE);
    setProgressVisibility(false);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ViewGroup(android.view.ViewGroup) View(android.view.View) OsmandSettings(net.osmand.plus.OsmandSettings)

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