forked from upstream-mirrors/OpenTracks
Improve marker list view layout
This commit is contained in:
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2013 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||||
|
<gradient
|
||||||
|
android:angle="90"
|
||||||
|
android:endColor="@android:color/black"
|
||||||
|
android:startColor="@android:color/white" />
|
||||||
|
</shape>
|
||||||
@@ -17,15 +17,24 @@ limitations under the License.
|
|||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_width="match_parent" >
|
android:layout_width="match_parent" >
|
||||||
|
<!-- Photo -->
|
||||||
<ImageView
|
<ImageView
|
||||||
android:contentDescription="@string/icon_marker"
|
android:contentDescription="@string/icon_marker"
|
||||||
android:id="@+id/list_item_background"
|
android:id="@+id/list_item_photo"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:scaleType="centerCrop" />
|
android:scaleType="centerCrop" />
|
||||||
|
<!-- A gradient on top of the photo -->
|
||||||
|
<ImageView
|
||||||
|
android:alpha=".6"
|
||||||
|
android:contentDescription="@string/icon_marker"
|
||||||
|
android:id="@+id/list_item_photo_gradient"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:src="@drawable/photo_gradient" />
|
||||||
<!-- Table 1 -->
|
<!-- Table 1 -->
|
||||||
<TableLayout
|
<TableLayout
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:minHeight="?android:attr/listPreferredItemHeight"
|
android:minHeight="?android:attr/listPreferredItemHeight"
|
||||||
android:paddingBottom="12dp"
|
android:paddingBottom="12dp"
|
||||||
|
|||||||
@@ -183,14 +183,13 @@ public class MarkerListActivity extends AbstractMyTracksActivity implements Dele
|
|||||||
int iconId = statistics ? R.drawable.ic_marker_yellow_pushpin
|
int iconId = statistics ? R.drawable.ic_marker_yellow_pushpin
|
||||||
: R.drawable.ic_marker_blue_pushpin;
|
: R.drawable.ic_marker_blue_pushpin;
|
||||||
String name = cursor.getString(nameIndex);
|
String name = cursor.getString(nameIndex);
|
||||||
String sharedOwner = track.getSharedOwner();
|
|
||||||
long time = cursor.getLong(timeIndex);
|
long time = cursor.getLong(timeIndex);
|
||||||
String category = statistics ? null : cursor.getString(categoryIndex);
|
String category = statistics ? null : cursor.getString(categoryIndex);
|
||||||
String description = statistics ? null : cursor.getString(descriptionIndex);
|
String description = statistics ? null : cursor.getString(descriptionIndex);
|
||||||
String photoUrl = cursor.getString(photoUrlIndex);
|
String photoUrl = cursor.getString(photoUrlIndex);
|
||||||
|
|
||||||
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
ListItemUtils.setListItem(MarkerListActivity.this, view, false, true, iconId,
|
||||||
R.string.icon_marker, name, sharedOwner, null, null, 0, time, category, description,
|
R.string.icon_marker, name, null, null, null, 0, time, category, description,
|
||||||
photoUrl);
|
photoUrl);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -475,13 +475,11 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
* the retrieval phase of the search.
|
* the retrieval phase of the search.
|
||||||
*/
|
*/
|
||||||
String trackName = null;
|
String trackName = null;
|
||||||
String sharedOwner = null;
|
|
||||||
long trackId = waypoint.getTrackId();
|
long trackId = waypoint.getTrackId();
|
||||||
if (trackId != -1L) {
|
if (trackId != -1L) {
|
||||||
Track track = myTracksProviderUtils.getTrack(trackId);
|
Track track = myTracksProviderUtils.getTrack(trackId);
|
||||||
if (track != null) {
|
if (track != null) {
|
||||||
trackName = track.getName();
|
trackName = track.getName();
|
||||||
sharedOwner = track.getSharedOwner();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +491,7 @@ public class SearchListActivity extends AbstractSendToGoogleActivity implements
|
|||||||
statistics ? R.drawable.ic_marker_yellow_pushpin : R.drawable.ic_marker_blue_pushpin);
|
statistics ? R.drawable.ic_marker_yellow_pushpin : R.drawable.ic_marker_blue_pushpin);
|
||||||
resultMap.put(ICON_CONTENT_DESCRIPTION_ID_FIELD, R.string.icon_marker);
|
resultMap.put(ICON_CONTENT_DESCRIPTION_ID_FIELD, R.string.icon_marker);
|
||||||
resultMap.put(NAME_FIELD, waypoint.getName());
|
resultMap.put(NAME_FIELD, waypoint.getName());
|
||||||
resultMap.put(SHARED_OWNER_FIELD, sharedOwner);
|
resultMap.put(SHARED_OWNER_FIELD, null);
|
||||||
// Display the marker's track name in the total time field
|
// Display the marker's track name in the total time field
|
||||||
resultMap.put(TOTAL_TIME_FIELD, trackName == null ? null
|
resultMap.put(TOTAL_TIME_FIELD, trackName == null ? null
|
||||||
: getString(R.string.search_list_marker_track_location, trackName));
|
: getString(R.string.search_list_marker_track_location, trackName));
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ public class ListItemUtils {
|
|||||||
ownerTimeDistance = activity.getString(
|
ownerTimeDistance = activity.getString(
|
||||||
isPaused ? R.string.generic_paused : R.string.generic_recording);
|
isPaused ? R.string.generic_paused : R.string.generic_recording);
|
||||||
} else {
|
} else {
|
||||||
// Need to match the style set in list_item.xml
|
// Match list_item_owner_time_distance in list_item.xml
|
||||||
ownerTimeDistanceTextView.setTextAppearance(activity, R.style.TextSmall);
|
ownerTimeDistanceTextView.setTextAppearance(activity, R.style.TextSmall);
|
||||||
ownerTimeDistance = getOwnerTimeDistance(sharedOwner, totalTime, totalDistance);
|
ownerTimeDistance = getOwnerTimeDistance(sharedOwner, totalTime, totalDistance);
|
||||||
if (markerCount > 0) {
|
if (markerCount > 0) {
|
||||||
@@ -99,7 +99,7 @@ public class ListItemUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
setTextView(ownerTimeDistanceTextView, ownerTimeDistance);
|
setTextView(ownerTimeDistanceTextView, ownerTimeDistance);
|
||||||
|
|
||||||
// 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);
|
||||||
@@ -126,26 +126,31 @@ public class ListItemUtils {
|
|||||||
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(timeTextView, dateTime[1]);
|
||||||
|
|
||||||
/*
|
// Set category and description
|
||||||
* If column0 is GONE, change to INVISIBLE so column1 is placed at the
|
TextView categoryDescriptionTextView = (TextView) view.findViewById(
|
||||||
* correct position.
|
R.id.list_item_category_description);
|
||||||
*/
|
String categoryDescription = isRecording ? null
|
||||||
if (timeTextView.getVisibility() == View.VISIBLE
|
: StringUtils.getCategoryDescription(category, description);
|
||||||
&& ownerTimeDistanceTextView.getVisibility() == View.GONE) {
|
if (sharedOwner == null && totalTime == null && totalDistance == null && markerCount == 0) {
|
||||||
ownerTimeDistanceTextView.setVisibility(View.INVISIBLE);
|
setTextView(categoryDescriptionTextView, null);
|
||||||
|
// Match list_item_category_description in list_item.xml
|
||||||
|
ownerTimeDistanceTextView.setSingleLine(false);
|
||||||
|
ownerTimeDistanceTextView.setMaxLines(2);
|
||||||
|
setTextView(ownerTimeDistanceTextView, categoryDescription);
|
||||||
|
} else {
|
||||||
|
// Match list_item_owner_time_distance in list_item.xml
|
||||||
|
ownerTimeDistanceTextView.setSingleLine(true);
|
||||||
|
setTextView(categoryDescriptionTextView, categoryDescription);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set category and description
|
ImageView photo = (ImageView) view.findViewById(R.id.list_item_photo);
|
||||||
TextView categoryDescription = (TextView) view.findViewById(
|
ImageView photoGradient = (ImageView) view.findViewById(R.id.list_item_photo_gradient);
|
||||||
R.id.list_item_category_description);
|
|
||||||
setTextView(categoryDescription,
|
|
||||||
isRecording ? null : StringUtils.getCategoryDescription(category, description));
|
|
||||||
|
|
||||||
ImageView photo = (ImageView) view.findViewById(R.id.list_item_background);
|
|
||||||
if (photoUrl == null || photoUrl.equals("")) {
|
if (photoUrl == null || photoUrl.equals("")) {
|
||||||
photo.setVisibility(View.GONE);
|
photo.setVisibility(View.GONE);
|
||||||
|
photoGradient.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
photo.setVisibility(View.VISIBLE);
|
photo.setVisibility(View.VISIBLE);
|
||||||
|
photoGradient.setVisibility(View.VISIBLE);
|
||||||
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
|
||||||
PhotoUtils.setImageVew(
|
PhotoUtils.setImageVew(
|
||||||
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
photo, Uri.parse(photoUrl), defaultDisplay.getWidth(), getPhotoHeight(activity), false);
|
||||||
|
|||||||
Reference in New Issue
Block a user