Updated osmo card
This commit is contained in:
parent
9a0b8aff61
commit
6f46b3b576
3 changed files with 40 additions and 12 deletions
|
@ -43,13 +43,13 @@
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal">
|
||||||
android:visibility="gone">
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/people_icon"
|
android:id="@+id/people_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="@dimen/dashFavDirectionSize"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="@dimen/dashFavDirectionSize"
|
||||||
|
tools:src="@drawable/ic_action_start_navigation"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/people_count"
|
android:id="@+id/people_count"
|
||||||
|
@ -59,7 +59,8 @@
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/direction_icon"
|
android:id="@+id/direction_icon"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
tools:src="@drawable/ic_action_start_navigation"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/distance"
|
android:id="@+id/distance"
|
||||||
|
|
|
@ -104,9 +104,12 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
||||||
LatLon loc = (useCenter ? mw : myLoc);
|
LatLon loc = (useCenter ? mw : myLoc);
|
||||||
float h = useCenter ? -mapRotation : head;
|
float h = useCenter ? -mapRotation : head;
|
||||||
for (DashLocationView lv : distances) {
|
for (DashLocationView lv : distances) {
|
||||||
|
if (lv.loc != null){
|
||||||
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc.getLatitude(), lv.loc.getLongitude(),
|
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc.getLatitude(), lv.loc.getLongitude(),
|
||||||
screenOrientation, getMyApplication(), getActivity(), lv.paint);
|
screenOrientation, getMyApplication(), getActivity(), lv.paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.IconsCache;
|
import net.osmand.plus.IconsCache;
|
||||||
import net.osmand.plus.NavigationService;
|
import net.osmand.plus.NavigationService;
|
||||||
|
@ -24,7 +25,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.OsmandPlugin;
|
import net.osmand.plus.OsmandPlugin;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.dashboard.DashBaseFragment;
|
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||||
import net.osmand.plus.helpers.FontCache;
|
import net.osmand.plus.helpers.FontCache;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -34,7 +35,7 @@ import java.util.List;
|
||||||
* Created by Denis
|
* Created by Denis
|
||||||
* on 20.01.2015.
|
* on 20.01.2015.
|
||||||
*/
|
*/
|
||||||
public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsMoGroupsUIListener {
|
public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups.OsMoGroupsUIListener {
|
||||||
|
|
||||||
public static final String TAG = "DASH_OSMO_FRAGMENT";
|
public static final String TAG = "DASH_OSMO_FRAGMENT";
|
||||||
|
|
||||||
|
@ -179,10 +180,14 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
for (final OsMoGroupsStorage.OsMoGroup group : groups) {
|
for (final OsMoGroupsStorage.OsMoGroup group : groups) {
|
||||||
View v = inflater.inflate(R.layout.dash_osmo_item, null, false);
|
View v = inflater.inflate(R.layout.dash_osmo_item, null, false);
|
||||||
|
v.findViewById(R.id.direction_icon).setVisibility(View.GONE);
|
||||||
|
v.findViewById(R.id.distance).setVisibility(View.GONE);
|
||||||
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
||||||
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
v.findViewById(R.id.check_item).setVisibility(View.GONE);
|
||||||
final String name = group.getVisibleName(getActivity());
|
final String name = group.getVisibleName(getActivity());
|
||||||
|
//TODO show group users
|
||||||
|
TextView peopleCount = (TextView) v.findViewById(R.id.people_count);
|
||||||
|
peopleCount.setText(String.valueOf(group.getGroupUsers(null).size()));
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
icon.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_group));
|
icon.setImageDrawable(getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_group));
|
||||||
((TextView) v.findViewById(R.id.name)).setText(name);
|
((TextView) v.findViewById(R.id.name)).setText(name);
|
||||||
|
@ -203,15 +208,19 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
private void setupDeviceViews(LinearLayout contentList, List<OsMoGroupsStorage.OsMoDevice> devices) {
|
private void setupDeviceViews(LinearLayout contentList, List<OsMoGroupsStorage.OsMoDevice> devices) {
|
||||||
Drawable markerIcon = getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_marker_dark);
|
Drawable markerIcon = getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_marker_dark);
|
||||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||||
|
List<DashLocationFragment.DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||||
for (final OsMoGroupsStorage.OsMoDevice device : devices) {
|
for (final OsMoGroupsStorage.OsMoDevice device : devices) {
|
||||||
View v = inflater.inflate(R.layout.dash_osmo_item, null, false);
|
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);
|
final ImageButton showOnMap = (ImageButton) v.findViewById(R.id.show_on_map);
|
||||||
showOnMap.setImageDrawable(markerIcon);
|
showOnMap.setImageDrawable(markerIcon);
|
||||||
final String name = device.getVisibleName();
|
final String name = device.getVisibleName();
|
||||||
|
final Location loc = device.getLastLocation();
|
||||||
showOnMap.setOnClickListener(new View.OnClickListener() {
|
showOnMap.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Location loc = device.getLastLocation();
|
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
Toast.makeText(getActivity(), R.string.osmo_device_not_found, Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), R.string.osmo_device_not_found, Toast.LENGTH_SHORT).show();
|
||||||
return;
|
return;
|
||||||
|
@ -223,6 +232,14 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
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);
|
final CompoundButton enableDevice = (CompoundButton) v.findViewById(R.id.check_item);
|
||||||
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||||
if (device.isEnabled()) {
|
if (device.isEnabled()) {
|
||||||
|
@ -255,6 +272,7 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
});
|
});
|
||||||
contentList.addView(v);
|
contentList.addView(v);
|
||||||
}
|
}
|
||||||
|
this.distances = distances;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void refreshItems() {
|
private void refreshItems() {
|
||||||
|
@ -287,6 +305,12 @@ public class DashOsMoFragment extends DashBaseFragment implements OsMoGroups.OsM
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deviceLocationChanged(OsMoGroupsStorage.OsMoDevice device) {
|
public void deviceLocationChanged(OsMoGroupsStorage.OsMoDevice device) {
|
||||||
//
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateConnectedDevices(getView());
|
||||||
|
updateAllWidgets();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue