From 48ad505e55327cc42f63811d13b5d911493049c8 Mon Sep 17 00:00:00 2001 From: Jimmy Shih Date: Mon, 4 Nov 2013 12:30:29 -0800 Subject: [PATCH] Improve marker detail layout --- .../{photo_gradient.xml => text_gradient.xml} | 5 +- MyTracks/res/layout/list_item.xml | 6 +-- .../res/layout/marker_detail_fragment.xml | 51 ++++++++++--------- MyTracks/res/values/colors.xml | 5 +- .../fragments/MarkerDetailFragment.java | 29 +++-------- .../apps/mytracks/util/ListItemUtils.java | 6 +-- .../mytracks/fragments/ChartFragmentTest.java | 14 ++--- 7 files changed, 52 insertions(+), 64 deletions(-) rename MyTracks/res/drawable/{photo_gradient.xml => text_gradient.xml} (83%) diff --git a/MyTracks/res/drawable/photo_gradient.xml b/MyTracks/res/drawable/text_gradient.xml similarity index 83% rename from MyTracks/res/drawable/photo_gradient.xml rename to MyTracks/res/drawable/text_gradient.xml index 34181b1f6..2b6a856be 100644 --- a/MyTracks/res/drawable/photo_gradient.xml +++ b/MyTracks/res/drawable/text_gradient.xml @@ -17,6 +17,7 @@ + android:centerColor="@color/text_gradient_center" + android:endColor="@color/text_gradient_start" + android:startColor="@color/text_gradient_end" /> \ No newline at end of file diff --git a/MyTracks/res/layout/list_item.xml b/MyTracks/res/layout/list_item.xml index 3be7ff963..3c2816b1a 100644 --- a/MyTracks/res/layout/list_item.xml +++ b/MyTracks/res/layout/list_item.xml @@ -24,14 +24,14 @@ limitations under the License. android:layout_height="match_parent" android:layout_width="match_parent" android:scaleType="centerCrop" /> - + + android:src="@drawable/text_gradient" /> - - - - - - - + android:layout_width="match_parent" > + + + + + + + + #40401465 #FF0066FF #40C8E0FF - #00000000 - #FF000000 + #B2000000 + #00000000 + #FF000000 #FFBE161B #FFFAAD2C #99999999 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 1f18c75f7..91298c76a 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java +++ b/MyTracks/src/com/google/android/apps/mytracks/fragments/MarkerDetailFragment.java @@ -37,14 +37,12 @@ import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.util.Log; import android.view.Display; -import android.view.Gravity; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; -import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -72,14 +70,14 @@ public class MarkerDetailFragment extends Fragment { private MyTracksProviderUtils myTracksProviderUtils; private Handler handler; private ImageView photo; - private ImageView photoGradient; + private ImageView textGradient; private LinearLayout waypointInfo; private Waypoint waypoint; private Runnable hideText = new Runnable() { @Override public void run() { - photoGradient.setVisibility(View.GONE); + textGradient.setVisibility(View.GONE); waypointInfo.setVisibility(View.GONE); } }; @@ -110,11 +108,11 @@ public class MarkerDetailFragment extends Fragment { public void onClick(View v) { handler.removeCallbacks(hideText); int visibility = waypointInfo.getVisibility() == View.GONE ? View.VISIBLE : View.GONE; - photoGradient.setVisibility(visibility); + textGradient.setVisibility(visibility); waypointInfo.setVisibility(visibility); } }); - photoGradient = (ImageView) view.findViewById(R.id.marker_detail_waypoint_photo_gradient); + textGradient = (ImageView) view.findViewById(R.id.marker_detail_waypoint_text_gradient); waypointInfo = (LinearLayout) view.findViewById(R.id.marker_detail_waypoint_info); return view; @@ -221,14 +219,12 @@ public class MarkerDetailFragment extends Fragment { String photoUrl = waypoint.getPhotoUrl(); if (photoUrl == null || photoUrl.equals("")) { photo.setVisibility(View.GONE); - photoGradient.setVisibility(View.GONE); + textGradient.setVisibility(View.GONE); waypointInfo.setVisibility(View.VISIBLE); - setLayoutGravity(waypointInfo, Gravity.TOP); } else { photo.setVisibility(View.VISIBLE); - photoGradient.setVisibility(View.VISIBLE); + textGradient.setVisibility(View.VISIBLE); waypointInfo.setVisibility(View.VISIBLE); - setLayoutGravity(waypointInfo, Gravity.BOTTOM); Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay(); PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), @@ -258,19 +254,6 @@ public class MarkerDetailFragment extends Fragment { } } - /** - * Sets the layout gravity. Assuming the parent is a framelayout. - * - * @param linearLayout the linear layout - * @param gravity the gravity - */ - private void setLayoutGravity(LinearLayout linearLayout, int gravity) { - FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) linearLayout - .getLayoutParams(); - layoutParams.gravity = gravity; - linearLayout.setLayoutParams(layoutParams); - } - /** * Sets a text view. * 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 aedf9e251..3c7fc8c56 100644 --- a/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java +++ b/MyTracks/src/com/google/android/apps/mytracks/util/ListItemUtils.java @@ -144,13 +144,13 @@ public class ListItemUtils { } ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo); - ImageView photoGradient = (ImageView) view.findViewById(R.id.list_item_photo_gradient); + ImageView textGradient = (ImageView) view.findViewById(R.id.list_item_text_gradient); if (photoUrl == null || photoUrl.equals("")) { photo.setVisibility(View.GONE); - photoGradient.setVisibility(View.GONE); + textGradient.setVisibility(View.GONE); } else { photo.setVisibility(View.VISIBLE); - photoGradient.setVisibility(View.VISIBLE); + textGradient.setVisibility(View.VISIBLE); Display defaultDisplay = activity.getWindowManager().getDefaultDisplay(); PhotoUtils.setImageVew( photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false); diff --git a/MyTracksTest/src/com/google/android/apps/mytracks/fragments/ChartFragmentTest.java b/MyTracksTest/src/com/google/android/apps/mytracks/fragments/ChartFragmentTest.java index 043b0e892..7c0d781a1 100644 --- a/MyTracksTest/src/com/google/android/apps/mytracks/fragments/ChartFragmentTest.java +++ b/MyTracksTest/src/com/google/android/apps/mytracks/fragments/ChartFragmentTest.java @@ -46,7 +46,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the incorrect values of sensor in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)} + * double[])} */ public void testFillDataPoint_sensorIncorrect() { MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation(); @@ -80,7 +80,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the correct values of sensor in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)}. + * double[])}. */ public void testFillDataPoint_sensorCorrect() { MyTracksLocation myTracksLocation = TrackStubUtils.createMyTracksLocation(); @@ -112,7 +112,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the value of metric Distance in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)}. + * double[])}. */ public void testFillDataPoint_distanceMetric() { // By distance. @@ -153,7 +153,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the value of imperial Distance in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)}. + * double[])}. */ public void testFillDataPoint_distanceImperial() { // By distance. @@ -198,7 +198,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the values of time in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)}. + * double[])}. */ public void testFillDataPoint_time() { // By time @@ -215,7 +215,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the value of elevation in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)} by one and two points. + * double[])} by one and two points. */ public void testFillDataPoint_elevation() { MyTracksLocation myTracksLocation1 = TrackStubUtils.createMyTracksLocation(); @@ -240,7 +240,7 @@ public class ChartFragmentTest extends AndroidTestCase { /** * Tests the logic to get the value of speed in {@link ChartFragment#fillDataPoint(Location, - * double[], android.content.Context)}. In this test, firstly remove all + * double[])}. In this test, firstly remove all * points in memory, and then fill in two points one by one. The speed values * of these points are 129, 130. */