Add button configure map

This commit is contained in:
Victor Shcherb 2015-03-08 20:59:18 +01:00
parent f840db83b9
commit 9350515844
16 changed files with 360 additions and 283 deletions

View 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>

View file

@ -12,6 +12,12 @@
layout="@layout/application_loading" layout="@layout/application_loading"
android:visibility="gone" /> android:visibility="gone" />
<LinearLayout
android:id="@+id/animateContent"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<net.osmand.plus.dashboard.NotifyingScrollView <net.osmand.plus.dashboard.NotifyingScrollView
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main_scroll" android:id="@+id/main_scroll"
@ -23,7 +29,6 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/animateContent"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout <LinearLayout
@ -40,4 +45,15 @@
</LinearLayout> </LinearLayout>
</net.osmand.plus.dashboard.NotifyingScrollView> </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> </FrameLayout>

View file

@ -19,18 +19,32 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:fadeScrollbars="true" > android:fadeScrollbars="true" >
<FrameLayout
android:id="@+id/animateContent"
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 <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/animateContent" android:layout_marginTop="@dimen/dashboard_map_top_padding"
android:orientation="vertical" > android:orientation="vertical" >
<LinearLayout <LinearLayout
android:id="@+id/content" android:id="@+id/content"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical" android:orientation="vertical" />
android:paddingTop="@dimen/dashboard_map_top_padding" />
<net.osmand.plus.activities.search.toolbar.SplitToolbar <net.osmand.plus.activities.search.toolbar.SplitToolbar
android:id="@+id/bottomControls" android:id="@+id/bottomControls"
@ -38,6 +52,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/bottomToolBarColor" /> android:background="?attr/bottomToolBarColor" />
</LinearLayout> </LinearLayout>
</FrameLayout>
</net.osmand.plus.dashboard.NotifyingScrollView> </net.osmand.plus.dashboard.NotifyingScrollView>
</FrameLayout> </FrameLayout>

View file

@ -45,6 +45,9 @@
<dimen name="dashboard_map_top_padding">240dp</dimen> <dimen name="dashboard_map_top_padding">240dp</dimen>
<dimen name="dashboard_map_bottom_padding">90dp</dimen> <dimen name="dashboard_map_bottom_padding">90dp</dimen>
<dimen name="map_button_size">40dp</dimen>
<dimen name="map_button_margin">8dp</dimen>
<!-- TextSizes --> <!-- TextSizes -->
<dimen name="list_header_text_size">14sp</dimen> <dimen name="list_header_text_size">14sp</dimen>
<dimen name="showAllButtonTextSize">12sp</dimen> <dimen name="showAllButtonTextSize">12sp</dimen>

View file

@ -622,7 +622,7 @@ public class OsmandSettings {
return p; 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 // 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(); public final CommonPreference<Boolean> USE_INTERNET_TO_DOWNLOAD_TILES = new BooleanPreference("use_internet_to_download_tiles", true).makeGlobal().cache();

View file

@ -1,40 +1,26 @@
package net.osmand.plus.activities; package net.osmand.plus.activities;
import java.io.File;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import java.util.Random;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.access.AccessibleAlertBuilder;
import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndLocationProvider; import net.osmand.plus.OsmAndLocationProvider;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.base.BasicProgressAsyncTask; import net.osmand.plus.base.BasicProgressAsyncTask;
import net.osmand.plus.dashboard.DashDownloadMapsFragment; import net.osmand.plus.dashboard.DashDownloadMapsFragment;
import net.osmand.plus.dashboard.DashErrorFragment; import net.osmand.plus.dashboard.DashErrorFragment;
import net.osmand.plus.dashboard.DashLocationFragment;
import net.osmand.plus.dashboard.DashUpdatesFragment; import net.osmand.plus.dashboard.DashUpdatesFragment;
import net.osmand.plus.dashboard.NotifyingScrollView; import net.osmand.plus.dashboard.NotifyingScrollView;
import net.osmand.plus.download.BaseDownloadActivity; import net.osmand.plus.download.BaseDownloadActivity;
import net.osmand.plus.download.DownloadActivity;
import net.osmand.plus.download.IndexItem; import net.osmand.plus.download.IndexItem;
import net.osmand.plus.render.MapRenderRepositories;
import net.osmand.plus.sherpafy.TourViewActivity; import net.osmand.plus.sherpafy.TourViewActivity;
import net.osmand.plus.views.controls.FloatingActionButton; import net.osmand.plus.views.controls.FloatingActionButton;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent; 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.content.res.Resources;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
@ -44,7 +30,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBar;
import android.text.method.LinkMovementMethod;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.Menu; import android.view.Menu;
@ -53,7 +38,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.ScrollView; import android.widget.ScrollView;
import android.widget.TextView;
/** /**
@ -302,22 +286,19 @@ public class MainMenuActivity extends BaseDownloadActivity implements OsmAndLoca
@Override @Override
public void updateCompassValue(float value) { public void updateCompassValue(float value) {
for (WeakReference<Fragment> ref : fragList) { //
Fragment f = ref.get(); // throw new UnsupportedOperationException();
if (f instanceof DashLocationFragment && !f.isDetached()) {
((DashLocationFragment) f).updateCompassValue(value);
}
}
} }
@Override @Override
public void updateLocation(Location location) { public void updateLocation(Location location) {
for (WeakReference<Fragment> ref : fragList) { // for (WeakReference<Fragment> ref : fragList) {
Fragment f = ref.get(); // Fragment f = ref.get();
if (f instanceof DashLocationFragment && !f.isDetached()) { // if (f instanceof DashLocationFragment && !f.isDetached()) {
((DashLocationFragment) f).updateLocation(location); // ((DashLocationFragment) f).updateLocation(location);
} // }
} // }
// throw new UnsupportedOperationException();
} }
private OsmAndLocationProvider getLocationProvider() { private OsmAndLocationProvider getLocationProvider() {

View file

@ -142,6 +142,9 @@ public class MapActivity extends AccessibleActivity {
setContentView(R.layout.main); setContentView(R.layout.main);
mapActions = new MapActivityActions(this); mapActions = new MapActivityActions(this);
mapLayers = new MapActivityLayers(this); mapLayers = new MapActivityLayers(this);
if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
dashboardOnMap.createDashboardView(); dashboardOnMap.createDashboardView();
if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) { if (app.isApplicationInitializing() || DashboardOnMap.staticVisible) {
@ -168,11 +171,12 @@ public class MapActivity extends AccessibleActivity {
@Override @Override
public void onFinish(AppInitializer init) { public void onFinish(AppInitializer init) {
applicationInitialized();
if(!openGlSetup) { if(!openGlSetup) {
setupOpenGLView(); setupOpenGLView();
} }
mapView.refreshMap(); mapView.refreshMap(true);
findViewById(R.id.init_progress).setVisibility(View.GONE);
findViewById(R.id.ParentLayout).invalidate();
} }
}; };
getMyApplication().checkApplicationIsBeingInitialized(this, initListener); getMyApplication().checkApplicationIsBeingInitialized(this, initListener);
@ -194,9 +198,6 @@ public class MapActivity extends AccessibleActivity {
} }
}); });
mapView.setAccessibilityActions(new MapAccessibilityActions(this)); mapView.setAccessibilityActions(new MapAccessibilityActions(this));
if (mapViewTrackingUtilities == null) {
mapViewTrackingUtilities = new MapViewTrackingUtilities(app);
}
mapViewTrackingUtilities.setMapView(mapView); mapViewTrackingUtilities.setMapView(mapView);
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(new IMapDownloaderCallback() { 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() { private void setupOpenGLView() {
if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) { if (settings.USE_OPENGL_RENDER.get() && NativeCoreContext.isInit()) {
@ -259,6 +255,7 @@ public class MapActivity extends AccessibleActivity {
atlasMapRendererView.setElevationAngle(90); atlasMapRendererView.setElevationAngle(90);
NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView); NativeCoreContext.getMapRendererContext().setMapRendererView(atlasMapRendererView);
mapView = ml.getMapView(); mapView = ml.getMapView();
mapViewTrackingUtilities.setMapView(mapView);
mapView.setMapRender(atlasMapRendererView); mapView.setMapRender(atlasMapRendererView);
OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView); OsmAndMapSurfaceView surf = (OsmAndMapSurfaceView) findViewById(R.id.MapView);
surf.setVisibility(View.GONE); surf.setVisibility(View.GONE);
@ -693,9 +690,19 @@ public class MapActivity extends AccessibleActivity {
} }
public LatLon getMapLocation() { public LatLon getMapLocation() {
if(mapView == null) {
return settings.getLastKnownMapLocation();
}
return new LatLon(mapView.getLatitude(), mapView.getLongitude()); return new LatLon(mapView.getLatitude(), mapView.getLongitude());
} }
public float getMapRotate() {
if(mapView == null) {
return 0;
}
return mapView.getRotate();
}
// Duplicate methods to OsmAndApplication // Duplicate methods to OsmAndApplication
public TargetPoint getPointToNavigate() { public TargetPoint getPointToNavigate() {
return app.getTargetPointsHelper().getPointToNavigate(); return app.getTargetPointsHelper().getPointToNavigate();

View file

@ -785,7 +785,8 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
} }
} }
if(loc != null){ 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 h = heading;
float a = h != null ? h : 0; float a = h != null ? h : 0;

View file

@ -15,6 +15,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.AutoZoomMap; import net.osmand.plus.OsmandSettings.AutoZoomMap;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener; import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
import net.osmand.plus.views.AnimateDraggingMapThread; import net.osmand.plus.views.AnimateDraggingMapThread;
@ -29,6 +30,7 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
private long lastTimeAutoZooming = 0; private long lastTimeAutoZooming = 0;
private boolean sensorRegistered = false; private boolean sensorRegistered = false;
private OsmandMapTileView mapView; private OsmandMapTileView mapView;
private DashboardOnMap dashboard;
private OsmandSettings settings; private OsmandSettings settings;
private OsmandApplication app; private OsmandApplication app;
// by default turn off causing unexpected movements due to network establishing // by default turn off causing unexpected movements due to network establishing
@ -80,6 +82,17 @@ public class MapViewTrackingUtilities implements OsmAndLocationListener, IMapLoc
mapView.refreshMap(); mapView.refreshMap();
} }
} }
if(dashboard != null) {
dashboard.updateCompassValue(val);
}
}
public void setDashboard(DashboardOnMap dashboard) {
this.dashboard = dashboard;
}
public DashboardOnMap getDashboard() {
return dashboard;
} }
@Override @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! // When location is changed we need to refresh map in order to show movement!
mapView.refreshMap(); mapView.refreshMap();
} }
if(dashboard != null) {
dashboard.updateMyLocation(location);
}
} }
private boolean isSmallSpeedForCompass(Location location) { private boolean isSmallSpeedForCompass(Location location) {

View file

@ -11,7 +11,7 @@ import net.osmand.plus.activities.MapActivity;
*/ */
public abstract class DashBaseFragment extends Fragment { public abstract class DashBaseFragment extends Fragment {
private DashboardOnMap dashboard; protected DashboardOnMap dashboard;
public OsmandApplication getMyApplication(){ public OsmandApplication getMyApplication(){
if (getActivity() == null){ if (getActivity() == null){

View file

@ -5,13 +5,11 @@ import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
import net.osmand.Location;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.FavouritesDbHelper;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmAndFormatter;
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.base.FavoriteImageDrawable; import net.osmand.plus.base.FavoriteImageDrawable;
@ -35,11 +33,8 @@ import android.widget.TextView;
/** /**
* Created by Denis on 24.11.2014. * 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"; 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>(); List<FavouritePoint> points = new ArrayList<FavouritePoint>();
@Override @Override
@ -63,19 +58,8 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
return view; return view;
} }
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
}
@Override @Override
public void onOpenDash() { 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(); setupFavorites();
} }
@ -83,25 +67,26 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
View mainView = getView(); View mainView = getView();
final FavouritesDbHelper helper = getMyApplication().getFavorites(); final FavouritesDbHelper helper = getMyApplication().getFavorites();
points = new ArrayList<FavouritePoint>(helper.getFavouritePoints()); points = new ArrayList<FavouritePoint>(helper.getFavouritePoints());
arrows.clear();
if (points.size() == 0) { if (points.size() == 0) {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE); (mainView.findViewById(R.id.main_fav)).setVisibility(View.GONE);
return; return;
} else { } else {
(mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE); (mainView.findViewById(R.id.main_fav)).setVisibility(View.VISIBLE);
} }
final LatLon loc = getDefaultLocation();
if (loc != null) {
Collections.sort(points, new Comparator<FavouritePoint>() { Collections.sort(points, new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint point, FavouritePoint point2) { public int compare(FavouritePoint point, FavouritePoint point2) {
// LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation(); // LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), loc.getLatitude(), int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(),
loc.getLongitude())); loc.getLatitude(), loc.getLongitude()));
int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(), loc.getLatitude(), int dist2 = (int) (MapUtils.getDistance(point2.getLatitude(), point2.getLongitude(),
loc.getLongitude())); loc.getLatitude(), loc.getLongitude()));
return (dist - dist2); return (dist - dist2);
} }
}); });
}
LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items); LinearLayout favorites = (LinearLayout) mainView.findViewById(R.id.items);
favorites.removeAllViews(); favorites.removeAllViews();
if (points.size() > 3) { if (points.size() > 3) {
@ -109,12 +94,15 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
points.remove(3); points.remove(3);
} }
} }
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final FavouritePoint point : points) { for (final FavouritePoint point : points) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.favorites_list_item, null, false); View view = inflater.inflate(R.layout.favorites_list_item, null, false);
TextView name = (TextView) view.findViewById(R.id.favourite_label); TextView name = (TextView) view.findViewById(R.id.favourite_label);
TextView label = (TextView) view.findViewById(R.id.distance); TextView label = (TextView) view.findViewById(R.id.distance);
ImageView direction = (ImageView) view.findViewById(R.id.direction); ImageView direction = (ImageView) view.findViewById(R.id.direction);
direction.setVisibility(View.VISIBLE);
label.setVisibility(View.VISIBLE);
view.findViewById(R.id.divider).setVisibility(View.VISIBLE); view.findViewById(R.id.divider).setVisibility(View.VISIBLE);
if (point.getCategory().length() > 0) { if (point.getCategory().length() > 0) {
((TextView) view.findViewById(R.id.group_name)).setText(point.getCategory()); ((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( ((ImageView) view.findViewById(R.id.favourite_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(
getActivity(), point.getColor())); 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()); 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).setVisibility(View.VISIBLE);
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() { view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -146,7 +126,6 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName())); new PointDescription(PointDescription.POINT_TYPE_FAVORITE, point.getName()));
} }
}); });
label.setText(distance, TextView.BufferType.SPANNABLE);
label.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC); label.setTypeface(Typeface.DEFAULT, point.isVisible() ? Typeface.NORMAL : Typeface.ITALIC);
view.setOnClickListener(new View.OnClickListener() { view.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -159,42 +138,8 @@ public class DashFavoritesFragment extends DashLocationFragment implements Favou
}); });
favorites.addView(view); 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();
}
});
}
} }

View file

@ -1,51 +1,56 @@
package net.osmand.plus.dashboard; package net.osmand.plus.dashboard;
import java.util.ArrayList;
import java.util.List;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.R;
import net.osmand.plus.views.DirectionDrawable; import net.osmand.plus.views.DirectionDrawable;
import net.osmand.util.MapUtils; import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.hardware.Sensor; import android.hardware.Sensor;
import android.hardware.SensorManager; import android.hardware.SensorManager;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView;
/** /**
* Created by Denis * Created by Denis
* on 26.01.2015. * on 26.01.2015.
*/ */
@SuppressLint("ResourceAsColor")
public abstract class DashLocationFragment extends DashBaseFragment { public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_0 = 0; private static final int ORIENTATION_0 = 0;
private static final int ORIENTATION_90 = 3; private static final int ORIENTATION_90 = 3;
private static final int ORIENTATION_270 = 1; private static final int ORIENTATION_270 = 1;
private static final int ORIENTATION_180 = 2; private static final int ORIENTATION_180 = 2;
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
private int screenOrientation;
protected Float heading = null; public static class DashLocationView {
public boolean useOnlyMyLocation;
public ImageView arrow;
public TextView txt;
public LatLon loc;
protected LatLon loc = null; public DashLocationView(ImageView arrow, TextView txt, LatLon loc) {
super();
public void updateLocation(Location location) { this.arrow = arrow;
//This is used as origin for both Fav-list and direction arrows this.txt = txt;
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) { this.loc = loc;
loc = getMyApplication().getSettings().getLastKnownMapLocation();
} else {
loc = new LatLon(0f, 0f);
}
} }
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 //Hardy: getRotation() is the correction if device's screen orientation != the default display's standard orientation
int screenOrientation = 0; screenOrientation = 0;
screenOrientation = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation(); screenOrientation = ((WindowManager) getActivity().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
switch (screenOrientation) switch (screenOrientation)
{ {
case ORIENTATION_0: // Device default (normally portrait) case ORIENTATION_0: // Device default (normally portrait)
@ -61,29 +66,80 @@ public abstract class DashLocationFragment extends DashBaseFragment {
screenOrientation = 180; screenOrientation = 180;
break; break;
} }
//Looks like screenOrientation correction must not be applied for devices without compass? //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) { if (compass == null) {
screenOrientation = 0; screenOrientation = 0;
} }
draw.setAngle(mes[1] - a + 180 + screenOrientation);
direction.setImageDrawable(draw);
} }
public boolean updateCompassValue(float value) { public LatLon getDefaultLocation() {
//heading = value; DashboardOnMap d = dashboard;
//updateArrows(); if(d == null) {
//99 in next line used to one-time initalize arrows (with reference vs. fixed-north direction) on non-compass devices return null;
float lastHeading = heading != null ? heading : 99; }
heading = value; return d.getMapViewLocation();
if (heading != null && Math.abs(MapUtils.degreesDiff(lastHeading, heading)) > 5) { }
return true;
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 { } else {
heading = lastHeading; dd.setAngle(mes[1] - h + 180 + screenOrientation);
} }
return false; 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();
} }
} }

View file

@ -3,7 +3,6 @@ package net.osmand.plus.dashboard;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.OsmAndAppCustomization; import net.osmand.plus.OsmAndAppCustomization;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
@ -18,9 +17,7 @@ import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.graphics.PorterDuff;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -39,7 +36,6 @@ public class DashRecentsFragment extends DashLocationFragment {
private List<ImageView> arrows = new ArrayList<ImageView>(); private List<ImageView> arrows = new ArrayList<ImageView>();
List<HistoryEntry> points = new ArrayList<HistoryEntry>(); List<HistoryEntry> points = new ArrayList<HistoryEntry>();
Drawable icon;
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
@ -63,22 +59,11 @@ public class DashRecentsFragment extends DashLocationFragment {
activity.startActivity(search); 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; return view;
} }
@Override @Override
public void onOpenDash() { 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(); setupRecents();
} }
@ -100,6 +85,8 @@ public class DashRecentsFragment extends DashLocationFragment {
if (points.size() > 3) { if (points.size() > 3) {
points = points.subList(0, 3); points = points.subList(0, 3);
} }
LatLon loc = getDefaultLocation();
List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
for (final HistoryEntry historyEntry : points) { for (final HistoryEntry historyEntry : points) {
LayoutInflater inflater = getActivity().getLayoutInflater(); LayoutInflater inflater = getActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.search_history_list_item, null, false); View view = inflater.inflate(R.layout.search_history_list_item, null, false);
@ -120,34 +107,14 @@ public class DashRecentsFragment extends DashLocationFragment {
MapActivity.launchMapActivityMoveToTop(getActivity()); 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); 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();
}
} }

View file

@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import net.osmand.data.LatLon;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -50,6 +51,11 @@ public class DashboardOnMap {
private boolean visible = false; private boolean visible = false;
private boolean landscape; private boolean landscape;
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<WeakReference<DashBaseFragment>>(); 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) { public DashboardOnMap(MapActivity ma) {
@ -72,6 +78,16 @@ public class DashboardOnMap {
dashboardView.setOnClickListener(listener); dashboardView.setOnClickListener(listener);
((FrameLayout) mapActivity.findViewById(R.id.ParentLayout)).addView(dashboardView); ((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) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
fabButton = new FloatingActionButton.Builder(mapActivity) fabButton = new FloatingActionButton.Builder(mapActivity)
.withDrawable(mapActivity.getResources().getDrawable(R.drawable.ic_action_map)) .withDrawable(mapActivity.getResources().getDrawable(R.drawable.ic_action_map))
@ -99,16 +115,39 @@ 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() { protected OsmandApplication getMyApplication() {
return mapActivity.getMyApplication(); return mapActivity.getMyApplication();
} }
public void setDashboardVisibility(boolean visible) { public void setDashboardVisibility(boolean visible) {
this.visible = visible; this.visible = visible;
DashboardOnMap.staticVisible = visible; DashboardOnMap.staticVisible = visible;
if (visible) { if (visible) {
mapViewLocation = mapActivity.getMapLocation();
mapRotation = mapActivity.getMapRotate();
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
mapActivity.getMapViewTrackingUtilities().setDashboard(this);
addOrUpdateDashboardFragments(); addOrUpdateDashboardFragments();
setupActionBar(); setupActionBar();
dashboardView.setVisibility(View.VISIBLE); dashboardView.setVisibility(View.VISIBLE);
@ -117,8 +156,10 @@ public class DashboardOnMap {
mapActivity.getMapActions().disableDrawer(); mapActivity.getMapActions().disableDrawer();
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.GONE); mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.GONE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.GONE); mapActivity.findViewById(R.id.MapButtons).setVisibility(View.GONE);
updateLocation(true, true, false);
} else { } else {
mapActivity.getMapActions().enableDrawer(); mapActivity.getMapActions().enableDrawer();
mapActivity.getMapViewTrackingUtilities().setDashboard(null);
hide(dashboardView.findViewById(R.id.animateContent)); hide(dashboardView.findViewById(R.id.animateContent));
mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE); mapActivity.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
@ -285,6 +326,7 @@ public class DashboardOnMap {
} }
}; };
public boolean isVisible() { public boolean isVisible() {
return visible; return visible;
} }
@ -299,7 +341,40 @@ 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) { public void onAttach(DashBaseFragment dashBaseFragment) {
fragList.add(new WeakReference<DashBaseFragment>(dashBaseFragment)); fragList.add(new WeakReference<DashBaseFragment>(dashBaseFragment));
} }
} }

View file

@ -50,11 +50,6 @@ public class DashParkingFragment extends DashLocationFragment {
@Override @Override
public void onOpenDash() { public void onOpenDash() {
plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class); plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
if (getMyApplication().getSettings().getLastKnownMapLocation() != null) {
loc = getMyApplication().getSettings().getLastKnownMapLocation();
} else {
loc = new LatLon(0f, 0f);
}
updateParkingPosition(); updateParkingPosition();
} }
@ -69,38 +64,18 @@ public class DashParkingFragment extends DashLocationFragment {
LatLon position = plugin.getParkingPosition(); LatLon position = plugin.getParkingPosition();
int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(), loc.getLatitude(), // int dist = (int) (MapUtils.getDistance(position.getLatitude(), position.getLongitude(), loc.getLatitude(),
loc.getLongitude())); // loc.getLongitude()));
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()); // String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication());
((TextView) mainView.findViewById(R.id.distance)).setText(distance); // ((TextView) mainView.findViewById(R.id.distance)).setText(distance);
// TODO add parking time // // TODO add parking time
String parking_name = plugin.getParkingType() ? getString(R.string.parking_place) // String parking_name = plugin.getParkingType() ? getString(R.string.parking_place)
: getString(R.string.parking_place); // : getString(R.string.parking_place);
((TextView) mainView.findViewById(R.id.name)).setText(parking_name); // ((TextView) mainView.findViewById(R.id.name)).setText(parking_name);
ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon); // ImageView direction = (ImageView) mainView.findViewById(R.id.direction_icon);
if (loc != null) { // if (loc != null) {
direction.setVisibility(View.VISIBLE); // direction.setVisibility(View.VISIBLE);
updateArrow(getActivity(), loc, position, direction, 10, R.drawable.ic_destination_arrow, heading); // 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();
} }
} }

View file

@ -5,7 +5,7 @@ import android.graphics.*;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.WindowManager; import android.view.WindowManager;
import net.osmand.plus.IconsCache;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -20,10 +20,17 @@ public class DirectionDrawable extends Drawable {
Context ctx; Context ctx;
private float angle; private float angle;
int resourceId = -1; 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(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 @Override
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
if (resourceId != -1) { if (arrowImage != null) {
canvas.rotate(angle, canvas.getHeight() / 2, canvas.getWidth() / 2); 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.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
arrowImage.draw(canv); arrowImage.draw(canvas);
canvas.drawBitmap(arrow, null, new Rect(0, 0, arrow.getHeight(), arrow.getWidth()), null); // 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 { } else {
canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth() / 2); canvas.rotate(angle, canvas.getHeight()/2, canvas.getWidth() / 2);
Path directionPath = createDirectionPath(); Path directionPath = createDirectionPath();