fix settings navigation no profiles crash
This commit is contained in:
parent
386041950c
commit
c5ae8a7373
3 changed files with 15 additions and 1 deletions
|
@ -11,6 +11,7 @@
|
||||||
Thx - Hardy
|
Thx - Hardy
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
<string name="turn_on_profile_desc">Please turn on at least one application profile, to use this setting.</string>
|
||||||
<string name="rendering_attr_winter_road_name">Winter road</string>
|
<string name="rendering_attr_winter_road_name">Winter road</string>
|
||||||
<string name="rendering_attr_ice_road_name">Ice road</string>
|
<string name="rendering_attr_ice_road_name">Ice road</string>
|
||||||
<string name="routeInfo_winter_ice_road_name">Winter and ice roads</string>
|
<string name="routeInfo_winter_ice_road_name">Winter and ice roads</string>
|
||||||
|
|
|
@ -339,6 +339,14 @@ public class OsmandSettings {
|
||||||
public ApplicationMode getApplicationMode() {
|
public ApplicationMode getApplicationMode() {
|
||||||
return APPLICATION_MODE.get();
|
return APPLICATION_MODE.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasAvailableApplicationMode() {
|
||||||
|
int currentModeCount = ApplicationMode.values(ctx).size();
|
||||||
|
if (currentModeCount == 0 || currentModeCount == 1 && getApplicationMode() == ApplicationMode.DEFAULT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
protected ApplicationMode readApplicationMode() {
|
protected ApplicationMode readApplicationMode() {
|
||||||
String s = settingsAPI.getString(globalPreferences, APPLICATION_MODE.getId(), ApplicationMode.DEFAULT.getStringKey());
|
String s = settingsAPI.getString(globalPreferences, APPLICATION_MODE.getId(), ApplicationMode.DEFAULT.getStringKey());
|
||||||
|
|
|
@ -25,6 +25,7 @@ import android.widget.ArrayAdapter;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
import android.widget.SeekBar.OnSeekBarChangeListener;
|
import android.widget.SeekBar.OnSeekBarChangeListener;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.plus.ApplicationMode;
|
import net.osmand.plus.ApplicationMode;
|
||||||
import net.osmand.plus.ContextMenuAdapter;
|
import net.osmand.plus.ContextMenuAdapter;
|
||||||
|
@ -81,6 +82,11 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
((OsmandApplication) getApplication()).applyTheme(this);
|
((OsmandApplication) getApplication()).applyTheme(this);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
settings = getMyApplication().getSettings();
|
||||||
|
if (!settings.hasAvailableApplicationMode()) {
|
||||||
|
Toast.makeText(this, R.string.turn_on_profile_desc, Toast.LENGTH_SHORT).show();
|
||||||
|
onBackPressed();
|
||||||
|
}
|
||||||
getToolbar().setTitle(R.string.routing_settings);
|
getToolbar().setTitle(R.string.routing_settings);
|
||||||
createUI();
|
createUI();
|
||||||
}
|
}
|
||||||
|
@ -98,7 +104,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
||||||
private void createUI() {
|
private void createUI() {
|
||||||
addPreferencesFromResource(R.xml.navigation_settings);
|
addPreferencesFromResource(R.xml.navigation_settings);
|
||||||
PreferenceScreen screen = getPreferenceScreen();
|
PreferenceScreen screen = getPreferenceScreen();
|
||||||
settings = getMyApplication().getSettings();
|
|
||||||
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
RouteService[] vls = RouteService.getAvailableRouters(getMyApplication());
|
||||||
String[] entries = new String[vls.length];
|
String[] entries = new String[vls.length];
|
||||||
for (int i = 0; i < entries.length; i++) {
|
for (int i = 0; i < entries.length; i++) {
|
||||||
|
|
Loading…
Reference in a new issue