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