Merge pull request #1094 from Bars107/master
Dashboard over map view added.
This commit is contained in:
commit
e77dce249c
17 changed files with 425 additions and 106 deletions
33
OsmAnd/res/layout/dashboard_over_map.xml
Normal file
33
OsmAnd/res/layout/dashboard_over_map.xml
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout
|
||||
android:id="@+id/dashboard"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="#70000000"
|
||||
android:visibility="gone">
|
||||
|
||||
<LinearLayout android:orientation="vertical"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<net.osmand.plus.dashboard.NotifyingScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="360dp"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/main_scroll">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/content"
|
||||
android:paddingTop="@dimen/dashboard_map_top_padding"
|
||||
android:paddingBottom="@dimen/dashboard_map_bottom_padding"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"/>
|
||||
|
||||
</net.osmand.plus.dashboard.NotifyingScrollView>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
|
@ -1,53 +1,63 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<android.support.v4.widget.DrawerLayout
|
||||
android:id="@+id/drawer_layout"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:clipChildren="false"
|
||||
android:keepScreenOn="true"
|
||||
android:orientation="vertical">
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:clipChildren="false"
|
||||
android:keepScreenOn="true"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ViewStub
|
||||
android:id="@+id/atlasMapRendererViewStub"
|
||||
android:inflatedId="@+id/atlasMapRendererView"
|
||||
android:layout="@layout/atlas_map_renderer_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
<ViewStub
|
||||
android:id="@+id/atlasMapRendererViewStub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:inflatedId="@+id/atlasMapRendererView"
|
||||
android:layout="@layout/atlas_map_renderer_view"/>
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone" />
|
||||
<net.osmand.plus.views.OsmAndMapSurfaceView
|
||||
android:id="@+id/MapView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<net.osmand.plus.views.OsmAndMapLayersView
|
||||
android:id="@+id/MapLayersView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone" />
|
||||
<net.osmand.plus.views.OsmAndMapLayersView
|
||||
android:id="@+id/MapLayersView"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:contentDescription="@string/map_view"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal" />
|
||||
</FrameLayout>
|
||||
<FrameLayout android:id="@+id/MapInfoControls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:choiceMode="singleChoice"
|
||||
<LinearLayout
|
||||
android:id="@+id/dialog_layout"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:orientation="horizontal"/>
|
||||
|
||||
|
||||
<FrameLayout android:id="@+id/MapButtons"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
</FrameLayout>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/left_drawer"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
android:background="?attr/expandable_list_background"
|
||||
android:divider="@drawable/divider"
|
||||
android:dividerHeight="1dp" />
|
||||
android:choiceMode="singleChoice"
|
||||
android:divider="@drawable/divider"
|
||||
android:dividerHeight="1dp"/>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
|
@ -56,6 +56,22 @@
|
|||
android:textSize="@dimen/showAllButtonTextSize"
|
||||
tools:text="100500 km"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/type_name_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/ic_small_group"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/type_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/showAllButtonTextSize"
|
||||
tools:text="100500 km"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
|
5
OsmAnd/res/values-land/sizes.xml
Normal file
5
OsmAnd/res/values-land/sizes.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="dashboard_map_top_padding">100dp</dimen>
|
||||
<dimen name="dashboard_map_bottom_padding">0dp</dimen>
|
||||
</resources>
|
|
@ -43,6 +43,9 @@
|
|||
<dimen name="gpx_small_icon_margin">3dp</dimen>
|
||||
<dimen name="gpx_small_text_margin">14dp</dimen>
|
||||
<dimen name="gpx_text_top_margin">6dp</dimen>
|
||||
<dimen name="dashboard_map_width">360dp</dimen>
|
||||
<dimen name="dashboard_map_top_padding">200dp</dimen>
|
||||
<dimen name="dashboard_map_bottom_padding">80dp</dimen>
|
||||
|
||||
<!-- TextSizes -->
|
||||
<dimen name="list_header_text_size">14sp</dimen>
|
||||
|
|
|
@ -51,6 +51,10 @@ public class PointDescription {
|
|||
}
|
||||
}
|
||||
|
||||
public String getTypeName() {
|
||||
return typeName;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String getName() {
|
||||
return name;
|
||||
|
|
|
@ -1,13 +1,32 @@
|
|||
package net.osmand.plus.activities;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import android.app.Dialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewStub;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.StateChangedListener;
|
||||
|
@ -33,9 +52,9 @@ import net.osmand.plus.TargetPointsHelper;
|
|||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.search.SearchActivity;
|
||||
import net.osmand.plus.audionotes.MediaRemoteControlReceiver;
|
||||
import net.osmand.plus.base.FailSafeFuntions;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.helpers.GpxImportHelper;
|
||||
import net.osmand.plus.helpers.WakeLockHelper;
|
||||
import net.osmand.plus.poi.PoiLegacyFilter;
|
||||
|
@ -51,33 +70,14 @@ import net.osmand.plus.views.OsmandMapTileView;
|
|||
import net.osmand.plus.views.corenative.NativeCoreContext;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.util.Algorithms;
|
||||
import android.app.Dialog;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.media.AudioManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
import android.view.ViewStub;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class MapActivity extends AccessibleActivity {
|
||||
|
||||
|
@ -113,8 +113,9 @@ public class MapActivity extends AccessibleActivity {
|
|||
private GpxImportHelper gpxImportHelper;
|
||||
private WakeLockHelper wakeLockHelper ;
|
||||
private boolean intentLocation = false;
|
||||
|
||||
|
||||
|
||||
private DashboardOnMap dashboardOnMap;
|
||||
|
||||
private Notification getNotification() {
|
||||
Intent notificationIndent = new Intent(this, getMyApplication().getAppCustomization().getMapActivity());
|
||||
notificationIndent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
|
@ -224,9 +225,11 @@ public class MapActivity extends AccessibleActivity {
|
|||
mapActions.prepareStartOptionsMenu();
|
||||
|
||||
wakeLockHelper = new WakeLockHelper(getMyApplication());
|
||||
|
||||
dashboardOnMap = new DashboardOnMap(this);
|
||||
dashboardOnMap.createDashboardView();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addLockView(FrameLayout lockView) {
|
||||
this.lockView = lockView;
|
||||
}
|
||||
|
@ -300,6 +303,9 @@ public class MapActivity extends AccessibleActivity {
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (dashboardOnMap.isVisible()){
|
||||
dashboardOnMap.setDashboardVisibility(false);
|
||||
}
|
||||
if (!mapActions.onBackPressed()) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
@ -840,4 +846,7 @@ public class MapActivity extends AccessibleActivity {
|
|||
}
|
||||
|
||||
|
||||
public DashboardOnMap getDashboard() {
|
||||
return dashboardOnMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -700,9 +700,10 @@ public class MapActivityActions implements DialogProvider {
|
|||
.listen(new OnContextMenuClick() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
mapActivity.startActivity(newIntent);
|
||||
// Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization().getMainMenuActivity());
|
||||
// newIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
// mapActivity.startActivity(newIntent);
|
||||
mapActivity.getDashboard().setDashboardVisibility(true);
|
||||
return true;
|
||||
}
|
||||
}).reg();
|
||||
|
@ -948,6 +949,14 @@ public class MapActivityActions implements DialogProvider {
|
|||
listAdapter, null));
|
||||
}
|
||||
|
||||
public void disableDrawer(){
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
|
||||
}
|
||||
|
||||
public void enableDrawer(){
|
||||
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
|
||||
}
|
||||
|
||||
public void openIntermediatePointsDialog(){
|
||||
waypointDialogHelper.showWaypointsDialog(mapActivity, false);
|
||||
}
|
||||
|
|
|
@ -230,6 +230,14 @@ public class SearchHistoryFragment extends ListFragment implements SearchActivit
|
|||
icon.setImageDrawable(addressIcon);
|
||||
}
|
||||
|
||||
String typeName = historyEntry.getName().getTypeName();
|
||||
if (typeName !=null && !typeName.isEmpty()){
|
||||
row.findViewById(R.id.type_name_icon).setVisibility(View.VISIBLE);
|
||||
((TextView) row.findViewById(R.id.type_name)).setText(typeName);
|
||||
} else {
|
||||
row.findViewById(R.id.type_name_icon).setVisibility(View.GONE);
|
||||
((TextView) row.findViewById(R.id.type_name)).setText("");
|
||||
}
|
||||
|
||||
options.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
|
|
@ -14,6 +14,7 @@ import net.osmand.util.Algorithms;
|
|||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
|
@ -30,6 +31,9 @@ import android.widget.TextView;
|
|||
* on 15.12.2014.
|
||||
*/
|
||||
public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_NOTES_FRAGMENT";
|
||||
|
||||
AudioVideoNotesPlugin plugin;
|
||||
|
||||
@Override
|
||||
|
@ -98,6 +102,7 @@ public class DashAudioVideoNotesFragment extends DashBaseFragment {
|
|||
View view = inflater.inflate(R.layout.note, null, false);
|
||||
|
||||
getNoteView(recording, view, getActivity());
|
||||
view.setBackgroundColor(Color.TRANSPARENT);
|
||||
view.findViewById(R.id.play).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -25,9 +25,13 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* Created by Denis on 21.11.2014.
|
||||
* Created by Denis
|
||||
* on 21.11.2014.
|
||||
*/
|
||||
public class DashPluginsFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_PLUGINS_FRAGMENT";
|
||||
|
||||
private final CompoundButton.OnCheckedChangeListener enableDisableListener =
|
||||
new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -115,7 +115,7 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
if (points.size() > 3){
|
||||
points = points.subList(0, 3);
|
||||
}
|
||||
for (final HistoryEntry point : points) {
|
||||
for (final HistoryEntry historyEntry : points) {
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.dash_favorites_item, null, false);
|
||||
TextView name = (TextView) view.findViewById(R.id.name);
|
||||
|
@ -133,33 +133,42 @@ public class DashRecentsFragment extends DashLocationFragment {
|
|||
|
||||
if(loc != null){
|
||||
direction.setVisibility(View.VISIBLE);
|
||||
updateArrow(getActivity(), loc, new LatLon(point.getLat(), point.getLon()), direction,
|
||||
updateArrow(getActivity(), loc, new LatLon(historyEntry.getLat(), historyEntry.getLon()), direction,
|
||||
10, R.drawable.ic_destination_arrow, heading);
|
||||
}
|
||||
arrows.add(direction);
|
||||
name.setText(point.getName().getName());
|
||||
name.setText(historyEntry.getName().getName());
|
||||
|
||||
//LatLon lastKnownMapLocation = getMyApplication().getSettings().getLastKnownMapLocation();
|
||||
int dist = (int) (MapUtils.getDistance(point.getLat(), point.getLon(),
|
||||
int dist = (int) (MapUtils.getDistance(historyEntry.getLat(), historyEntry.getLon(),
|
||||
loc.getLatitude(), loc.getLongitude()));
|
||||
String distance = OsmAndFormatter.getFormattedDistance(dist, getMyApplication()) + " ";
|
||||
view.findViewById(R.id.navigate_to).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), point.getLat(), point.getLon(),
|
||||
point.getName());
|
||||
DirectionsDialogs.directionsToDialogAndLaunchMap(getActivity(), historyEntry.getLat(), historyEntry.getLon(),
|
||||
historyEntry.getName());
|
||||
}
|
||||
});
|
||||
label.setText(distance, TextView.BufferType.SPANNABLE);
|
||||
view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
getMyApplication().getSettings().setMapLocationToShow(point.getLat(), point.getLon(), 15,
|
||||
point.getName(), true,
|
||||
point); //$NON-NLS-1$
|
||||
getMyApplication().getSettings().setMapLocationToShow(historyEntry.getLat(), historyEntry.getLon(), 15,
|
||||
historyEntry.getName(), true,
|
||||
historyEntry); //$NON-NLS-1$
|
||||
MapActivity.launchMapActivityMoveToTop(getActivity());
|
||||
}
|
||||
});
|
||||
|
||||
String typeName = historyEntry.getName().getTypeName();
|
||||
if (typeName !=null && !typeName.isEmpty()){
|
||||
view.findViewById(R.id.group_image).setVisibility(View.VISIBLE);
|
||||
((TextView) view.findViewById(R.id.group_name)).setText(typeName);
|
||||
} else {
|
||||
view.findViewById(R.id.group_image).setVisibility(View.GONE);
|
||||
((TextView) view.findViewById(R.id.group_name)).setText("");
|
||||
}
|
||||
favorites.addView(view);
|
||||
}
|
||||
updateLocation(location);
|
||||
|
|
194
OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
Normal file
194
OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package net.osmand.plus.dashboard;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentTransaction;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.TranslateAnimation;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.DashAudioVideoNotesFragment;
|
||||
import net.osmand.plus.helpers.ScreenOrientationHelper;
|
||||
import net.osmand.plus.monitoring.DashTrackFragment;
|
||||
import net.osmand.plus.views.controls.FloatingActionButton;
|
||||
|
||||
/**
|
||||
* Created by Denis
|
||||
* on 03.03.15.
|
||||
*/
|
||||
public class DashboardOnMap {
|
||||
|
||||
|
||||
private MapActivity ma;
|
||||
FloatingActionButton fabButton;
|
||||
boolean floatingButtonVisible = false;
|
||||
private FrameLayout dashboardView;
|
||||
private boolean visible = false;
|
||||
|
||||
|
||||
public DashboardOnMap(MapActivity ma) {
|
||||
this.ma = ma;
|
||||
}
|
||||
|
||||
|
||||
public void createDashboardView() {
|
||||
dashboardView = (FrameLayout) ma.getLayoutInflater().inflate(R.layout.dashboard_over_map, null, false);
|
||||
dashboardView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
View.OnClickListener listener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
setDashboardVisibility(false);
|
||||
}
|
||||
};
|
||||
dashboardView.findViewById(R.id.content).setOnClickListener(listener);
|
||||
dashboardView.setOnClickListener(listener);
|
||||
((FrameLayout)ma.getMapView().getParent()).addView(dashboardView);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
|
||||
fabButton = new FloatingActionButton.Builder(ma)
|
||||
.withDrawable(ma.getResources().getDrawable(R.drawable.ic_action_map))
|
||||
.withButtonColor(Color.parseColor("#ff8f00"))
|
||||
.withGravity(Gravity.BOTTOM | Gravity.RIGHT)
|
||||
.withMargins(0, 0, 16, 16)
|
||||
.create();
|
||||
fabButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
setDashboardVisibility(false);
|
||||
fabButton.hideFloatingActionButton();
|
||||
}
|
||||
});
|
||||
fabButton.hideFloatingActionButton();
|
||||
}
|
||||
|
||||
if (ScreenOrientationHelper.isOrientationPortrait(ma)) {
|
||||
((NotifyingScrollView)dashboardView.findViewById(R.id.main_scroll)).setOnScrollChangedListener(onScrollChangedListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setDashboardVisibility(boolean visible) {
|
||||
this.visible = visible;
|
||||
if (visible) {
|
||||
addDashboardFragments();
|
||||
dashboardView.setVisibility(View.VISIBLE);
|
||||
if (floatingButtonVisible) {
|
||||
fabButton.showFloatingActionButton();
|
||||
}
|
||||
open(dashboardView.findViewById(R.id.content));
|
||||
ma.getMapActions().disableDrawer();
|
||||
//View close = dashboardView.findViewById(R.id.close_dashboard);
|
||||
if (ScreenOrientationHelper.isOrientationPortrait(ma)) {
|
||||
//close.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
//close.setVisibility(View.GONE);
|
||||
}
|
||||
ma.findViewById(R.id.MapInfoControls).setVisibility(View.GONE);
|
||||
ma.findViewById(R.id.MapButtons).setVisibility(View.GONE);
|
||||
} else {
|
||||
ma.getMapActions().enableDrawer();
|
||||
dashboardView.setVisibility(View.GONE);
|
||||
hide(dashboardView.findViewById(R.id.content));
|
||||
ma.findViewById(R.id.MapInfoControls).setVisibility(View.VISIBLE);
|
||||
ma.findViewById(R.id.MapButtons).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
// To animate view slide out from right to left
|
||||
public void open(View view){
|
||||
TranslateAnimation animate = new TranslateAnimation(0,0,ma.getMapView().getHeight(),0);
|
||||
animate.setDuration(500);
|
||||
animate.setFillAfter(true);
|
||||
view.startAnimation(animate);
|
||||
view.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void hide(View view){
|
||||
TranslateAnimation animate = new TranslateAnimation(0,0,0,ma.getMapView().getHeight());
|
||||
animate.setDuration(500);
|
||||
animate.setFillAfter(true);
|
||||
view.startAnimation(animate);
|
||||
view.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void addDashboardFragments(){
|
||||
FragmentManager manager =ma. getSupportFragmentManager();
|
||||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
if (manager.findFragmentByTag(DashSearchFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashSearchFragment(), DashSearchFragment.TAG);
|
||||
}
|
||||
if (manager.findFragmentByTag(DashRecentsFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashRecentsFragment(), DashRecentsFragment.TAG);
|
||||
}
|
||||
if (manager.findFragmentByTag(DashFavoritesFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashFavoritesFragment(), DashFavoritesFragment.TAG);
|
||||
}
|
||||
if (manager.findFragmentByTag(DashAudioVideoNotesFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashAudioVideoNotesFragment(), DashAudioVideoNotesFragment.TAG);
|
||||
}
|
||||
if (manager.findFragmentByTag(DashTrackFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashTrackFragment(), DashTrackFragment.TAG);
|
||||
}
|
||||
//fragmentTransaction.add(R.id.content, new DashUpdatesFragment(), DashUpdatesFragment.TAG);
|
||||
if (manager.findFragmentByTag(DashPluginsFragment.TAG) == null) {
|
||||
fragmentTransaction.add(R.id.content, new DashPluginsFragment(), DashPluginsFragment.TAG);
|
||||
}
|
||||
|
||||
fragmentTransaction.commit();
|
||||
|
||||
}
|
||||
|
||||
private void addErrorFragment() {
|
||||
FragmentManager manager = ma.getSupportFragmentManager();
|
||||
FragmentTransaction fragmentTransaction = manager.beginTransaction();
|
||||
if (manager.findFragmentByTag(DashErrorFragment.TAG) == null) {
|
||||
DashErrorFragment errorFragment = new DashErrorFragment();
|
||||
fragmentTransaction.add(R.id.content, errorFragment, DashErrorFragment.TAG).commit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private NotifyingScrollView.OnScrollChangedListener onScrollChangedListener = new NotifyingScrollView.OnScrollChangedListener() {
|
||||
public void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt) {
|
||||
//making background of actionbar transparent with scroll
|
||||
final int imageHeight = 200;
|
||||
final int headerHeight = 200;
|
||||
final float ratio = (float) Math.min(Math.max(t, 0), headerHeight) / headerHeight;
|
||||
int margintop = -(int)(ratio * 60);
|
||||
Resources r = ma.getResources();
|
||||
int px = (int) TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
margintop,
|
||||
r.getDisplayMetrics());
|
||||
int margin = px + (int)ma.getResources().getDimension(R.dimen.dashboard_map_bottom_padding);
|
||||
if (headerHeight < t - margin){
|
||||
//hiding action bar - showing floating button
|
||||
//getSupportActionBar().hide();
|
||||
if (fabButton != null) {
|
||||
fabButton.showFloatingActionButton();
|
||||
floatingButtonVisible = true;
|
||||
}
|
||||
} else {
|
||||
//getSupportActionBar().show();
|
||||
if (fabButton != null) {
|
||||
fabButton.hideFloatingActionButton();
|
||||
floatingButtonVisible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
}
|
|
@ -25,6 +25,7 @@ import net.osmand.plus.helpers.FontCache;
|
|||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
@ -45,6 +46,8 @@ import android.widget.Toast;
|
|||
*/
|
||||
public class DashTrackFragment extends DashBaseFragment {
|
||||
|
||||
public static final String TAG = "DASH_TRACK_FRAGMENT";
|
||||
|
||||
private Drawable gpxOnMap;
|
||||
private Drawable gpxNormal;
|
||||
private boolean updateEnable;
|
||||
|
@ -158,6 +161,7 @@ public class DashTrackFragment extends DashBaseFragment {
|
|||
showOnMap(GPXUtilities.loadGPXFile(app, f));
|
||||
}
|
||||
});
|
||||
v.setBackgroundColor(Color.TRANSPARENT);
|
||||
tracks.addView(v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
scaleCoefficient = view.getScaleCoefficient();
|
||||
FrameLayout parent = (FrameLayout) view.getParent();
|
||||
FrameLayout parent = getParent();
|
||||
Handler showUIHandler = new Handler();
|
||||
int rightGravity = Gravity.RIGHT | Gravity.BOTTOM;
|
||||
int leftGravity = Gravity.LEFT | Gravity.BOTTOM;
|
||||
|
@ -208,19 +208,23 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
RotatedTileBox tileBox, DrawSettings nightMode) {
|
||||
if(visibility != controls.isVisible() ){
|
||||
if(visibility) {
|
||||
controls.show((FrameLayout) mapActivity.getMapView().getParent());
|
||||
controls.show(getParent());
|
||||
} else {
|
||||
controls.hide((FrameLayout) mapActivity.getMapView().getParent());
|
||||
controls.hide(getParent());
|
||||
}
|
||||
}
|
||||
if(controls.isVisible()) {
|
||||
controls.onDraw(canvas, tileBox, nightMode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private FrameLayout getParent() {
|
||||
return (FrameLayout) mapActivity.findViewById(R.id.MapButtons);
|
||||
}
|
||||
|
||||
private void forceHideView(MapControls controls) {
|
||||
if (controls.isVisible()) {
|
||||
controls.forceHide((FrameLayout) mapActivity.getMapView().getParent());
|
||||
controls.forceHide(getParent());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,10 +243,10 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
public boolean onTouchEvent(MotionEvent event, RotatedTileBox tileBox) {
|
||||
if(!mapActivity.getRoutingHelper().isRoutePlanningMode() && mapActivity.getRoutingHelper().isFollowingMode()) {
|
||||
if(!settings.SHOW_ZOOM_BUTTONS_NAVIGATION.get()) {
|
||||
zoomControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
mapMenuControls.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
zoomControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
mapMenuControls.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
}
|
||||
mapRoutePlanControl.showWithDelay((FrameLayout) mapActivity.getMapView().getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
mapRoutePlanControl.showWithDelay(getParent(), TIMEOUT_TO_SHOW_BUTTONS);
|
||||
}
|
||||
for(MapControls m : allControls) {
|
||||
if(m.isVisible() && m.onTouchEvent(event, tileBox)){
|
||||
|
@ -318,7 +322,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public void shiftLayout(int height) {
|
||||
FrameLayout parent = (FrameLayout) mapActivity.getMapView().getParent();
|
||||
FrameLayout parent = getParent();
|
||||
parent.requestLayout();
|
||||
for(MapControls mc : allControls) {
|
||||
if(mc.isBottom()){
|
||||
|
|
|
@ -220,6 +220,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
public void createControls() {
|
||||
FrameLayout parent = (FrameLayout) ((FrameLayout) view.getParent()).findViewById(R.id.MapInfoControls);
|
||||
// 1. Create view groups and controls
|
||||
statusBar.setBackgroundDrawable(view.getResources().getDrawable(R.drawable.box_top));
|
||||
|
||||
|
@ -239,7 +240,7 @@ public class MapInfoLayer extends OsmandMapLayer {
|
|||
Rect statusBarPadding = new Rect();
|
||||
statusBar.getBackground().getPadding(statusBarPadding);
|
||||
// 3. put into frame parent layout controls
|
||||
FrameLayout parent = (FrameLayout) view.getParent();
|
||||
|
||||
// status bar hides own top part
|
||||
int topMargin = statusBar.getMeasuredHeight() - statusBarPadding.top - statusBarPadding.bottom ;
|
||||
// we want that status bar lays over map stack controls
|
||||
|
|
|
@ -65,7 +65,8 @@ public abstract class MapControls {
|
|||
protected Button addButton(FrameLayout parent, int stringId, int resourceId) {
|
||||
return addButton(parent, stringId, resourceId, 0);
|
||||
}
|
||||
protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) {
|
||||
|
||||
protected Button addButton(FrameLayout parent, int stringId, int resourceId, int extraMargin) {
|
||||
Context ctx = mapActivity;
|
||||
Button button = new Button(ctx);
|
||||
applyAttributes(ctx, parent, button, stringId, resourceId, extraMargin);
|
||||
|
|
Loading…
Reference in a new issue