Add profile dialog to settings
This commit is contained in:
parent
f7aa832c9e
commit
812d010b13
8 changed files with 49 additions and 14 deletions
BIN
OsmAnd/res/drawable-hdpi/ic_browse_map.png
Normal file
BIN
OsmAnd/res/drawable-hdpi/ic_browse_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_browse_map.png
Normal file
BIN
OsmAnd/res/drawable-mdpi/ic_browse_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_browse_map.png
Normal file
BIN
OsmAnd/res/drawable-xhdpi/ic_browse_map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
|
@ -2,7 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<ToggleButton
|
||||
android:id="@+id/DefaultButton"
|
||||
|
|
|
@ -465,13 +465,17 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
|
||||
public static View showActivityActionsDialog(Activity a, AlertDialog.Builder builder, final Set<ApplicationMode> selected) {
|
||||
public static View showActivityActionsDialog(Activity a, final Set<ApplicationMode> selected, boolean showDefault) {
|
||||
View view = a.getLayoutInflater().inflate(R.layout.mode_toggles, null);
|
||||
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
||||
boolean lc = settings.isLightContentMenu();
|
||||
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
|
||||
buttons[ApplicationMode.DEFAULT.ordinal()] = (ToggleButton) view.findViewById(R.id.DefaultButton);
|
||||
buttons[ApplicationMode.DEFAULT.ordinal()].setButtonDrawable(R.drawable.ic_action_globus_light );
|
||||
if(showDefault) {
|
||||
buttons[ApplicationMode.DEFAULT.ordinal()] = (ToggleButton) view.findViewById(R.id.DefaultButton);
|
||||
buttons[ApplicationMode.DEFAULT.ordinal()].setButtonDrawable(R.drawable.ic_browse_map );
|
||||
} else {
|
||||
view.findViewById(R.id.DefaultButton).setVisibility(View.GONE);
|
||||
}
|
||||
buttons[ApplicationMode.CAR.ordinal()] = (ToggleButton) view.findViewById(R.id.CarButton);
|
||||
buttons[ApplicationMode.CAR.ordinal()].setButtonDrawable(R.drawable.ic_car );
|
||||
buttons[ApplicationMode.BICYCLE.ordinal()] = (ToggleButton) view.findViewById(R.id.BicycleButton);
|
||||
|
|
|
@ -3,9 +3,11 @@ package net.osmand.plus.activities;
|
|||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
|
@ -19,6 +21,7 @@ import android.app.AlertDialog;
|
|||
import android.app.AlertDialog.Builder;
|
||||
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;
|
||||
|
@ -28,6 +31,7 @@ import android.preference.Preference;
|
|||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.preference.Preference.OnPreferenceClickListener;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
@ -289,16 +293,7 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
|
|||
super.onResume();
|
||||
if (profileSettings) {
|
||||
previousAppMode = settings.getApplicationMode();
|
||||
int ind = 0;
|
||||
boolean found = false;
|
||||
for (ApplicationMode a : modes) {
|
||||
if (previousAppMode == a) {
|
||||
getSupportActionBar().setSelectedNavigationItem(ind);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
ind++;
|
||||
}
|
||||
boolean found = setSelectedAppMode(previousAppMode);
|
||||
if (!found) {
|
||||
getSupportActionBar().setSelectedNavigationItem(0);
|
||||
}
|
||||
|
@ -307,6 +302,37 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im
|
|||
}
|
||||
}
|
||||
|
||||
protected void profileDialog() {
|
||||
Builder b = new AlertDialog.Builder(this);
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
View v = MapActivityActions.showActivityActionsDialog(this, selected, false);
|
||||
b.setView(v);
|
||||
b.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if(selected.size() > 0) {
|
||||
setSelectedAppMode(selected.iterator().next());
|
||||
}
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
}
|
||||
|
||||
protected boolean setSelectedAppMode(ApplicationMode am) {
|
||||
int ind = 0;
|
||||
boolean found = false;
|
||||
for (ApplicationMode a : modes) {
|
||||
if (am == a) {
|
||||
getSupportActionBar().setSelectedNavigationItem(ind);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
ind++;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
|
|
|
@ -95,7 +95,11 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
|
||||
speakAlarms = (Preference) screen.findPreference("speak_routing_alarms");
|
||||
speakAlarms.setOnPreferenceClickListener(this);
|
||||
|
||||
profileDialog();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public class SettingsMonitoringActivity extends SettingsBaseActivity {
|
|||
if(REGISTER_BG_SETTINGS) {
|
||||
registerBackgroundSettings();
|
||||
}
|
||||
profileDialog();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue