forked from upstream-mirrors/OpenTracks
Merge heads
This commit is contained in:
@@ -20,6 +20,7 @@ import com.google.android.maps.mytracks.R;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.net.Uri;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.Display;
|
||||
@@ -36,6 +37,8 @@ import java.util.Calendar;
|
||||
*/
|
||||
public class ListItemUtils {
|
||||
|
||||
private static final int LIST_PREFERRED_ITEM_HEIGHT_DEFAULT = 128;
|
||||
|
||||
private ListItemUtils() {}
|
||||
|
||||
/**
|
||||
@@ -56,6 +59,7 @@ public class ListItemUtils {
|
||||
* @param category the category value
|
||||
* @param description the description value
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void setListItem(Activity activity, View view, boolean isRecording,
|
||||
boolean isPaused, int iconId, int iconContentDescriptionId, String name, String sharedOwner,
|
||||
String totalTime, String totalDistance, String photoUrl, long startTime, String category,
|
||||
@@ -87,17 +91,14 @@ public class ListItemUtils {
|
||||
setTextView(timeDistanceTextView,
|
||||
getTimeDistance(activity, isRecording, isPaused, sharedOwner, totalTime, totalDistance));
|
||||
|
||||
// Set photoUrl
|
||||
ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo);
|
||||
ImageView photo = (ImageView) view.findViewById(R.id.list_item_background);
|
||||
if (photoUrl == null || photoUrl.equals("")) {
|
||||
photo.setVisibility(View.GONE);
|
||||
} else {
|
||||
photo.setVisibility(View.VISIBLE);
|
||||
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
||||
// Set the initial width to 33% of the display width.
|
||||
int width = (int) (defaultDisplay.getWidth() * .33);
|
||||
int height = 0;
|
||||
PhotoUtils.setImageVew(photo, Uri.parse(photoUrl), width, height);
|
||||
PhotoUtils.setImageVew(
|
||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
||||
}
|
||||
|
||||
// Set date/time
|
||||
@@ -108,6 +109,15 @@ public class ListItemUtils {
|
||||
TextView timeTextView = (TextView) view.findViewById(R.id.list_item_time);
|
||||
setTextView(timeTextView, startTimeDisplay[1]);
|
||||
|
||||
/*
|
||||
* If column0 is GONE, change to INVISIBLE so column1 is placed at the
|
||||
* correct position.
|
||||
*/
|
||||
if (timeTextView.getVisibility() == View.VISIBLE
|
||||
&& timeDistanceTextView.getVisibility() == View.GONE) {
|
||||
timeDistanceTextView.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
// Set category/description
|
||||
TextView descriptionTextView = (TextView) view.findViewById(R.id.list_item_description);
|
||||
setTextView(descriptionTextView,
|
||||
@@ -201,4 +211,17 @@ public class ListItemUtils {
|
||||
textView.setText(value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the photo height.
|
||||
*
|
||||
* @param context the context
|
||||
*/
|
||||
private static int getPhotoHeight(Context context) {
|
||||
int[] attrs = new int[] { android.R.attr.listPreferredItemHeight };
|
||||
TypedArray typeArray = context.obtainStyledAttributes(attrs);
|
||||
int height = typeArray.getDimensionPixelSize(0, LIST_PREFERRED_ITEM_HEIGHT_DEFAULT);
|
||||
typeArray.recycle();
|
||||
return 2 * height;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,13 +37,17 @@ public class PhotoUtils {
|
||||
*
|
||||
* @param imageView the image view
|
||||
* @param uri the image uri
|
||||
* @param displayWidth the display width
|
||||
* @param displayHeight the display height
|
||||
* @param targetWidth the target width
|
||||
* @param targetHeight the target height
|
||||
* @param fitWithin true to fit within the target area in order to display the
|
||||
* entire image (no cropping). False to fill the entire target area.
|
||||
* (allow cropping).
|
||||
*/
|
||||
public static void setImageVew(
|
||||
ImageView imageView, Uri uri, int displayWidth, int displayHeight) {
|
||||
ImageView imageView, Uri uri, int targetWidth, int targetHeight, boolean fitWithin) {
|
||||
if (cancelBitmapLoader(imageView, uri)) {
|
||||
BitmapLoader bitmapLoader = new BitmapLoader(imageView, uri, displayWidth, displayHeight);
|
||||
BitmapLoader bitmapLoader = new BitmapLoader(
|
||||
imageView, uri, targetWidth, targetHeight, fitWithin);
|
||||
WeakReference<BitmapLoader> bitmapLoaderReference = new WeakReference<BitmapLoader>(
|
||||
bitmapLoader);
|
||||
imageView.setTag(bitmapLoaderReference);
|
||||
|
||||
@@ -82,6 +82,7 @@ public class PreferencesUtils {
|
||||
public static final int MIN_RECORDING_INTERVAL_ADAPT_BATTERY_LIFE = -2;
|
||||
public static final int MIN_RECORDING_INTERVAL_DEFAULT = 0;
|
||||
|
||||
public static final int PHOTO_SIZE_DEFAULT = 1024; // 1024 kB
|
||||
public static final int RECORDING_DISTANCE_INTERVAL_DEFAULT = 10;
|
||||
|
||||
// Values for recording_gps_accuracy
|
||||
|
||||
Reference in New Issue
Block a user