diff --git a/OsmAnd/res/layout/main.xml b/OsmAnd/res/layout/main.xml index d66cce8b72..93c8d907aa 100644 --- a/OsmAnd/res/layout/main.xml +++ b/OsmAnd/res/layout/main.xml @@ -1,9 +1,23 @@ - - + + + - - + + + diff --git a/OsmAnd/res/values-ko/strings.xml b/OsmAnd/res/values-ko/strings.xml index 2110c0e4a6..74a4321825 100644 --- a/OsmAnd/res/values-ko/strings.xml +++ b/OsmAnd/res/values-ko/strings.xml @@ -493,7 +493,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵 인덱스 \'\'{0}\'\' 가 메모리에 적합하지 않습니다 인덱스 \'\'{0}\'\' 버전은 지원되지 않습니다 - OsmAnd 라우팅 >20km + OsmAnd 라우팅 서비스 >20km 20km 이상 긴 거리를 위해 CloudMade 대신에 OsmAnd 오프라인 라우팅을 사용합니다 OsmAnd 오프라인 라우팅은 실험적인 기능이며 20 km 이상의 거리에서는 동작하지 않습니다.\n\n라우팅 서비스는 일시적으로 온라인서비스인 CloudMade로 변경합니다. 지정한 폴더를 찾을 수 없습니다. @@ -1174,7 +1174,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵 라우팅을 중지하시겠습니까 ? 목적지를 취소하시겠습니까? 고장 없이 정확한 경로를 계산(라우팅) 할 수 있습니다 (여전히 거리 제한하고 느린 속도로). - 정확한 길찾기:라우팅 (알파) + 정확한 라우팅 모드 표시 사진 %1$s of %2$s 사진 찍기 diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 08eb8bbc77..eb736b610d 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -67,5 +67,7 @@ #33888888 #ff33b5e5 #b9b9b9 + + #303030 \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index f9c34ddd02..a90f81a685 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -10,6 +10,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import android.opengl.GLSurfaceView; +import android.content.pm.ActivityInfo; +import android.content.res.Configuration; +import android.graphics.Color; +import android.graphics.drawable.ColorDrawable; +import android.support.v4.app.ActionBarDrawerToggle; +import android.support.v4.widget.DrawerLayout; +import com.actionbarsherlock.app.ActionBar; import net.osmand.Location; import net.osmand.StateChangedListener; import net.osmand.access.AccessibilityPlugin; @@ -102,6 +109,8 @@ public class MapActivity extends AccessibleActivity { private FrameLayout lockView; private GpxImportHelper gpxImportHelper; private MapViewBaseController mapViewController; + private ActionBarDrawerToggle mDrawerToggle; + private DrawerLayout mDrawerLayout; private Notification getNotification() { @@ -128,7 +137,7 @@ public class MapActivity extends AccessibleActivity { requestWindowFeature(Window.FEATURE_NO_TITLE); // Full screen is not used here //getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); - + //getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY); startProgressDialog = new ProgressDialog(this); startProgressDialog.setCancelable(true); app.checkApplicationIsBeingInitialized(this, startProgressDialog); @@ -206,12 +215,40 @@ public class MapActivity extends AccessibleActivity { } gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView()); + +// ActionBar actionBar = getSupportActionBar(); +// actionBar.setDisplayHomeAsUpEnabled(true); +// actionBar.setHomeButtonEnabled(true); +// actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff"))); +// actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff"))); + + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); + mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_navigation_drawer_light, + R.string.default_buttons_other_actions, R.string.close); } public void addLockView(FrameLayout lockView) { this.lockView = lockView; } + public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { + if (item.getItemId() == android.R.id.home && mDrawerToggle.isDrawerIndicatorEnabled()) { + if (mDrawerLayout.isDrawerOpen(findViewById(R.id.left_drawer))) { + mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); + } else { + mapActions.openOptionsMenuAsDrawer(); + } + return true; + } + return super.onOptionsItemSelected(item); + } + + @Override + protected void onPostCreate(Bundle savedInstanceState) { + super.onPostCreate(savedInstanceState); + mDrawerToggle.syncState(); + } + private void createProgressBarForRouting() { FrameLayout parent = (FrameLayout) mapViewController.getParentView(); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, @@ -241,7 +278,13 @@ public class MapActivity extends AccessibleActivity { }); } - + + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDrawerToggle.onConfigurationChanged(newConfig); + } + @SuppressWarnings("rawtypes") public Object getLastNonConfigurationInstanceByKey(String key) { Object k = super.getLastNonConfigurationInstance(); @@ -272,9 +315,10 @@ public class MapActivity extends AccessibleActivity { mapViewController.resume(); cancelNotification(); //fixing bug with action bar appearing on android 2.3.3 - if (getSupportActionBar() != null){ - getSupportActionBar().hide(); - } +// if (getSupportActionBar() != null){ +// getSupportActionBar().hide(); +// } + if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) { setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get()); // can't return from this method we are not sure if activity will be recreated or not @@ -459,7 +503,7 @@ public class MapActivity extends AccessibleActivity { } return true; } else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) { - mapActions.openOptionsMenuAsList(); + mapActions.openOptionsMenuAsDrawer(); return true; } else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) { Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity()); diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 405ea5e422..c21b413b02 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -10,6 +10,9 @@ import java.util.Date; import java.util.Iterator; import java.util.List; +import android.support.v4.view.GravityCompat; +import android.support.v4.widget.DrawerLayout; +import android.widget.*; import net.londatiga.android.ActionItem; import net.londatiga.android.QuickAction; import net.osmand.AndroidUtils; @@ -67,17 +70,6 @@ import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.view.WindowManager; -import android.widget.ArrayAdapter; -import android.widget.AutoCompleteTextView; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.EditText; -import android.widget.FrameLayout; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListAdapter; -import android.widget.TextView; -import android.widget.Toast; public class MapActivityActions implements DialogProvider { @@ -731,7 +723,41 @@ public class MapActivityActions implements DialogProvider { } } - + public void openOptionsMenuAsDrawer(){ + final ContextMenuAdapter cm = createOptionsMenu(); + final DrawerLayout mDrawerLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout); + final ListView mDrawerList = (ListView) mapActivity.findViewById(R.id.left_drawer); + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); + ListAdapter listAdapter ; + if(Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB){ + listAdapter = + cm.createListAdapter(mapActivity, R.layout.list_menu_item, getMyApplication().getSettings().isLightContentMenu()); + } else { + listAdapter = + cm.createListAdapter(mapActivity, R.layout.list_menu_item_native, getMyApplication().getSettings().isLightContentMenu()); + } + mDrawerList.setAdapter(listAdapter); + + if (getMyApplication().getSettings().isLightContentMenu()){ + mDrawerList.setBackgroundColor(mapActivity.getResources().getColor(R.color.shadow_color)); + } else { + mDrawerList.setBackgroundColor(mapActivity.getResources().getColor(R.color.dark_drawer_bg_color)); + } + mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() { + + @Override + public void onItemClick(AdapterView parent, View view, int which, long id) { + OnContextMenuClick click = cm.getClickAdapter(which); + if (click != null) { + click.onContextMenuClick(cm.getItemId(which), which, false, null); + } + mDrawerLayout.closeDrawer(mDrawerList); + } + }); + + mDrawerLayout.openDrawer(mDrawerList); + } + public AlertDialog openOptionsMenuAsList() { final ContextMenuAdapter cm = createOptionsMenu(); final Builder bld = new AlertDialog.Builder(mapActivity); @@ -753,7 +779,6 @@ public class MapActivityActions implements DialogProvider { } }); return bld.show(); - } private ContextMenuAdapter createOptionsMenu() { diff --git a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java index cfa4ac1663..efddb224c5 100644 --- a/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java +++ b/OsmAnd/src/net/osmand/plus/helpers/WaypointDialogHelper.java @@ -3,6 +3,7 @@ package net.osmand.plus.helpers; import java.util.ArrayList; import java.util.List; +import android.support.v4.widget.DrawerLayout; import net.osmand.Location; import net.osmand.data.LatLon; import net.osmand.data.LocationPoint; @@ -47,7 +48,7 @@ import android.widget.TextView; public class WaypointDialogHelper implements OsmAndLocationListener { private MapActivity mapActivity; private OsmandApplication app; - private FrameLayout mainLayout; + private DrawerLayout mainLayout; private WaypointHelper waypointHelper; public final static boolean OVERLAP_LAYOUT = true; // only true is supported @@ -59,25 +60,26 @@ public class WaypointDialogHelper implements OsmAndLocationListener { this.app = mapActivity.getMyApplication(); waypointHelper = this.app.getWaypointHelper(); this.mapActivity = mapActivity; - this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0); + this.mainLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout); + } - + public void init() { app.getLocationProvider().addLocationListener(this); } - + @Override public void updateLocation(Location location) { - if(mapActivity != null) { + if (mapActivity != null) { updateDialog(); } } - + public void removeListener() { app.getLocationProvider().removeLocationListener(this); mapActivity = null; } - + @SuppressWarnings("deprecation") public void updateDialog() { @@ -100,7 +102,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { all.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - showWaypointsDialog(mapActivity); + showWaypointsDialog(mapActivity); } }); @@ -120,7 +122,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { } private static void updatePointInfoView(final OsmandApplication app, final Activity ctx, - View localView, final LocationPointWrapper ps, final DialogFragment dialog) { + View localView, final LocationPointWrapper ps, final DialogFragment dialog) { WaypointHelper wh = app.getWaypointHelper(); final LocationPoint point = ps.getPoint(); TextView text = (TextView) localView.findViewById(R.id.waypoint_text); @@ -200,47 +202,47 @@ public class WaypointDialogHelper implements OsmAndLocationListener { wdf.setArguments(args); fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit(); } - + public static void showWaypointsDialog(FragmentActivity fragmentActivity) { Bundle args = new Bundle(); WaypointDialogFragment wdf = new WaypointDialogFragment(); wdf.setArguments(args); fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit(); } - + public static class WaypointDialogFragment extends DialogFragment { - + WaypointHelper waypointHelper; private OsmandApplication app; - - public static final String FLAT_ARG = "FLAT_ARG"; - + + public static final String FLAT_ARG = "FLAT_ARG"; + @Override public void onAttach(Activity activity) { super.onAttach(activity); app = (OsmandApplication) activity.getApplication(); waypointHelper = app.getWaypointHelper(); } - + @Override public Dialog onCreateDialog(Bundle savedInstanceState) { - if(getArguments() != null && getArguments().getBoolean(FLAT_ARG)) { + if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) { return createWaypointsDialogFlat(waypointHelper.getAllPoints()); } return createWaypointsDialog(); } - + private void selectPoi(final int[] running, final ArrayAdapter listAdapter, final int type, - final boolean enable) { - if(getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) { + final boolean enable) { + if (getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) { MapActivity map = (MapActivity) getActivity(); final PoiFilter[] selected = new PoiFilter[1]; AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected); dlg.setOnDismissListener(new OnDismissListener() { - + @Override public void onDismiss(DialogInterface dialog) { - if(selected != null) { + if (selected != null) { enableType(running, listAdapter, type, enable); } } @@ -249,54 +251,58 @@ public class WaypointDialogHelper implements OsmAndLocationListener { enableType(running, listAdapter, type, enable); } } - + private void enableType(final int[] running, final ArrayAdapter listAdapter, final int type, - final boolean enable) { + final boolean enable) { new AsyncTask() { protected void onPreExecute() { - }; + } + + ; @Override protected Void doInBackground(Void... params) { app.getWaypointHelper().enableWaypointType(type, enable); return null; } - + protected void onPostExecute(Void result) { running[0] = -1; listAdapter.clear(); - listAdapter.addAll(getPoints()); + for (Object point : getPoints()) { + listAdapter.add(point); + } listAdapter.notifyDataSetChanged(); - }; + } }.execute((Void) null); } - + protected String getHeader(int type, boolean checked) { FragmentActivity ctx = getActivity(); String str = ctx.getString(R.string.waypoints); switch (type) { - case WaypointHelper.TARGETS: - str = ctx.getString(R.string.targets); - break; - case WaypointHelper.ALARMS: - str = ctx.getString(R.string.way_alarms); - break; - case WaypointHelper.FAVORITES: - str = ctx.getString(R.string.my_favorites); - break; - case WaypointHelper.WAYPOINTS: - str = ctx.getString(R.string.waypoints); - break; - case WaypointHelper.POI: - str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper - .getPoiFilter().getName(); - break; + case WaypointHelper.TARGETS: + str = ctx.getString(R.string.targets); + break; + case WaypointHelper.ALARMS: + str = ctx.getString(R.string.way_alarms); + break; + case WaypointHelper.FAVORITES: + str = ctx.getString(R.string.my_favorites); + break; + case WaypointHelper.WAYPOINTS: + str = ctx.getString(R.string.waypoints); + break; + case WaypointHelper.POI: + str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper + .getPoiFilter().getName(); + break; } return str; } - - public AlertDialog createWaypointsDialogFlat(final List points){ + + public AlertDialog createWaypointsDialogFlat(final List points) { final List deletedPoints = new ArrayList(); final FragmentActivity ctx = getActivity(); final ArrayAdapter listAdapter = new ArrayAdapter(ctx, R.layout.waypoint_reached, R.id.title, @@ -311,7 +317,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { updatePointInfoView(app, ctx, v, getItem(position), WaypointDialogFragment.this); View remove = v.findViewById(R.id.info_close); ((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable( - app.getSettings().isLightContent()? R.drawable.ic_action_gremove_light: + app.getSettings().isLightContent() ? R.drawable.ic_action_gremove_light : R.drawable.ic_action_gremove_dark)); remove.setOnClickListener(new View.OnClickListener() { @Override @@ -339,7 +345,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setView(listView); builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() { - + @Override public void onClick(DialogInterface dialog, int which) { waypointHelper.removeVisibleLocationPoint(deletedPoints); @@ -348,7 +354,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null); return builder.create(); } - + public AlertDialog createWaypointsDialog() { final List points = getPoints(); final List deletedPoints = new ArrayList(); @@ -377,14 +383,14 @@ public class WaypointDialogHelper implements OsmAndLocationListener { btn.setEnabled(running[0] == -1); v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE); btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - + @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { running[0] = position; thisAdapter.notifyDataSetInvalidated(); - if(type == WaypointHelper.POI && isChecked) { + if (type == WaypointHelper.POI && isChecked) { selectPoi(running, thisAdapter, type, isChecked); - } else { + } else { enableType(running, thisAdapter, type, isChecked); } } @@ -411,12 +417,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener { return v; } }; - + listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int item, long l) { - if(listAdapter.getItem(item) instanceof LocationPointWrapper) { + if (listAdapter.getItem(item) instanceof LocationPointWrapper) { LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item); showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this); } @@ -425,7 +431,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { AlertDialog.Builder builder = new AlertDialog.Builder(ctx); builder.setView(listView); builder.setNeutralButton(R.string.flat_list_waypoints, new OnClickListener() { - + @Override public void onClick(DialogInterface dialog, int which) { showWaypointsDialogFlat(getActivity()); @@ -442,7 +448,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener { builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null); return builder.create(); } - + protected List getPoints() { final List points = new ArrayList(); for (int i = 0; i < WaypointHelper.MAX; i++) { @@ -458,9 +464,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener { } } - + private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) { - if(!(a instanceof MapActivity)) { + if (!(a instanceof MapActivity)) { return; } MapActivity ctx = (MapActivity) a; @@ -475,12 +481,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener { final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(), locationPoint.getLatitude(), locationPoint.getLongitude()); double t = 10; - if(dist < t) { + if (dist < t) { app.getAppCustomization().showLocationPoint(ctx, locationPoint); } else { thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true); } - if(di) { + if (di) { ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint); ctx.getMapLayers() .getContextMenuLayer() @@ -492,6 +498,4 @@ public class WaypointDialogHelper implements OsmAndLocationListener { } - - } diff --git a/OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java b/OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java new file mode 100644 index 0000000000..4beef8f2c6 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java @@ -0,0 +1,264 @@ +package net.osmand.plus.sherpafy; + +import android.app.AlertDialog; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.graphics.Color; +import android.os.AsyncTask; +import android.os.SystemClock; +import android.support.v4.widget.DrawerLayout; +import android.text.Spannable; +import android.text.style.ForegroundColorSpan; +import android.util.TypedValue; +import android.view.Gravity; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.*; +import net.osmand.Location; +import net.osmand.data.LocationPoint; +import net.osmand.plus.*; +import net.osmand.plus.activities.FavouritesActivity; +import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.base.FavoriteImageDrawable; +import net.osmand.plus.views.MapControlsLayer; +import net.osmand.util.MapUtils; + +import java.util.List; + +/** + * Created by Denis on 25.07.2014. + */ +public class WaypointDialogHelper { + private MapActivity mapActivity; + private OsmandApplication app; + private FrameLayout mainLayout; + private OsmAndLocationProvider locationProvider; + + public static boolean OVERLAP_LAYOUT = true; + private long uiModified; + private View closePointDialog; + + public WaypointDialogHelper(MapActivity mapActivity) { + this.app = mapActivity.getMyApplication(); + locationProvider = this.app.getLocationProvider(); + this.mapActivity = mapActivity; + this.mainLayout = (FrameLayout) ((DrawerLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0)).getChildAt(0); + } + + public void updateDialog() { + List vlp = locationProvider.getVisibleLocationPoints(); + long locationPointsModified = locationProvider.getLocationPointsModified(); + if (locationPointsModified != uiModified) { + uiModified = locationPointsModified; + if (vlp.isEmpty()) { + removeDialog(); + } else { + final LocationPoint point = vlp.get(0); + boolean created = false; + if (closePointDialog == null) { + created = true; + final LayoutInflater vi = (LayoutInflater) app.getSystemService(Context.LAYOUT_INFLATER_SERVICE); + closePointDialog = vi.inflate(R.layout.waypoint_reached, null); + } + + updatePointInfoView(closePointDialog, point); + closePointDialog.setBackgroundColor(mapActivity.getResources().getColor(R.color.color_black)); + ((TextView)closePointDialog.findViewById(R.id.waypoint_text)).setTextColor(Color.WHITE); + View all = closePointDialog.findViewById(R.id.all_points); + all.setVisibility(vlp.size() <= 1 ? View.GONE : View.VISIBLE); + all.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showAllDialog(); + } + }); + + View btnN = closePointDialog.findViewById(R.id.info_close); + btnN.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + locationProvider.removeVisibleLocationPoint(point); + updateDialog(); + } + }); + + if (created) { + mainLayout.addView(closePointDialog, getDialogLayoutParams()); + waitBeforeLayoutIsResized(closePointDialog); + } + } + } + } + + private void updatePointInfoView(View localView, final LocationPoint point) { + TextView text = (TextView) localView.findViewById(R.id.waypoint_text); + text.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + itemClick(point); + } + }); + + ((ImageView) localView.findViewById(R.id.waypoint_icon)).setImageDrawable(FavoriteImageDrawable.getOrCreate(mapActivity, point.getColor())); + Location lastKnownMapLocation = app.getLocationProvider().getLastKnownLocation(); + String distance; + if (lastKnownMapLocation != null) { + int dist = (int) (MapUtils.getDistance(point.getLatitude(), point.getLongitude(), + lastKnownMapLocation.getLatitude(), lastKnownMapLocation.getLongitude())); + distance = OsmAndFormatter.getFormattedDistance(dist, app) + " "; + } else { + distance = ""; + } + text.setText(distance + point.getName(), TextView.BufferType.SPANNABLE); + if (distance.length() > 0) { + ((Spannable) text.getText()).setSpan( + new ForegroundColorSpan(mapActivity.getResources().getColor(R.color.color_distance)), 0, distance.length() - 1, + 0); + } + } + + private void itemClick(LocationPoint point) { + final Intent favorites = new Intent(mapActivity, app.getAppCustomization().getFavoritesActivity()); + favorites.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); + favorites.putExtra(FavouritesActivity.TAB_PARAM, + point instanceof GPXUtilities.WptPt ? FavouritesActivity.GPX_TAB : FavouritesActivity.FAVORITES_TAB); + mapActivity.startActivity(favorites); + } + + public void removeDialog() { + if (closePointDialog != null) { + mainLayout.removeView(closePointDialog); + closePointDialog = null; + shiftButtons(0); + } + } + + private FrameLayout.LayoutParams getDialogLayoutParams() { + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT); + params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; + return params; + } + + private boolean checkIfDialogExists() { + if (mainLayout == null) { + return true; + } + + if (mainLayout.findViewById(R.id.package_delivered_layout) != null) { + return false; + } + return true; + } + + private void shiftButtons(int height) { + MapControlsLayer mapControls = mapActivity.getMapLayers().getMapControlsLayer(); + if (mapControls != null) { + mapControls.shiftLayout(height); + } + } + + + private void waitBeforeLayoutIsResized(View reachedView) { + //this async task is needed because layout height is not set + // right after you add it so we need to w8 some time + new AsyncTask() { + int height; + + @Override + protected Void doInBackground(View... params) { + for (int i = 0; i < 10; i++) { + SystemClock.sleep(50); + height = params[0].getHeight(); + if (params[0].getHeight() > 0) { + break; + } + } + return null; + } + + protected void onPostExecute(Void result) { + if (height > 0 && OVERLAP_LAYOUT) { + shiftButtons(height); + } + } + }.execute(reachedView); + } + + public void showAllDialog(){ + final List visibleLocationPoints = locationProvider.getVisibleLocationPoints(); + final ArrayAdapter listAdapter = new ArrayAdapter(mapActivity, R.layout.waypoint_reached, R.id.title, + visibleLocationPoints) { + @Override + public View getView(final int position, View convertView, ViewGroup parent) { + // User super class to create the View + View v = convertView; + if (v == null) { + v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_reached, null); + int vl = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32, mapActivity.getResources() + .getDisplayMetrics()); + final LinearLayout.LayoutParams ll = new LinearLayout.LayoutParams(vl, vl); + ll.setMargins(vl / 4, vl / 4, vl / 4, vl / 4); + v.findViewById(R.id.waypoint_icon).setLayoutParams(ll); + } + updatePointInfoView(v, getItem(position)); + TextView text = (TextView) v.findViewById(R.id.waypoint_text); + text.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + showOnMap(visibleLocationPoints.get(position)); + } + }); + + View remove = v.findViewById(R.id.info_close); + ((ImageButton) remove).setImageDrawable(mapActivity.getResources().getDrawable( + app.getSettings().isLightContent()? R.drawable.ic_action_gremove_light: + R.drawable.ic_action_gremove_dark)); + remove.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + LocationPoint point = locationProvider.getVisibleLocationPoints().get(position); + remove(point); + locationProvider.removeVisibleLocationPoint(point); + notifyDataSetChanged(); + } + }); + + return v; + } + }; + + ListView listView = new ListView(mapActivity); + listView.setAdapter(listAdapter); + listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { + @Override + public void onItemClick(AdapterView adapterView, View view, int i, long l) { + showOnMap(visibleLocationPoints.get(i)); + } + }); + +// Dialog dlg = new Dialog(mapActivity); +// dlg.setContentView(listView); +// dlg.show(); + AlertDialog.Builder builder = new AlertDialog.Builder(mapActivity); + builder.setView(listView); + builder.setPositiveButton(R.string.default_buttons_ok, null); + builder.setNegativeButton(mapActivity.getString(R.string.hide_all_waypoints), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + locationProvider.clearAllVisiblePoints(); + updateDialog(); + } + }); + builder.show(); + } + + private void showOnMap(LocationPoint locationPoint) { + // AnimateDraggingMapThread thread = mapActivity.getMapView().getAnimatedDraggingThread(); + int fZoom = mapActivity.getMapView().getZoom() < 15 ? 15 : mapActivity.getMapView().getZoom(); + // thread.startMoving(pointToNavigate.getLatitude(), pointToNavigate.getLongitude(), fZoom, true); + mapActivity.getMapView().setIntZoom(fZoom); + mapActivity.getMapView().setLatLon(locationPoint.getLatitude(), locationPoint.getLongitude()); + } +} diff --git a/OsmAnd/src/net/osmand/plus/views/controls/MapMenuControls.java b/OsmAnd/src/net/osmand/plus/views/controls/MapMenuControls.java index e156963fcc..c4ce14bcc3 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/MapMenuControls.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/MapMenuControls.java @@ -39,7 +39,7 @@ public class MapMenuControls extends MapControls { // double lat = activity.getMapView().getLatitude(); // double lon = activity.getMapView().getLongitude(); // MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon)); - mapActivity.getMapActions().openOptionsMenuAsList(); + mapActivity.getMapActions().openOptionsMenuAsDrawer(); notifyClicked(); } }); diff --git a/OsmAnd/src/net/osmand/plus/views/controls/SmallMapMenuControls.java b/OsmAnd/src/net/osmand/plus/views/controls/SmallMapMenuControls.java index 127a23706f..aa8c7b1ed0 100644 --- a/OsmAnd/src/net/osmand/plus/views/controls/SmallMapMenuControls.java +++ b/OsmAnd/src/net/osmand/plus/views/controls/SmallMapMenuControls.java @@ -26,7 +26,8 @@ public class SmallMapMenuControls extends MapControls { @Override public void onClick(View v) { notifyClicked(); - mapActivity.getMapActions().openOptionsMenuAsList(); + //mapActivity.getMapActions().openOptionsMenuAsDrawer(); + mapActivity.getMapActions().openOptionsMenuAsDrawer(); } }); }