use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class NavAutoZoomMapAction method execute.
@Override
public void execute(@NonNull MapActivity mapActivity) {
OsmandSettings settings = mapActivity.getMyApplication().getSettings();
settings.AUTO_ZOOM_MAP.set(!settings.AUTO_ZOOM_MAP.get());
Toast.makeText(mapActivity, mapActivity.getString(!settings.AUTO_ZOOM_MAP.get() ? R.string.quick_action_auto_zoom_off : R.string.quick_action_auto_zoom_on), Toast.LENGTH_SHORT).show();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class SelectAppModesBottomSheetDialogFragment method onProfilePressed.
@Override
public void onProfilePressed(ApplicationMode appMode) {
OsmandSettings settings = getMyApplication().getSettings();
if (appMode != this.appMode) {
if (appModeChangeable) {
settings.setApplicationMode(appMode);
}
Fragment targetFragment = getTargetFragment();
if (targetFragment instanceof AppModeChangedListener) {
AppModeChangedListener listener = (AppModeChangedListener) targetFragment;
listener.onAppModeChanged(appMode);
}
}
dismiss();
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapLayers method updateLayers.
public void updateLayers(@Nullable MapActivity mapActivity) {
OsmandSettings settings = app.getSettings();
OsmandMapTileView mapView = app.getOsmandMap().getMapView();
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
OsmandPlugin.refreshLayers(app, mapActivity);
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class MapLayers method showGPXFileLayer.
public AlertDialog showGPXFileLayer(@NonNull List<String> files, final MapActivity mapActivity) {
final OsmandSettings settings = app.getSettings();
OsmandMapTileView mapView = mapActivity.getMapView();
DashboardOnMap dashboard = mapActivity.getDashboard();
CallbackWithObject<GPXFile[]> callbackWithObject = result -> {
WptPt locToShow = null;
for (GPXFile g : result) {
if (g.showCurrentTrack) {
if (!settings.SAVE_TRACK_TO_GPX.get() && !settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
app.showToastMessage(R.string.gpx_monitoring_disabled_warn);
}
break;
} else {
locToShow = g.findPointToShow();
}
}
app.getSelectedGpxHelper().setGpxFileToDisplay(result);
if (locToShow != null) {
mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getZoom(), true);
}
mapView.refreshMap();
dashboard.refreshContent(true);
return true;
};
return GpxUiHelper.selectGPXFiles(files, mapActivity, callbackWithObject, getThemeRes(), isNightMode());
}
use of net.osmand.plus.settings.backend.OsmandSettings in project Osmand by osmandapp.
the class WikivoyageExploreActivity method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
app = getMyApplication();
OsmandSettings settings = app.getSettings();
nightMode = !settings.isLightContent();
int themeId = nightMode ? R.style.OsmandDarkTheme_NoActionbar : R.style.OsmandLightTheme_NoActionbar_LightStatusBar;
app.getLocaleHelper().setLanguage(this);
setTheme(themeId);
super.onCreate(savedInstanceState);
setContentView(R.layout.wikivoyage_explore);
Window window = getWindow();
if (window != null) {
if (settings.DO_NOT_USE_ANIMATIONS.get()) {
window.getAttributes().windowAnimations = R.style.Animations_NoAnimation;
}
if (Build.VERSION.SDK_INT >= 21) {
window.setStatusBarColor(getResolvedColor(getStatusBarColor()));
}
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
Drawable icBack = getContentIcon(AndroidUtils.getNavigationIconResId(app));
toolbar.setNavigationIcon(icBack);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
findViewById(R.id.options_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fm = getSupportFragmentManager();
if (fm == null) {
return;
}
WikivoyageOptionsBottomSheetDialogFragment fragment = new WikivoyageOptionsBottomSheetDialogFragment();
fragment.setUsedOnMap(false);
fragment.show(fm, WikivoyageOptionsBottomSheetDialogFragment.TAG);
}
});
int searchColorId = ColorUtilities.getSecondaryTextColorId(nightMode);
((TextView) findViewById(R.id.search_hint)).setTextColor(getResolvedColor(searchColorId));
((ImageView) findViewById(R.id.search_icon)).setImageDrawable(getIcon(R.drawable.ic_action_search_dark, searchColorId));
findViewById(R.id.search_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
WikivoyageSearchDialogFragment.showInstance(getSupportFragmentManager());
}
});
viewPager = (LockableViewPager) findViewById(R.id.view_pager);
viewPager.setOffscreenPageLimit(2);
viewPager.setSwipeLocked(true);
setViewPagerAdapter(viewPager, new ArrayList<TabItem>());
OsmandFragmentPagerAdapter pagerAdapter = (OsmandFragmentPagerAdapter) viewPager.getAdapter();
if (pagerAdapter != null) {
pagerAdapter.addTab(getTabIndicator(R.string.shared_string_explore, ExploreTabFragment.class));
pagerAdapter.addTab(getTabIndicator(R.string.saved_articles, SavedArticlesTabFragment.class));
}
final ColorStateList navColorStateList = AndroidUtils.createBottomNavColorStateList(app, nightMode);
final BottomNavigationView bottomNav = (BottomNavigationView) findViewById(R.id.bottom_navigation);
bottomNav.setItemIconTintList(navColorStateList);
bottomNav.setItemTextColor(navColorStateList);
bottomNav.setOnNavigationItemSelectedListener(new OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int position = -1;
int i = item.getItemId();
if (i == R.id.action_explore) {
position = EXPLORE_POSITION;
} else if (i == R.id.action_saved_articles) {
position = SAVED_ARTICLES_POSITION;
}
if (position != -1 && position != viewPager.getCurrentItem()) {
viewPager.setCurrentItem(position);
return true;
}
return false;
}
});
updateSearchBarVisibility();
populateData(true);
}
Aggregations