map context menu with images and some other ui improvements

This commit is contained in:
Pavol Zibrita 2012-06-12 05:48:32 +02:00 committed by Victor Shcherb
parent 7b3191b209
commit 2a22295542
18 changed files with 90 additions and 34 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 598 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- checked -->
<item android:state_checked="true">
<bitmap android:gravity="center" android:src="@drawable/list_activities_dot_marker2_pressed" />
</item>
<!-- unchecked -->
<item><bitmap android:gravity="center" android:src="@drawable/list_activities_dot_marker2_unpressed" />
</item>
</selector>

View file

@ -1,31 +1,30 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingBottom="0dip" android:paddingBottom="0dip"
android:paddingLeft="5dip" android:paddingLeft="5dip"
android:paddingRight="5dip" android:paddingRight="5dip"
android:paddingTop="0dip" > android:paddingTop="0dip"
<TextView android:weightSum="1" >
<TextView
android:id="@+id/title" android:id="@+id/title"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/check_item"
android:drawableLeft="@drawable/list_activities_poi" android:drawableLeft="@drawable/list_activities_poi"
android:gravity="center_vertical" android:gravity="center_vertical"
android:text="@string/layer_poi" android:text="@string/layer_poi"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/color_black" /> android:textColor="@color/color_black" android:layout_weight="1"/>
<CheckBox <CheckBox
android:id="@+id/check_item" android:id="@+id/check_item"
android:layout_width="wrap_content" android:layout_width="25dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:button="@drawable/orangedot_checkbox"
android:layout_alignParentTop="true" android:focusable="false" />
android:focusable="false" />
</RelativeLayout> </LinearLayout>

View file

@ -69,6 +69,10 @@ public class ContextMenuAdapter {
registerSelectedItem(stringResId, selected, icon, null, -1); registerSelectedItem(stringResId, selected, icon, null, -1);
} }
public void registerItem(int stringResId, int icon) {
registerSelectedItem(stringResId, -1, icon);
}
public void registerItem(int stringResId) { public void registerItem(int stringResId) {
registerSelectedItem(stringResId, -1, 0); registerSelectedItem(stringResId, -1, 0);
} }

View file

@ -7,7 +7,6 @@ import java.util.List;
import net.osmand.Algoritms; import net.osmand.Algoritms;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt;
import net.osmand.LogUtil; import net.osmand.LogUtil;
import net.osmand.Version; import net.osmand.Version;
import net.osmand.access.AccessibilityPlugin; import net.osmand.access.AccessibilityPlugin;

View file

@ -40,8 +40,10 @@ import android.app.AlertDialog;
import android.app.AlertDialog.Builder; import android.app.AlertDialog.Builder;
import android.app.Dialog; import android.app.Dialog;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener; import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.DialogInterface.OnShowListener;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Rect; import android.graphics.Rect;
@ -54,12 +56,17 @@ import android.text.Html;
import android.util.FloatMath; import android.util.FloatMath;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView; import android.widget.AutoCompleteTextView;
import android.widget.Button; import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText; import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ListAdapter;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import android.widget.ToggleButton; import android.widget.ToggleButton;
@ -121,9 +128,19 @@ public class MapActivityActions implements DialogProvider {
args.putSerializable(KEY_FAVORITE, point); args.putSerializable(KEY_FAVORITE, point);
final EditText editText = (EditText) dialog.findViewById(R.id.Name); final EditText editText = (EditText) dialog.findViewById(R.id.Name);
editText.setText(point.getName()); editText.setText(point.getName());
editText.requestFocus();
final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category); final AutoCompleteTextView cat = (AutoCompleteTextView) dialog.findViewById(R.id.Category);
cat.setText(point.getCategory()); cat.setText(point.getCategory());
editText.selectAll();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
InputMethodManager imm = (InputMethodManager) mapActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}
}
});
} }
protected Dialog createAddFavouriteDialog(final Bundle args) { protected Dialog createAddFavouriteDialog(final Bundle args) {
@ -678,16 +695,41 @@ public class MapActivityActions implements DialogProvider {
Builder builder = new AlertDialog.Builder(mapActivity); Builder builder = new AlertDialog.Builder(mapActivity);
final OsmandMapTileView mapView = mapActivity.getMapView(); final OsmandMapTileView mapView = mapActivity.getMapView();
adapter.registerItem(R.string.context_menu_item_navigate_point); adapter.registerItem(R.string.context_menu_item_navigate_point, R.drawable.list_view_set_destination);
adapter.registerItem(R.string.context_menu_item_search); adapter.registerItem(R.string.context_menu_item_search, R.drawable.list_view_search_near_here);
adapter.registerItem(R.string.context_menu_item_directions); adapter.registerItem(R.string.context_menu_item_directions);
adapter.registerItem(R.string.context_menu_item_show_route); adapter.registerItem(R.string.context_menu_item_show_route, R.drawable.list_view_show_route_from_here);
adapter.registerItem(R.string.context_menu_item_add_favorite); adapter.registerItem(R.string.context_menu_item_add_favorite, R.drawable.list_activities_favorites);
adapter.registerItem(R.string.context_menu_item_share_location); adapter.registerItem(R.string.context_menu_item_share_location, R.drawable.list_view_share_location);
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj); OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
builder.setItems(adapter.getItemNames(), new DialogInterface.OnClickListener() { ListAdapter listadapter = new ArrayAdapter<String>(
mapActivity,
R.layout.layers_list_activity_item,
R.id.title,
adapter.getItemNames()){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
//User super class to create the View
View v = super.getView(position, convertView, parent);
TextView tv = (TextView)v.findViewById(R.id.title);
tv.setText(adapter.getItemName(position));
//Put the image on the TextView
if(adapter.getImageId(position) != 0) {
tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position), 0, 0, 0);
} else {
tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.list_activities_transparent, 0, 0, 0);
}
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
ch.setVisibility(View.GONE);
return v;
}
};
builder.setAdapter(listadapter, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {

View file

@ -268,7 +268,7 @@ public class MapActivityLayers {
adapter.registerSelectedItem(R.string.layer_poi, settings.SHOW_POI_OVER_MAP.get() ? 1 : 0, adapter.registerSelectedItem(R.string.layer_poi, settings.SHOW_POI_OVER_MAP.get() ? 1 : 0,
R.drawable.list_activities_poi); R.drawable.list_activities_poi);
adapter.registerSelectedItem(R.string.layer_poi_label, settings.SHOW_POI_LABEL.get() ? 1 : 0, adapter.registerSelectedItem(R.string.layer_poi_label, settings.SHOW_POI_LABEL.get() ? 1 : 0,
0); R.drawable.list_activities_poi_labels);
adapter.registerSelectedItem(R.string.layer_favorites, settings.SHOW_FAVORITES.get() ? 1 : 0, adapter.registerSelectedItem(R.string.layer_favorites, settings.SHOW_FAVORITES.get() ? 1 : 0,
R.drawable.list_activities_favorites); R.drawable.list_activities_favorites);
adapter.registerSelectedItem(R.string.layer_gpx_layer, adapter.registerSelectedItem(R.string.layer_gpx_layer,

View file

@ -1,19 +1,19 @@
package net.osmand.plus.monitoring; package net.osmand.plus.monitoring;
import org.apache.commons.logging.Log;
import net.osmand.LogUtil; import net.osmand.LogUtil;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.ProgressDialogImplementation; import net.osmand.plus.ProgressDialogImplementation;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.ContextMenuAdapter.OnContextMenuClick;
import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.activities.SavingTrackHelper;
import net.osmand.plus.activities.SettingsActivity; import net.osmand.plus.activities.SettingsActivity;
import org.apache.commons.logging.Log;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.preference.Preference; import android.preference.Preference;

View file

@ -131,8 +131,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
} }
} }
}; };
adapter.registerItem(R.string.context_menu_item_create_poi, 0, listener, -1); adapter.registerItem(R.string.context_menu_item_create_poi, R.drawable.list_view_create_poi, listener, -1);
adapter.registerItem(R.string.context_menu_item_open_bug, 0, listener, -1); adapter.registerItem(R.string.context_menu_item_open_bug, R.drawable.list_activities_osm_bugs, listener, -1);
} }
@Override @Override

View file

@ -222,8 +222,8 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
} }
} }
}; };
adapter.registerItem(R.string.context_menu_item_update_map, 0, listener, -1); adapter.registerItem(R.string.context_menu_item_update_map, R.drawable.list_activities_update_map, listener, -1);
adapter.registerItem(R.string.context_menu_item_download_map, 0, listener, -1); adapter.registerItem(R.string.context_menu_item_download_map, R.drawable.list_activities_download_map, listener, -1);
} }
} }