From 216b92efc46f5c1f9383335c773732c8781a508b Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 16 Jul 2013 01:52:49 +0200 Subject: [PATCH] Add profile dialog to settings --- OsmAnd/res/layout/mode_toggles.xml | 4 +++- .../plus/activities/MapActivityActions.java | 6 +++++- .../plus/activities/SettingsBaseActivity.java | 20 +++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/OsmAnd/res/layout/mode_toggles.xml b/OsmAnd/res/layout/mode_toggles.xml index 831daf0ea8..b60c9fab1d 100644 --- a/OsmAnd/res/layout/mode_toggles.xml +++ b/OsmAnd/res/layout/mode_toggles.xml @@ -2,7 +2,9 @@ + android:orientation="horizontal" android:layout_gravity="center_horizontal" android:gravity="center_horizontal" + android:layout_marginTop="7dp" + android:layout_marginBottom="7dp"> selected, boolean showDefault) { + public static View showActivityActionsDialog(Activity a, final Set selected, boolean showDefault, + final View.OnClickListener onClickListener) { View view = a.getLayoutInflater().inflate(R.layout.mode_toggles, null); OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings(); boolean lc = settings.isLightContentMenu(); @@ -523,6 +524,9 @@ public class MapActivityActions implements DialogProvider { buttons[ind].setChecked(true); } } + if(onClickListener != null) { + onClickListener.onClick(null); + } } }); } diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java index fbe45c9a0c..2ab794e2d3 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsBaseActivity.java @@ -21,7 +21,6 @@ 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; @@ -305,18 +304,17 @@ public abstract class SettingsBaseActivity extends SherlockPreferenceActivity im protected void profileDialog() { Builder b = new AlertDialog.Builder(this); final Set selected = new LinkedHashSet(); - View v = MapActivityActions.showActivityActionsDialog(this, selected, false); + View v = MapActivityActions.showActivityActionsDialog(this, selected, false, + new View.OnClickListener() { + @Override + public void onClick(View v) { + if(selected.size() > 0) { + setSelectedAppMode(selected.iterator().next()); + } + } + }); b.setTitle(R.string.profile_settings); 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(); }