forked from upstream-mirrors/OpenTracks
Add text shadow when displaying photo
This commit is contained in:
@@ -14,7 +14,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
<resources>
|
<resources xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<!-- The style for large size text -->
|
<!-- The style for large size text -->
|
||||||
<style name="TextLarge" parent="@android:style/TextAppearance.Holo.Large">
|
<style name="TextLarge" parent="@android:style/TextAppearance.Holo.Large">
|
||||||
<!-- same as TextLarge in values/styles.xml except inheriting from a parent instead of specifying textSize -->
|
<!-- same as TextLarge in values/styles.xml except inheriting from a parent instead of specifying textSize -->
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ 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 -->
|
||||||
<color name="text_gradient_end">#00000000</color> <!-- black 0% opacity -->
|
<color name="text_gradient_end">#00000000</color> <!-- black 0% opacity -->
|
||||||
<color name="text_gradient_start">#FF000000</color> <!-- black 100% opacity -->
|
<color name="text_gradient_start">#FF000000</color> <!-- black 100% opacity -->
|
||||||
@@ -38,5 +39,4 @@ limitations under the License.
|
|||||||
<color name="track_color_normal">#F75858FA</color> <!-- blue color -->
|
<color name="track_color_normal">#F75858FA</color> <!-- blue color -->
|
||||||
<color name="track_color_slow">#F774DF00</color> <!-- green color -->
|
<color name="track_color_slow">#F774DF00</color> <!-- green color -->
|
||||||
<color name="track_controller_background">#FF0E0E0E</color> <!-- dark gray -->
|
<color name="track_controller_background">#FF0E0E0E</color> <!-- dark gray -->
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
@@ -65,7 +65,23 @@ public class ListItemUtils {
|
|||||||
boolean isPaused, int iconId, int iconContentDescriptionId, String name, String sharedOwner,
|
boolean isPaused, int iconId, int iconContentDescriptionId, String name, String sharedOwner,
|
||||||
String totalTime, String totalDistance, int markerCount, long startTime,
|
String totalTime, String totalDistance, int markerCount, long startTime,
|
||||||
boolean useRelativeTime, String category, String description, String photoUrl) {
|
boolean useRelativeTime, String category, String description, String photoUrl) {
|
||||||
|
|
||||||
|
// Set photo
|
||||||
|
ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo);
|
||||||
|
ImageView textGradient = (ImageView) view.findViewById(R.id.list_item_text_gradient);
|
||||||
|
boolean hasPhoto = photoUrl != null && !photoUrl.equals("");
|
||||||
|
|
||||||
|
photo.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||||
|
textGradient.setVisibility(hasPhoto ? View.VISIBLE : View.GONE);
|
||||||
|
|
||||||
|
if (hasPhoto) {
|
||||||
|
photo.setImageResource(android.R.color.transparent);
|
||||||
|
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
||||||
|
PhotoUtils.setImageVew(
|
||||||
|
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set icon
|
||||||
if (isRecording) {
|
if (isRecording) {
|
||||||
iconId = isPaused ? R.drawable.ic_track_paused : R.drawable.ic_track_recording;
|
iconId = isPaused ? R.drawable.ic_track_paused : R.drawable.ic_track_recording;
|
||||||
iconContentDescriptionId = isPaused ? R.string.icon_pause_recording
|
iconContentDescriptionId = isPaused ? R.string.icon_pause_recording
|
||||||
@@ -78,7 +94,7 @@ public class ListItemUtils {
|
|||||||
|
|
||||||
// Set name
|
// Set name
|
||||||
TextView nameTextView = (TextView) view.findViewById(R.id.list_item_name);
|
TextView nameTextView = (TextView) view.findViewById(R.id.list_item_name);
|
||||||
nameTextView.setText(name);
|
setTextView(activity, nameTextView, name, hasPhoto);
|
||||||
|
|
||||||
// Set sharedOwner/totalTime/totalDistance
|
// Set sharedOwner/totalTime/totalDistance
|
||||||
TextView ownerTimeDistanceTextView = (TextView) view.findViewById(
|
TextView ownerTimeDistanceTextView = (TextView) view.findViewById(
|
||||||
@@ -97,33 +113,30 @@ public class ListItemUtils {
|
|||||||
ownerTimeDistance += " \u2027";
|
ownerTimeDistance += " \u2027";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTextView(ownerTimeDistanceTextView, ownerTimeDistance);
|
setTextView(activity, ownerTimeDistanceTextView, ownerTimeDistance, hasPhoto);
|
||||||
|
|
||||||
// Set markerCount
|
// Set markerCount
|
||||||
ImageView markerCountIcon = (ImageView) view.findViewById(R.id.list_item_marker_count_icon);
|
ImageView markerCountIcon = (ImageView) view.findViewById(R.id.list_item_marker_count_icon);
|
||||||
TextView markerCountTextView = (TextView) view.findViewById(R.id.list_item_marker_count);
|
TextView markerCountTextView = (TextView) view.findViewById(R.id.list_item_marker_count);
|
||||||
if (markerCount > 0) {
|
boolean hasMarker = markerCount > 0;
|
||||||
markerCountIcon.setVisibility(View.VISIBLE);
|
markerCountIcon.setVisibility(hasMarker ? View.VISIBLE : View.GONE);
|
||||||
markerCountTextView.setVisibility(View.VISIBLE);
|
String markerCountValue = hasMarker ? String.valueOf(markerCount) : null;
|
||||||
|
if (hasMarker) {
|
||||||
|
// Scale markerCountIcon
|
||||||
int lineHeight = markerCountTextView.getLineHeight();
|
int lineHeight = markerCountTextView.getLineHeight();
|
||||||
LayoutParams layoutParams = markerCountIcon.getLayoutParams();
|
LayoutParams layoutParams = markerCountIcon.getLayoutParams();
|
||||||
layoutParams.width = lineHeight;
|
layoutParams.width = lineHeight;
|
||||||
layoutParams.height = lineHeight;
|
layoutParams.height = lineHeight;
|
||||||
|
|
||||||
markerCountTextView.setText(String.valueOf(markerCount));
|
|
||||||
} else {
|
|
||||||
markerCountIcon.setVisibility(View.GONE);
|
|
||||||
markerCountTextView.setVisibility(View.GONE);
|
|
||||||
}
|
}
|
||||||
|
setTextView(activity, markerCountTextView, markerCountValue, hasPhoto);
|
||||||
|
|
||||||
// Set date/time
|
// Set date/time
|
||||||
String[] dateTime = getDateTime(isRecording, activity, startTime, useRelativeTime);
|
String[] dateTime = getDateTime(isRecording, activity, startTime, useRelativeTime);
|
||||||
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
TextView dateTextView = (TextView) view.findViewById(R.id.list_item_date);
|
||||||
setTextView(dateTextView, dateTime[0]);
|
setTextView(activity, dateTextView, dateTime[0], hasPhoto);
|
||||||
|
|
||||||
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
|
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
|
||||||
setTextView(timeTextView, dateTime[1]);
|
setTextView(activity, timeTextView, dateTime[1], hasPhoto);
|
||||||
|
|
||||||
// Set category and description
|
// Set category and description
|
||||||
TextView categoryDescriptionTextView = (TextView) view.findViewById(
|
TextView categoryDescriptionTextView = (TextView) view.findViewById(
|
||||||
@@ -131,29 +144,15 @@ public class ListItemUtils {
|
|||||||
String categoryDescription = isRecording ? null
|
String categoryDescription = isRecording ? null
|
||||||
: StringUtils.getCategoryDescription(category, description);
|
: StringUtils.getCategoryDescription(category, description);
|
||||||
if (sharedOwner == null && totalTime == null && totalDistance == null && markerCount == 0) {
|
if (sharedOwner == null && totalTime == null && totalDistance == null && markerCount == 0) {
|
||||||
setTextView(categoryDescriptionTextView, null);
|
setTextView(activity, categoryDescriptionTextView, null, hasPhoto);
|
||||||
// Match list_item_category_description in list_item.xml
|
// Match list_item_category_description in list_item.xml
|
||||||
ownerTimeDistanceTextView.setSingleLine(false);
|
ownerTimeDistanceTextView.setSingleLine(false);
|
||||||
ownerTimeDistanceTextView.setMaxLines(2);
|
ownerTimeDistanceTextView.setMaxLines(2);
|
||||||
setTextView(ownerTimeDistanceTextView, categoryDescription);
|
setTextView(activity, ownerTimeDistanceTextView, categoryDescription, hasPhoto);
|
||||||
} else {
|
} else {
|
||||||
// Match list_item_owner_time_distance in list_item.xml
|
// Match list_item_owner_time_distance in list_item.xml
|
||||||
ownerTimeDistanceTextView.setSingleLine(true);
|
ownerTimeDistanceTextView.setSingleLine(true);
|
||||||
setTextView(categoryDescriptionTextView, categoryDescription);
|
setTextView(activity, categoryDescriptionTextView, categoryDescription, hasPhoto);
|
||||||
}
|
|
||||||
|
|
||||||
ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo);
|
|
||||||
ImageView textGradient = (ImageView) view.findViewById(R.id.list_item_text_gradient);
|
|
||||||
if (photoUrl == null || photoUrl.equals("")) {
|
|
||||||
photo.setVisibility(View.GONE);
|
|
||||||
textGradient.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
photo.setImageResource(android.R.color.transparent);
|
|
||||||
photo.setVisibility(View.VISIBLE);
|
|
||||||
textGradient.setVisibility(View.VISIBLE);
|
|
||||||
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
|
||||||
PhotoUtils.setImageVew(
|
|
||||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,15 +217,23 @@ public class ListItemUtils {
|
|||||||
/**
|
/**
|
||||||
* Sets a text view.
|
* Sets a text view.
|
||||||
*
|
*
|
||||||
|
* @param context the context
|
||||||
* @param textView the text view
|
* @param textView the text view
|
||||||
* @param value the value for the text view
|
* @param value the value for the text view
|
||||||
|
* @param addShadow true to add shadow
|
||||||
*/
|
*/
|
||||||
private static void setTextView(TextView textView, String value) {
|
private static void setTextView(
|
||||||
|
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);
|
||||||
} else {
|
} else {
|
||||||
textView.setVisibility(View.VISIBLE);
|
textView.setVisibility(View.VISIBLE);
|
||||||
textView.setText(value);
|
textView.setText(value);
|
||||||
|
if (addShadow) {
|
||||||
|
textView.setShadowLayer(8, 0, 10, context.getResources().getColor(R.color.shadow_color));
|
||||||
|
} else {
|
||||||
|
textView.setShadowLayer(0, 0, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user