Add selection dialog
This commit is contained in:
parent
326b4f1e0b
commit
9cbfb9aba8
4 changed files with 52 additions and 14 deletions
15
OsmAnd/res/layout/configuration_dialog.xml
Normal file
15
OsmAnd/res/layout/configuration_dialog.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"
|
||||
android:id="@+id/TopBar"/>
|
||||
<ListView
|
||||
android:id="@android:id/list"
|
||||
style="@style/OsmandListView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" >
|
||||
</ListView>
|
||||
|
||||
</LinearLayout>
|
|
@ -67,6 +67,7 @@ import android.text.Html;
|
|||
import android.util.FloatMath;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Button;
|
||||
|
@ -465,9 +466,9 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
|
||||
public static View showActivityActionsDialog(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
|
||||
final View.OnClickListener onClickListener) {
|
||||
View view = a.getLayoutInflater().inflate(R.layout.mode_toggles, null);
|
||||
public static View prepareAppModeView(Activity a, final Set<ApplicationMode> selected, boolean showDefault,
|
||||
ViewGroup parent, final View.OnClickListener onClickListener) {
|
||||
View view = a.getLayoutInflater().inflate(R.layout.mode_toggles, parent);
|
||||
OsmandSettings settings = ((OsmandApplication) a.getApplication()).getSettings();
|
||||
boolean lc = settings.isLightContentMenu();
|
||||
final ToggleButton[] buttons = new ToggleButton[ApplicationMode.values().length];
|
||||
|
|
|
@ -305,7 +305,7 @@ 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,
|
||||
View v = MapActivityActions.prepareAppModeView(this, selected, false, null,
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityActions;
|
||||
import net.osmand.plus.activities.SettingsActivity;
|
||||
import net.osmand.plus.extrasettings.OsmandExtraSettings;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
|
@ -53,9 +54,12 @@ import android.view.View;
|
|||
import android.view.View.MeasureSpec;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ListView;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
@ -497,7 +501,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
final ArrayList<Object> list = new ArrayList<Object>();
|
||||
String appMode = settings.getApplicationMode().toHumanString(view.getApplication());
|
||||
list.add(map.getString(R.string.map_widget_reset) + " [" + appMode +"] ");
|
||||
list.add(map.getString(R.string.map_widget_reset));
|
||||
list.add(map.getString(R.string.map_widget_top_stack));
|
||||
list.addAll(mapInfoControls.getTop());
|
||||
list.add(map.getString(R.string.map_widget_right_stack));
|
||||
|
@ -516,11 +520,11 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
|
||||
|
||||
// final LayerMenuListener listener = new LayerMenuListener(adapter, mapView, settings);
|
||||
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
ListAdapter listAdapter = new ArrayAdapter<Object>(map, R.layout.layers_list_activity_item, R.id.title, list) {
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
|
||||
final ArrayAdapter<Object> listAdapter = new ArrayAdapter<Object>(map, R.layout.layers_list_activity_item, R.id.title, list) {
|
||||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
View v = convertView;
|
||||
if (v == null) {
|
||||
v = map.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
|
||||
|
@ -586,11 +590,27 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
};
|
||||
Builder b = new AlertDialog.Builder(map);
|
||||
b.setAdapter(listAdapter, new OnClickListener() {
|
||||
|
||||
View confirmDialog = view.inflate(view.getContext(), R.layout.configuration_dialog, null);
|
||||
final ListView lv = (ListView) confirmDialog.findViewById(android.R.id.list);
|
||||
MapActivityActions.prepareAppModeView(map, selected, true,
|
||||
(ViewGroup) confirmDialog.findViewById(R.id.TopBar),
|
||||
new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Object o = list.get(which);
|
||||
public void onClick(View v) {
|
||||
if(selected.size() > 0) {
|
||||
view.getSettings().APPLICATION_MODE.set(selected.iterator().next());
|
||||
listAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
lv.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
final ApplicationMode mode = settings.getApplicationMode();
|
||||
Object o = list.get(position);
|
||||
if (o instanceof MapWidgetRegInfo) {
|
||||
final MapWidgetRegInfo mi = (MapWidgetRegInfo) o;
|
||||
final boolean selecteable = mi.selecteable();
|
||||
|
@ -599,12 +619,14 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
mapInfoControls.changeVisibility(mi);
|
||||
}
|
||||
recreateControls();
|
||||
} else if(which == 0) {
|
||||
} else if(position == 0) {
|
||||
mapInfoControls.resetToDefault();
|
||||
recreateControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
lv.setAdapter(listAdapter);
|
||||
b.setView(confirmDialog);
|
||||
final AlertDialog dlg = b.create();
|
||||
// listener.setDialog(dlg);
|
||||
dlg.setCanceledOnTouchOutside(true);
|
||||
|
|
Loading…
Reference in a new issue