Merge branch 'master' of https://github.com/osmandapp/Osmand
This commit is contained in:
commit
c66a9da5be
14 changed files with 204 additions and 181 deletions
|
@ -1720,4 +1720,17 @@
|
|||
<string name="poi_diet_gluten_free_only">Només dieta per celíacs</string>
|
||||
<string name="poi_diet_gluten_free_yes">Dieta per celíacs</string>
|
||||
<string name="poi_diet_gluten_free_no">Dieta per celíacs:no</string>
|
||||
<string name="poi_payment_icsf_yes">S\'accepten targes IC Stored Fare</string>
|
||||
<string name="poi_payment_icsf_no">No s\'accepten targes IC Stored Fare</string>
|
||||
<string name="poi_diet_kosher_only">Només dieta kosher</string>
|
||||
<string name="poi_diet_kosher_yes">Dieta kosher</string>
|
||||
<string name="poi_diet_kosher_no">Dieta kosher: no</string>
|
||||
<string name="poi_diet_halal_only">Només dieta halal</string>
|
||||
<string name="poi_diet_halal_yes">Dieta halal</string>
|
||||
<string name="poi_diet_halal_no">Dieta halal: no</string>
|
||||
<string name="poi_diet_lactose_free_only">Només dieta sense lactosa</string>
|
||||
<string name="poi_diet_lactose_free_yes">Dieta sense lactosa</string>
|
||||
<string name="poi_diet_lactose_free_no">Dieta sense lactosa: no</string>
|
||||
<string name="poi_drive_in_yes"/>
|
||||
<string name="poi_drive_in_no"></string>
|
||||
</resources>
|
||||
|
|
|
@ -559,7 +559,7 @@
|
|||
<string name="reload_tile">Обновить часть карты</string>
|
||||
<string name="user_name_descr">Укажите имя пользователя (требуется для работы с OSM)</string>
|
||||
<string name="user_name">Имя пользователя</string>
|
||||
<string name="mark_point">Точка</string>
|
||||
<string name="mark_point">Цель</string>
|
||||
<string name="use_english_names_descr">Использовать английские названия вместо местных</string>
|
||||
<string name="use_english_names">Использовать английские названия</string>
|
||||
<string name="app_settings">Настройки приложения</string>
|
||||
|
|
|
@ -88,6 +88,7 @@ import net.osmand.util.Algorithms;
|
|||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -1043,9 +1044,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
// DownloadEvents
|
||||
@Override
|
||||
public void newDownloadIndexes() {
|
||||
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||
if (contextMenuFragment != null) {
|
||||
contextMenuFragment.newDownloadIndexes();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = getContextMenu().findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().newDownloadIndexes();
|
||||
}
|
||||
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||
refreshMap();
|
||||
|
@ -1054,9 +1055,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
|
||||
@Override
|
||||
public void downloadInProgress() {
|
||||
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||
if (contextMenuFragment != null) {
|
||||
contextMenuFragment.downloadInProgress();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = getContextMenu().findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().downloadInProgress();
|
||||
}
|
||||
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||
refreshMap();
|
||||
|
@ -1065,9 +1066,9 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents {
|
|||
|
||||
@Override
|
||||
public void downloadHasFinished() {
|
||||
MapContextMenuFragment contextMenuFragment = getContextMenu().findMenuFragment();
|
||||
if (contextMenuFragment != null) {
|
||||
contextMenuFragment.downloadHasFinished();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = getContextMenu().findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().downloadHasFinished();
|
||||
}
|
||||
if (getMapLayers().getDownloadedRegionsLayer().updateObjects()) {
|
||||
refreshMap();
|
||||
|
|
|
@ -17,6 +17,8 @@ import net.osmand.plus.views.ContextMenuLayer;
|
|||
import net.osmand.plus.views.OsmandMapLayer;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class MapContextMenu extends MenuTitleController {
|
||||
|
||||
private MapActivity mapActivity;
|
||||
|
@ -74,6 +76,13 @@ public class MapContextMenu extends MenuTitleController {
|
|||
this.mapCenter = mapCenter;
|
||||
}
|
||||
|
||||
public void updateMapCenter(LatLon mapCenter) {
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().updateMapCenter(mapCenter);
|
||||
}
|
||||
}
|
||||
|
||||
public void setMapPosition(int mapPosition) {
|
||||
this.mapPosition = mapPosition;
|
||||
}
|
||||
|
@ -131,10 +140,13 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
active = true;
|
||||
|
||||
acquireMenuController();
|
||||
if (menuController == null || !update) {
|
||||
acquireMenuController();
|
||||
}
|
||||
initTitle();
|
||||
|
||||
if (menuController != null) {
|
||||
menuController.clearPlainMenuItems();
|
||||
menuController.addPlainMenuItems(typeStr, this.pointDescription, this.latLon);
|
||||
}
|
||||
|
||||
|
@ -160,10 +172,10 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
public void update(LatLon latLon, PointDescription pointDescription, Object object) {
|
||||
MapContextMenuFragment fragment = findMenuFragment();
|
||||
if (fragment != null) {
|
||||
init(latLon, pointDescription, object, true);
|
||||
fragment.rebuildMenu();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
init(latLon, pointDescription, object, true);
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().rebuildMenu();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,9 +201,16 @@ public class MapContextMenu extends MenuTitleController {
|
|||
mapActivity.getMapView().setMapPosition(mapPosition);
|
||||
mapPosition = 0;
|
||||
}
|
||||
MapContextMenuFragment fragment = findMenuFragment();
|
||||
if (fragment != null) {
|
||||
fragment.dismissMenu();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().dismissMenu();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMenuUI() {
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().updateMenu();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,15 +256,15 @@ public class MapContextMenu extends MenuTitleController {
|
|||
|
||||
@Override
|
||||
public void refreshMenuTitle() {
|
||||
MapContextMenuFragment fragment = findMenuFragment();
|
||||
if (fragment != null)
|
||||
fragment.refreshTitle();
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null)
|
||||
fragmentRef.get().refreshTitle();
|
||||
}
|
||||
|
||||
public MapContextMenuFragment findMenuFragment() {
|
||||
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
||||
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG);
|
||||
if (fragment != null) {
|
||||
return (MapContextMenuFragment) fragment;
|
||||
if (fragment != null && !fragment.isDetached()) {
|
||||
return new WeakReference<>((MapContextMenuFragment) fragment);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -308,9 +327,9 @@ public class MapContextMenu extends MenuTitleController {
|
|||
}
|
||||
|
||||
public void setBaseFragmentVisibility(boolean visible) {
|
||||
MapContextMenuFragment menuFragment = findMenuFragment();
|
||||
if (menuFragment != null) {
|
||||
menuFragment.setFragmentVisibility(visible);
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().setFragmentVisibility(visible);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,9 +478,9 @@ public class MapContextMenu extends MenuTitleController {
|
|||
@Override
|
||||
public void run() {
|
||||
inLocationUpdate = false;
|
||||
MapContextMenuFragment menuFragment = findMenuFragment();
|
||||
if (menuFragment != null) {
|
||||
menuFragment.updateLocation(centerChanged, locationChanged, compassChanged);
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().updateLocation(centerChanged, locationChanged, compassChanged);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -204,6 +204,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
});
|
||||
}
|
||||
|
||||
menu.updateData();
|
||||
updateButtonsAndProgress();
|
||||
|
||||
if (menu.isLandscapeLayout()) {
|
||||
|
@ -440,6 +441,15 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
return view;
|
||||
}
|
||||
|
||||
public void updateMapCenter(LatLon mapCenter) {
|
||||
customMapCenter = true;
|
||||
menu.setMapCenter(mapCenter);
|
||||
this.mapCenter = mapCenter;
|
||||
RotatedTileBox box = map.getCurrentRotatedTileBox().copy();
|
||||
origMarkerX = box.getCenterPixelX();
|
||||
origMarkerY = box.getCenterPixelY();
|
||||
}
|
||||
|
||||
private void updateButtonsAndProgress() {
|
||||
// Title buttons
|
||||
boolean showButtonsContainer = (leftTitleButtonController != null || rightTitleButtonController != null)
|
||||
|
@ -592,6 +602,17 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
@Override
|
||||
public void onGlobalLayout() {
|
||||
|
||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
|
||||
if (getActivity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newMenuTopViewHeight = view.findViewById(R.id.context_menu_top_view).getHeight();
|
||||
menuTopShadowHeight = view.findViewById(R.id.context_menu_top_shadow).getHeight();
|
||||
menuTopShadowAllHeight = view.findViewById(R.id.context_menu_top_shadow_all).getHeight();
|
||||
|
@ -607,14 +628,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
|
||||
menuFullHeightMax = menuTitleHeight + (menuBottomViewHeight > 0 ? menuBottomViewHeight : -dpToPx(SHADOW_HEIGHT_BOTTOM_DP));
|
||||
|
||||
ViewTreeObserver obs = view.getViewTreeObserver();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
obs.removeOnGlobalLayoutListener(this);
|
||||
} else {
|
||||
obs.removeGlobalOnLayoutListener(this);
|
||||
}
|
||||
|
||||
if (origMarkerX == 0 && origMarkerY == 0) {
|
||||
origMarkerX = view.getWidth() / 2;
|
||||
origMarkerY = view.getHeight() / 2;
|
||||
|
@ -887,6 +900,12 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
}
|
||||
}
|
||||
|
||||
public void updateMenu() {
|
||||
menu.updateData();
|
||||
updateButtonsAndProgress();
|
||||
runLayoutListener();
|
||||
}
|
||||
|
||||
private MapActivity getMapActivity() {
|
||||
return (MapActivity)getActivity();
|
||||
}
|
||||
|
|
|
@ -203,6 +203,10 @@ public class MenuBuilder {
|
|||
plainMenuItems.add(new PlainMenuItem(iconId, text, needLinks));
|
||||
}
|
||||
|
||||
public void clearPlainMenuItems() {
|
||||
plainMenuItems.clear();
|
||||
}
|
||||
|
||||
public Drawable getRowIcon(int iconId) {
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
boolean light = app.getSettings().isLightContent();
|
||||
|
|
|
@ -113,6 +113,10 @@ public abstract class MenuController extends BaseMenuController {
|
|||
builder.addPlainMenuItem(iconId, text, needLinks);
|
||||
}
|
||||
|
||||
public void clearPlainMenuItems() {
|
||||
builder.clearPlainMenuItems();
|
||||
}
|
||||
|
||||
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
|
||||
addMyLocationToPlainItems(pointDescription, latLon);
|
||||
}
|
||||
|
|
|
@ -14,9 +14,12 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.mapcontextmenu.builders.AudioVideoNoteMenuBuilder;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
public class AudioVideoNoteMenuController extends MenuController {
|
||||
private Recording recording;
|
||||
|
||||
|
@ -111,7 +114,9 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
sharingIntent.setType("video/*");
|
||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, videoUri);
|
||||
}
|
||||
getMapActivity().getContextMenu().findMenuFragment()
|
||||
.startActivity(Intent.createChooser(sharingIntent, getMapActivity().getString(R.string.share_note)));
|
||||
WeakReference<MapContextMenuFragment> fragmentRef = getMapActivity().getContextMenu().findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
fragmentRef.get().startActivity(Intent.createChooser(sharingIntent, getMapActivity().getString(R.string.share_note)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ public class MapDataMenuController extends MenuController {
|
|||
this.region = osmandRegions.getRegionData(fullName);
|
||||
downloadThread = app.getDownloadThread();
|
||||
|
||||
mapActivity.getSupportFragmentManager();
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
|
|
|
@ -3,14 +3,20 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.osmo.OsMoGroupsActivity;
|
||||
import net.osmand.plus.osmo.OsMoGroupsStorage.OsMoDevice;
|
||||
import net.osmand.plus.osmo.OsMoPlugin;
|
||||
import net.osmand.plus.osmo.OsMoPositionLayer;
|
||||
|
||||
public class OsMoMenuController extends MenuController {
|
||||
|
||||
|
@ -19,6 +25,47 @@ public class OsMoMenuController extends MenuController {
|
|||
public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final OsMoDevice device) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
this.device = device;
|
||||
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
if (OsMoPositionLayer.getFollowDestinationId() != null) {
|
||||
OsMoPositionLayer.setFollowDestination(null);
|
||||
} else {
|
||||
if(device.getLastLocation() != null) {
|
||||
TargetPointsHelper targets = getMapActivity().getMyApplication().getTargetPointsHelper();
|
||||
targets.navigateToPoint(new LatLon(device.getLastLocation().getLatitude(), device.getLastLocation().getLongitude()), true, -1);
|
||||
}
|
||||
OsMoPositionLayer.setFollowDestination(device);
|
||||
}
|
||||
getMapActivity().getContextMenu().updateMenuUI();
|
||||
}
|
||||
};
|
||||
|
||||
rightTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
||||
if (osMoPlugin != null) {
|
||||
OsMoGroupsActivity.showSettingsDialog(getMapActivity(), osMoPlugin, device);
|
||||
}
|
||||
}
|
||||
};
|
||||
rightTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_settings);
|
||||
rightTitleButtonController.leftIconId = R.drawable.ic_action_settings;
|
||||
|
||||
updateData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateData() {
|
||||
if (OsMoPositionLayer.getFollowDestinationId() != null) {
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.shared_string_cancel);
|
||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_remove_dark;
|
||||
} else {
|
||||
leftTitleButtonController.caption = getMapActivity().getString(R.string.mark_point);
|
||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_flag_dark;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.osmo;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -12,7 +11,6 @@ import android.widget.ImageButton;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -274,32 +272,15 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
|||
}
|
||||
|
||||
private void setupDeviceViews(LinearLayout contentList, List<OsMoGroupsStorage.OsMoDevice> devices) {
|
||||
Drawable markerIcon = getMyApplication().getIconsCache().getContentIcon(R.drawable.ic_action_marker_dark);
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
List<DashLocationFragment.DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
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);
|
||||
v.findViewById(R.id.show_on_map).setVisibility(View.GONE);
|
||||
final String name = device.getVisibleName();
|
||||
final Location loc = device.getLastLocation();
|
||||
showOnMap.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (loc == null) {
|
||||
Toast.makeText(getActivity(), R.string.osmo_device_not_found, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
getMyApplication().getSettings().setMapLocationToShow(loc.getLatitude(),
|
||||
loc.getLongitude(), 15,
|
||||
new PointDescription(PointDescription.POINT_TYPE_MARKER, name),
|
||||
false, device); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
});
|
||||
|
||||
ImageView direction = (ImageView) v.findViewById(R.id.direction_icon);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
|
@ -315,7 +296,6 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
|||
icon.setImageDrawable(getMyApplication().getIconsCache().
|
||||
getPaintedContentIcon(R.drawable.ic_person, device.getColor()));
|
||||
} else {
|
||||
showOnMap.setVisibility(View.GONE);
|
||||
icon.setImageDrawable(getMyApplication().getIconsCache().
|
||||
getContentIcon(R.drawable.ic_person));
|
||||
}
|
||||
|
@ -324,7 +304,16 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
|
|||
v.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
launchOsMoGroupsActivity();
|
||||
if (loc == null || !device.isEnabled()) {
|
||||
launchOsMoGroupsActivity();
|
||||
} else {
|
||||
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
getMyApplication().getSettings().setMapLocationToShow(loc.getLatitude(), loc.getLongitude(), getMyApplication().getSettings().getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_MARKER, device.getVisibleName()), false,
|
||||
device);
|
||||
OsMoPositionLayer.setFollowTrackerId(device, loc);
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
}
|
||||
});
|
||||
contentList.addView(v);
|
||||
|
|
|
@ -111,12 +111,9 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
public static final int CREATE_GROUP = 3;
|
||||
protected static final int ON_OFF_ACTION_ID = 4;
|
||||
protected static final int SHARE_ID = 5;
|
||||
protected static final int SHOW_ON_MAP_ID = 6;
|
||||
public static final int SHARE_SESSION = 7;
|
||||
public static final int GROUP_INFO = 8;
|
||||
protected static final int SETTINGS_ID = 9;
|
||||
protected static final int SETTINGS_DEV_ID = 10;
|
||||
protected static final int TRACK_DEV_ID = 11;
|
||||
protected static final int LOGIN_ID = 12;
|
||||
public static final int LIST_REFRESH_MSG_ID = OsmAndConstants.UI_HANDLER_SEARCH + 30;
|
||||
public static final long RECENT_THRESHOLD = 60000;
|
||||
|
@ -184,11 +181,14 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
|
||||
@Override
|
||||
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
|
||||
OsMoDevice model = adapter.getChild(groupPosition, childPosition);
|
||||
if (model != selectedObject) {
|
||||
enterSelectionMode(model);
|
||||
} else {
|
||||
quitSelectionMode();
|
||||
OsMoDevice device = adapter.getChild(groupPosition, childPosition);
|
||||
if (device != null) {
|
||||
Location location = device.getLastLocation();
|
||||
if (location != null) {
|
||||
showDeviceOnMap(device);
|
||||
} else {
|
||||
showSettingsDialog(OsMoGroupsActivity.this, osMoPlugin, device);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -431,13 +431,30 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
osMoPlugin.getGroups().removeUiListener(this);
|
||||
osMoPlugin.setGroupsActivity(null);
|
||||
}
|
||||
|
||||
|
||||
private void showDeviceOnMap(final Object o) {
|
||||
if(!checkOperationIsNotRunning()) {
|
||||
return;
|
||||
}
|
||||
OsMoDevice device = (OsMoDevice) (o instanceof OsMoDevice ? o : null);
|
||||
if (device != null) {
|
||||
Location location = device.getLastLocation();
|
||||
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
if (location != null) {
|
||||
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), app.getSettings().getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_MARKER, device.getVisibleName()), false,
|
||||
device);
|
||||
}
|
||||
OsMoPositionLayer.setFollowTrackerId(device, location);
|
||||
MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this);
|
||||
}
|
||||
}
|
||||
|
||||
private void enterSelectionMode(final Object o) {
|
||||
if(!checkOperationIsNotRunning()) {
|
||||
return;
|
||||
}
|
||||
actionMode = startSupportActionMode(new ActionMode.Callback() {
|
||||
private OsMoDevice device;
|
||||
private OsMoGroup group;
|
||||
private Menu menu;
|
||||
|
||||
|
@ -464,30 +481,8 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
getClearToolbar(false);
|
||||
}
|
||||
this.menu = menu;
|
||||
device = (OsMoDevice) (o instanceof OsMoDevice ? o : null);
|
||||
group = (OsMoGroup) (o instanceof OsMoGroup ? o : null);
|
||||
MenuItem mi = null;
|
||||
if (device != null) {
|
||||
// mi = createActionModeMenuItem(actionMode, menu, ON_OFF_ACTION_ID, R.string.shared_string_ok, 0,
|
||||
// MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
mode.setTitle(device.getVisibleName());
|
||||
if (device.getLastLocation() != null) {
|
||||
createActionModeMenuItem(actionMode, menu, SHOW_ON_MAP_ID, R.string.shared_string_show_on_map,
|
||||
R.drawable.ic_action_marker_dark, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
MenuItem menuItem = createActionModeMenuItem(actionMode, menu, TRACK_DEV_ID,
|
||||
R.string.osmo_set_moving_target, R.drawable.ic_action_flage_dark,
|
||||
// // there is a bug in Android 4.2 layout
|
||||
// device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER :
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
menuItem.setTitleCondensed(getString(R.string.osmo_follow));
|
||||
}
|
||||
createActionModeMenuItem(actionMode, menu, SETTINGS_DEV_ID, R.string.shared_string_settings,
|
||||
R.drawable.ic_action_settings,
|
||||
// // there is a bug in Android 4.2 layout
|
||||
// device.getLastLocation() != null ? MenuItemCompat.SHOW_AS_ACTION_NEVER :
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
||||
}
|
||||
if (group != null) {
|
||||
createActionModeMenuItem(actionMode, menu, SHARE_ID, R.string.shared_string_share, R.drawable.ic_action_gshare_dark,
|
||||
MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
|
||||
|
@ -505,7 +500,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
FrameLayout l = new FrameLayout(OsMoGroupsActivity.this);
|
||||
View view = inflater.inflate(R.layout.check_item_rel, l);
|
||||
final CompoundButton check = (CompoundButton) view.findViewById(R.id.check_item);
|
||||
check.setChecked((device != null && device.isActive() && device.isEnabled()) || (group != null && group.isActive() && group.isEnabled()));
|
||||
check.setChecked(group != null && group.isActive() && group.isEnabled());
|
||||
check.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
|
@ -534,17 +529,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
|
||||
@Override
|
||||
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
|
||||
if (item.getItemId() == TRACK_DEV_ID) {
|
||||
if (device != null && device.getLastLocation() != null) {
|
||||
TargetPointsHelper targets = getMyApplication().getTargetPointsHelper();
|
||||
targets.navigateToPoint(new LatLon(device.getLastLocation().getLatitude(), device
|
||||
.getLastLocation().getLongitude()), true, -1);
|
||||
OsMoPositionLayer.setFollowDestination(device);
|
||||
MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this);
|
||||
}
|
||||
} else if (item.getItemId() == SETTINGS_DEV_ID) {
|
||||
showSettingsDialog(device);
|
||||
} else if (item.getItemId() == DELETE_ACTION_ID) {
|
||||
if (item.getItemId() == DELETE_ACTION_ID) {
|
||||
Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this);
|
||||
String name = ((OsMoGroup) selectedObject).getVisibleName(OsMoGroupsActivity.this);
|
||||
bld.setTitle(getString(R.string.osmo_leave_confirmation_msg, name));
|
||||
|
@ -563,18 +548,6 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
showGroupInfo(group);
|
||||
} else if (item.getItemId() == SHARE_ID) {
|
||||
shareOsMoGroup(group.getVisibleName(app), group.getGroupId());
|
||||
} else if (item.getItemId() == SHOW_ON_MAP_ID) {
|
||||
if (device != null) {
|
||||
Location location = device.getLastLocation();
|
||||
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
if (location != null) {
|
||||
app.getSettings().setMapLocationToShow(location.getLatitude(), location.getLongitude(), app.getSettings().getLastKnownMapZoom(),
|
||||
new PointDescription(PointDescription.POINT_TYPE_MARKER, device.getVisibleName()), false,
|
||||
device);
|
||||
}
|
||||
OsMoPositionLayer.setFollowTrackerId(device, location);
|
||||
MapActivity.launchMapActivityMoveToTop(OsMoGroupsActivity.this);
|
||||
}
|
||||
} else if (item.getItemId() == ON_OFF_ACTION_ID) {
|
||||
CompoundButton bt = ((CompoundButton) MenuItemCompat.getActionView(item).findViewById(R.id.check_item));
|
||||
onOffAction(bt);
|
||||
|
@ -596,7 +569,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
});
|
||||
refreshList();
|
||||
}
|
||||
|
||||
|
||||
private StringBuilder setFields(StringBuilder bld, int field, String value) {
|
||||
bld.append(getString(field)).append(": ").append(value).append("\n");
|
||||
return bld;
|
||||
|
@ -1294,14 +1267,10 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
final OsMoDevice model = getChild(groupPosition, childPosition);
|
||||
row.setTag(model);
|
||||
if(selectedObject == model) {
|
||||
row.setBackgroundColor(getResources().getColor(R.color.row_selection_color));
|
||||
if (app.getSettings().isLightContent()) {
|
||||
row.setBackgroundResource(R.drawable.expandable_list_item_background_light);
|
||||
} else {
|
||||
if (app.getSettings().isLightContent()){
|
||||
row.setBackgroundResource(R.drawable.expandable_list_item_background_light);
|
||||
} else {
|
||||
row.setBackgroundResource(R.drawable.expandable_list_item_background_dark);
|
||||
}
|
||||
row.setBackgroundResource(R.drawable.expandable_list_item_background_dark);
|
||||
}
|
||||
TextView label = (TextView) row.findViewById(R.id.osmo_label);
|
||||
TextView labelTime = (TextView) row.findViewById(R.id.osmo_label_time);
|
||||
|
@ -1432,14 +1401,14 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
}
|
||||
|
||||
|
||||
private void showSettingsDialog(final OsMoDevice device) {
|
||||
Builder bld = new AlertDialog.Builder(OsMoGroupsActivity.this);
|
||||
public static void showSettingsDialog(Context ctx, final OsMoPlugin plugin, final OsMoDevice device) {
|
||||
Builder bld = new AlertDialog.Builder(ctx);
|
||||
bld.setTitle(R.string.osmo_edit_device);
|
||||
final LayoutInflater inflater = LayoutInflater.from(this);
|
||||
final LayoutInflater inflater = LayoutInflater.from(ctx);
|
||||
View view = inflater.inflate(R.layout.osmo_edit_device, null);
|
||||
final EditText name = (EditText) view.findViewById(R.id.Name);
|
||||
if(device.getColor() == 0) {
|
||||
osMoPlugin.getGroups().setDeviceProperties(device, device.getVisibleName(),
|
||||
plugin.getGroups().setDeviceProperties(device, device.getVisibleName(),
|
||||
ColorDialogs.getRandomColor());
|
||||
}
|
||||
int devColor = device.getColor();
|
||||
|
@ -1448,13 +1417,13 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
|
|||
|
||||
final Spinner colorSpinner = (Spinner) view.findViewById(R.id.ColorSpinner);
|
||||
final TIntArrayList list = new TIntArrayList();
|
||||
ColorDialogs.setupColorSpinner(this, devColor, colorSpinner, list);
|
||||
ColorDialogs.setupColorSpinner(ctx, devColor, colorSpinner, list);
|
||||
|
||||
bld.setPositiveButton(R.string .shared_string_yes, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
osMoPlugin.getGroups().setDeviceProperties(device,
|
||||
plugin.getGroups().setDeviceProperties(device,
|
||||
name.getText().toString(), list.get(colorSpinner.getSelectedItemPosition()));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -128,52 +128,6 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
|
|||
return "feature_articles/osmo-plugin.html";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerMapContextMenuActions(final MapActivity mapActivity, final double latitude, final double longitude,
|
||||
ContextMenuAdapter adapter, final Object selectedObj) {
|
||||
if(selectedObj instanceof OsMoDevice) {
|
||||
adapter.item(R.string.osmo_center_location).iconColor(R.drawable.ic_action_gloc_dark).listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
OsMoDevice o = (OsMoDevice) selectedObj;
|
||||
Location loc = o.getLastLocation();
|
||||
double lat = loc == null ? latitude : loc.getLatitude();
|
||||
double lon = loc == null ? longitude : loc.getLongitude();
|
||||
mapActivity.getMapView().setLatLon(lat, lon);
|
||||
MapActivity.getSingleMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
OsMoPositionLayer.setFollowTrackerId(o, loc);
|
||||
return true;
|
||||
}
|
||||
}).position(0).reg();
|
||||
if(OsMoPositionLayer.getFollowDestinationId() != null) {
|
||||
adapter.item(R.string.osmo_cancel_moving_target).iconColor(R.drawable.ic_action_remove_dark).listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
OsMoPositionLayer.setFollowDestination(null);
|
||||
return true;
|
||||
}
|
||||
|
||||
}).position(0).reg();
|
||||
}
|
||||
adapter.item(R.string.osmo_set_moving_target).iconColor(R.drawable.ic_action_flag_dark).listen(new OnContextMenuClick() {
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
OsMoDevice o = (OsMoDevice) selectedObj;
|
||||
if(o.getLastLocation() != null) {
|
||||
TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
targets.navigateToPoint(new LatLon(o.getLastLocation().getLatitude(), o.getLastLocation().getLongitude()), true, -1);
|
||||
}
|
||||
OsMoPositionLayer.setFollowDestination(o);
|
||||
return true;
|
||||
}
|
||||
}).position(1).reg();
|
||||
}
|
||||
super.registerMapContextMenuActions(mapActivity, latitude, longitude, adapter, selectedObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLayers(OsmandMapTileView mapView, MapActivity activity) {
|
||||
if(isActive()) {
|
||||
|
|
|
@ -376,9 +376,9 @@ public class OsMoPositionLayer extends OsmandMapLayer implements ContextMenuLaye
|
|||
if (sameObject) {
|
||||
Location l = device.getLastLocation();
|
||||
if (centered) {
|
||||
map.getContextMenu().setMapCenter(loc);
|
||||
map.getContextMenu().updateMapCenter(loc);
|
||||
}
|
||||
map.getContextMenu().showOrUpdate(new LatLon(l.getLatitude(), l.getLongitude()),
|
||||
map.getContextMenu().update(new LatLon(l.getLatitude(), l.getLongitude()),
|
||||
getObjectName(device), device);
|
||||
}
|
||||
if (centered) {
|
||||
|
|
Loading…
Reference in a new issue