From 961d8be8b99e92bbf12dc05625a30e29b029f96d Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Wed, 30 Oct 2013 10:53:37 -0700 Subject: [PATCH] Improve marker count layout in list view --- MyTracks/.classpath | 2 +- MyTracks/res/layout/list_item.xml | 15 +++++++++++-- .../apps/mytracks/util/ListItemUtils.java | 22 +++++++++++-------- MyTracksLib/.classpath | 2 +- MyTracksTest/.classpath | 2 +- MyTracksTest_E2E/.classpath | 2 +- google-play-services_lib/.classpath | 2 +- 7 files changed, 31 insertions(+), 16 deletions(-) diff --git a/MyTracks/.classpath b/MyTracks/.classpath index 49bf11604..092cde2eb 100644 --- a/MyTracks/.classpath +++ b/MyTracks/.classpath @@ -7,6 +7,6 @@ - + diff --git a/MyTracks/res/layout/list_item.xml b/MyTracks/res/layout/list_item.xml index 0892c208d..00156666c 100644 --- a/MyTracks/res/layout/list_item.xml +++ b/MyTracks/res/layout/list_item.xml @@ -69,19 +69,30 @@ limitations under the License. + 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 00605ae6e..b366addcb 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java @@ -21,11 +21,11 @@ import com.google.android.maps.mytracks.R; import android.app.Activity; import android.content.Context; import android.content.res.TypedArray; -import android.graphics.drawable.Drawable; import android.net.Uri; import android.text.format.DateUtils; import android.view.Display; import android.view.View; +import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; import android.widget.TextView; @@ -95,25 +95,29 @@ public class ListItemUtils { ownerTimeDistanceTextView.setTextAppearance(activity, R.style.TextSmall); ownerTimeDistance = getOwnerTimeDistance(sharedOwner, totalTime, totalDistance); if (markerCount > 0) { - ownerTimeDistance += " \u2027 "; + ownerTimeDistance += " \u2027"; } } setTextView(ownerTimeDistanceTextView, ownerTimeDistance); // Set markerCount + ImageView markerCountIcon = (ImageView) view.findViewById(R.id.list_item_marker_count_icon); TextView markerCountTextView = (TextView) view.findViewById(R.id.list_item_marker_count); if (markerCount > 0) { + markerCountIcon.setVisibility(View.VISIBLE); markerCountTextView.setVisibility(View.VISIBLE); - Drawable markerDrawable = activity.getResources() - .getDrawable(R.drawable.ic_menu_insert_marker); - int size = markerCountTextView.getLineHeight(); - markerDrawable.setBounds(0, 0, size, size); - markerCountTextView.setCompoundDrawables(markerDrawable, null, null, null); - markerCountTextView.setText(markerCount + ""); + + int lineHeight = markerCountTextView.getLineHeight(); + LayoutParams layoutParams = markerCountIcon.getLayoutParams(); + layoutParams.width = lineHeight; + layoutParams.height = lineHeight; + + markerCountTextView.setText(String.valueOf(markerCount)); } else { + markerCountIcon.setVisibility(View.GONE); markerCountTextView.setVisibility(View.GONE); } - + // Set date/time String[] dateTime = getDateTime(isRecording, activity, startTime); TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date); diff --git a/MyTracksLib/.classpath b/MyTracksLib/.classpath index f7b8a1f99..d57ec0251 100644 --- a/MyTracksLib/.classpath +++ b/MyTracksLib/.classpath @@ -4,6 +4,6 @@ - + diff --git a/MyTracksTest/.classpath b/MyTracksTest/.classpath index 48c3f4ed5..f2f17228c 100644 --- a/MyTracksTest/.classpath +++ b/MyTracksTest/.classpath @@ -10,6 +10,6 @@ - + diff --git a/MyTracksTest_E2E/.classpath b/MyTracksTest_E2E/.classpath index 48c3f4ed5..f2f17228c 100644 --- a/MyTracksTest_E2E/.classpath +++ b/MyTracksTest_E2E/.classpath @@ -10,6 +10,6 @@ - + diff --git a/google-play-services_lib/.classpath b/google-play-services_lib/.classpath index 2731f9c53..7bc01d9a9 100644 --- a/google-play-services_lib/.classpath +++ b/google-play-services_lib/.classpath @@ -4,6 +4,6 @@ - +