From 4049c9cbeb6c6e551c0ed9c64537b39ba3d4aba5 Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Mon, 30 Mar 2015 14:46:08 +0800 Subject: [PATCH] show location in status details --- .../support/OpenStreetMapViewerActivity.java | 1 + .../fragment/support/StatusFragment.java | 15 +++++- .../main/res/layout/header_status_common.xml | 52 +++++-------------- 3 files changed, 27 insertions(+), 41 deletions(-) diff --git a/twidere/src/fdroid/java/org/mariotaku/twidere/activity/support/OpenStreetMapViewerActivity.java b/twidere/src/fdroid/java/org/mariotaku/twidere/activity/support/OpenStreetMapViewerActivity.java index c3a0771da..45fe9a8c6 100644 --- a/twidere/src/fdroid/java/org/mariotaku/twidere/activity/support/OpenStreetMapViewerActivity.java +++ b/twidere/src/fdroid/java/org/mariotaku/twidere/activity/support/OpenStreetMapViewerActivity.java @@ -110,6 +110,7 @@ public class OpenStreetMapViewerActivity extends BaseActionBarActivity implement setContentView(R.layout.activity_osm_viewer); mMapView.setMultiTouchControls(true); mMapView.setBuiltInZoomControls(true); + mMapView.setTilesScaledToDpi(true); final List overlays = mMapView.getOverlays(); final GeoPoint gp = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6)); final Drawable d = ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_marker, null); diff --git a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java index 98bf7a321..b9bd6fa24 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java +++ b/twidere/src/main/java/org/mariotaku/twidere/fragment/support/StatusFragment.java @@ -74,6 +74,7 @@ import org.mariotaku.twidere.loader.support.StatusRepliesLoader; import org.mariotaku.twidere.model.ListResponse; import org.mariotaku.twidere.model.ParcelableAccount; import org.mariotaku.twidere.model.ParcelableAccount.ParcelableCredentials; +import org.mariotaku.twidere.model.ParcelableLocation; import org.mariotaku.twidere.model.ParcelableMedia; import org.mariotaku.twidere.model.ParcelableStatus; import org.mariotaku.twidere.model.SingleResponse; @@ -944,7 +945,7 @@ public class StatusFragment extends BaseSupportFragment private final View mediaPreviewLoad; private final LinearLayout mediaPreviewGrid; - private final View locationContainer; + private final TextView locationView; private final TwitterCardContainer twitterCard; public DetailStatusViewHolder(StatusAdapter adapter, View itemView) { @@ -969,7 +970,7 @@ public class StatusFragment extends BaseSupportFragment mediaPreviewContainer = itemView.findViewById(R.id.media_preview); mediaPreviewLoad = itemView.findViewById(R.id.media_preview_load); mediaPreviewGrid = (LinearLayout) itemView.findViewById(R.id.media_preview_grid); - locationContainer = itemView.findViewById(R.id.location_container); + locationView = (TextView) itemView.findViewById(R.id.location_view); profileContainer = itemView.findViewById(R.id.profile_container); twitterCard = (TwitterCardContainer) itemView.findViewById(R.id.twitter_card); @@ -1010,6 +1011,13 @@ public class StatusFragment extends BaseSupportFragment } break; } + case R.id.location_view: { + final ParcelableStatus status = adapter.getStatus(getAdapterPosition()); + final ParcelableLocation location = status.location; + if (!ParcelableLocation.isValidLocation(location)) return; + Utils.openMap(adapter.getContext(), location.latitude, location.longitude); + break; + } } } @@ -1069,6 +1077,7 @@ public class StatusFragment extends BaseSupportFragment } timeSourceView.setMovementMethod(LinkMovementMethod.getInstance()); + locationView.setVisibility(ParcelableLocation.isValidLocation(status.location) ? View.VISIBLE : View.GONE); retweetsContainer.setVisibility(!status.user_is_protected ? View.VISIBLE : View.GONE); repliesContainer.setVisibility(status.reply_count < 0 ? View.GONE : View.VISIBLE); @@ -1138,11 +1147,13 @@ public class StatusFragment extends BaseSupportFragment profileContainer.setOnClickListener(this); retweetsContainer.setOnClickListener(this); retweetedByContainer.setOnClickListener(this); + locationView.setOnClickListener(this); final float defaultTextSize = adapter.getTextSize(); nameView.setTextSize(defaultTextSize * 1.25f); textView.setTextSize(defaultTextSize * 1.25f); screenNameView.setTextSize(defaultTextSize * 0.85f); + locationView.setTextSize(defaultTextSize * 0.85f); timeSourceView.setTextSize(defaultTextSize * 0.85f); } diff --git a/twidere/src/main/res/layout/header_status_common.xml b/twidere/src/main/res/layout/header_status_common.xml index a4a2bf836..063e495cb 100644 --- a/twidere/src/main/res/layout/header_status_common.xml +++ b/twidere/src/main/res/layout/header_status_common.xml @@ -181,47 +181,21 @@ android:layout_height="wrap_content" android:visibility="gone"/> - - - - - - - - + android:layout_alignParentBottom="true" + android:background="?android:selectableItemBackground" + android:drawableLeft="@drawable/ic_indicator_location" + android:drawablePadding="4dp" + android:gravity="center_vertical" + android:padding="@dimen/element_spacing_normal" + android:singleLine="true" + android:text="@string/view_map" + android:textColor="?android:textColorSecondary" + android:textAppearance="?android:attr/textAppearanceSmall"/>