Show date and group in marker selection

This commit is contained in:
PavelRatushny 2017-10-13 16:00:17 +03:00
parent ff6ccb3726
commit d64c73ce37
3 changed files with 40 additions and 6 deletions

View file

@ -79,15 +79,28 @@
<TextView <TextView
android:id="@+id/waypoint_desc_text" android:id="@+id/waypoint_desc_text"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_weight="1"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="1" android:maxLines="1"
android:textColor="@color/secondary_text_dark" android:textColor="@color/secondary_text_dark"
android:textSize="@dimen/default_sub_text_size"/> android:textSize="@dimen/default_sub_text_size"/>
<TextView
android:visibility="gone"
android:id="@+id/date_group_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="6dp"
android:layout_marginStart="6dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/>
</LinearLayout> </LinearLayout>

View file

@ -414,7 +414,7 @@ public class MapMarkerDialogHelper {
v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null); v = mapActivity.getLayoutInflater().inflate(R.layout.map_marker_item, null);
} }
updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation, updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode, screenOrientation,
selectionMode, helperCallbacks, marker); selectionMode, helperCallbacks, marker, false);
final View more = v.findViewById(R.id.all_points); final View more = v.findViewById(R.id.all_points);
final View move = v.findViewById(R.id.info_move); final View move = v.findViewById(R.id.info_move);
final View remove = v.findViewById(R.id.info_close); final View remove = v.findViewById(R.id.info_close);
@ -467,7 +467,7 @@ public class MapMarkerDialogHelper {
Float heading, boolean useCenter, boolean nightMode, Float heading, boolean useCenter, boolean nightMode,
int screenOrientation, boolean selectionMode, int screenOrientation, boolean selectionMode,
final MapMarkersDialogHelperCallbacks helperCallbacks, final MapMarkersDialogHelperCallbacks helperCallbacks,
final MapMarker marker) { final MapMarker marker, boolean showDateAndGroup) {
TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist); TextView textDist = (TextView) localView.findViewById(R.id.waypoint_dist);
@ -476,6 +476,7 @@ public class MapMarkerDialogHelper {
TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation); TextView waypointDeviation = (TextView) localView.findViewById(R.id.waypoint_deviation);
TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text); TextView descText = (TextView) localView.findViewById(R.id.waypoint_desc_text);
final CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox); final CheckBox checkBox = (CheckBox) localView.findViewById(R.id.checkbox);
TextView dateGroupText = (TextView) localView.findViewById(R.id.date_group_text);
if (text == null || textDist == null || arrow == null || waypointIcon == null if (text == null || textDist == null || arrow == null || waypointIcon == null
|| waypointDeviation == null || descText == null) { || waypointDeviation == null || descText == null) {
@ -538,6 +539,26 @@ public class MapMarkerDialogHelper {
descText.setVisibility(View.GONE); descText.setVisibility(View.GONE);
if (showDateAndGroup) {
Date date = new Date(marker.creationDate);
String month = new SimpleDateFormat("MMM", Locale.getDefault()).format(date);
if (month.length() > 1) {
month = Character.toUpperCase(month.charAt(0)) + month.substring(1);
}
month = month.replaceAll("\\.", "");
String day = new SimpleDateFormat("d", Locale.getDefault()).format(date);
String desc = month + " " + day;
String markerGroupName = marker.groupName;
if (markerGroupName != null) {
if (markerGroupName.equals("")) {
markerGroupName = app.getString(R.string.shared_string_favorites);
}
desc += "" + markerGroupName;
}
dateGroupText.setVisibility(View.VISIBLE);
dateGroupText.setText(desc);
}
if (selectionMode) { if (selectionMode) {
checkBox.setChecked(marker.selected); checkBox.setChecked(marker.selected);
checkBox.setVisibility(View.VISIBLE); checkBox.setVisibility(View.VISIBLE);
@ -824,7 +845,7 @@ public class MapMarkerDialogHelper {
View v = listView.getChildAt(i - listView.getFirstVisiblePosition()); View v = listView.getChildAt(i - listView.getFirstVisiblePosition());
if (obj == marker) { if (obj == marker) {
updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode, updateMapMarkerInfo(mapActivity, v, loc, heading, useCenter, nightMode,
screenOrientation, selectionMode, helperCallbacks, marker); screenOrientation, selectionMode, helperCallbacks, marker, false);
} }
} }
} catch (Exception e) { } catch (Exception e) {

View file

@ -127,7 +127,7 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
convertView = getMapActivity().getLayoutInflater().inflate(R.layout.map_marker_item, null); convertView = getMapActivity().getLayoutInflater().inflate(R.layout.map_marker_item, null);
} }
MapMarkerDialogHelper.updateMapMarkerInfo(getContext(), convertView, loc, heading, MapMarkerDialogHelper.updateMapMarkerInfo(getContext(), convertView, loc, heading,
useCenter, nightMode, screenOrientation, false, null, marker); useCenter, nightMode, screenOrientation, false, null, marker, true);
final View remove = convertView.findViewById(R.id.info_close); final View remove = convertView.findViewById(R.id.info_close);
remove.setVisibility(View.GONE); remove.setVisibility(View.GONE);
AndroidUtils.setListItemBackground(getMapActivity(), convertView, nightMode); AndroidUtils.setListItemBackground(getMapActivity(), convertView, nightMode);