diff options
| -rw-r--r-- | main/res/layout/main.xml | 2 | ||||
| -rw-r--r-- | main/res/values/styles.xml | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeoaddresses.java | 35 |
3 files changed, 22 insertions, 16 deletions
diff --git a/main/res/layout/main.xml b/main/res/layout/main.xml index 6fd54f1..e1c25cf 100644 --- a/main/res/layout/main.xml +++ b/main/res/layout/main.xml @@ -137,7 +137,7 @@ android:layout_alignParentBottom="true" android:layout_marginLeft="16dip" android:layout_marginRight="16dip" - android:layout_marginBottom="48dip" + android:layout_marginBottom="64dip" android:background="@drawable/helper_bcg" > <ImageView android:layout_width="32dip" diff --git a/main/res/values/styles.xml b/main/res/values/styles.xml index 1e0d8a2..ad3fc8d 100644 --- a/main/res/values/styles.xml +++ b/main/res/values/styles.xml @@ -196,6 +196,7 @@ <item name="android:ellipsize">marquee</item> <item name="android:textSize">14dip</item> <item name="android:textColor">@color/text_icon</item> + <item name="android:background">@drawable/icon_bcg</item> </style> <style name="location_current_type"> diff --git a/main/src/cgeo/geocaching/cgeoaddresses.java b/main/src/cgeo/geocaching/cgeoaddresses.java index 769e84d..27a3110 100644 --- a/main/src/cgeo/geocaching/cgeoaddresses.java +++ b/main/src/cgeo/geocaching/cgeoaddresses.java @@ -1,8 +1,10 @@ package cgeo.geocaching; import cgeo.geocaching.activity.AbstractActivity; +import cgeo.geocaching.geopoint.Geopoint; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import android.app.ProgressDialog; import android.location.Address; @@ -15,6 +17,7 @@ import android.view.View; import android.widget.Button; import android.widget.LinearLayout; +import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -79,32 +82,34 @@ public class cgeoaddresses extends AbstractActivity { return; } else { LinearLayout oneAddPre = null; + final Geopoint lastLoc = cgeoapplication.getInstance().getLastCoords(); for (Address address : addresses) { oneAddPre = (LinearLayout) inflater.inflate(R.layout.address_button, null); Button oneAdd = (Button) oneAddPre.findViewById(R.id.button); - int index = 0; - StringBuilder allAdd = new StringBuilder(); - StringBuilder allAddLine = new StringBuilder(); - while (address.getAddressLine(index) != null) { - if (allAdd.length() > 0) { - allAdd.append('\n'); - } - if (allAddLine.length() > 0) { - allAddLine.append("; "); + final int maxIndex = address.getMaxAddressLineIndex(); + final ArrayList<String> lines = new ArrayList<String>(); + for (int i = 0; i <= maxIndex; i++) { + String line = address.getAddressLine(i); + if (StringUtils.isNotBlank(line)) { + lines.add(line); } + } - allAdd.append(address.getAddressLine(index)); - allAddLine.append(address.getAddressLine(index)); + final String listTitle = StringUtils.join(lines, "; "); - index++; + if (lastLoc != null) { + if (address.hasLatitude() && address.hasLongitude()) { + lines.add(cgBase.getHumanDistance(lastLoc.distanceTo(new Geopoint(address.getLatitude(), address.getLongitude())))); + } } - oneAdd.setText(allAdd.toString()); - oneAdd.setLines(allAdd.toString().split("\n").length); + oneAdd.setText(StringUtils.join(lines, "\n")); + oneAdd.setLines(lines.size()); oneAdd.setClickable(true); - oneAdd.setOnClickListener(new buttonListener(address.getLatitude(), address.getLongitude(), allAddLine.toString())); + + oneAdd.setOnClickListener(new buttonListener(address.getLatitude(), address.getLongitude(), listTitle)); addList.addView(oneAddPre); } } |
