quick action add favorite functionality (ui/logic/ without categories)
This commit is contained in:
parent
285ee3d266
commit
8af53645c0
9 changed files with 404 additions and 34 deletions
208
OsmAnd/res/layout/quick_action_add_favorite.xml
Normal file
208
OsmAnd/res/layout/quick_action_add_favorite.xml
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="?attr/bg_color">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="16dp"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/quick_action_favorite_dialog"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/textView3" />
|
||||
|
||||
<android.support.v7.widget.SwitchCompat
|
||||
android:id="@+id/saveButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginLeft="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_bottom" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="16dp"
|
||||
android:src="@drawable/bg_shadow_list_top"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/title_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/name_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:scaleType="centerInside"
|
||||
android:tint="@color/icon_color"
|
||||
android:src="@drawable/ic_action_fav_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/name_caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:text="@string/favourites_edit_dialog_name"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatEditText
|
||||
android:id="@+id/name_edit"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textColorHint="?android:textColorSecondary"
|
||||
tools:text="Name"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="68dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="Leave field blank and OsmAnd will use the address or name of a place for the favorite point"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/shadow_color"
|
||||
android:layout_marginLeft="68dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="42dp"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/category_image"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:scaleType="centerInside"
|
||||
android:tint="@color/icon_color"
|
||||
android:src="@drawable/ic_action_folder"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/category_caption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp"
|
||||
android:text="@string/favourites_edit_dialog_category"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<net.osmand.plus.widgets.AutoCompleteTextViewEx
|
||||
android:id="@+id/category_edit"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:text="@string/shared_string_favorites"
|
||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||
android:editable="false"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="68dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:text="You can select a category to save favorite point."
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:layout_marginBottom="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_bottom" />
|
||||
|
||||
</LinearLayout>
|
23
OsmAnd/res/layout/quick_action_add_marker.xml
Normal file
23
OsmAnd/res/layout/quick_action_add_marker.xml
Normal file
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bg_color"
|
||||
android:padding="16dp"
|
||||
android:text="@string/quick_action_add_marker_discr"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/default_list_text_size" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/bg_shadow_list_bottom" />
|
||||
</LinearLayout>
|
|
@ -2464,6 +2464,7 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="reports_for">Report for</string>
|
||||
<string name="file_name_containes_illegal_char">File name contains illegal character</string>
|
||||
<string name="configure_screen_quick_action">Quick action</string>
|
||||
|
||||
<string name="quick_action_item_action">Action %d</string>
|
||||
<string name="quick_action_item_screen">Screen %d</string>
|
||||
<string name="quick_action_add_marker">Add marker</string>
|
||||
|
@ -2480,4 +2481,6 @@ If you need help with OsmAnd application, please contact our support team: suppo
|
|||
<string name="quick_favorites_name_description">Leave field blank and OsmAnd will use the address or name of a place for the favorite point</string>
|
||||
<string name="quick_action_name_hint">Action name</string>
|
||||
<string name="text_name">Name</string>
|
||||
<string name="quick_action_add_marker_discr">Tap on action will add marker to the specified location.</string>
|
||||
<string name="quick_action_favorite_dialog">Show favorite dialog</string>
|
||||
</resources>
|
||||
|
|
|
@ -671,6 +671,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void buttonFavoritePressed() {
|
||||
if (object != null && object instanceof FavouritePoint) {
|
||||
getFavoritePointEditor().edit((FavouritePoint) object);
|
||||
|
|
|
@ -153,7 +153,7 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
|
||||
MapContextMenu menu = getMapActivity().getContextMenu();
|
||||
LatLon latLon = new LatLon(favorite.getLatitude(), favorite.getLongitude());
|
||||
if (menu.getLatLon().equals(latLon)) {
|
||||
if (menu.getLatLon() != null && menu.getLatLon().equals(latLon)) {
|
||||
menu.update(latLon, favorite.getPointDescription(), favorite);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,15 +107,15 @@ public class CreateEditActionDialog extends DialogFragment {
|
|||
? isNew = actionId == 0
|
||||
: savedInstanceState.getBoolean(KEY_ACTION_IS_NEW);
|
||||
|
||||
action = isNew
|
||||
action = QuickActionFactory.produceAction(isNew
|
||||
? QuickActionFactory.newActionByType(type)
|
||||
: quickActionRegistry.getQuickAction(actionId);
|
||||
: quickActionRegistry.getQuickAction(actionId));
|
||||
|
||||
setupToolbar(view);
|
||||
setupHeader(view, savedInstanceState);
|
||||
setupFooter(view);
|
||||
|
||||
action.drawUI((ViewGroup) view.findViewById(R.id.container));
|
||||
action.drawUI((ViewGroup) view.findViewById(R.id.container), (MapActivity) getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -175,13 +175,13 @@ public class CreateEditActionDialog extends DialogFragment {
|
|||
image.setImageResource(action.iconRes);
|
||||
}
|
||||
|
||||
private void setupFooter(View root){
|
||||
private void setupFooter(final View root){
|
||||
|
||||
root.findViewById(R.id.btnApply).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
|
||||
action.fillParams();
|
||||
action.fillParams(((ViewGroup) root.findViewById(R.id.container)).getChildAt(0));
|
||||
|
||||
if (isNew) quickActionRegistry.addQuickAction(action);
|
||||
else quickActionRegistry.updateQuickAction(action);
|
||||
|
|
|
@ -6,11 +6,18 @@ import android.os.Parcel;
|
|||
import android.os.Parcelable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class QuickAction {
|
||||
|
||||
|
@ -62,6 +69,9 @@ public class QuickAction {
|
|||
}
|
||||
|
||||
public HashMap<String, String> getParams() {
|
||||
|
||||
if (params == null) params = new HashMap<>();
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
@ -74,8 +84,8 @@ public class QuickAction {
|
|||
}
|
||||
|
||||
public void execute(MapActivity activity){};
|
||||
public void drawUI(ViewGroup parent){};
|
||||
public void fillParams(){};
|
||||
public void drawUI(ViewGroup parent, MapActivity activity){};
|
||||
public void fillParams(View root){};
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,21 +1,50 @@
|
|||
package net.osmand.plus.quickaction;
|
||||
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.GeocodingLookupService;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.dialogs.ProgressDialogFragment;
|
||||
import net.osmand.plus.mapcontextmenu.editors.FavoritePointEditor;
|
||||
import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
|
||||
import net.osmand.plus.osmedit.OsmEditsUploadListener;
|
||||
import net.osmand.plus.osmedit.OsmEditsUploadListenerHelper;
|
||||
import net.osmand.plus.osmedit.OsmPoint;
|
||||
import net.osmand.plus.widgets.AutoCompleteTextViewEx;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class QuickActionFactory {
|
||||
|
||||
public String quickActionListToString(List<QuickAction> quickActions){
|
||||
public String quickActionListToString(List<QuickAction> quickActions) {
|
||||
|
||||
String json = new Gson().toJson(quickActions);
|
||||
return json;
|
||||
|
@ -23,7 +52,8 @@ public class QuickActionFactory {
|
|||
|
||||
public List<QuickAction> parseActiveActionsList(String json) {
|
||||
|
||||
Type type = new TypeToken<List<QuickAction>>(){}.getType();
|
||||
Type type = new TypeToken<List<QuickAction>>() {
|
||||
}.getType();
|
||||
ArrayList<QuickAction> quickActions = new Gson().fromJson(json, type);
|
||||
|
||||
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
|
||||
|
@ -39,31 +69,39 @@ public class QuickActionFactory {
|
|||
return quickActions;
|
||||
}
|
||||
|
||||
public static QuickAction newActionByType(int type){
|
||||
public static QuickAction newActionByType(int type) {
|
||||
|
||||
switch (type){
|
||||
switch (type) {
|
||||
|
||||
case NewAction.TYPE: return new NewAction();
|
||||
case NewAction.TYPE:
|
||||
return new NewAction();
|
||||
|
||||
case MarkerAction.TYPE: return new MarkerAction();
|
||||
case MarkerAction.TYPE:
|
||||
return new MarkerAction();
|
||||
|
||||
case FavoriteAction.TYPE: return new FavoriteAction();
|
||||
case FavoriteAction.TYPE:
|
||||
return new FavoriteAction();
|
||||
|
||||
default: return new QuickAction();
|
||||
default:
|
||||
return new QuickAction();
|
||||
}
|
||||
}
|
||||
|
||||
public static QuickAction produceAction(QuickAction quickAction){
|
||||
public static QuickAction produceAction(QuickAction quickAction) {
|
||||
|
||||
switch (quickAction.type){
|
||||
switch (quickAction.type) {
|
||||
|
||||
case NewAction.TYPE: return new NewAction(quickAction);
|
||||
case NewAction.TYPE:
|
||||
return new NewAction(quickAction);
|
||||
|
||||
case MarkerAction.TYPE: return new MarkerAction(quickAction);
|
||||
case MarkerAction.TYPE:
|
||||
return new MarkerAction(quickAction);
|
||||
|
||||
case FavoriteAction.TYPE: return new FavoriteAction(quickAction);
|
||||
case FavoriteAction.TYPE:
|
||||
return new FavoriteAction(quickAction);
|
||||
|
||||
default: return quickAction;
|
||||
default:
|
||||
return quickAction;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +109,7 @@ public class QuickActionFactory {
|
|||
|
||||
public static final int TYPE = 1;
|
||||
|
||||
protected NewAction(){
|
||||
protected NewAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
nameRes = R.string.quick_action_new_action;
|
||||
|
@ -90,7 +128,7 @@ public class QuickActionFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent) {
|
||||
public void drawUI(ViewGroup parent, MapActivity activity) {
|
||||
|
||||
//TODO inflate view & fill with params
|
||||
}
|
||||
|
@ -100,7 +138,7 @@ public class QuickActionFactory {
|
|||
|
||||
public static final int TYPE = 2;
|
||||
|
||||
private MarkerAction(){
|
||||
private MarkerAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
nameRes = R.string.quick_action_add_marker;
|
||||
|
@ -114,13 +152,33 @@ public class QuickActionFactory {
|
|||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
|
||||
//TODO do some action
|
||||
LatLon latLon = activity.getMapView()
|
||||
.getCurrentRotatedTileBox()
|
||||
.getCenterLatLon();
|
||||
|
||||
PointDescription pointDescription = new PointDescription(
|
||||
latLon.getLatitude(),
|
||||
latLon.getLongitude());
|
||||
|
||||
if (pointDescription.isLocation() && pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(activity)))
|
||||
pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
|
||||
|
||||
activity.getMapActions().addMapMarker(
|
||||
latLon.getLatitude(),
|
||||
latLon.getLongitude(),
|
||||
pointDescription);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent) {
|
||||
public void drawUI(ViewGroup parent, MapActivity activity) {
|
||||
|
||||
//TODO inflate view & fill with params
|
||||
if (parent.getChildCount() == 0) {
|
||||
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.quick_action_add_marker, parent, false);
|
||||
|
||||
parent.addView(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +186,10 @@ public class QuickActionFactory {
|
|||
|
||||
public static final int TYPE = 3;
|
||||
|
||||
public FavoriteAction() {
|
||||
public static final String KEY_NAME = "name";
|
||||
public static final String KEY_DIALOG = "dialog";
|
||||
|
||||
private FavoriteAction() {
|
||||
id = System.currentTimeMillis();
|
||||
type = TYPE;
|
||||
nameRes = R.string.quick_action_add_favorite;
|
||||
|
@ -140,15 +201,77 @@ public class QuickActionFactory {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapActivity activity) {
|
||||
public void execute(final MapActivity activity) {
|
||||
|
||||
//TODO do some action
|
||||
final LatLon latLon = activity.getMapView()
|
||||
.getCurrentRotatedTileBox()
|
||||
.getCenterLatLon();
|
||||
|
||||
final String title = getParams().get(KEY_NAME);
|
||||
|
||||
if (title == null || title.isEmpty()) {
|
||||
|
||||
final Dialog progressDialog = new ProgressDialog(activity);
|
||||
progressDialog.setCancelable(false);
|
||||
progressDialog.setTitle(R.string.search_address);
|
||||
progressDialog.show();
|
||||
|
||||
GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon,
|
||||
|
||||
new GeocodingLookupService.OnAddressLookupResult() {
|
||||
|
||||
@Override
|
||||
public void geocodingDone(String address) {
|
||||
|
||||
progressDialog.dismiss();
|
||||
activity.getContextMenu().getFavoritePointEditor().add(latLon, address, "");
|
||||
}
|
||||
|
||||
}, null);
|
||||
|
||||
activity.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest);
|
||||
|
||||
} else activity.getContextMenu().getFavoritePointEditor().add(latLon, title, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawUI(ViewGroup parent) {
|
||||
public void drawUI(final ViewGroup parent, MapActivity activity) {
|
||||
|
||||
//TODO inflate view & fill with params
|
||||
FavouritesDbHelper helper = activity.getMyApplication().getFavorites();
|
||||
|
||||
String category = helper.getFavoriteGroups().size() > 0
|
||||
? helper.getFavoriteGroups().get(0).name
|
||||
: activity.getString(R.string.shared_string_favorites);
|
||||
|
||||
View root;
|
||||
|
||||
if (parent.getChildCount() == 0) {
|
||||
|
||||
root = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.quick_action_add_favorite, parent, false);
|
||||
|
||||
parent.addView(root);
|
||||
|
||||
} else root = parent.getChildAt(0);
|
||||
|
||||
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx)
|
||||
root.findViewById(R.id.category_edit);
|
||||
|
||||
categoryEdit.setText(category);
|
||||
categoryEdit.setFocusable(false);
|
||||
|
||||
if (!getParams().isEmpty()){
|
||||
|
||||
((EditText) root.findViewById(R.id.name_edit)).setText(getParams().get(KEY_NAME));
|
||||
((SwitchCompat) root.findViewById(R.id.saveButton)).setChecked(Boolean.getBoolean(getParams().get(KEY_DIALOG)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillParams(View root) {
|
||||
|
||||
getParams().put(KEY_NAME, ((EditText) root.findViewById(R.id.name_edit)).getText().toString());
|
||||
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
import net.osmand.plus.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||
|
||||
|
@ -278,7 +279,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
|
||||
@Override
|
||||
public void onActionSelected(QuickAction action) {
|
||||
action.execute(mapActivity);
|
||||
QuickActionFactory.produceAction(action).execute(mapActivity);
|
||||
}
|
||||
|
||||
public PointF getMovableCenterPoint(RotatedTileBox tb) {
|
||||
|
|
Loading…
Reference in a new issue