Add button configure map
This commit is contained in:
parent
f840db83b9
commit
9350515844
16 changed files with 360 additions and 283 deletions
11
OsmAnd/res/drawable/roundedbutton.xml
Normal file
11
OsmAnd/res/drawable/roundedbutton.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"><shape android:shape="oval">
|
||||
<solid android:color="#eeaaaaaa" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="oval">
|
||||
<solid android:color="#eeffffff" />
|
||||
</shape></item>
|
||||
|
||||
</selector>
|
|
@ -12,32 +12,48 @@
|
|||
layout="@layout/application_loading"
|
||||
android:visibility="gone" />
|
||||
|
||||
<net.osmand.plus.dashboard.NotifyingScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_scroll"
|
||||
android:layout_width="360dp"
|
||||
<LinearLayout
|
||||
android:id="@+id/animateContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fadeScrollbars="true" >
|
||||
android:orientation="horizontal" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/animateContent"
|
||||
android:orientation="vertical" >
|
||||
<net.osmand.plus.dashboard.NotifyingScrollView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/main_scroll"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:fadeScrollbars="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
android:orientation="vertical" >
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_layers_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginLeft="@dimen/map_button_margin"
|
||||
android:layout_marginTop="@dimen/map_button_margin"
|
||||
android:background="@drawable/roundedbutton"
|
||||
android:src="@drawable/ic_action_layers_light" />
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -19,25 +19,40 @@
|
|||
android:layout_height="match_parent"
|
||||
android:fadeScrollbars="true" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
<FrameLayout
|
||||
android:id="@+id/animateContent"
|
||||
android:orientation="vertical" >
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_layers_button"
|
||||
android:layout_width="@dimen/map_button_size"
|
||||
android:layout_height="@dimen/map_button_size"
|
||||
android:layout_gravity="top|left"
|
||||
android:layout_marginLeft="@dimen/map_button_margin"
|
||||
android:layout_marginTop="@dimen/map_button_margin"
|
||||
android:background="@drawable/roundedbutton"
|
||||
android:src="@drawable/ic_action_layers_light" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="@dimen/dashboard_map_top_padding" />
|
||||
android:layout_marginTop="@dimen/dashboard_map_top_padding"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" />
|
||||
|
||||
<net.osmand.plus.activities.search.toolbar.SplitToolbar
|
||||
android:id="@+id/bottomControls"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/bottomToolBarColor" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
|
||||
</FrameLayout>
|
|
@ -44,6 +44,9 @@
|
|||
<dimen name="gpx_text_top_margin">6dp</dimen>
|
||||
<dimen name="dashboard_map_top_padding">240dp</dimen>
|
||||
<dimen name="dashboard_map_bottom_padding">90dp</dimen>
|
||||
|
||||
<dimen name="map_button_size">40dp</dimen>
|
||||
<dimen name="map_button_margin">8dp</dimen>
|
||||
|
||||
<!-- TextSizes -->
|
||||
<dimen name="list_header_text_size">14sp</dimen>
|
||||
|
|
|
@ -622,7 +622,7 @@ public class OsmandSettings {
|
|||
return p;
|
||||
}
|
||||
|
||||
public final CommonPreference<Boolean> USE_DASHBOARD_INSTEAD_OF_DRAWER = new BooleanPreference("use_dashboard_instead_of_drawer", true).makeGlobal().cache();
|
||||
public final CommonPreference<Boolean> USE_DASHBOARD_INSTEAD_OF_DRAWER = new BooleanPreference("use_dashboard_instead_of_drawer", false).makeGlobal().cache();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();
|
||||
|
|
|
@ -1,40 +1,26 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.access.AccessibleAlertBuilder;
|
||||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndLocationProvider;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.base.BasicProgressAsyncTask;
|
||||
import net.osmand.plus.dashboard.DashDownloadMapsFragment;
|
||||
import net.osmand.plus.dashboard.DashErrorFragment;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.dashboard.DashUpdatesFragment;
|
||||
import net.osmand.plus.dashboard.NotifyingScrollView;
|
||||
import net.osmand.plus.download.BaseDownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.plus.render.MapRenderRepositories;
|
||||
import net.osmand.plus.sherpafy.TourViewActivity;
|
||||
import net.osmand.plus.views.controls.FloatingActionButton;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog.Builder;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
|
@ -44,7 +30,6 @@ import android.os.Bundle;
|
|||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.view.MenuItemCompat;
|
||||
import android.support.v7.app.ActionBar;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.Menu;
|
||||
|
@ -53,7 +38,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -302,22 +286,19 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
|
|||
|
||||
@Override
|
||||
public void updateCompassValue(float value) {
|
||||
for (WeakReference<Fragment> ref : fragList) {
|
||||
Fragment f = ref.get();
|
||||
if (f instanceof DashLocationFragment && !f.isDetached()) {
|
||||
((DashLocationFragment) f).updateCompassValue(value);
|
||||
}
|
||||
}
|
||||
//
|
||||
// throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
for (WeakReference<Fragment> ref : fragList) {
|
||||
Fragment f = ref.get();
|
||||
if (f instanceof DashLocationFragment && !f.isDetached()) {
|
||||
((DashLocationFragment) f).updateLocation(location);
|
||||
}
|
||||
}
|
||||
// for (WeakReference<Fragment> ref : fragList) {
|
||||
// Fragment f = ref.get();
|
||||
// if (f instanceof DashLocationFragment && !f.isDetached()) {
|
||||
// ((DashLocationFragment) f).updateLocation(location);
|
||||
// }
|
||||
// }
|
||||
// throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
private OsmAndLocationProvider getLocationProvider() {
|
||||
|
|
|
@ -142,6 +142,9 @@ public class MapActivity extends AccessibleActivity {
|
|||
setContentView(R.layout.main);
|
||||
mapActions = new MapActivityActions(this);
|
||||
mapLayers = new MapActivityLayers(this);
|
||||
if (mapViewTrackingUtilities == null) {
|
||||
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
|
||||
}
|
||||
|
||||
dashboardOnMap.createDashboardView();
|
||||
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
|
||||
|
@ -168,11 +171,12 @@ public class MapActivity extends AccessibleActivity {
|
|||
|
||||
@Override
|
||||
public void onFinish(AppInitializer init) {
|
||||
applicationInitialized();
|
||||
if(!openGlSetup) {
|
||||
setupOpenGLView();
|
||||
}
|
||||
mapView.refreshMap();
|
||||
mapView.refreshMap(true);
|
||||
findViewById(R.id.init_progress).setVisibility(View.GONE);
|
||||
findViewById(R.id.ParentLayout).invalidate();
|
||||
}
|
||||
};
|
||||
getMyApplication().checkApplicationIsBeingInitialized(this, initListener);
|
||||
|
@ -194,9 +198,6 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
});
|
||||
mapView.setAccessibilityActions(new MapAccessibilityActions(this));
|
||||
if (mapViewTrackingUtilities == null) {
|
||||
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
|
||||
}
|
||||
mapViewTrackingUtilities.setMapView(mapView);
|
||||
|
||||
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(new IMapDownloaderCallback() {
|
||||
|
@ -243,11 +244,6 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
}
|
||||
|
||||
private void applicationInitialized() {
|
||||
mapView.refreshMap(true);
|
||||
findViewById(R.id.init_progress).setVisibility(View.GONE);
|
||||
findViewById(R.id.ParentLayout).invalidate();
|
||||
}
|
||||
|
||||
private void setupOpenGLView() {
|
||||
if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
|
||||
|
@ -259,6 +255,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
atlasMapRendererView.setElevationAngle(90);
|
||||
NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
|
||||
mapView = ml.getMapView();
|
||||
mapViewTrackingUtilities.setMapView(mapView);
|
||||
mapView.setMapRender(atlasMapRendererView);
|
||||
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
|
||||
surf.setVisibility(View.GONE);
|
||||
|
@ -693,8 +690,18 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
|
||||
public LatLon getMapLocation() {
|
||||
if(mapView == null) {
|
||||
return settings.getLastKnownMapLocation();
|
||||
}
|
||||
return new LatLon(mapView.getLatitude(), mapView.getLongitude());
|
||||
}
|
||||
|
||||
public float getMapRotate() {
|
||||
if(mapView == null) {
|
||||
return 0;
|
||||
}
|
||||
return mapView.getRotate();
|
||||
}
|
||||
|
||||
// Duplicate methods to OsmAndApplication
|
||||
public TargetPoint getPointToNavigate() {
|
||||
|
|
|
@ -785,7 +785,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
}
|
||||
}
|
||||
if(loc != null){
|
||||
DirectionDrawable draw = new DirectionDrawable(SearchPOIActivity.this, width, height, R.drawable.ic_destination_arrow_white);
|
||||
DirectionDrawable draw = new DirectionDrawable(SearchPOIActivity.this, width, height,
|
||||
R.drawable.ic_destination_arrow_white, R.color.color_distance);
|
||||
Float h = heading;
|
||||
float a = h != null ? h : 0;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.plus.OsmandSettings;
|
|||
import net.osmand.plus.OsmandSettings.AutoZoomMap;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
|
@ -29,6 +30,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
private long lastTimeAutoZooming = 0;
|
||||
private boolean sensorRegistered = false;
|
||||
private OsmandMapTileView mapView;
|
||||
private DashboardOnMap dashboard;
|
||||
private OsmandSettings settings;
|
||||
private OsmandApplication app;
|
||||
// by default turn off causing unexpected movements due to network establishing
|
||||
|
@ -80,6 +82,17 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
mapView.refreshMap();
|
||||
}
|
||||
}
|
||||
if(dashboard != null) {
|
||||
dashboard.updateCompassValue(val);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDashboard(DashboardOnMap dashboard) {
|
||||
this.dashboard = dashboard;
|
||||
}
|
||||
|
||||
public DashboardOnMap getDashboard() {
|
||||
return dashboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,6 +134,10 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
|
|||
// When location is changed we need to refresh map in order to show movement!
|
||||
mapView.refreshMap();
|
||||
}
|
||||
|
||||
if(dashboard != null) {
|
||||
dashboard.updateMyLocation(location);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isSmallSpeedForCompass(Location location) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import net.osmand.plus.activities.MapActivity;
|
|||
*/
|
||||
public abstract class DashBaseFragment extends Fragment {
|
||||
|
||||
private DashboardOnMap dashboard;
|
||||
protected DashboardOnMap dashboard;
|
||||
|
||||
public OsmandApplication getMyApplication(){
|
||||
if (getActivity() == null){
|
||||
|
|
|
@ -5,13 +5,11 @@ import java.util.Collections;
|
|||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.FavouritesDbHelper;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -35,11 +33,8 @@ import android.widget.TextView;
|
|||
/**
|
||||
* Created by Denis on 24.11.2014.
|
||||
*/
|
||||
public class DashFavoritesFragment extends DashLocationFragment implements FavouritesDbHelper.FavoritesUpdatedListener {
|
||||
public class DashFavoritesFragment extends DashLocationFragment {
|
||||
public static final String TAG = "DASH_FAVORITES_FRAGMENT";
|
||||
private net.osmand.Location location = null;
|
||||
|
||||
private List<ImageView> arrows = new ArrayList<ImageView>();
|
||||
List<FavouritePoint> points = new ArrayList<FavouritePoint>();
|
||||
|
||||
@Override
|
||||
|
@ -63,19 +58,8 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
// This is used as origin for both Fav-list and direction arrows
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
} else {
|
||||
loc = new LatLon(0f, 0f);
|
||||
}
|
||||
setupFavorites();
|
||||
}
|
||||
|
||||
|
@ -83,25 +67,26 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
View mainView = getView();
|
||||
final FavouritesDbHelper helper = getMyApplication().getFavorites();
|
||||
points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
|
||||
arrows.clear();
|
||||
if (points.size() == 0) {
|
||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
|
||||
return;
|
||||
} else {
|
||||
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
Collections.sort(points, new Comparator<FavouritePoint>() {
|
||||
@Override
|
||||
public int compare(FavouritePoint point, FavouritePoint point2) {
|
||||
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), loc.getLatitude(),
|
||||
loc.getLongitude()));
|
||||
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(), loc.getLatitude(),
|
||||
loc.getLongitude()));
|
||||
return (dist - dist2);
|
||||
}
|
||||
});
|
||||
final LatLon loc = getDefaultLocation();
|
||||
if (loc != null) {
|
||||
Collections.sort(points, new Comparator<FavouritePoint>() {
|
||||
@Override
|
||||
public int compare(FavouritePoint point, FavouritePoint point2) {
|
||||
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
|
||||
loc.getLatitude(), loc.getLongitude()));
|
||||
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(),
|
||||
loc.getLatitude(), loc.getLongitude()));
|
||||
return (dist - dist2);
|
||||
}
|
||||
});
|
||||
}
|
||||
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
|
||||
favorites.removeAllViews();
|
||||
if (points.size() > 3) {
|
||||
|
@ -109,12 +94,15 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
points.remove(3);
|
||||
}
|
||||
}
|
||||
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
for (final FavouritePoint point : points) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.favorites_list_item, null, false);
|
||||
TextView name = (TextView) view.findViewById(R.id.favourite_label);
|
||||
TextView label = (TextView) view.findViewById(R.id.distance);
|
||||
ImageView direction = (ImageView) view.findViewById(R.id.direction);
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
label.setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
|
||||
if (point.getCategory().length() > 0) {
|
||||
((TextView) view.findViewById(R.id.group_name)).setText(point.getCategory());
|
||||
|
@ -124,19 +112,11 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
|
||||
((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(
|
||||
getActivity(), point.getColor()));
|
||||
DashLocationView dv = new DashLocationView(direction, label, new LatLon(point.getLatitude(),
|
||||
point.getLongitude()));
|
||||
distances.add(dv);
|
||||
|
||||
if (loc != null) {
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
updateArrow(getActivity(), loc, new LatLon(point.getLatitude(), point.getLongitude()), direction, 10,
|
||||
R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
arrows.add(direction);
|
||||
name.setText(point.getName());
|
||||
|
||||
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), loc.getLatitude(),
|
||||
loc.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
view.findViewById(R.id.navigate_to).setVisibility(View.VISIBLE);
|
||||
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -146,7 +126,6 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()));
|
||||
}
|
||||
});
|
||||
label.setText(distance, TextView.BufferType.SPANNABLE);
|
||||
label.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -159,42 +138,8 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
|
|||
});
|
||||
favorites.addView(view);
|
||||
}
|
||||
updateLocation(location);
|
||||
this.distances = distances;
|
||||
}
|
||||
|
||||
private void updateArrows() {
|
||||
if (loc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < arrows.size(); i++) {
|
||||
arrows.get(i).setVisibility(View.VISIBLE);
|
||||
updateArrow(getActivity(), loc, new LatLon(points.get(i).getLatitude(), points.get(i).getLongitude()),
|
||||
arrows.get(i), 10, R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCompassValue(float value) {
|
||||
if (super.updateCompassValue(value)) {
|
||||
updateArrows();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
super.updateLocation(location);
|
||||
updateArrows();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFavourites() {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setupFavorites();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +1,56 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.util.MapUtils;
|
||||
import android.app.Activity;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 26.01.2015.
|
||||
*/
|
||||
@SuppressLint("ResourceAsColor")
|
||||
public abstract class DashLocationFragment extends DashBaseFragment {
|
||||
|
||||
private static final int ORIENTATION_0 = 0;
|
||||
private static final int ORIENTATION_90 = 3;
|
||||
private static final int ORIENTATION_270 = 1;
|
||||
private static final int ORIENTATION_180 = 2;
|
||||
|
||||
protected Float heading = null;
|
||||
|
||||
protected LatLon loc = null;
|
||||
|
||||
public void updateLocation(Location location) {
|
||||
//This is used as origin for both Fav-list and direction arrows
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
} else {
|
||||
loc = new LatLon(0f, 0f);
|
||||
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
private int screenOrientation;
|
||||
|
||||
public static class DashLocationView {
|
||||
public boolean useOnlyMyLocation;
|
||||
public ImageView arrow;
|
||||
public TextView txt;
|
||||
public LatLon loc;
|
||||
|
||||
public DashLocationView(ImageView arrow, TextView txt, LatLon loc) {
|
||||
super();
|
||||
this.arrow = arrow;
|
||||
this.txt = txt;
|
||||
this.loc = loc;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static void updateArrow(Activity ctx, LatLon currentLocation, LatLon pointLocation,
|
||||
ImageView direction, int size, int resourceId, Float heading) {
|
||||
float[] mes = new float[2];
|
||||
Location.distanceBetween(pointLocation.getLatitude(), pointLocation.getLongitude(), currentLocation.getLatitude(), currentLocation.getLongitude(), mes);
|
||||
DirectionDrawable draw = new DirectionDrawable(ctx, size, size, resourceId);
|
||||
Float h = heading;
|
||||
float a = h != null ? h : 0;
|
||||
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
//Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
|
||||
int screenOrientation = 0;
|
||||
screenOrientation = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||
screenOrientation = 0;
|
||||
screenOrientation = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||
switch (screenOrientation)
|
||||
{
|
||||
case ORIENTATION_0: // Device default (normally portrait)
|
||||
|
@ -61,29 +66,80 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
screenOrientation = 180;
|
||||
break;
|
||||
}
|
||||
|
||||
//Looks like screenOrientation correction must not be applied for devices without compass?
|
||||
Sensor compass = ((SensorManager) ctx.getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||
Sensor compass = ((SensorManager) getActivity().getSystemService(Context.SENSOR_SERVICE)).getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
|
||||
if (compass == null) {
|
||||
screenOrientation = 0;
|
||||
}
|
||||
|
||||
draw.setAngle(mes[1] - a + 180 + screenOrientation);
|
||||
|
||||
direction.setImageDrawable(draw);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean updateCompassValue(float value) {
|
||||
//heading = value;
|
||||
//updateArrows();
|
||||
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices
|
||||
float lastHeading = heading != null ? heading : 99;
|
||||
heading = value;
|
||||
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) {
|
||||
return true;
|
||||
} else {
|
||||
heading = lastHeading;
|
||||
public LatLon getDefaultLocation() {
|
||||
DashboardOnMap d = dashboard;
|
||||
if(d == null) {
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
return d.getMapViewLocation();
|
||||
}
|
||||
|
||||
public void updateAllWidgets() {
|
||||
DashboardOnMap d = dashboard;
|
||||
if(d == null) {
|
||||
return;
|
||||
}
|
||||
float head = d.getHeading();
|
||||
float mapRotation = d.getMapRotation();
|
||||
LatLon mw = d.getMapViewLocation();
|
||||
Location l = d.getMyLocation();
|
||||
boolean mapLinked = d.isMapLinkedToLocation() && l != null;
|
||||
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
|
||||
for (DashLocationView lv : distances) {
|
||||
boolean useCenter = !mapLinked && !lv.useOnlyMyLocation;
|
||||
LatLon loc = (useCenter ? mw : myLoc);
|
||||
float h = useCenter ? -mapRotation : head;
|
||||
float[] mes = new float[2];
|
||||
if (loc != null) {
|
||||
Location.distanceBetween(lv.loc.getLatitude(), lv.loc.getLongitude(), loc.getLatitude(),
|
||||
loc.getLongitude(), mes);
|
||||
}
|
||||
if (lv.arrow != null) {
|
||||
if (!(lv.arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
DirectionDrawable dd = new DirectionDrawable(getActivity(), 10, 10);
|
||||
lv.arrow.setImageDrawable(dd);
|
||||
}
|
||||
DirectionDrawable dd = (DirectionDrawable) lv.arrow.getDrawable();
|
||||
dd.setImage(R.drawable.ic_destination_arrow_white, useCenter ? R.color.color_distance
|
||||
: R.color.color_myloc_distance);
|
||||
if (loc == null) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
dd.setAngle(mes[1] - h + 180 + screenOrientation);
|
||||
}
|
||||
lv.arrow.invalidate();
|
||||
}
|
||||
if (loc != null) {
|
||||
lv.txt.setTextColor(getActivity().getResources().getColor(useCenter ? R.color.color_distance
|
||||
: R.color.color_myloc_distance));
|
||||
lv.txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], dashboard.getMyApplication()));
|
||||
} else {
|
||||
lv.txt.setText("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateLocation(boolean centerChanged, boolean locationChanged, boolean compassChanged) {
|
||||
if(compassChanged && !dashboard.isMapLinkedToLocation()) {
|
||||
boolean update = false;
|
||||
for (DashLocationView lv : distances) {
|
||||
if(lv.useOnlyMyLocation) {
|
||||
update = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!update) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
updateAllWidgets();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.dashboard;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmAndAppCustomization;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -18,9 +17,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
|
|||
import net.osmand.util.Algorithms;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -39,7 +36,6 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
|
||||
private List<ImageView> arrows = new ArrayList<ImageView>();
|
||||
List<HistoryEntry> points = new ArrayList<HistoryEntry>();
|
||||
Drawable icon;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
@ -63,22 +59,11 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
activity.startActivity(search);
|
||||
}
|
||||
});
|
||||
icon = getResources().getDrawable(R.drawable.ic_type_coordinates);
|
||||
if (getMyApplication().getSettings().isLightContent()) {
|
||||
icon = icon.mutate();
|
||||
icon.setColorFilter(getResources().getColor(R.color.icon_color_light), PorterDuff.Mode.MULTIPLY);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOpenDash() {
|
||||
// This is used as origin for both Fav-list and direction arrows
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
} else {
|
||||
loc = new LatLon(0f, 0f);
|
||||
}
|
||||
setupRecents();
|
||||
}
|
||||
|
||||
|
@ -100,6 +85,8 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
if (points.size() > 3) {
|
||||
points = points.subList(0, 3);
|
||||
}
|
||||
LatLon loc = getDefaultLocation();
|
||||
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
for (final HistoryEntry historyEntry : points) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.search_history_list_item, null, false);
|
||||
|
@ -120,34 +107,14 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
});
|
||||
DashLocationView dv = new DashLocationView((ImageView) view.findViewById(R.id.direction),
|
||||
(TextView) view.findViewById(R.id.distance), new LatLon(historyEntry.getLat(),
|
||||
historyEntry.getLon()));
|
||||
distances.add(dv);
|
||||
recents.addView(view);
|
||||
}
|
||||
this.distances = distances;
|
||||
}
|
||||
|
||||
private void updateArrows() {
|
||||
if (loc == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < arrows.size(); i++) {
|
||||
arrows.get(i).setVisibility(View.VISIBLE);
|
||||
updateArrow(getActivity(), loc, new LatLon(points.get(i).getLat(), points.get(i).getLon()), arrows.get(i),
|
||||
10, R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCompassValue(float value) {
|
||||
if (super.updateCompassValue(value)) {
|
||||
updateArrows();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
super.updateLocation(location);
|
||||
updateArrows();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -50,6 +51,11 @@ public class DashboardOnMap {
|
|||
private boolean visible = false;
|
||||
private boolean landscape;
|
||||
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>();
|
||||
private net.osmand.Location myLocation;
|
||||
private LatLon mapViewLocation;
|
||||
private float heading;
|
||||
private boolean mapLinkedToLocation;
|
||||
private float mapRotation;
|
||||
|
||||
|
||||
public DashboardOnMap(MapActivity ma) {
|
||||
|
@ -71,6 +77,16 @@ public class DashboardOnMap {
|
|||
dashboardView.findViewById(R.id.content).setOnClickListener(listener);
|
||||
dashboardView.setOnClickListener(listener);
|
||||
((FrameLayout) mapActivity.findViewById(R.id.ParentLayout)).addView(dashboardView);
|
||||
|
||||
dashboardView.findViewById(R.id.map_layers_button).setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setDashboardVisibility(false);
|
||||
mapActivity.getMapActions().prepareConfigureMap();
|
||||
mapActivity.getMapActions().toggleDrawer();
|
||||
}
|
||||
});
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
fabButton = new FloatingActionButton.Builder(mapActivity)
|
||||
|
@ -98,17 +114,40 @@ public class DashboardOnMap {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public net.osmand.Location getMyLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
public LatLon getMapViewLocation() {
|
||||
return mapViewLocation;
|
||||
}
|
||||
|
||||
public float getHeading() {
|
||||
return heading;
|
||||
}
|
||||
|
||||
public float getMapRotation() {
|
||||
return mapRotation;
|
||||
}
|
||||
|
||||
public boolean isMapLinkedToLocation() {
|
||||
return mapLinkedToLocation;
|
||||
}
|
||||
|
||||
protected OsmandApplication getMyApplication() {
|
||||
return mapActivity.getMyApplication();
|
||||
}
|
||||
|
||||
|
||||
public void setDashboardVisibility(boolean visible) {
|
||||
this.visible = visible;
|
||||
DashboardOnMap.staticVisible = visible;
|
||||
if (visible) {
|
||||
mapViewLocation = mapActivity.getMapLocation();
|
||||
mapRotation = mapActivity.getMapRotate();
|
||||
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
mapActivity.getMapViewTrackingUtilities().setDashboard(this);
|
||||
addOrUpdateDashboardFragments();
|
||||
setupActionBar();
|
||||
dashboardView.setVisibility(View.VISIBLE);
|
||||
|
@ -117,8 +156,10 @@ public class DashboardOnMap {
|
|||
mapActivity.getMapActions().disableDrawer();
|
||||
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.GONE);
|
||||
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.GONE);
|
||||
updateLocation(true, true, false);
|
||||
} else {
|
||||
mapActivity.getMapActions().enableDrawer();
|
||||
mapActivity.getMapViewTrackingUtilities().setDashboard(null);
|
||||
hide(dashboardView.findViewById(R.id.animateContent));
|
||||
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
|
||||
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
|
||||
|
@ -284,6 +325,7 @@ public class DashboardOnMap {
|
|||
((FrameLayout) fabButton.getParent()).updateViewLayout(fabButton, lp);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
|
@ -298,8 +340,41 @@ public class DashboardOnMap {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean inLocationUpdate = false;
|
||||
public void updateLocation(final boolean centerChanged, final boolean locationChanged, final boolean compassChanged){
|
||||
if(inLocationUpdate) {
|
||||
return ;
|
||||
}
|
||||
inLocationUpdate = true;
|
||||
mapActivity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
inLocationUpdate = false;
|
||||
for (WeakReference<DashBaseFragment> df : fragList) {
|
||||
if (df.get() instanceof DashLocationFragment) {
|
||||
((DashLocationFragment)df.get()).updateLocation(centerChanged, locationChanged, compassChanged);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void updateMyLocation(net.osmand.Location location) {
|
||||
myLocation = location;
|
||||
updateLocation(false, true, false);
|
||||
}
|
||||
|
||||
public void updateCompassValue(double heading) {
|
||||
this.heading = (float) heading;
|
||||
updateLocation(false, false, true);
|
||||
}
|
||||
|
||||
public void onAttach(DashBaseFragment dashBaseFragment) {
|
||||
fragList.add(new WeakReference<DashBaseFragment>(dashBaseFragment));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -50,11 +50,6 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
@Override
|
||||
public void onOpenDash() {
|
||||
plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
|
||||
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
|
||||
loc = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
} else {
|
||||
loc = new LatLon(0f, 0f);
|
||||
}
|
||||
updateParkingPosition();
|
||||
}
|
||||
|
||||
|
@ -69,38 +64,18 @@ public class DashParkingFragment extends DashLocationFragment {
|
|||
|
||||
LatLon position = plugin.getParkingPosition();
|
||||
|
||||
int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(), loc.getLatitude(),
|
||||
loc.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
|
||||
((TextView) mainView.findViewById(R.id.distance)).setText(distance);
|
||||
// TODO add parking time
|
||||
String parking_name = plugin.getParkingType() ? getString(R.string.parking_place)
|
||||
: getString(R.string.parking_place);
|
||||
((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
|
||||
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
|
||||
if (loc != null) {
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateCompassValue(float value) {
|
||||
if (plugin == null) {
|
||||
return true;
|
||||
}
|
||||
if (super.updateCompassValue(value)) {
|
||||
updateParkingPosition();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLocation(Location location) {
|
||||
super.updateLocation(location);
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
updateParkingPosition();
|
||||
// int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(), loc.getLatitude(),
|
||||
// loc.getLongitude()));
|
||||
// String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
|
||||
// ((TextView) mainView.findViewById(R.id.distance)).setText(distance);
|
||||
// // TODO add parking time
|
||||
// String parking_name = plugin.getParkingType() ? getString(R.string.parking_place)
|
||||
// : getString(R.string.parking_place);
|
||||
// ((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
|
||||
// ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
|
||||
// if (loc != null) {
|
||||
// direction.setVisibility(View.VISIBLE);
|
||||
// updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import android.graphics.*;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
||||
|
@ -20,10 +20,17 @@ public class DirectionDrawable extends Drawable {
|
|||
Context ctx;
|
||||
private float angle;
|
||||
int resourceId = -1;
|
||||
Drawable arrowImage ;
|
||||
|
||||
public DirectionDrawable(Context ctx, float width, float height, int resourceId) {
|
||||
public DirectionDrawable(Context ctx, float width, float height, int resourceId, int clrId) {
|
||||
this(ctx, width, height);
|
||||
this.resourceId = resourceId;
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
}
|
||||
|
||||
public void setImage(int resourceId, int clrId) {
|
||||
IconsCache iconsCache = ((OsmandApplication) ctx.getApplicationContext()).getIconsCache();
|
||||
arrowImage = iconsCache.getIcon(resourceId, clrId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -54,15 +61,16 @@ public class DirectionDrawable extends Drawable {
|
|||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
if (resourceId != -1) {
|
||||
if (arrowImage != null) {
|
||||
canvas.rotate(angle, canvas.getHeight() / 2, canvas.getWidth() / 2);
|
||||
|
||||
Drawable arrowImage = ctx.getResources().getDrawable(resourceId);
|
||||
Bitmap arrow = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
Canvas canv = new Canvas(arrow);
|
||||
arrowImage.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
arrowImage.draw(canv);
|
||||
canvas.drawBitmap(arrow, null, new Rect(0, 0, arrow.getHeight(), arrow.getWidth()), null);
|
||||
arrowImage.draw(canvas);
|
||||
// TODO delete?
|
||||
// Bitmap arrow = Bitmap.createBitmap(canvas.getWidth(), canvas.getHeight(), Bitmap.Config.ARGB_8888);
|
||||
// Canvas canv = new Canvas(arrow);
|
||||
// arrowImage.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
// arrowImage.draw(canv);
|
||||
// canvas.drawBitmap(arrow, null, new Rect(0, 0, arrow.getHeight(), arrow.getWidth()), null);
|
||||
} else {
|
||||
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth() / 2);
|
||||
Path directionPath = createDirectionPath();
|
||||
|
|
Loading…
Reference in a new issue