quick action show/hide favorites

This commit is contained in:
Rosty 2016-12-29 16:21:04 +02:00
parent 7f1fa6636a
commit 7482f623b8
3 changed files with 67 additions and 6 deletions

View 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_showhides_favorites_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>

View file

@ -2487,4 +2487,6 @@ If you need help with OsmAnd application, please contact our support team: suppo
<string name="favorite_empty_place_name">Place</string>
<string name="quick_action_duplicates">Specified quick action name already in use, was changed to %1$s to avoid duplication.</string>
<string name="quick_action_duplicate">Quick action name duplicate</string>
<string name="quick_action_showhides_favorites_discr">Tap on action will Show or Hide favorites points on map.</string>
<string name="quic_action_showhide_favorites_title">Show/Hide Favorites</string>
</resources>

View file

@ -70,6 +70,7 @@ public class QuickActionFactory {
quickActions.add(new MarkerAction());
quickActions.add(new FavoriteAction());
quickActions.add(new ShowHideFavoritesAction());
return quickActions;
}
@ -87,6 +88,9 @@ public class QuickActionFactory {
case FavoriteAction.TYPE:
return new FavoriteAction();
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction();
default:
return new QuickAction();
}
@ -105,6 +109,9 @@ public class QuickActionFactory {
case FavoriteAction.TYPE:
return new FavoriteAction(quickAction);
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction(quickAction);
default:
return quickAction;
}
@ -177,13 +184,10 @@ public class QuickActionFactory {
@Override
public void drawUI(ViewGroup parent, MapActivity activity) {
if (parent.getChildCount() == 0) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_add_marker, parent, false);
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_add_marker, parent, false);
parent.addView(view);
}
parent.addView(view);
}
}
@ -374,4 +378,36 @@ public class QuickActionFactory {
}
}
}
public static class ShowHideFavoritesAction extends QuickAction {
public static final int TYPE = 4;
protected ShowHideFavoritesAction() {
id = System.currentTimeMillis();
type = TYPE;
nameRes = R.string.quic_action_showhide_favorites_title;
iconRes = R.drawable.ic_action_fav_dark;
}
public ShowHideFavoritesAction(QuickAction quickAction) {
super(quickAction);
}
@Override
public void execute(MapActivity activity) {
activity.getMyApplication().getSettings().SHOW_FAVORITES.set(
!activity.getMyApplication().getSettings().SHOW_FAVORITES.get());
}
@Override
public void drawUI(ViewGroup parent, MapActivity activity) {
View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_show_hide_favorites, parent, false);
parent.addView(view);
}
}
}