diff --git a/OsmAnd/res/layout/preference_activity.xml b/OsmAnd/res/layout/preference_activity.xml
index 408c420c38..e00b04752d 100644
--- a/OsmAnd/res/layout/preference_activity.xml
+++ b/OsmAnd/res/layout/preference_activity.xml
@@ -35,6 +35,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
index 421fb4a9e0..4f8aa2b3a2 100644
--- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java
+++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java
@@ -470,10 +470,6 @@ public class ApplicationMode {
return routingProfile;
}
- public int getMapIconsSetId() {
- return mapIconsSetId;
- }
-
public String getUserProfileName() {
return userProfileName;
}
diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
index 36af56140b..3a603c85e3 100644
--- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
+++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java
@@ -482,6 +482,7 @@ public class GpxSelectionHelper {
public void loadGPXTracks(IProgress p) {
String load = app.getSettings().SELECTED_GPX.get();
+ LOG.debug("Saved selection:" + load);
if (!Algorithms.isEmpty(load)) {
try {
JSONArray ar = new JSONArray(load);
diff --git a/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java
index 9eec370077..e1bc125908 100644
--- a/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/ActionBarPreferenceActivity.java
@@ -9,8 +9,11 @@ import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
import android.widget.Spinner;
+import android.widget.TextView;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
@@ -56,6 +59,7 @@ public abstract class ActionBarPreferenceActivity extends AppCompatPreferenceAct
});
getSpinner().setVisibility(View.GONE);
+ getTypeButton().setVisibility(View.GONE);
setProgressVisibility(false);
}
@@ -81,6 +85,25 @@ public abstract class ActionBarPreferenceActivity extends AppCompatPreferenceAct
return (Spinner) findViewById(R.id.spinner_nav);
}
+ protected LinearLayout getTypeButton() {
+ return (LinearLayout) findViewById(R.id.type_selection_button);
+ }
+
+ protected TextView getModeTitleTV() {
+ return (TextView) findViewById(R.id.mode_title);
+ }
+
+ protected TextView getModeSubTitleTV() {
+ return (TextView) findViewById(R.id.mode_subtitle);
+ }
+
+ protected ImageView getModeIconIV() {
+ return (ImageView) findViewById(R.id.mode_icon);
+ }
+ protected ImageView getDropDownArrow() {
+ return (ImageView) findViewById(R.id.type_down_arrow);
+ }
+
protected void setProgressVisibility(boolean visibility) {
if (visibility) {
findViewById(R.id.ProgressBar).setVisibility(View.VISIBLE);
diff --git a/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java b/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java
index 2e8e66a679..91d2b688e5 100644
--- a/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/AppCompatPreferenceActivity.java
@@ -14,6 +14,7 @@
* limitations under the License.
*/
package net.osmand.plus.activities;
+import android.app.FragmentManager;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.PreferenceActivity;
diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
index d1f251407f..ea4711a97d 100644
--- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
+++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java
@@ -2,6 +2,7 @@ package net.osmand.plus.activities;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -13,6 +14,7 @@ import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.support.v7.app.AlertDialog;
+import android.support.v7.app.AlertDialog.Builder;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@@ -28,6 +30,7 @@ import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.OsmandPreference;
import net.osmand.plus.R;
import net.osmand.plus.activities.actions.AppModeDialog;
+import net.osmand.plus.profiles.BaseProfile;
import net.osmand.plus.views.SeekBarPreference;
import java.lang.reflect.Field;
@@ -38,6 +41,7 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import net.osmand.util.Algorithms;
public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
@@ -48,6 +52,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
protected OsmandSettings settings;
protected final boolean profileSettings;
protected List modes = new ArrayList();
+ protected final ArrayList appModes = new ArrayList<>();
private ApplicationMode previousAppMode;
private Map screenPreferences = new LinkedHashMap();
@@ -328,7 +333,6 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
settings = app.getSettings();
getToolbar().setTitle(R.string.shared_string_settings);
-
if (profileSettings) {
modes.clear();
for (ApplicationMode a : ApplicationMode.values(app)) {
@@ -336,52 +340,63 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
modes.add(a);
}
}
- List s = new ArrayList();
- for (ApplicationMode a : modes) {
- s.add(a.toHumanString(app));
- }
- 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();
- }
+ updateModeButton(settings.APPLICATION_MODE.get());
+ //--------------------------
+ getTypeButton().setVisibility(View.VISIBLE);
+ getTypeButton().setOnClickListener(new View.OnClickListener() {
@Override
- public void onNothingSelected(AdapterView> parent) {
-
+ public void onClick(View v) {
+ AlertDialog.Builder singleSelectDialogBuilder = new Builder(SettingsBaseActivity.this);
+ singleSelectDialogBuilder.setTitle("Select App Profile");
+ final ArrayAdapter modeNames = new ArrayAdapter<>(
+ SettingsBaseActivity.this, android.R.layout.select_dialog_singlechoice);
+ for (ApplicationMode am : modes) {
+ modeNames.add(am.toHumanString(SettingsBaseActivity.this));
+ }
+ singleSelectDialogBuilder.setNegativeButton(R.string.shared_string_cancel,
+ new OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.dismiss();
+ }
+ });
+ singleSelectDialogBuilder.setAdapter(modeNames, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ settings.APPLICATION_MODE.set(modes.get(which));
+ updateModeButton(modes.get(which));
+ updateAllSettings();
+ }
+ });
+ singleSelectDialogBuilder.show();
}
});
- getSpinner().setAdapter(spinnerAdapter);
- getSpinner().setVisibility(View.VISIBLE);
+
}
setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
}
+ void updateModeButton(ApplicationMode mode) {
+ String title = Algorithms.isEmpty(mode.getUserProfileName())
+ ? mode.toHumanString(SettingsBaseActivity.this)
+ : mode.getUserProfileName();
+ String subtitle = mode.getParent() == null
+ ? "Mode: " + Algorithms.capitalizeFirstLetterAndLowercase(mode.getStringKey().replace("_", ""))
+ : "User Mode, derived from: " + Algorithms
+ .capitalizeFirstLetterAndLowercase(mode.getParent().getStringKey());
+ getModeTitleTV().setText(title);
+ getModeSubTitleTV().setText(subtitle);
+ getModeIconIV().setImageDrawable(getMyApplication().getUIUtilities().getIcon(mode.getSmallIconDark(),
+ getMyApplication().getSettings().isLightContent()
+ ? R.color.active_buttons_and_links_light
+ : R.color.active_buttons_and_links_dark));
+ getDropDownArrow().setImageDrawable(getMyApplication().getUIUtilities().getIcon(R.drawable.ic_action_arrow_drop_down,
+ getMyApplication().getSettings().isLightContent()
+ ? R.color.active_buttons_and_links_light
+ : R.color.active_buttons_and_links_dark));
- class SpinnerAdapter extends ArrayAdapter{
-
-
- public SpinnerAdapter(Context context, int resource, List objects) {
- super(context, resource, objects);
- }
-
- @Override
- public View getDropDownView(int position, View convertView, ViewGroup parent) {
- View view = super.getDropDownView(position, convertView, parent);
- if (!settings.isLightActionBar()){
- TextView textView = (TextView) view.findViewById(android.R.id.text1);
- textView.setBackgroundColor(getResources().getColor(R.color.actionbar_dark_color));
- }
- return view;
- }
- }
-
-
+ }
@Override
protected void onResume() {
@@ -431,7 +446,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
boolean found = false;
for (ApplicationMode a : modes) {
if (am == a) {
- getSpinner().setSelection(ind);
+ updateModeButton(a);
found = true;
break;
}
@@ -541,7 +556,7 @@ public abstract class SettingsBaseActivity extends ActionBarPreferenceActivity
}
-
+
public void showBooleanSettings(String[] vals, final OsmandPreference[] prefs) {
AlertDialog.Builder bld = new AlertDialog.Builder(this);