Add text shadow when displaying photo in marker detail page

This commit is contained in:
Jimmy Shih
2013-12-05 10:45:53 -08:00
parent 7fe603c5fe
commit 0a83728b82
4 changed files with 20 additions and 39 deletions
@@ -71,8 +71,8 @@ limitations under the License.
android:paddingTop="8dp" android:paddingTop="8dp"
style="@style/TextMedium" /> style="@style/TextMedium" />
<TextView <TextView
android:paddingBottom="4dp" android:paddingBottom="6dp"
android:paddingTop="8dp" android:paddingTop="4dp"
android:text="@string/marker_detail_statistics_title" android:text="@string/marker_detail_statistics_title"
style="@style/TextSmall" /> style="@style/TextSmall" />
<include layout="@layout/stats_content" /> <include layout="@layout/stats_content" />
-1
View File
@@ -29,7 +29,6 @@ limitations under the License.
<color name="chart_speed_fill">#40C8E0FF</color> <!-- transparent blue --> <color name="chart_speed_fill">#40C8E0FF</color> <!-- transparent blue -->
<color name="holo_orange_dark">#FFFF8800</color> <color name="holo_orange_dark">#FFFF8800</color>
<color name="recording_text">#FFBE161B</color> <!-- red --> <color name="recording_text">#FFBE161B</color> <!-- red -->
<color name="shadow_color">#B2000000</color> <!-- black 70% opacity -->
<color name="stats_large_label">#FFFAAD2C</color> <!-- orange --> <color name="stats_large_label">#FFFAAD2C</color> <!-- orange -->
<color name="stats_separator">#99999999</color> <!-- light gray --> <color name="stats_separator">#99999999</color> <!-- light gray -->
<color name="text_gradient_center">#B2000000</color> <!-- black 70% opacity --> <color name="text_gradient_center">#B2000000</color> <!-- black 70% opacity -->
@@ -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;
import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType; import com.google.android.apps.mytracks.util.CalorieUtils.ActivityType;
import com.google.android.apps.mytracks.util.IntentUtils; 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.PhotoUtils;
import com.google.android.apps.mytracks.util.StatsUtils; import com.google.android.apps.mytracks.util.StatsUtils;
import com.google.android.apps.mytracks.util.StringUtils; 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 waypointView = getView().findViewById(R.id.marker_detail_waypoint);
View statisticsView = getView().findViewById(R.id.marker_detail_statistics); View statisticsView = getView().findViewById(R.id.marker_detail_statistics);
if (waypoint.getType() == WaypointType.WAYPOINT) { boolean isWaypoint = waypoint.getType() == WaypointType.WAYPOINT;
waypointView.setVisibility(View.VISIBLE); waypointView.setVisibility(isWaypoint ? View.VISIBLE : View.GONE);
statisticsView.setVisibility(View.GONE); statisticsView.setVisibility(isWaypoint ? View.GONE : View.VISIBLE);
if (isWaypoint) {
String photoUrl = waypoint.getPhotoUrl(); String photoUrl = waypoint.getPhotoUrl();
if (photoUrl == null || photoUrl.equals("")) { boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
photo.setVisibility(View.GONE); photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
textGradient.setVisibility(View.GONE); textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
waypointInfo.setVisibility(View.VISIBLE); waypointInfo.setVisibility(View.VISIBLE);
} else {
handler.removeCallbacks(hideText);
photo.setVisibility(View.VISIBLE);
textGradient.setVisibility(View.VISIBLE);
waypointInfo.setVisibility(View.VISIBLE);
if (hasPhoto) {
handler.removeCallbacks(hideText);
Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay(); Display defaultDisplay = getActivity().getWindowManager().getDefaultDisplay();
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), defaultDisplay.getWidth(),
defaultDisplay.getHeight(), true); defaultDisplay.getHeight(), true);
@@ -269,20 +268,18 @@ public class MarkerDetailFragment extends Fragment {
} }
TextView name = (TextView) getView().findViewById(R.id.marker_detail_waypoint_name); 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); 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() TextView description = (TextView) getView()
.findViewById(R.id.marker_detail_waypoint_description); .findViewById(R.id.marker_detail_waypoint_description);
setTextView(description, waypoint.getDescription()); ListItemUtils.setTextView(getActivity(), description, waypoint.getDescription(), hasPhoto);
} else { } else {
waypointView.setVisibility(View.GONE);
statisticsView.setVisibility(View.VISIBLE);
TextView name = (TextView) getView().findViewById(R.id.marker_detail_statistics_name); 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()); Track track = myTracksProviderUtils.getTrack(waypoint.getTrackId());
ActivityType activityType = track != null ? CalorieUtils.getActivityType( ActivityType activityType = track != null ? CalorieUtils.getActivityType(
@@ -293,19 +290,4 @@ public class MarkerDetailFragment extends Fragment {
StatsUtils.setLocationValues(getActivity(), null, getView(), waypoint.getLocation(), false); 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);
}
}
} }
@@ -222,7 +222,7 @@ public class ListItemUtils {
* @param value the value for the text view * @param value the value for the text view
* @param addShadow true to add shadow * @param addShadow true to add shadow
*/ */
private static void setTextView( public static void setTextView(
Context context, TextView textView, String value, boolean addShadow) { Context context, TextView textView, String value, boolean addShadow) {
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
textView.setVisibility(View.GONE); textView.setVisibility(View.GONE);
@@ -230,7 +230,7 @@ public class ListItemUtils {
textView.setVisibility(View.VISIBLE); textView.setVisibility(View.VISIBLE);
textView.setText(value); textView.setText(value);
if (addShadow) { 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 { } else {
textView.setShadowLayer(0, 0, 0, 0); textView.setShadowLayer(0, 0, 0, 0);
} }