From 6f46b3b57692fe9d5df2f0ae04710006f6d6bfa0 Mon Sep 17 00:00:00 2001 From: Denis Date: Fri, 20 Mar 2015 11:48:55 +0200 Subject: [PATCH] Updated osmo card --- OsmAnd/res/layout/dash_osmo_item.xml | 11 +++--- .../plus/dashboard/DashLocationFragment.java | 7 ++-- .../osmand/plus/osmo/DashOsmoFragment.java | 34 ++++++++++++++++--- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/OsmAnd/res/layout/dash_osmo_item.xml b/OsmAnd/res/layout/dash_osmo_item.xml index 989c28b82a..aa2b8b77e5 100644 --- a/OsmAnd/res/layout/dash_osmo_item.xml +++ b/OsmAnd/res/layout/dash_osmo_item.xml @@ -43,13 +43,13 @@ + android:orientation="horizontal"> + android:layout_width="@dimen/dashFavDirectionSize" + android:layout_height="@dimen/dashFavDirectionSize" + tools:src="@drawable/ic_action_start_navigation"/> + android:layout_height="wrap_content" + tools:src="@drawable/ic_action_start_navigation"/> devices) { Drawable markerIcon = getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_marker_dark); LayoutInflater inflater = getActivity().getLayoutInflater(); + List distances = new ArrayList(); for (final OsMoGroupsStorage.OsMoDevice device : devices) { View v = inflater.inflate(R.layout.dash_osmo_item, null, false); + v.findViewById(R.id.people_icon).setVisibility(View.GONE); + v.findViewById(R.id.people_count).setVisibility(View.GONE); final ImageButton showOnMap = (ImageButton) v.findViewById(R.id.show_on_map); showOnMap.setImageDrawable(markerIcon); final String name = device.getVisibleName(); + final Location loc = device.getLastLocation(); showOnMap.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Location loc = device.getLastLocation(); + if (loc == null) { Toast.makeText(getActivity(), R.string.osmo_device_not_found, Toast.LENGTH_SHORT).show(); return; @@ -223,6 +232,14 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM MapActivity.launchMapActivityMoveToTop(getActivity()); } }); + + ImageView direction = (ImageView) v.findViewById(R.id.direction_icon); + direction.setVisibility(View.VISIBLE); + TextView label = (TextView) v.findViewById(R.id.distance); + DashLocationFragment.DashLocationView dv = new DashLocationFragment.DashLocationView(direction, label, loc != null ? new LatLon(loc.getLatitude(), + loc.getLongitude()) : null); + distances.add(dv); + final CompoundButton enableDevice = (CompoundButton) v.findViewById(R.id.check_item); ImageView icon = (ImageView) v.findViewById(R.id.icon); if (device.isEnabled()) { @@ -255,6 +272,7 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM }); contentList.addView(v); } + this.distances = distances; } private void refreshItems() { @@ -287,6 +305,12 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM @Override public void deviceLocationChanged(OsMoGroupsStorage.OsMoDevice device) { - // + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + updateConnectedDevices(getView()); + updateAllWidgets(); + } + }); } }