Updated recents views

This commit is contained in:
Bars107 2015-03-02 15:32:20 +02:00
parent 2fb513c558
commit 34611f7a57
4 changed files with 105 additions and 44 deletions

View file

@ -107,6 +107,9 @@ public class PointDescription {
return POINT_TYPE_FAVORITE.equals(type);
}
public boolean isAvNote() {
return POINT_TYPE_NOTE.equals(type);
}
@Override
public int hashCode() {

View file

@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable;
import android.support.v4.app.ListFragment;
import android.support.v7.widget.PopupMenu;
import android.view.*;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter;
@ -22,6 +23,7 @@ import net.osmand.plus.activities.search.SearchActivity.SearchActivityChild;
import net.osmand.plus.base.FavoriteImageDrawable;
import net.osmand.plus.dialogs.DirectionsDialogs;
import net.osmand.util.MapUtils;
import android.app.Activity;
import android.content.Intent;
import android.widget.ArrayAdapter;
@ -73,14 +75,14 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
}
}
}
if (!isSelectFavoriteMode()) {
if (location == null && getActivity() instanceof SearchActivity) {
location = ((SearchActivity) getActivity()).getSearchPoint();
}
if (location == null) {
location = settings.getLastKnownMapLocation();
}
}
locationUpdate(location);
}
@ -93,14 +95,14 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
}
}
public boolean isSelectFavoriteMode(){
public boolean isSelectFavoriteMode() {
return selectFavoriteMode;
}
@Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
if(getActivity() instanceof SearchActivity) {
if (getActivity() instanceof SearchActivity) {
((SearchActivity) getActivity()).getClearToolbar(false);
}
}
@ -168,7 +170,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
}
}
public String getName(FavouritePoint model){
public String getName(FavouritePoint model) {
return model.getName();
}
@ -186,23 +188,23 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
ImageView direction = (ImageView) row.findViewById(R.id.direction);
direction.setImageDrawable(arrowImage);
direction.setVisibility(View.VISIBLE);
final FavouritePoint model = getItem(position);
if (!model.getCategory().isEmpty()){
final FavouritePoint favorite = getItem(position);
if (!favorite.getCategory().isEmpty()) {
row.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
} else {
row.findViewById(R.id.group_image).setVisibility(View.GONE);
}
((TextView) row.findViewById(R.id.group_name)).setText(model.getCategory());
((TextView) row.findViewById(R.id.group_name)).setText(favorite.getCategory());
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, model.getColor()));
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor()));
String distance = "";
if (location != null) {
int dist = (int) (MapUtils.getDistance(model.getLatitude(), model.getLongitude(), location.getLatitude(), location
int dist = (int) (MapUtils.getDistance(favorite.getLatitude(), favorite.getLongitude(), location.getLatitude(), location
.getLongitude()));
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " " ;
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " ";
}
distanceText.setText(distance);
name.setText(getName(model));
name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
ch.setVisibility(View.GONE);
@ -212,6 +214,6 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
}
public OsmandApplication getMyApplication() {
return (OsmandApplication)getActivity().getApplication();
return (OsmandApplication) getActivity().getApplication();
}
}

View file

@ -43,6 +43,12 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
public static final String SEARCH_LAT = SearchActivity.SEARCH_LAT;
public static final String SEARCH_LON = SearchActivity.SEARCH_LON;
private HistoryAdapter historyAdapter;
private Drawable addressIcon;
private Drawable favoriteIcon;
private Drawable locationIcon;
private Drawable poiIcon;
private Drawable wptIcon;
private Drawable noteIcon;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -57,9 +63,33 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
clearButton.setVisibility(View.GONE);
}
});
loadIcons();
return view;
}
private void loadIcons() {
addressIcon = getResources().getDrawable(R.drawable.ic_type_coordinates);
favoriteIcon = getResources().getDrawable(R.drawable.ic_action_fav_dark);
locationIcon = getResources().getDrawable(R.drawable.ic_action_marker_dark);
poiIcon = getResources().getDrawable(R.drawable.ic_action_gabout_dark);
wptIcon = getResources().getDrawable(R.drawable.ic_action_flage_dark);
noteIcon = getResources().getDrawable(R.drawable.ic_action_note_dark);
if (getMyApplication().getSettings().isLightContent()) {
addressIcon = addressIcon.mutate();
addressIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
favoriteIcon = favoriteIcon.mutate();
favoriteIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
locationIcon = locationIcon.mutate();
locationIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
poiIcon = poiIcon.mutate();
poiIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
wptIcon = wptIcon.mutate();
wptIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
noteIcon = noteIcon.mutate();
noteIcon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -97,7 +127,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
location = ((OsmandApplication) activity.getApplication()).getSettings().getLastKnownMapLocation();
}
historyAdapter.clear();
for(HistoryEntry entry : helper.getHistoryEntries()){
for (HistoryEntry entry : helper.getHistoryEntries()) {
historyAdapter.add(entry);
}
locationUpdate(location);
@ -108,7 +138,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
@Override
public void locationUpdate(LatLon l) {
//location = l;
if(historyAdapter != null) {
if (historyAdapter != null) {
historyAdapter.updateLocation(l);
}
}
@ -175,18 +205,36 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
ImageView arrow = (ImageView) row.findViewById(R.id.direction);
arrow.setImageDrawable(arrowImage);
ImageButton options = (ImageButton) row.findViewById(R.id.options);
final HistoryEntry model = getItem(position);
final HistoryEntry historyEntry = getItem(position);
if (location != null) {
int dist = (int) (MapUtils.getDistance(location, model.getLat(), model.getLon()));
int dist = (int) (MapUtils.getDistance(location, historyEntry.getLat(), historyEntry.getLon()));
distance = OsmAndFormatter.getFormattedDistance(dist, (OsmandApplication) getActivity().getApplication()) + " ";
}
distanceText.setText(distance);
nameText.setText(model.getName().getName(), BufferType.SPANNABLE);
nameText.setText(historyEntry.getName().getName(), BufferType.SPANNABLE);
ImageView icon =((ImageView) row.findViewById(R.id.icon));
if (historyEntry.getName().isAddress()) {
icon.setImageDrawable(addressIcon);
} else if (historyEntry.getName().isFavorite()) {
icon.setImageDrawable(favoriteIcon);
} else if (historyEntry.getName().isLocation()) {
icon.setImageDrawable(locationIcon);
} else if (historyEntry.getName().isPoi()) {
icon.setImageDrawable(poiIcon);
} else if (historyEntry.getName().isWpt()) {
icon.setImageDrawable(wptIcon);
} else if (historyEntry.getName().isAvNote()) {
icon.setImageDrawable(noteIcon);
} else {
icon.setImageDrawable(addressIcon);
}
options.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectModel(model, v);
selectModel(historyEntry, v);
}
});
@ -197,7 +245,7 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
@Override
public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) {
if(getActivity() instanceof SearchActivity) {
if (getActivity() instanceof SearchActivity) {
((SearchActivity) getActivity()).getClearToolbar(false);
}
}

View file

@ -21,7 +21,9 @@ import net.osmand.util.MapUtils;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
@ -42,6 +44,7 @@ public class DashRecentsFragment extends DashLocationFragment {
private List<ImageView> arrows = new ArrayList<ImageView>();
List<HistoryEntry> points = new ArrayList<HistoryEntry>();
Drawable icon;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -65,6 +68,11 @@ public class DashRecentsFragment extends DashLocationFragment {
activity.startActivity(search);
}
});
icon = getResources().getDrawable(R.drawable.ic_type_coordinates);
if (getMyApplication().getSettings().isLightContent()) {
icon = icon.mutate();
icon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
}
return view;
}
@ -121,7 +129,7 @@ public class DashRecentsFragment extends DashLocationFragment {
((ImageView) view.findViewById(R.id.icon)).
setImageDrawable(FavoriteImageDrawable.getOrCreate(getActivity(), Color.BLUE));
setImageDrawable(icon);
if(loc != null){
direction.setVisibility(View.VISIBLE);