Fix parking dialog UI

This commit is contained in:
Alexey Kulish 2017-03-14 18:03:43 +03:00
parent fb51eb6060
commit 2c2d4fcc30
3 changed files with 38 additions and 92 deletions

View file

@ -1,58 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/tableRow1"
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content">
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/parking_no_lim_button"
android:gravity="center_horizontal"
android:background="@drawable/list_poi_parking_pos_no_limit_menu"
android:contentDescription="@string/osmand_parking_time_no_limit"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
android:id="@+id/parking_lim_text"
android:gravity="center_horizontal"
android:text="@string/osmand_parking_no_lim_text"/>
</LinearLayout>
<LinearLayout android:id="@+id/tableRow2"
android:orientation="vertical"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content">
<ImageButton android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/parking_lim_button"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:background="@drawable/list_poi_parking_pos_limit_menu"
android:contentDescription="@string/osmand_parking_time_limit"/>
<TextView android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:id="@+id/parking_no_lim_text"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
android:text="@string/osmand_parking_lim_text"/>
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,7 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
--> -->
<string name="parking_options">Parking options</string>
<string name="full_version_thanks">Thank you for purchasing full version of OsmAnd!</string> <string name="full_version_thanks">Thank you for purchasing full version of OsmAnd!</string>
<string name="routing_attr_relief_smoothness_factor_hills_name">Hills</string> <string name="routing_attr_relief_smoothness_factor_hills_name">Hills</string>
<string name="routing_attr_relief_smoothness_factor_plains_name">Plains</string> <string name="routing_attr_relief_smoothness_factor_plains_name">Plains</string>

View file

@ -240,42 +240,45 @@ public class ParkingPositionPlugin extends OsmandPlugin {
*/ */
public void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) { public void showAddParkingDialog(final MapActivity mapActivity, final double latitude, final double longitude) {
final boolean wasEventPreviouslyAdded = isParkingEventAdded(); final boolean wasEventPreviouslyAdded = isParkingEventAdded();
final View addParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_type, null);
final Dialog choose = new Dialog(mapActivity);
choose.setContentView(addParking);
choose.setCancelable(true);
choose.setTitle(mapActivity.getString(R.string.osmand_parking_choose_type));
ImageButton limitButton = (ImageButton) addParking.findViewById(R.id.parking_lim_button); final ContextMenuAdapter menuAdapter = new ContextMenuAdapter();
limitButton.setOnClickListener(new View.OnClickListener() { ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
menuAdapter.addItem(itemBuilder.setTitleId(R.string.osmand_parking_no_lim_text, app)
.setIcon(R.drawable.ic_action_time_start).setTag(1).createItem());
menuAdapter.addItem(itemBuilder.setTitleId(R.string.osmand_parking_time_limit, app)
.setIcon(R.drawable.ic_action_time_span).setTag(2).createItem());
final AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity);
boolean light = app.getSettings().isLightContent() && !app.getDaynightHelper().isNightMode();
final ArrayAdapter<ContextMenuItem> listAdapter = menuAdapter.createListAdapter(mapActivity, light);
builder.setTitle(R.string.parking_options);
builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(final DialogInterface dialog, int which) {
if (wasEventPreviouslyAdded) { ContextMenuItem item = menuAdapter.getItem(which);
showDeleteEventWarning(mapActivity); int index = item.getTag();
if (index == 1) {
dialog.dismiss();
if (wasEventPreviouslyAdded) {
showDeleteEventWarning(mapActivity);
}
addOrRemoveParkingEvent(false);
setParkingPosition(mapActivity, latitude, longitude, false);
showContextMenuIfNeeded(mapActivity);
mapActivity.getMapView().refreshMap();
} else if (index == 2) {
if (wasEventPreviouslyAdded) {
showDeleteEventWarning(mapActivity);
}
setParkingPosition(mapActivity, latitude, longitude, true);
showSetTimeLimitDialog(mapActivity, dialog);
mapActivity.getMapView().refreshMap();
} }
setParkingPosition(mapActivity, latitude, longitude, true);
showSetTimeLimitDialog(mapActivity, choose);
mapActivity.getMapView().refreshMap();
} }
}); });
builder.setNegativeButton(R.string.shared_string_cancel, null);
ImageButton noLimitButton = (ImageButton) addParking.findViewById(R.id.parking_no_lim_button); builder.create().show();
noLimitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
choose.dismiss();
if (wasEventPreviouslyAdded) {
showDeleteEventWarning(mapActivity);
}
addOrRemoveParkingEvent(false);
setParkingPosition(mapActivity, latitude, longitude, false);
showContextMenuIfNeeded(mapActivity);
mapActivity.getMapView().refreshMap();
}
});
choose.show();
} }
private void showContextMenuIfNeeded(final MapActivity mapActivity) { private void showContextMenuIfNeeded(final MapActivity mapActivity) {
@ -317,7 +320,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
* @param mapActivity * @param mapActivity
* @param choose * @param choose
*/ */
private void showSetTimeLimitDialog(final MapActivity mapActivity, final Dialog choose) { private void showSetTimeLimitDialog(final MapActivity mapActivity, final DialogInterface choose) {
final View setTimeParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_time_limit, null); final View setTimeParking = mapActivity.getLayoutInflater().inflate(R.layout.parking_set_time_limit, null);
AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity); AlertDialog.Builder setTime = new AlertDialog.Builder(mapActivity);
setTime.setView(setTimeParking); setTime.setView(setTimeParking);