From 2fb513c558a7ec95946277580efd7b3eba923da0 Mon Sep 17 00:00:00 2001 From: Bars107 Date: Mon, 2 Mar 2015 14:04:12 +0200 Subject: [PATCH 1/2] Added divider for current track on dashboard. Updated my places grop item. Added compound button for selected track. Updated track view. --- OsmAnd/res/layout/available_gpx.xml | 1 - OsmAnd/res/layout/dash_gpx_track_item.xml | 75 ++++++++++--------- OsmAnd/res/layout/expandable_list.xml | 1 - OsmAnd/res/values/sizes.xml | 1 + .../plus/activities/AvailableGPXFragment.java | 27 +++++++ .../plus/monitoring/DashTrackFragment.java | 1 + 6 files changed, 68 insertions(+), 38 deletions(-) diff --git a/OsmAnd/res/layout/available_gpx.xml b/OsmAnd/res/layout/available_gpx.xml index 79fadd724f..e1386906b5 100644 --- a/OsmAnd/res/layout/available_gpx.xml +++ b/OsmAnd/res/layout/available_gpx.xml @@ -67,7 +67,6 @@ android:layout_marginRight="0dp" android:layout_marginTop="0dp" android:layout_weight="1" - android:background="?attr/expandable_list_background" android:groupIndicator="@android:color/transparent"/> diff --git a/OsmAnd/res/layout/dash_gpx_track_item.xml b/OsmAnd/res/layout/dash_gpx_track_item.xml index 700e614bd0..fc6c7453a5 100644 --- a/OsmAnd/res/layout/dash_gpx_track_item.xml +++ b/OsmAnd/res/layout/dash_gpx_track_item.xml @@ -23,46 +23,47 @@ android:id="@+id/check_local_index" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:focusable="false" - android:visibility="gone" android:layout_marginLeft="@dimen/local_index_check_right_margin" - android:layout_marginTop="@dimen/favorites_icon_top_margin"/> + android:layout_marginTop="@dimen/favorites_icon_top_margin" + android:focusable="false" + android:visibility="gone"/> + android:focusable="false" + android:src="@drawable/ic_gpx_track" + android:visibility="gone"/> + android:orientation="horizontal" + android:visibility="visible"> + android:textColor="?android:textColorSecondary" + android:textSize="@dimen/download_descr_text_size"/> + android:layout_marginRight="@dimen/gpx_small_text_margin" + android:textColor="?android:textColorSecondary" + android:textSize="@dimen/download_descr_text_size"/> + android:textColor="?android:textColorSecondary" + android:textSize="@dimen/download_descr_text_size"/> + android:orientation="horizontal" + android:visibility="gone"> + android:textColor="?android:textColorSecondary" + android:textSize="@dimen/download_descr_text_size"/> + android:visibility="gone"/> + android:src="@drawable/ic_action_gsave_dark" + android:visibility="gone" + tools:visibility="visible"/> + android:src="?attr/list_settings_icon" + android:visibility="gone"/> + + - diff --git a/OsmAnd/res/layout/expandable_list.xml b/OsmAnd/res/layout/expandable_list.xml index 39dc5fc613..b5e7e756ab 100644 --- a/OsmAnd/res/layout/expandable_list.xml +++ b/OsmAnd/res/layout/expandable_list.xml @@ -20,7 +20,6 @@ style="@style/OsmandListView" android:layout_width="fill_parent" android:layout_height="0dp" - android:background="?attr/expandable_list_background" android:layout_marginLeft="0dp" android:layout_marginRight="0dp" android:layout_marginTop="0dp" diff --git a/OsmAnd/res/values/sizes.xml b/OsmAnd/res/values/sizes.xml index a613afb73a..973aa05ae9 100644 --- a/OsmAnd/res/values/sizes.xml +++ b/OsmAnd/res/values/sizes.xml @@ -42,6 +42,7 @@ 24dp 3dp 14dp + 6dp 14sp diff --git a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java index ae45358df0..dff0ce9bb0 100644 --- a/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/AvailableGPXFragment.java @@ -66,6 +66,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CheckBox; +import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ExpandableListView; import android.widget.Filter; @@ -267,6 +268,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { v.findViewById(R.id.options).setVisibility(View.GONE); v.findViewById(R.id.stop).setVisibility(View.VISIBLE); + v.findViewById(R.id.check_item).setVisibility(View.GONE); save.setImageDrawable(icon); } @@ -787,6 +789,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { v = inflater.inflate(R.layout.dash_gpx_track_item, parent, false); } udpateGpxInfoView(v, child, app, gpxNormal, gpxOnMap, false); + ImageView icon = (ImageView) v.findViewById(R.id.icon); ImageButton options = (ImageButton) v.findViewById(R.id.options); options.setOnClickListener(new View.OnClickListener() { @@ -821,6 +824,27 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { options.setVisibility(View.VISIBLE); } + final CompoundButton checkItem = (CompoundButton) v.findViewById(R.id.check_item); + if (isSelectedGroup(groupPosition)) { + checkItem.setVisibility(View.VISIBLE); + v.findViewById(R.id.options).setVisibility(View.GONE); + } else { + checkItem.setVisibility(View.GONE); + } + + final SelectedGpxFile selectedGpxFile = selectedGpxHelper.getSelectedFileByName(child.getFileName()); + checkItem.setChecked(selectedGpxFile != null); + checkItem.setOnClickListener( new View.OnClickListener() { + @Override + public void onClick(View v) { + if (child.gpx != null) { + selectedGpxHelper.selectGpxFile(child.gpx, checkItem.isChecked(), false); + } else { + selectedGpxHelper.getSelectedGPXFiles().remove(selectedGpxFile); + } + } + }); + v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -1420,6 +1444,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { if (sgpx != null) { icon.setImageDrawable(gpxOnMap); analysis = sgpx.getTrackAnalysis(); + } boolean sectionRead = analysis == null; if (sectionRead) { @@ -1473,6 +1498,8 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment { } else { descr.setVisibility(View.GONE); } + + v.findViewById(R.id.check_item).setVisibility(View.GONE); } } diff --git a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java index 3ca9771f97..2905447ce2 100644 --- a/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java +++ b/OsmAnd/src/net/osmand/plus/monitoring/DashTrackFragment.java @@ -140,6 +140,7 @@ public class DashTrackFragment extends DashBaseFragment { AvailableGPXFragment.createCurrentTrackView(view, app); ((TextView) view.findViewById(R.id.name)).setText(R.string.currently_recording_track); AvailableGPXFragment.updateCurrentTrack(view, getActivity(), app); + view.findViewById(R.id.divider).setVisibility(View.VISIBLE); tracks.addView(view); startHandler(view); From 34611f7a57bac2f5e38f0ce2383b8946c851f29a Mon Sep 17 00:00:00 2001 From: Bars107 Date: Mon, 2 Mar 2015 15:32:20 +0200 Subject: [PATCH 2/2] Updated recents views --- .../src/net/osmand/data/PointDescription.java | 3 + .../activities/FavoritesListFragment.java | 64 +++++++++-------- .../search/SearchHistoryFragment.java | 72 +++++++++++++++---- .../plus/dashboard/DashRecentsFragment.java | 10 ++- 4 files changed, 105 insertions(+), 44 deletions(-) diff --git a/OsmAnd/src/net/osmand/data/PointDescription.java b/OsmAnd/src/net/osmand/data/PointDescription.java index fdf0691b51..991a54b7ba 100644 --- a/OsmAnd/src/net/osmand/data/PointDescription.java +++ b/OsmAnd/src/net/osmand/data/PointDescription.java @@ -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() { diff --git a/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java b/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java index 4dc224cf09..91563fd0a2 100644 --- a/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/FavoritesListFragment.java @@ -1,5 +1,5 @@ /** - * + * */ package net.osmand.plus.activities; @@ -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; @@ -31,20 +33,20 @@ import android.widget.ListView; import android.widget.TextView; /** - * + * */ public class FavoritesListFragment extends ListFragment implements SearchActivityChild { - public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY"; + public static final String SELECT_FAVORITE_POINT_INTENT_KEY = "SELECT_FAVORITE_POINT_INTENT_KEY"; public static final int SELECT_FAVORITE_POINT_RESULT_OK = 1; - + private FavouritesAdapter favouritesAdapter; private boolean selectFavoriteMode; private OsmandSettings settings; private LatLon location; - + @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -58,7 +60,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit private OsmandApplication getApplication() { return (OsmandApplication) getActivity().getApplication(); } - + @Override public void onResume() { super.onResume(); @@ -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(); - } + + if (location == null && getActivity() instanceof SearchActivity) { + location = ((SearchActivity) getActivity()).getSearchPoint(); } + if (location == null) { + location = settings.getLastKnownMapLocation(); + } + locationUpdate(location); } @@ -92,22 +94,22 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit favouritesAdapter.updateLocation(l); } } - - 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); } } @Override public void onListItemClick(ListView l, View v, int position, long id) { - + if (!isSelectFavoriteMode()) { FavouritePoint point = favouritesAdapter.getItem(position); LatLon location = new LatLon(point.getLatitude(), point.getLongitude()); @@ -128,11 +130,11 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit private LatLon location; private OsmandApplication app; Drawable arrowImage; - + public LatLon getLocation() { return location; } - + public void updateLocation(LatLon l) { location = l; sort(new Comparator() { @@ -151,7 +153,7 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit return getName(object1).compareTo(getName(object2)); } } - }); + }); } public FavouritesAdapter(Activity activity, List list) { @@ -167,11 +169,11 @@ public class FavoritesListFragment extends ListFragment implements SearchActivit arrowImage.setColorFilter(activity.getResources().getColor(R.color.color_distance), PorterDuff.Mode.MULTIPLY); } } - - public String getName(FavouritePoint model){ + + public String getName(FavouritePoint model) { return model.getName(); } - + @Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; @@ -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(); } } diff --git a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java index 6e2afda578..6b741d391a 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/SearchHistoryFragment.java @@ -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,15 +63,39 @@ 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); helper = SearchHistoryHelper.getInstance((OsmandApplication) getActivity().getApplicationContext()); } - + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -73,8 +103,8 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit setListAdapter(historyAdapter); setHasOptionsMenu(true); } - - + + @Override public void onResume() { super.onResume(); @@ -97,18 +127,18 @@ 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); clearButton.setVisibility(historyAdapter.isEmpty() ? View.GONE : View.VISIBLE); - + } @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,8 +245,8 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit @Override public void onCreateOptionsMenu(Menu onCreate, MenuInflater inflater) { - if(getActivity() instanceof SearchActivity) { - ((SearchActivity) getActivity()).getClearToolbar(false); + if (getActivity() instanceof SearchActivity) { + ((SearchActivity) getActivity()).getClearToolbar(false); } } diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java index 5f0d7601f5..884aca052f 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashRecentsFragment.java @@ -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 arrows = new ArrayList(); List points = new ArrayList(); + 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);