Search in sources :

Example 26 with ApplicationMode

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

the class AvoidSpecificRoads method replaceImpassableRoad.

public void replaceImpassableRoad(final MapActivity activity, final RouteDataObject currentObject, final LatLon loc, final boolean showDialog, final AvoidSpecificRoadsCallback callback) {
    LatLon latLon = getLocation(currentObject);
    app.getSettings().moveImpassableRoad(latLon, loc);
    final Location ll = new Location("");
    ll.setLatitude(loc.getLatitude());
    ll.setLongitude(loc.getLongitude());
    ApplicationMode appMode = app.getRoutingHelper().getAppMode();
    app.getLocationProvider().getRouteSegment(ll, appMode, new ResultMatcher<RouteDataObject>() {

        @Override
        public boolean publish(RouteDataObject object) {
            if (object == null) {
                Toast.makeText(activity, R.string.error_avoid_specific_road, Toast.LENGTH_LONG).show();
                if (callback != null) {
                    callback.onAddImpassableRoad(false, null);
                }
            } else {
                app.getDefaultRoutingConfig().removeImpassableRoad(currentObject);
                addImpassableRoadInternal(object, ll, showDialog, activity, loc);
                if (callback != null) {
                    callback.onAddImpassableRoad(true, object);
                }
            }
            return true;
        }

        @Override
        public boolean isCancelled() {
            return callback != null && callback.isCancelled();
        }
    });
}
Also used : LatLon(net.osmand.data.LatLon) RouteDataObject(net.osmand.binary.RouteDataObject) ApplicationMode(net.osmand.plus.ApplicationMode) Location(net.osmand.Location)

Example 27 with ApplicationMode

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

the class SettingsGeneralActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    ((OsmandApplication) getApplication()).applyTheme(this);
    super.onCreate(savedInstanceState);
    getToolbar().setTitle(R.string.global_app_settings);
    addPreferencesFromResource(R.xml.general_settings);
    String[] entries;
    String[] entrieValues;
    PreferenceScreen screen = getPreferenceScreen();
    settings = getMyApplication().getSettings();
    ApplicationMode[] appModes = ApplicationMode.values(settings).toArray(new ApplicationMode[0]);
    entries = new String[appModes.length];
    for (int i = 0; i < entries.length; i++) {
        entries[i] = appModes[i].toHumanString(getMyApplication());
    }
    registerListPreference(settings.APPLICATION_MODE, screen, entries, appModes);
    // List preferences
    registerListPreference(settings.ROTATE_MAP, screen, new String[] { getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt) }, new Integer[] { OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS });
    registerListPreference(settings.MAP_SCREEN_ORIENTATION, screen, new String[] { getString(R.string.map_orientation_portrait), getString(R.string.map_orientation_landscape), getString(R.string.map_orientation_default) }, new Integer[] { ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED });
    drivingRegionPreference = screen.findPreference(settings.DRIVING_REGION.getId());
    addLocalPrefs((PreferenceGroup) screen.findPreference("localization"));
    addProxyPrefs((PreferenceGroup) screen.findPreference("proxy"));
    addMiscPreferences((PreferenceGroup) screen.findPreference("misc"));
    applicationModePreference = (ListPreference) screen.findPreference(settings.APPLICATION_MODE.getId());
    applicationModePreference.setOnPreferenceChangeListener(this);
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) PreferenceScreen(android.preference.PreferenceScreen) ApplicationMode(net.osmand.plus.ApplicationMode)

Example 28 with ApplicationMode

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

the class SettingsBaseActivity method onCreate.

@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    settings = getMyApplication().getSettings();
    getToolbar().setTitle(R.string.shared_string_settings);
    if (profileSettings) {
        modes.clear();
        for (ApplicationMode a : ApplicationMode.values(settings)) {
            if (a != ApplicationMode.DEFAULT) {
                modes.add(a);
            }
        }
        List<String> s = new ArrayList<String>();
        for (ApplicationMode a : modes) {
            s.add(a.toHumanString(getMyApplication()));
        }
        SpinnerAdapter spinnerAdapter = new SpinnerAdapter(this, R.layout.spinner_item, s);
        // android.R.layout.simple_spinner_dropdown_item
        spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
        getSpinner().setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

            @Override
            public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
                settings.APPLICATION_MODE.set(modes.get(position));
                updateAllSettings();
            }

            @Override
            public void onNothingSelected(AdapterView<?> parent) {
            }
        });
        getSpinner().setAdapter(spinnerAdapter);
        getSpinner().setVisibility(View.VISIBLE);
    }
    setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
}
Also used : ArrayList(java.util.ArrayList) AdapterView(android.widget.AdapterView) ApplicationMode(net.osmand.plus.ApplicationMode) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView)

Example 29 with ApplicationMode

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

the class SettingsBaseActivity method setSelectedAppMode.

protected boolean setSelectedAppMode(ApplicationMode am) {
    int ind = 0;
    boolean found = false;
    for (ApplicationMode a : modes) {
        if (am == a) {
            getSpinner().setSelection(ind);
            found = true;
            break;
        }
        ind++;
    }
    return found;
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Example 30 with ApplicationMode

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

the class SettingsBaseActivity method onResume.

@Override
protected void onResume() {
    super.onResume();
    if (profileSettings) {
        previousAppMode = settings.getApplicationMode();
        boolean found;
        if (getIntent() != null && getIntent().hasExtra(INTENT_APP_MODE)) {
            String modeStr = getIntent().getStringExtra(INTENT_APP_MODE);
            ApplicationMode mode = ApplicationMode.valueOfStringKey(modeStr, previousAppMode);
            found = setSelectedAppMode(mode);
        } else {
            found = setSelectedAppMode(previousAppMode);
        }
        if (!found) {
            getSpinner().setSelection(0);
        }
    } else {
        updateAllSettings();
    }
}
Also used : ApplicationMode(net.osmand.plus.ApplicationMode)

Aggregations

ApplicationMode (net.osmand.plus.ApplicationMode)41 View (android.view.View)13 TextView (android.widget.TextView)11 ImageView (android.widget.ImageView)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 OsmandSettings (net.osmand.plus.OsmandSettings)7 AlertDialog (android.support.v7.app.AlertDialog)6 ArrayList (java.util.ArrayList)6 DialogInterface (android.content.DialogInterface)5 AdapterView (android.widget.AdapterView)5 LatLon (net.osmand.data.LatLon)5 Intent (android.content.Intent)4 TargetPointsHelper (net.osmand.plus.TargetPointsHelper)4 TargetPoint (net.osmand.plus.TargetPointsHelper.TargetPoint)4 File (java.io.File)3 OsmandPreference (net.osmand.plus.OsmandSettings.OsmandPreference)3 RoutingHelper (net.osmand.plus.routing.RoutingHelper)3 OsmandMapTileView (net.osmand.plus.views.OsmandMapTileView)3 Uri (android.net.Uri)2 PreferenceCategory (android.preference.PreferenceCategory)2