Search in sources :

Example 26 with OsmandSettings

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();
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 27 with OsmandSettings

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();
}
Also used : Fragment(androidx.fragment.app.Fragment) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 28 with OsmandSettings

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);
}
Also used : OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 29 with OsmandSettings

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());
}
Also used : FavouritesLayer(net.osmand.plus.views.layers.FavouritesLayer) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) ShowQuickSearchMode(net.osmand.plus.activities.MapActivity.ShowQuickSearchMode) NonNull(androidx.annotation.NonNull) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) R(net.osmand.plus.R) WptPt(net.osmand.GPXUtilities.WptPt) Drawable(android.graphics.drawable.Drawable) TransportStopsLayer(net.osmand.plus.views.layers.TransportStopsLayer) UiUtilities(net.osmand.plus.utils.UiUtilities) MapVectorLayer(net.osmand.plus.views.layers.MapVectorLayer) CallbackWithObject(net.osmand.CallbackWithObject) DownloadedRegionsLayer(net.osmand.plus.views.layers.DownloadedRegionsLayer) IndexConstants(net.osmand.IndexConstants) Map(java.util.Map) Button(android.widget.Button) GPXFile(net.osmand.GPXUtilities.GPXFile) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) PreviewRouteLineLayer(net.osmand.plus.views.layers.PreviewRouteLineLayer) DashboardOnMap(net.osmand.plus.dashboard.DashboardOnMap) RenderingIcons(net.osmand.plus.render.RenderingIcons) OsmandApplication(net.osmand.plus.OsmandApplication) StyleRes(androidx.annotation.StyleRes) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin) OsmandRasterMapsPlugin(net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin) List(java.util.List) DistanceRulerControlLayer(net.osmand.plus.views.layers.DistanceRulerControlLayer) MapWidgetRegistry(net.osmand.plus.views.mapwidgets.MapWidgetRegistry) Nullable(androidx.annotation.Nullable) Entry(java.util.Map.Entry) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) ImpassableRoadsLayer(net.osmand.plus.views.layers.ImpassableRoadsLayer) MapInfoLayer(net.osmand.plus.views.layers.MapInfoLayer) ListView(android.widget.ListView) MapQuickActionLayer(net.osmand.plus.views.layers.MapQuickActionLayer) PointNavigationLayer(net.osmand.plus.views.layers.PointNavigationLayer) DialogListItemAdapter(net.osmand.plus.DialogListItemAdapter) Context(android.content.Context) PoiFiltersHelper(net.osmand.plus.poi.PoiFiltersHelper) PointLocationLayer(net.osmand.plus.views.layers.PointLocationLayer) AlertDialog(androidx.appcompat.app.AlertDialog) TileSourceTemplate(net.osmand.map.TileSourceManager.TileSourceTemplate) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) RouteLayer(net.osmand.plus.views.layers.RouteLayer) MapMarkersLayer(net.osmand.plus.views.layers.MapMarkersLayer) GpxUiHelper(net.osmand.plus.helpers.GpxUiHelper) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) MeasurementToolLayer(net.osmand.plus.measurementtool.MeasurementToolLayer) Toast(android.widget.Toast) ContextMenuLayer(net.osmand.plus.views.layers.ContextMenuLayer) GPXLayer(net.osmand.plus.views.layers.GPXLayer) MapTileLayer(net.osmand.plus.views.layers.MapTileLayer) MapTextLayer(net.osmand.plus.views.layers.MapTextLayer) DialogInterface(android.content.DialogInterface) OsmandMapLayer(net.osmand.plus.views.layers.base.OsmandMapLayer) POIMapLayer(net.osmand.plus.views.layers.POIMapLayer) ITileSource(net.osmand.map.ITileSource) StateChangedListener(net.osmand.StateChangedListener) SQLiteTileSource(net.osmand.plus.resources.SQLiteTileSource) ContextThemeWrapper(androidx.appcompat.view.ContextThemeWrapper) ArrayAdapter(android.widget.ArrayAdapter) MapControlsLayer(net.osmand.plus.views.layers.MapControlsLayer) RoutingHelper(net.osmand.plus.routing.RoutingHelper) ContextMenuItem(net.osmand.plus.ContextMenuItem) RadiusRulerControlLayer(net.osmand.plus.views.layers.RadiusRulerControlLayer) ResultMatcher(net.osmand.ResultMatcher) MapActivity(net.osmand.plus.activities.MapActivity) WptPt(net.osmand.GPXUtilities.WptPt) GPXFile(net.osmand.GPXUtilities.GPXFile) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) DashboardOnMap(net.osmand.plus.dashboard.DashboardOnMap)

Example 30 with OsmandSettings

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);
}
Also used : Window(android.view.Window) Drawable(android.graphics.drawable.Drawable) ColorStateList(android.content.res.ColorStateList) OnNavigationItemSelectedListener(com.google.android.material.bottomnavigation.BottomNavigationView.OnNavigationItemSelectedListener) MenuItem(android.view.MenuItem) ImageView(android.widget.ImageView) View(android.view.View) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) FragmentManager(androidx.fragment.app.FragmentManager) BottomNavigationView(com.google.android.material.bottomnavigation.BottomNavigationView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Toolbar(androidx.appcompat.widget.Toolbar)

Aggregations

OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)154 OsmandApplication (net.osmand.plus.OsmandApplication)52 View (android.view.View)25 ArrayList (java.util.ArrayList)23 LatLon (net.osmand.data.LatLon)17 MapActivity (net.osmand.plus.activities.MapActivity)17 TextView (android.widget.TextView)16 NonNull (androidx.annotation.NonNull)16 AlertDialog (androidx.appcompat.app.AlertDialog)15 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)15 ArrayAdapter (android.widget.ArrayAdapter)13 ContextMenuItem (net.osmand.plus.ContextMenuItem)13 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)12 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)12 Context (android.content.Context)11 ImageView (android.widget.ImageView)11 Intent (android.content.Intent)8 List (java.util.List)8 PointDescription (net.osmand.data.PointDescription)8 DialogInterface (android.content.DialogInterface)7