Merge branch 'master' of ssh://github.com/osmandapp/Osmand

This commit is contained in:
Victor Shcherb 2014-10-02 11:25:54 +02:00
commit d03ab35906
9 changed files with 447 additions and 93 deletions

View file

@ -1,9 +1,23 @@
<?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">
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false">
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:contentDescription="@string/map_view"/>
</FrameLayout>
<ListView android:id="@+id/left_drawer"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@drawable/divider"
android:dividerHeight="1px"/>
</android.support.v4.widget.DrawerLayout>

View file

@ -493,7 +493,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵
<string name="version_index_is_big_for_memory">인덱스 \'\'{0}\'\' 가 메모리에 적합하지 않습니다</string>
<string name="version_index_is_not_supported">인덱스 \'\'{0}\'\' 버전은 지원되지 않습니다</string>
<string name="use_osmand_routing_service">OsmAnd 라우팅 &gt;20km</string>
<string name="use_osmand_routing_service">OsmAnd 라우팅 서비스 &gt;20km</string>
<string name="use_osmand_routing_service_descr">20km 이상 긴 거리를 위해 CloudMade 대신에 OsmAnd 오프라인 라우팅을 사용합니다</string>
<string name="osmand_routing_experimental">OsmAnd 오프라인 라우팅은 실험적인 기능이며 20 km 이상의 거리에서는 동작하지 않습니다.\n\n라우팅 서비스는 일시적으로 온라인서비스인 CloudMade로 변경합니다.</string>
<string name="specified_dir_doesnt_exist">지정한 폴더를 찾을 수 없습니다.</string>
@ -1174,7 +1174,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵
<string name="stop_routing_confirm">라우팅을 중지하시겠습니까 ?</string>
<string name="clear_dest_confirm">목적지를 취소하시겠습니까?</string>
<string name="precise_routing_mode_descr">고장 없이 정확한 경로를 계산(라우팅) 할 수 있습니다 (여전히 거리 제한하고 느린 속도로).</string>
<string name="precise_routing_mode">정확한 길찾기:라우팅 (알파)</string>
<string name="precise_routing_mode">정확한 라우팅 모드</string>
<string name="recording_context_menu_show">표시</string>
<string name="recording_photo_description">사진 %1$s of %2$s</string>
<string name="av_def_action_picture">사진 찍기</string>

View file

@ -68,4 +68,6 @@
<color name="sherpafy_selection">#ff33b5e5</color>
<color name="sherpafy_add_text">#b9b9b9</color>
<color name="dark_drawer_bg_color">#303030</color>
</resources>

View file

@ -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,
@ -242,6 +279,12 @@ 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());

View file

@ -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,6 +723,40 @@ 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();
@ -753,7 +779,6 @@ public class MapActivityActions implements DialogProvider {
}
});
return bld.show();
}
private ContextMenuAdapter createOptionsMenu() {

View file

@ -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,7 +60,8 @@ 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() {
@ -255,7 +257,9 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
new AsyncTask<Void, Void, Void>() {
protected void onPreExecute() {
};
}
;
@Override
protected Void doInBackground(Void... params) {
@ -266,9 +270,11 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
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);
}
@ -492,6 +498,4 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
}
}

View file

@ -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<LocationPoint> 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<View, Void, Void>() {
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<LocationPoint> visibleLocationPoints = locationProvider.getVisibleLocationPoints();
final ArrayAdapter<LocationPoint> listAdapter = new ArrayAdapter<LocationPoint>(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());
}
}

View file

@ -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();
}
});

View file

@ -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();
}
});
}