Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2017-04-03 11:40:38 +02:00
commit 298b614146
6 changed files with 493 additions and 11 deletions

View file

@ -0,0 +1,217 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:osmand="http://schemas.android.com/apk/res-auto"
android:layout_gravity="bottom"
android:background="?attr/bottom_menu_view_bg"
android:orientation="vertical"
tools:context="net.osmand.plus.download.ui.DataStoragePlaceDialogFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:minHeight="@dimen/list_item_height"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:gravity="center_vertical">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
osmand:typeface="@string/font_roboto_medium"
tools:text="Category"/>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/edit_name_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/edit_name_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_edit_dark"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/edit_name"/>
</LinearLayout>
<LinearLayout
android:id="@+id/change_color_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/change_color_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_appearance"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/change_color"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/colorImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_circle"/>
</LinearLayout>
<LinearLayout
android:id="@+id/show_on_map_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/show_on_map_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_map"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:paddingRight="8dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_show_on_map"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/show_on_map_switch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
<LinearLayout
android:id="@+id/add_to_markers_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/add_to_markers_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_flag_dark"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_add_to_map_markers"/>
</LinearLayout>
<LinearLayout
android:id="@+id/share_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="@dimen/list_item_height"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/list_content_padding"
android:paddingRight="@dimen/list_content_padding"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/share_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_action_gshare_dark"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/list_content_padding"
android:paddingTop="6dp"
android:paddingBottom="6dp"
android:textColor="?android:attr/textColorPrimary"
android:textSize="@dimen/default_list_text_size"
android:text="@string/shared_string_share"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>

View file

@ -9,6 +9,9 @@
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
-->
<string name="favorite_group_name">Group name</string>
<string name="change_color">Change color</string>
<string name="edit_name">Edit name</string>
<string name="animate_my_location">Animate my location</string>
<string name="animate_my_location_desc">Enable animation of my location on the map</string>
<string name="shared_string_overview">Overview</string>

View file

@ -0,0 +1,241 @@
package net.osmand.plus.activities;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.ListPopupWindow;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.base.BottomSheetDialogFragment;
import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.util.Algorithms;
public class EditFavoriteGroupDialogFragment extends BottomSheetDialogFragment {
public static final String TAG = "EditFavoriteGroupDialogFragment";
private static final String GROUP_NAME_KEY = "group_name_key";
private OsmandApplication app;
private FavoriteGroup group;
private FavouritesDbHelper helper;
@Override
public void onStart() {
super.onStart();
final Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM;
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
window.setAttributes(params);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final Activity activity = getActivity();
app = (OsmandApplication) activity.getApplicationContext();
helper = app.getFavorites();
Bundle args = null;
if (savedInstanceState != null) {
args = savedInstanceState;
} else if (getArguments() != null) {
args = getArguments();
}
if (args != null) {
String groupName = args.getString(GROUP_NAME_KEY);
if (groupName != null) {
group = helper.getGroup(groupName);
}
}
final View view = inflater.inflate(R.layout.fragment_data_storage_place_dialog, container,
false);
if (group == null) {
return view;
}
IconsCache ic = app.getIconsCache();
View editNameView = view.findViewById(R.id.edit_name_view);
((ImageView) view.findViewById(R.id.edit_name_icon))
.setImageDrawable(ic.getIcon(R.drawable.ic_action_edit_dark));
editNameView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder b = new AlertDialog.Builder(activity);
b.setTitle(R.string.favorite_group_name);
final EditText nameEditText = new EditText(activity);
nameEditText.setText(group.name);
int leftPadding = AndroidUtils.dpToPx(activity, 24f);
int topPadding = AndroidUtils.dpToPx(activity, 4f);
b.setView(nameEditText, leftPadding, topPadding, leftPadding, topPadding);
b.setNegativeButton(R.string.shared_string_cancel, null);
b.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String name = nameEditText.getText().toString();
boolean nameChanged = !Algorithms.objectEquals(group.name, name);
if (nameChanged) {
getMyApplication().getFavorites()
.editFavouriteGroup(group, name, group.color, group.visible);
}
}
});
b.show();
}
});
final View changeColorView = view.findViewById(R.id.change_color_view);
((ImageView) view.findViewById(R.id.change_color_icon))
.setImageDrawable(ic.getIcon(R.drawable.ic_action_appearance));
updateColorView(changeColorView);
changeColorView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(getActivity());
popup.setAnchorView(changeColorView);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
final FavoriteColorAdapter colorAdapter = new FavoriteColorAdapter(getActivity());
popup.setAdapter(colorAdapter);
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Integer color = colorAdapter.getItem(position);
if (color != null) {
if (color != group.color) {
getMyApplication().getFavorites()
.editFavouriteGroup(group, group.name, color, group.visible);
}
}
popup.dismiss();
updateColorView(changeColorView);
}
});
popup.show();
}
});
View showOnMapView = view.findViewById(R.id.show_on_map_view);
((ImageView) view.findViewById(R.id.show_on_map_icon))
.setImageDrawable(ic.getIcon(R.drawable.ic_map));
showOnMapView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//todo
}
});
View addToMarkersView = view.findViewById(R.id.add_to_markers_view);
((ImageView) view.findViewById(R.id.add_to_markers_icon))
.setImageDrawable(ic.getIcon(R.drawable.ic_action_flag_dark));
addToMarkersView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//todo
}
});
View shareView = view.findViewById(R.id.share_view);
((ImageView) view.findViewById(R.id.share_icon))
.setImageDrawable(ic.getIcon(R.drawable.ic_action_gshare_dark));
shareView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//todo
}
});
return view;
}
@Override
public void onResume() {
super.onResume();
if (group == null) {
dismiss();
}
}
private void updateColorView(View colorView) {
ImageView colorImageView = (ImageView) colorView.findViewById(R.id.colorImage);
int color = group.color == 0 ? getResources().getColor(R.color.color_favorite) : group.color;
if (color == 0) {
colorImageView.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_circle));
} else {
colorImageView.setImageDrawable(app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color));
}
}
public static void showInstance(FragmentManager fragmentManager, String groupName) {
EditFavoriteGroupDialogFragment f = new EditFavoriteGroupDialogFragment();
Bundle args = new Bundle();
args.putString(GROUP_NAME_KEY, groupName);
f.setArguments(args);
f.show(fragmentManager, EditFavoriteGroupDialogFragment.TAG);
}
public static class FavoriteColorAdapter extends ArrayAdapter<Integer> {
private OsmandApplication app;
public FavoriteColorAdapter(Context context) {
super(context, R.layout.rendering_prop_menu_item);
this.app = (OsmandApplication) getContext().getApplicationContext();
init();
}
public void init() {
for (int color : ColorDialogs.pallette) {
add(color);
}
}
@NonNull
@Override
public View getView(int position, View convertView, @NonNull ViewGroup parent) {
Integer color = getItem(position);
View v = convertView;
if (v == null) {
v = LayoutInflater.from(getContext()).inflate(R.layout.rendering_prop_menu_item, null);
}
if (color != null) {
TextView textView = (TextView) v.findViewById(R.id.text1);
textView.setText(app.getString(ColorDialogs.paletteColors[position]));
textView.setCompoundDrawablesWithIntrinsicBounds(null, null,
app.getIconsCache().getPaintedIcon(R.drawable.ic_action_circle, color), null);
textView.setCompoundDrawablePadding(AndroidUtils.dpToPx(getContext(), 10f));
v.findViewById(R.id.divider).setVisibility(View.GONE);
}
return v;
}
}
}

View file

@ -3,6 +3,7 @@ package net.osmand.plus.activities;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
@ -745,8 +746,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
int enabledColor = light ? R.color.primary_text_light : R.color.primary_text_dark;
int disabledColor = light ? R.color.secondary_text_light : R.color.secondary_text_dark;
row.findViewById(R.id.group_divider).setVisibility(groupPosition == 0 ? View.GONE : View.VISIBLE);
int color = model.color == 0 || model.color == Color.BLACK ? getResources().getColor(R.color.color_favorite) : model.color;
setCategoryIcon(app, app.getIconsCache().getPaintedIcon(
R.drawable.ic_action_fav_dark, visible ? (model.color | 0xff000000) : getResources().getColor(disabledColor)),
R.drawable.ic_action_fav_dark, visible ? (color | 0xff000000) : getResources().getColor(disabledColor)),
groupPosition, isExpanded, row, light);
adjustIndicator(app, groupPosition, isExpanded, row, light);
TextView label = (TextView) row.findViewById(R.id.category_name);

View file

@ -8,6 +8,7 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup;
import net.osmand.plus.GPXUtilities;
import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.helpers.SearchHistoryHelper;
import net.osmand.plus.poi.PoiFiltersHelper;
import net.osmand.plus.resources.ResourceManager.ResourceListener;
@ -18,6 +19,7 @@ import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchCoreFactory.SearchBaseAPI;
import net.osmand.search.core.SearchPhrase;
import net.osmand.search.core.SearchResult;
import net.osmand.util.Algorithms;
import java.io.IOException;
import java.util.Arrays;
@ -164,18 +166,31 @@ public class QuickSearchHelper implements ResourceListener {
@Override
public boolean search(SearchPhrase phrase, SearchUICore.SearchResultMatcher resultMatcher) throws IOException {
List<FavouritePoint> favList = app.getFavorites().getFavouritePoints();
for (FavouritePoint point : favList) {
FavoriteGroup group = helper.getGroup(point);
if (group != null && group.visible) {
String baseGroupName = app.getString(R.string.shared_string_favorites);
List<FavoriteGroup> groups = app.getFavorites().getFavoriteGroups();
for (FavoriteGroup group : groups) {
if (group.visible) {
SearchResult sr = new SearchResult(phrase);
sr.localeName = group.name;
sr.localeName = Algorithms.isEmpty(group.name) ? baseGroupName : group.name;
sr.object = group;
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
sr.objectType = ObjectType.FAVORITE_GROUP;
sr.preferredZoom = 17;
if (phrase.getNameStringMatcher().matches(sr.localeName)) {
resultMatcher.publish(sr);
if (group.points.size() < 5) {
for (FavouritePoint point : group.points) {
SearchResult srp = new SearchResult(phrase);
srp.localeName = point.getName();
srp.object = point;
srp.priority = SEARCH_FAVORITE_OBJECT_PRIORITY;
srp.objectType = ObjectType.FAVORITE;
srp.location = new LatLon(point.getLatitude(), point.getLongitude());
srp.preferredZoom = 17;
resultMatcher.publish(srp);
}
} else {
resultMatcher.publish(sr);
}
}
}
}
@ -219,9 +234,11 @@ public class QuickSearchHelper implements ResourceListener {
sr.objectType = ObjectType.FAVORITE;
sr.location = new LatLon(point.getLatitude(), point.getLongitude());
sr.preferredZoom = 17;
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)
&& !point.getCategory().equals(phrase.getLastSelectedWord().getResult().localeName)) {
continue;
if (phrase.isLastWord(ObjectType.FAVORITE_GROUP)) {
FavoriteGroup group = (FavoriteGroup) phrase.getLastSelectedWord().getResult().object;
if (group != null && !point.getCategory().equals(group.name)) {
continue;
}
}
if (phrase.getUnknownSearchWordLength() <= 1
&& (phrase.isNoSelectedType() || phrase.isLastWord(ObjectType.FAVORITE_GROUP))) {

View file

@ -1,6 +1,7 @@
package net.osmand.plus.search.listitems;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.text.Spannable;
@ -370,7 +371,8 @@ public class QuickSearchListItem {
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false);
case FAVORITE_GROUP:
FavoriteGroup group = (FavoriteGroup) searchResult.object;
return app.getIconsCache().getPaintedIcon(R.drawable.ic_action_fav_dark, group.color | 0xff000000);
int color = group.color == 0 || group.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.color;
return app.getIconsCache().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
case REGION:
return app.getIconsCache().getIcon(R.drawable.ic_world_globe_dark,
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);