use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class SearchPOIActivity method onItemClick.
@Override
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
final Amenity amenity = ((AmenityAdapter) getListAdapter()).getItem(position);
final OsmandSettings settings = app.getSettings();
String poiSimpleFormat = OsmAndFormatter.getPoiStringWithoutType(amenity, app.getSettings().MAP_PREFERRED_LOCALE.get(), app.getSettings().MAP_TRANSLITERATE_NAMES.get());
PointDescription name = new PointDescription(PointDescription.POINT_TYPE_POI, poiSimpleFormat);
int z = Math.max(16, settings.getLastKnownMapZoom());
LatLon location = amenity.getLocation();
settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), z, name, true, // $NON-NLS-1$
amenity);
MapActivity.launchMapActivityMoveToTop(this);
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class ConfigureMapDialogs method showMapModeDialog.
protected static void showMapModeDialog(@NonNull MapActivity activity, int themeRes, boolean nightMode) {
OsmandApplication app = activity.getMyApplication();
OsmandSettings settings = app.getSettings();
int selectedProfileColor = settings.APPLICATION_MODE.get().getProfileColor(nightMode);
final OsmandMapTileView view = activity.getMapView();
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
bld.setTitle(R.string.daynight);
final String[] items = new String[DayNightMode.values().length];
for (int i = 0; i < items.length; i++) {
items[i] = DayNightMode.values()[i].toHumanString(app);
}
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setNegativeButton(R.string.shared_string_dismiss, null);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(items, nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override
public void onClick(View v) {
int which = (int) v.getTag();
view.getSettings().DAYNIGHT_MODE.set(DayNightMode.values()[which]);
activity.refreshMapComplete();
activity.getDashboard().refreshContent(true);
}
});
bld.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(bld.show());
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class ConfigureMapDialogs method showMapMagnifierDialog.
protected static void showMapMagnifierDialog(MapActivity activity, ContextMenuAdapter adapter, int themeRes, boolean nightMode, int pos, ArrayAdapter<ContextMenuItem> ad) {
OsmandApplication app = activity.getMyApplication();
OsmandSettings settings = app.getSettings();
int selectedProfileColor = settings.APPLICATION_MODE.get().getProfileColor(nightMode);
final OsmandMapTileView view = activity.getMapView();
final OsmandPreference<Float> mapDensity = view.getSettings().MAP_DENSITY;
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
int p = (int) (mapDensity.get() * 100);
final TIntArrayList tlist = new TIntArrayList(new int[] { 25, 33, 50, 75, 100, 125, 150, 200, 300, 400 });
final List<String> values = new ArrayList<>();
int i = -1;
for (int k = 0; k <= tlist.size(); k++) {
final boolean end = k == tlist.size();
if (i == -1) {
if ((end || p < tlist.get(k))) {
values.add(p + " %");
i = k;
} else if (p == tlist.get(k)) {
i = k;
}
}
if (k < tlist.size()) {
values.add(tlist.get(k) + " %");
}
}
if (values.size() != tlist.size()) {
tlist.insert(i, p);
}
bld.setTitle(R.string.map_magnifier);
bld.setNegativeButton(R.string.shared_string_dismiss, null);
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(values.toArray(new String[0]), nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override
public void onClick(View v) {
int which = (int) v.getTag();
int p = tlist.get(which);
mapDensity.set(p / 100.0f);
view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
MapRendererContext mapContext = NativeCoreContext.getMapRendererContext();
if (mapContext != null) {
mapContext.updateMapSettings();
}
adapter.getItem(pos).setDescription(String.format(Locale.UK, "%.0f", 100f * activity.getMyApplication().getSettings().MAP_DENSITY.get()) + " %");
ad.notifyDataSetInvalidated();
}
});
bld.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(bld.show());
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class DashboardOnMap method addOrUpdateDashboardFragments.
private void addOrUpdateDashboardFragments() {
OsmandSettings settings = getMyApplication().getSettings();
TransactionBuilder builder = new TransactionBuilder(mapActivity.getSupportFragmentManager(), settings, mapActivity);
builder.addFragmentsData(fragmentsData).addFragmentsData(OsmandPlugin.getPluginsCardsList()).getFragmentTransaction().commitAllowingStateLoss();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class DashboardSettingsDialogFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
TypedValue typedValue = new TypedValue();
FragmentActivity activity = requireActivity();
boolean nightMode = isNightMode();
context = new ContextThemeWrapper(activity, !nightMode ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme);
Theme theme = context.getTheme();
theme.resolveAttribute(android.R.attr.textColorPrimary, typedValue, true);
textColorPrimary = typedValue.data;
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
textColorSecondary = typedValue.data;
final OsmandSettings settings = mapActivity.getMyApplication().getSettings();
final View showDashboardOnStart = createCheckboxItem(settings.SHOW_DASHBOARD_ON_START, R.string.show_on_start, R.string.show_on_start_description);
final View accessFromMap = createCheckboxItem(settings.SHOW_DASHBOARD_ON_MAP_SCREEN, R.string.access_from_map, R.string.access_from_map_description);
AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (savedInstanceState != null && savedInstanceState.containsKey(CHECKED_ITEMS)) {
mAdapter = new DashFragmentAdapter(context, mFragmentsData, savedInstanceState.getBooleanArray(CHECKED_ITEMS), savedInstanceState.getIntArray(NUMBER_OF_ROWS_ARRAY));
} else {
mAdapter = new DashFragmentAdapter(context, mFragmentsData, settings);
}
builder.setTitle(R.string.dahboard_options_dialog_title).setAdapter(mAdapter, null).setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int type) {
boolean[] shouldShow = mAdapter.getCheckedItems();
int[] numberOfRows = mAdapter.getNumbersOfRows();
for (int i = 0; i < shouldShow.length; i++) {
final DashFragmentData fragmentData = mFragmentsData.get(i);
settings.registerBooleanPreference(DashboardOnMap.SHOULD_SHOW + fragmentData.tag, true).makeGlobal().set(shouldShow[i]);
if (fragmentData.rowNumberTag != null) {
settings.registerIntPreference(fragmentData.rowNumberTag, DEFAULT_NUMBER_OF_ROWS).makeGlobal().set(numberOfRows[i]);
}
}
mapActivity.getDashboard().refreshDashboardFragments();
settings.SHOW_DASHBOARD_ON_START.set(((CompoundButton) showDashboardOnStart.findViewById(R.id.toggle_item)).isChecked());
settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(((CompoundButton) accessFromMap.findViewById(R.id.toggle_item)).isChecked());
mapActivity.getMapLayers().getMapControlsLayer().initDasboardRelatedControls();
}
}).setNegativeButton(R.string.shared_string_cancel, null);
final AlertDialog dialog = builder.create();
ListView listView = dialog.getListView();
listView.addHeaderView(showDashboardOnStart);
listView.addHeaderView(accessFromMap);
return dialog;
}
Aggregations