diff --git a/MyTracks/res/layout/marker_detail_fragment.xml b/MyTracks/res/layout/marker_detail_fragment.xml index 54e87952f..b13113aa1 100644 --- a/MyTracks/res/layout/marker_detail_fragment.xml +++ b/MyTracks/res/layout/marker_detail_fragment.xml @@ -71,8 +71,8 @@ limitations under the License. android:paddingTop="8dp" style="@style/TextMedium" /> diff --git a/MyTracks/res/values/colors.xml b/MyTracks/res/values/colors.xml index f4a310196..f64d2400a 100644 --- a/MyTracks/res/values/colors.xml +++ b/MyTracks/res/values/colors.xml @@ -29,7 +29,6 @@ limitations under the License. #40C8E0FF #FFFF8800 #FFBE161B - #B2000000 #FFFAAD2C #99999999 #B2000000 diff --git a/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java b/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java index 832a020d7..beb2c9145 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java @@ -25,6 +25,7 @@ import com.google.android.apps.mytracks.content.Waypoint.WaypointType; import com.google.android.apps.mytracks.util.CalorieUtils; import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType; import com.google.android.apps.mytracks.util.IntentUtils; +import com.google.android.apps.mytracks.util.ListItemUtils; import com.google.android.apps.mytracks.util.PhotoUtils; import com.google.android.apps.mytracks.util.StatsUtils; import com.google.android.apps.mytracks.util.StringUtils; @@ -247,21 +248,19 @@ public class MarkerDetailFragment extends Fragment { View waypointView = getView().findViewById(R.id.marker_detail_waypoint); View statisticsView = getView().findViewById(R.id.marker_detail_statistics); - if (waypoint.getType() == WaypointType.WAYPOINT) { - waypointView.setVisibility(View.VISIBLE); - statisticsView.setVisibility(View.GONE); + boolean isWaypoint = waypoint.getType() == WaypointType.WAYPOINT; + waypointView.setVisibility(isWaypoint ? View.VISIBLE : View.GONE); + statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE); + if (isWaypoint) { String photoUrl = waypoint.getPhotoUrl(); - if (photoUrl == null || photoUrl.equals("")) { - photo.setVisibility(View.GONE); - textGradient.setVisibility(View.GONE); - waypointInfo.setVisibility(View.VISIBLE); - } else { - handler.removeCallbacks(hideText); - photo.setVisibility(View.VISIBLE); - textGradient.setVisibility(View.VISIBLE); - waypointInfo.setVisibility(View.VISIBLE); + boolean hasPhoto = photoUrl != null && !photoUrl.equals(""); + photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE); + textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE); + waypointInfo.setVisibility(View.VISIBLE); + if (hasPhoto) { + handler.removeCallbacks(hideText); Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay(); PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), defaultDisplay.getHeight(), true); @@ -269,20 +268,18 @@ public class MarkerDetailFragment extends Fragment { } TextView name = (TextView) getView().findViewById(R.id.marker_detail_waypoint_name); - setTextView(name, waypoint.getName()); + ListItemUtils.setTextView(getActivity(), name, waypoint.getName(), hasPhoto); TextView category = (TextView) getView().findViewById(R.id.marker_detail_waypoint_category); - setTextView(category, StringUtils.getCategory(waypoint.getCategory())); + ListItemUtils.setTextView( + getActivity(), category, StringUtils.getCategory(waypoint.getCategory()), hasPhoto); TextView description = (TextView) getView() .findViewById(R.id.marker_detail_waypoint_description); - setTextView(description, waypoint.getDescription()); + ListItemUtils.setTextView(getActivity(), description, waypoint.getDescription(), hasPhoto); } else { - waypointView.setVisibility(View.GONE); - statisticsView.setVisibility(View.VISIBLE); - TextView name = (TextView) getView().findViewById(R.id.marker_detail_statistics_name); - setTextView(name, waypoint.getName()); + ListItemUtils.setTextView(getActivity(), name, waypoint.getName(), false); Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId()); ActivityType activityType = track != null ? CalorieUtils.getActivityType( @@ -293,19 +290,4 @@ public class MarkerDetailFragment extends Fragment { StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false); } } - - /** - * Sets a text view. - * - * @param textView the text view - * @param value the value for the text view - */ - private void setTextView(TextView textView, String value) { - if (value == null || value.length() == 0) { - textView.setVisibility(View.GONE); - } else { - textView.setVisibility(View.VISIBLE); - textView.setText(value); - } - } } diff --git a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java index 0fe6ed59d..90ec8eb51 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java @@ -222,7 +222,7 @@ public class ListItemUtils { * @param value the value for the text view * @param addShadow true to add shadow */ - private static void setTextView( + public static void setTextView( Context context, TextView textView, String value, boolean addShadow) { if (value == null || value.length() == 0) { textView.setVisibility(View.GONE); @@ -230,7 +230,7 @@ public class ListItemUtils { textView.setVisibility(View.VISIBLE); textView.setText(value); if (addShadow) { - textView.setShadowLayer(8, 0, 10, context.getResources().getColor(R.color.shadow_color)); + textView.setShadowLayer(5, 0, 2, context.getResources().getColor(android.R.color.black)); } else { textView.setShadowLayer(0, 0, 0, 0); }