Updated favorites list in search
This commit is contained in:
parent
e787dd53af
commit
1f897d13f6
7 changed files with 75 additions and 114 deletions
|
@ -19,18 +19,18 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favourite_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favourite_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginRight="@dimen/favorites_icon_right_margin"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
<?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:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:orientation="horizontal">
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="@dimen/list_item_height"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="5dp"
|
||||
android:paddingLeft="@dimen/list_content_padding"
|
||||
android:paddingRight="@dimen/list_content_padding"
|
||||
android:paddingTop="5dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
style="@style/ListText"
|
||||
<TextView
|
||||
android:id="@+id/label"
|
||||
style="@style/ListText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="3dp"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:maxLines="1"
|
||||
android:layout_marginRight="3dp"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
tools:text="@string/lorem_ipsum"
|
||||
android:layout_weight="1" />
|
||||
android:maxLines="1"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/remove"
|
||||
android:contentDescription="@string/default_buttons_delete"
|
||||
<ImageButton
|
||||
android:id="@+id/remove"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/reset_image"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:paddingTop="2dp" />
|
||||
android:background="?attr/reset_image"
|
||||
android:contentDescription="@string/default_buttons_delete"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="2dp"
|
||||
android:paddingTop="2dp"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -45,7 +45,7 @@ import net.osmand.plus.views.controls.PagerSlidingTabStrip;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
public class FavoritesActivity extends TabActivity implements OsmAndLocationProvider.OsmAndCompassListener, OsmAndLocationProvider.OsmAndLocationListener {
|
||||
public class FavoritesActivity extends TabActivity {
|
||||
|
||||
private static final String FAVOURITES_INFO = "FAVOURITES_INFO";
|
||||
private static final String TRACKS = "TRACKS";
|
||||
|
@ -125,10 +125,6 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
|||
}
|
||||
});
|
||||
|
||||
if (getMyApplication().getFavorites().getFavouritePoints().size() > 0) {
|
||||
getLocationProvider().addCompassListener(this);
|
||||
getLocationProvider().registerOrUnregisterCompassListener(true);
|
||||
}
|
||||
}
|
||||
|
||||
public OsmandApplication getMyApplication() {
|
||||
|
@ -143,9 +139,6 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
|||
protected void onPause() {
|
||||
super.onPause();
|
||||
((OsmandApplication) getApplication()).getSelectedGpxHelper().setUiListener(FavoritesActivity.class, null);
|
||||
getLocationProvider().pauseAllUpdates();
|
||||
getLocationProvider().removeLocationListener(this);
|
||||
getLocationProvider().removeCompassListener(this);
|
||||
}
|
||||
|
||||
public void updateSelectedTracks() {
|
||||
|
@ -217,25 +210,5 @@ public class FavoritesActivity extends TabActivity implements OsmAndLocationProv
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCompassValue(float value) {
|
||||
for (WeakReference<Fragment> ref : fragList) {
|
||||
Fragment f = ref.get();
|
||||
if (f instanceof FavoritesTreeFragment && !f.isDetached()) {
|
||||
((FavoritesTreeFragment) f).updateCompassValue(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
for (WeakReference<Fragment> ref : fragList) {
|
||||
Fragment f = ref.get();
|
||||
if (f instanceof FavoritesTreeFragment && !f.isDetached()) {
|
||||
((FavoritesTreeFragment) f).updateLocation(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ package net.osmand.plus.activities;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.v4.app.ListFragment;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
import android.view.*;
|
||||
|
@ -84,6 +86,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
}
|
||||
}
|
||||
locationUpdate(location);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -129,6 +132,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
private Activity activity;
|
||||
private LatLon location;
|
||||
private OsmandApplication app;
|
||||
Drawable arrowImage;
|
||||
|
||||
public LatLon getLocation() {
|
||||
return location;
|
||||
|
@ -159,6 +163,14 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
super(activity, R.layout.favourites_list_item, list);
|
||||
this.activity = activity;
|
||||
this.app = ((OsmandApplication) activity.getApplication());
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
arrowImage = activity.getResources().getDrawable(R.drawable.ic_destination_arrow_white);
|
||||
arrowImage.mutate();
|
||||
if (light) {
|
||||
arrowImage.setColorFilter(activity.getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||
} else {
|
||||
arrowImage.setColorFilter(activity.getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
}
|
||||
|
||||
public String getName(FavouritePoint model){
|
||||
|
@ -176,8 +188,12 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
row = inflater.inflate(R.layout.favourites_list_item, parent, false);
|
||||
}
|
||||
|
||||
TextView label = (TextView) row.findViewById(R.id.favourite_label);
|
||||
TextView name = (TextView) row.findViewById(R.id.favourite_label);
|
||||
TextView distanceText = (TextView) row.findViewById(R.id.distance);
|
||||
ImageView icon = (ImageView) row.findViewById(R.id.favourite_icon);
|
||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||
direction.setImageDrawable(arrowImage);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
final FavouritePoint model = getItem(position);
|
||||
if (!model.getCategory().isEmpty()){
|
||||
row.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
|
||||
|
@ -193,9 +209,8 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
.getLongitude()));
|
||||
distance = OsmAndFormatter.getFormattedDistance(dist, app) + " " ;
|
||||
}
|
||||
|
||||
label.setText(distance + getName(model), BufferType.SPANNABLE);
|
||||
((Spannable) label.getText()).setSpan(new ForegroundColorSpan(activity.getResources().getColor(R.color.color_distance)), 0, distance.length(), 0);
|
||||
distanceText.setText(distance);
|
||||
name.setText(getName(model));
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||
row.findViewById(R.id.favourite_icon).setVisibility(View.VISIBLE);
|
||||
ch.setVisibility(View.GONE);
|
||||
|
@ -204,5 +219,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit
|
|||
|
||||
}
|
||||
|
||||
|
||||
public OsmandApplication getMyApplication() {
|
||||
return (OsmandApplication)getActivity().getApplication();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Handler;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.view.ActionMode;
|
||||
|
@ -19,7 +21,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -33,7 +34,6 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dialogs.DirectionsDialogs;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||
|
@ -80,9 +80,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
private Set<FavoriteGroup> groupsToDelete = new LinkedHashSet<FavoriteGroup>();
|
||||
private ActionMode actionMode;
|
||||
private SearchView searchView;
|
||||
|
||||
protected LatLon loc = null;
|
||||
protected Float heading = null;
|
||||
Drawable arrowImage;
|
||||
|
||||
@Override
|
||||
public void onAttach(Activity activity) {
|
||||
|
@ -92,6 +90,15 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
favouritesAdapter = new FavouritesAdapter();
|
||||
favouritesAdapter.synchronizeGroups();
|
||||
setAdapter(favouritesAdapter);
|
||||
|
||||
boolean light = getMyApplication().getSettings().isLightContent();
|
||||
arrowImage = getResources().getDrawable(R.drawable.ic_destination_arrow_white);
|
||||
arrowImage.mutate();
|
||||
if (light) {
|
||||
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||
} else {
|
||||
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteFavorites() {
|
||||
|
@ -126,7 +133,6 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
// final LatLon mapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
favouritesAdapter.synchronizeGroups();
|
||||
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
if(favouritesAdapter.getGroupCount() > 0 &&
|
||||
"".equals(favouritesAdapter.getGroup(0).name)) {
|
||||
getExpandableListView().expandGroup(0);
|
||||
|
@ -778,12 +784,9 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
distanceText.setTextColor(getResources().getColor(R.color.color_distance));
|
||||
row.findViewById(R.id.group_image).setVisibility(View.GONE);
|
||||
|
||||
if(loc != null){
|
||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
DashLocationFragment.updateArrow(getActivity(), loc, new LatLon(model.getLatitude(), model.getLongitude()), direction,
|
||||
10, R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
direction.setImageDrawable(arrowImage);
|
||||
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
|
||||
if (selectionMode) {
|
||||
|
@ -871,34 +874,4 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
//This is used as origin for both Fav-list and direction arrows
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
} else {
|
||||
loc = new LatLon(0f, 0f);
|
||||
}
|
||||
updateArrows();
|
||||
}
|
||||
|
||||
public boolean updateCompassValue(float value) {
|
||||
//heading = value;
|
||||
//updateArrows();
|
||||
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices
|
||||
float lastHeading = heading != null ? heading : 99;
|
||||
heading = value;
|
||||
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
||||
updateArrows();
|
||||
return true;
|
||||
} else {
|
||||
heading = lastHeading;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void updateArrows(){
|
||||
favouritesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -295,9 +295,6 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
} else {
|
||||
arrowImage.setColorFilter(getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addFooterView() {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.render;
|
||||
|
||||
import net.osmand.core.android.MapRendererView;
|
||||
import net.osmand.core.android.TileSourceProxyProvider;
|
||||
import net.osmand.core.jni.MapLayerConfiguration;
|
||||
import net.osmand.core.jni.PointI;
|
||||
import net.osmand.data.LatLon;
|
||||
|
|
Loading…
Reference in a new issue