Search in sources :

Example 76 with OsmandSettings

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

the class MapActivityLayers method showGPXFileLayer.

public AlertDialog showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
    final OsmandSettings settings = getApplication().getSettings();
    CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {

        @Override
        public boolean processResult(GPXFile[] 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()) {
                        Toast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_LONG).show();
                    }
                    break;
                } else {
                    locToShow = g.findPointToShow();
                }
            }
            getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
            if (locToShow != null) {
                mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getZoom(), true);
            }
            mapView.refreshMap();
            activity.getDashboard().refreshContent(true);
            return true;
        }
    };
    return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject);
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) CallbackWithObject(net.osmand.CallbackWithObject) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 77 with OsmandSettings

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

the class MapActivityLayers method updateMapSource.

public void updateMapSource(OsmandMapTileView mapView, CommonPreference<String> settingsToWarnAboutMap) {
    OsmandSettings settings = getApplication().getSettings();
    // update transparency
    int mapTransparency = settings.MAP_UNDERLAY.get() == null ? 255 : settings.MAP_TRANSPARENCY.get();
    mapTileLayer.setAlpha(mapTransparency);
    mapVectorLayer.setAlpha(mapTransparency);
    ITileSource newSource = settings.getMapTileSource(settings.MAP_TILE_SOURCES == settingsToWarnAboutMap);
    ITileSource oldMap = mapTileLayer.getMap();
    if (newSource != oldMap) {
        if (oldMap instanceof SQLiteTileSource) {
            ((SQLiteTileSource) oldMap).closeDB();
        }
        mapTileLayer.setMap(newSource);
    }
    boolean vectorData = !settings.MAP_ONLINE_DATA.get();
    mapTileLayer.setVisible(!vectorData);
    mapVectorLayer.setVisible(vectorData);
    if (vectorData) {
        mapView.setMainLayer(mapVectorLayer);
    } else {
        mapView.setMainLayer(mapTileLayer);
    }
}
Also used : ITileSource(net.osmand.map.ITileSource) OsmandSettings(net.osmand.plus.OsmandSettings) SQLiteTileSource(net.osmand.plus.SQLiteTileSource)

Example 78 with OsmandSettings

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

the class MapActivityLayers method updateLayers.

public void updateLayers(OsmandMapTileView mapView) {
    OsmandSettings settings = getApplication().getSettings();
    updateMapSource(mapView, settings.MAP_TILE_SOURCES);
    boolean showStops = settings.getCustomRenderBooleanProperty(OsmandSettings.TRANSPORT_STOPS_OVER_MAP).get();
    transportStopsLayer.setShowTransportStops(showStops);
    OsmandPlugin.refreshLayers(mapView, activity);
}
Also used : OsmandSettings(net.osmand.plus.OsmandSettings)

Example 79 with OsmandSettings

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

the class FavoritesListFragment method showOnMap.

public static void showOnMap(FavouritePoint point, Activity activity) {
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    final OsmandSettings settings = app.getSettings();
    LatLon location = new LatLon(point.getLatitude(), point.getLongitude());
    settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()), true, // $NON-NLS-1$
    point);
    MapActivity.launchMapActivityMoveToTop(activity);
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) PointDescription(net.osmand.data.PointDescription) OsmandSettings(net.osmand.plus.OsmandSettings)

Example 80 with OsmandSettings

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

the class SecondSplashScreenFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    OsmandApplication app = getMyApplication();
    OsmandSettings settings = app.getSettings();
    FragmentActivity activity = getActivity();
    RelativeLayout view = new RelativeLayout(activity);
    view.setOnClickListener(null);
    view.setBackgroundColor(getResources().getColor(R.color.map_background_color_light));
    ImageView logo = new ImageView(getContext());
    if (Version.isFreeVersion(app)) {
        logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand));
    } else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
        logo.setImageDrawable(getResources().getDrawable(R.drawable.ic_logo_splash_osmand_plus));
    }
    RelativeLayout.LayoutParams logoLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    logoLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    logoLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    ImageView text = new ImageView(activity);
    if (Version.isFreeVersion(app)) {
        if (settings.LIVE_UPDATES_PURCHASED.get()) {
            text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_osmlive));
        } else if (settings.FULL_VERSION_PURCHASED.get()) {
            text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_inapp));
        } else {
            text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand));
        }
    } else if (Version.isPaidVersion(app) || Version.isDeveloperVersion(app)) {
        if (settings.LIVE_UPDATES_PURCHASED.get()) {
            text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus_osmlive));
        } else {
            text.setImageDrawable(getResources().getDrawable(R.drawable.image_text_osmand_plus));
        }
    }
    RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    textLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    textLayoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
    int defaultLogoMarginTop = (int) getResources().getDimension(R.dimen.splash_screen_logo_top);
    int logoMarginTop = defaultLogoMarginTop - (Build.VERSION.SDK_INT >= 21 ? 0 : getStatusBarHeight());
    int logoPaddingLeft = 0;
    int logoPaddingRight = 0;
    int defaultTextMarginBottom = (int) getResources().getDimension(R.dimen.splash_screen_text_bottom);
    int textMarginBottom = defaultTextMarginBottom - getNavigationBarHeight();
    int textPaddingLeft = 0;
    int textPaddingRight = 0;
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N_MR1) {
        int screenOrientation = AndroidUiHelper.getScreenOrientation(activity);
        if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            logoPaddingLeft = getNavigationBarWidth();
            textPaddingLeft = getNavigationBarWidth();
        } else if (screenOrientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
            logoPaddingRight = getNavigationBarWidth();
            textPaddingRight = getNavigationBarWidth();
        }
    } else {
        logoPaddingLeft = getNavigationBarWidth();
        textPaddingLeft = getNavigationBarWidth();
    }
    logoLayoutParams.setMargins(0, logoMarginTop, 0, 0);
    logo.setPadding(logoPaddingLeft, 0, logoPaddingRight, 0);
    logo.setLayoutParams(logoLayoutParams);
    view.addView(logo);
    textLayoutParams.setMargins(0, 0, 0, textMarginBottom);
    text.setPadding(textPaddingLeft, 0, textPaddingRight, 0);
    text.setLayoutParams(textLayoutParams);
    view.addView(text);
    return view;
}
Also used : FragmentActivity(android.support.v4.app.FragmentActivity) OsmandApplication(net.osmand.plus.OsmandApplication) RelativeLayout(android.widget.RelativeLayout) ImageView(android.widget.ImageView) OsmandSettings(net.osmand.plus.OsmandSettings) Nullable(android.support.annotation.Nullable)

Aggregations

OsmandSettings (net.osmand.plus.OsmandSettings)91 View (android.view.View)27 OsmandApplication (net.osmand.plus.OsmandApplication)25 ArrayList (java.util.ArrayList)20 LatLon (net.osmand.data.LatLon)17 DialogInterface (android.content.DialogInterface)14 ArrayAdapter (android.widget.ArrayAdapter)14 TextView (android.widget.TextView)14 AlertDialog (android.support.v7.app.AlertDialog)11 ImageView (android.widget.ImageView)11 PointDescription (net.osmand.data.PointDescription)10 AdapterView (android.widget.AdapterView)9 ContextMenuAdapter (net.osmand.plus.ContextMenuAdapter)8 ContextMenuItem (net.osmand.plus.ContextMenuItem)8 ApplicationMode (net.osmand.plus.ApplicationMode)7 Paint (android.graphics.Paint)6 Pair (android.support.v4.util.Pair)6 ListView (android.widget.ListView)6 SpannableString (android.text.SpannableString)5 CompoundButton (android.widget.CompoundButton)5