Merge branch 'master' of ssh://github.com/osmandapp/Osmand
This commit is contained in:
commit
d03ab35906
9 changed files with 447 additions and 93 deletions
|
@ -1,9 +1,23 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<android.support.v4.widget.DrawerLayout
|
||||||
android:orientation="vertical"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent"
|
android:id="@+id/drawer_layout"
|
||||||
android:layout_height="fill_parent" android:keepScreenOn="true" android:clipChildren="false">
|
android:layout_width="match_parent"
|
||||||
<net.osmand.plus.views.OsmandMapTileView android:id="@+id/MapView" android:layout_width="fill_parent" android:layout_height="fill_parent" android:contentDescription="@string/map_view"/>
|
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"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</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>
|
||||||
|
|
|
@ -493,7 +493,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵
|
||||||
<string name="version_index_is_big_for_memory">인덱스 \'\'{0}\'\' 가 메모리에 적합하지 않습니다</string>
|
<string name="version_index_is_big_for_memory">인덱스 \'\'{0}\'\' 가 메모리에 적합하지 않습니다</string>
|
||||||
<string name="version_index_is_not_supported">인덱스 \'\'{0}\'\' 버전은 지원되지 않습니다</string>
|
<string name="version_index_is_not_supported">인덱스 \'\'{0}\'\' 버전은 지원되지 않습니다</string>
|
||||||
|
|
||||||
<string name="use_osmand_routing_service">OsmAnd 라우팅 >20km</string>
|
<string name="use_osmand_routing_service">OsmAnd 라우팅 서비스 >20km</string>
|
||||||
<string name="use_osmand_routing_service_descr">20km 이상 긴 거리를 위해 CloudMade 대신에 OsmAnd 오프라인 라우팅을 사용합니다</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="osmand_routing_experimental">OsmAnd 오프라인 라우팅은 실험적인 기능이며 20 km 이상의 거리에서는 동작하지 않습니다.\n\n라우팅 서비스는 일시적으로 온라인서비스인 CloudMade로 변경합니다.</string>
|
||||||
<string name="specified_dir_doesnt_exist">지정한 폴더를 찾을 수 없습니다.</string>
|
<string name="specified_dir_doesnt_exist">지정한 폴더를 찾을 수 없습니다.</string>
|
||||||
|
@ -1174,7 +1174,7 @@ OsmAnd 는 Openstreetmap.org (OSM) 데이터 기반의 맵을 사용하며 -맵
|
||||||
<string name="stop_routing_confirm">라우팅을 중지하시겠습니까 ?</string>
|
<string name="stop_routing_confirm">라우팅을 중지하시겠습니까 ?</string>
|
||||||
<string name="clear_dest_confirm">목적지를 취소하시겠습니까?</string>
|
<string name="clear_dest_confirm">목적지를 취소하시겠습니까?</string>
|
||||||
<string name="precise_routing_mode_descr">고장 없이 정확한 경로를 계산(라우팅) 할 수 있습니다 (여전히 거리 제한하고 느린 속도로).</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_context_menu_show">표시</string>
|
||||||
<string name="recording_photo_description">사진 %1$s of %2$s</string>
|
<string name="recording_photo_description">사진 %1$s of %2$s</string>
|
||||||
<string name="av_def_action_picture">사진 찍기</string>
|
<string name="av_def_action_picture">사진 찍기</string>
|
||||||
|
|
|
@ -67,5 +67,7 @@
|
||||||
<color name="shadow_color">#33888888</color>
|
<color name="shadow_color">#33888888</color>
|
||||||
<color name="sherpafy_selection">#ff33b5e5</color>
|
<color name="sherpafy_selection">#ff33b5e5</color>
|
||||||
<color name="sherpafy_add_text">#b9b9b9</color>
|
<color name="sherpafy_add_text">#b9b9b9</color>
|
||||||
|
|
||||||
|
<color name="dark_drawer_bg_color">#303030</color>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
|
@ -10,6 +10,13 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import android.opengl.GLSurfaceView;
|
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.Location;
|
||||||
import net.osmand.StateChangedListener;
|
import net.osmand.StateChangedListener;
|
||||||
import net.osmand.access.AccessibilityPlugin;
|
import net.osmand.access.AccessibilityPlugin;
|
||||||
|
@ -102,6 +109,8 @@ public class MapActivity extends AccessibleActivity {
|
||||||
private FrameLayout lockView;
|
private FrameLayout lockView;
|
||||||
private GpxImportHelper gpxImportHelper;
|
private GpxImportHelper gpxImportHelper;
|
||||||
private MapViewBaseController mapViewController;
|
private MapViewBaseController mapViewController;
|
||||||
|
private ActionBarDrawerToggle mDrawerToggle;
|
||||||
|
private DrawerLayout mDrawerLayout;
|
||||||
|
|
||||||
|
|
||||||
private Notification getNotification() {
|
private Notification getNotification() {
|
||||||
|
@ -128,7 +137,7 @@ public class MapActivity extends AccessibleActivity {
|
||||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
// Full screen is not used here
|
// Full screen is not used here
|
||||||
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
//getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
|
//getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
|
||||||
startProgressDialog = new ProgressDialog(this);
|
startProgressDialog = new ProgressDialog(this);
|
||||||
startProgressDialog.setCancelable(true);
|
startProgressDialog.setCancelable(true);
|
||||||
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
app.checkApplicationIsBeingInitialized(this, startProgressDialog);
|
||||||
|
@ -206,12 +215,40 @@ public class MapActivity extends AccessibleActivity {
|
||||||
|
|
||||||
}
|
}
|
||||||
gpxImportHelper = new GpxImportHelper(this, getMyApplication(), getMapView());
|
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) {
|
public void addLockView(FrameLayout lockView) {
|
||||||
this.lockView = 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() {
|
private void createProgressBarForRouting() {
|
||||||
FrameLayout parent = (FrameLayout) mapViewController.getParentView();
|
FrameLayout parent = (FrameLayout) mapViewController.getParentView();
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
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")
|
@SuppressWarnings("rawtypes")
|
||||||
public Object getLastNonConfigurationInstanceByKey(String key) {
|
public Object getLastNonConfigurationInstanceByKey(String key) {
|
||||||
Object k = super.getLastNonConfigurationInstance();
|
Object k = super.getLastNonConfigurationInstance();
|
||||||
|
@ -272,9 +315,10 @@ public class MapActivity extends AccessibleActivity {
|
||||||
mapViewController.resume();
|
mapViewController.resume();
|
||||||
cancelNotification();
|
cancelNotification();
|
||||||
//fixing bug with action bar appearing on android 2.3.3
|
//fixing bug with action bar appearing on android 2.3.3
|
||||||
if (getSupportActionBar() != null){
|
// if (getSupportActionBar() != null){
|
||||||
getSupportActionBar().hide();
|
// getSupportActionBar().hide();
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
|
if (settings.MAP_SCREEN_ORIENTATION.get() != getRequestedOrientation()) {
|
||||||
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
|
setRequestedOrientation(settings.MAP_SCREEN_ORIENTATION.get());
|
||||||
// can't return from this method we are not sure if activity will be recreated or not
|
// 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;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_MENU && event.getRepeatCount() == 0) {
|
||||||
mapActions.openOptionsMenuAsList();
|
mapActions.openOptionsMenuAsDrawer();
|
||||||
return true;
|
return true;
|
||||||
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
} else if (keyCode == KeyEvent.KEYCODE_SEARCH && event.getRepeatCount() == 0) {
|
||||||
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
Intent newIntent = new Intent(MapActivity.this, getMyApplication().getAppCustomization().getSearchActivity());
|
||||||
|
|
|
@ -10,6 +10,9 @@ import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
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.ActionItem;
|
||||||
import net.londatiga.android.QuickAction;
|
import net.londatiga.android.QuickAction;
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -67,17 +70,6 @@ import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
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 {
|
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() {
|
public AlertDialog openOptionsMenuAsList() {
|
||||||
final ContextMenuAdapter cm = createOptionsMenu();
|
final ContextMenuAdapter cm = createOptionsMenu();
|
||||||
final Builder bld = new AlertDialog.Builder(mapActivity);
|
final Builder bld = new AlertDialog.Builder(mapActivity);
|
||||||
|
@ -753,7 +779,6 @@ public class MapActivityActions implements DialogProvider {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return bld.show();
|
return bld.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContextMenuAdapter createOptionsMenu() {
|
private ContextMenuAdapter createOptionsMenu() {
|
||||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.helpers;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import android.support.v4.widget.DrawerLayout;
|
||||||
import net.osmand.Location;
|
import net.osmand.Location;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.LocationPoint;
|
import net.osmand.data.LocationPoint;
|
||||||
|
@ -47,7 +48,7 @@ import android.widget.TextView;
|
||||||
public class WaypointDialogHelper implements OsmAndLocationListener {
|
public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
private MapActivity mapActivity;
|
private MapActivity mapActivity;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
private FrameLayout mainLayout;
|
private DrawerLayout mainLayout;
|
||||||
private WaypointHelper waypointHelper;
|
private WaypointHelper waypointHelper;
|
||||||
|
|
||||||
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
public final static boolean OVERLAP_LAYOUT = true; // only true is supported
|
||||||
|
@ -59,25 +60,26 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
this.app = mapActivity.getMyApplication();
|
this.app = mapActivity.getMyApplication();
|
||||||
waypointHelper = this.app.getWaypointHelper();
|
waypointHelper = this.app.getWaypointHelper();
|
||||||
this.mapActivity = mapActivity;
|
this.mapActivity = mapActivity;
|
||||||
this.mainLayout = (FrameLayout) ((FrameLayout) mapActivity.getLayout()).getChildAt(0);
|
this.mainLayout = (DrawerLayout) mapActivity.findViewById(R.id.drawer_layout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init() {
|
public void init() {
|
||||||
app.getLocationProvider().addLocationListener(this);
|
app.getLocationProvider().addLocationListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateLocation(Location location) {
|
public void updateLocation(Location location) {
|
||||||
if(mapActivity != null) {
|
if (mapActivity != null) {
|
||||||
updateDialog();
|
updateDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener() {
|
public void removeListener() {
|
||||||
app.getLocationProvider().removeLocationListener(this);
|
app.getLocationProvider().removeLocationListener(this);
|
||||||
mapActivity = null;
|
mapActivity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void updateDialog() {
|
public void updateDialog() {
|
||||||
|
@ -100,7 +102,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
all.setOnClickListener(new View.OnClickListener() {
|
all.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
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,
|
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();
|
WaypointHelper wh = app.getWaypointHelper();
|
||||||
final LocationPoint point = ps.getPoint();
|
final LocationPoint point = ps.getPoint();
|
||||||
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
|
||||||
|
@ -200,47 +202,47 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
wdf.setArguments(args);
|
wdf.setArguments(args);
|
||||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showWaypointsDialog(FragmentActivity fragmentActivity) {
|
public static void showWaypointsDialog(FragmentActivity fragmentActivity) {
|
||||||
Bundle args = new Bundle();
|
Bundle args = new Bundle();
|
||||||
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
WaypointDialogFragment wdf = new WaypointDialogFragment();
|
||||||
wdf.setArguments(args);
|
wdf.setArguments(args);
|
||||||
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
fragmentActivity.getSupportFragmentManager().beginTransaction().add(wdf, "tag").commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class WaypointDialogFragment extends DialogFragment {
|
public static class WaypointDialogFragment extends DialogFragment {
|
||||||
|
|
||||||
WaypointHelper waypointHelper;
|
WaypointHelper waypointHelper;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
public static final String FLAT_ARG = "FLAT_ARG";
|
public static final String FLAT_ARG = "FLAT_ARG";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
public void onAttach(Activity activity) {
|
||||||
super.onAttach(activity);
|
super.onAttach(activity);
|
||||||
app = (OsmandApplication) activity.getApplication();
|
app = (OsmandApplication) activity.getApplication();
|
||||||
waypointHelper = app.getWaypointHelper();
|
waypointHelper = app.getWaypointHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
if(getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
if (getArguments() != null && getArguments().getBoolean(FLAT_ARG)) {
|
||||||
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
|
return createWaypointsDialogFlat(waypointHelper.getAllPoints());
|
||||||
}
|
}
|
||||||
return createWaypointsDialog();
|
return createWaypointsDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
private void selectPoi(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable) {
|
final boolean enable) {
|
||||||
if(getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
if (getActivity() instanceof MapActivity && !PoiFilter.CUSTOM_FILTER_ID.equals(app.getSettings().getPoiFilterForMap())) {
|
||||||
MapActivity map = (MapActivity) getActivity();
|
MapActivity map = (MapActivity) getActivity();
|
||||||
final PoiFilter[] selected = new PoiFilter[1];
|
final PoiFilter[] selected = new PoiFilter[1];
|
||||||
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
AlertDialog dlg = map.getMapLayers().selectPOIFilterLayer(map.getMapView(), selected);
|
||||||
dlg.setOnDismissListener(new OnDismissListener() {
|
dlg.setOnDismissListener(new OnDismissListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDismiss(DialogInterface dialog) {
|
public void onDismiss(DialogInterface dialog) {
|
||||||
if(selected != null) {
|
if (selected != null) {
|
||||||
enableType(running, listAdapter, type, enable);
|
enableType(running, listAdapter, type, enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,54 +251,58 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
enableType(running, listAdapter, type, enable);
|
enableType(running, listAdapter, type, enable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
private void enableType(final int[] running, final ArrayAdapter<Object> listAdapter, final int type,
|
||||||
final boolean enable) {
|
final boolean enable) {
|
||||||
new AsyncTask<Void, Void, Void>() {
|
new AsyncTask<Void, Void, Void>() {
|
||||||
|
|
||||||
protected void onPreExecute() {
|
protected void onPreExecute() {
|
||||||
};
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
app.getWaypointHelper().enableWaypointType(type, enable);
|
app.getWaypointHelper().enableWaypointType(type, enable);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onPostExecute(Void result) {
|
protected void onPostExecute(Void result) {
|
||||||
running[0] = -1;
|
running[0] = -1;
|
||||||
listAdapter.clear();
|
listAdapter.clear();
|
||||||
listAdapter.addAll(getPoints());
|
for (Object point : getPoints()) {
|
||||||
|
listAdapter.add(point);
|
||||||
|
}
|
||||||
listAdapter.notifyDataSetChanged();
|
listAdapter.notifyDataSetChanged();
|
||||||
};
|
}
|
||||||
}.execute((Void) null);
|
}.execute((Void) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getHeader(int type, boolean checked) {
|
protected String getHeader(int type, boolean checked) {
|
||||||
FragmentActivity ctx = getActivity();
|
FragmentActivity ctx = getActivity();
|
||||||
String str = ctx.getString(R.string.waypoints);
|
String str = ctx.getString(R.string.waypoints);
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WaypointHelper.TARGETS:
|
case WaypointHelper.TARGETS:
|
||||||
str = ctx.getString(R.string.targets);
|
str = ctx.getString(R.string.targets);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.ALARMS:
|
case WaypointHelper.ALARMS:
|
||||||
str = ctx.getString(R.string.way_alarms);
|
str = ctx.getString(R.string.way_alarms);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.FAVORITES:
|
case WaypointHelper.FAVORITES:
|
||||||
str = ctx.getString(R.string.my_favorites);
|
str = ctx.getString(R.string.my_favorites);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.WAYPOINTS:
|
case WaypointHelper.WAYPOINTS:
|
||||||
str = ctx.getString(R.string.waypoints);
|
str = ctx.getString(R.string.waypoints);
|
||||||
break;
|
break;
|
||||||
case WaypointHelper.POI:
|
case WaypointHelper.POI:
|
||||||
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
str = waypointHelper.getPoiFilter() == null || !checked ? ctx.getString(R.string.poi) : waypointHelper
|
||||||
.getPoiFilter().getName();
|
.getPoiFilter().getName();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points){
|
public AlertDialog createWaypointsDialogFlat(final List<LocationPointWrapper> points) {
|
||||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
final FragmentActivity ctx = getActivity();
|
final FragmentActivity ctx = getActivity();
|
||||||
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(ctx, R.layout.waypoint_reached, R.id.title,
|
final ArrayAdapter<LocationPointWrapper> listAdapter = new ArrayAdapter<LocationPointWrapper>(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);
|
updatePointInfoView(app, ctx, v, getItem(position), WaypointDialogFragment.this);
|
||||||
View remove = v.findViewById(R.id.info_close);
|
View remove = v.findViewById(R.id.info_close);
|
||||||
((ImageButton) remove).setImageDrawable(ctx.getResources().getDrawable(
|
((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));
|
R.drawable.ic_action_gremove_dark));
|
||||||
remove.setOnClickListener(new View.OnClickListener() {
|
remove.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -339,7 +345,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
builder.setView(listView);
|
builder.setView(listView);
|
||||||
builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() {
|
builder.setPositiveButton(R.string.default_buttons_ok, new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
waypointHelper.removeVisibleLocationPoint(deletedPoints);
|
||||||
|
@ -348,7 +354,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public AlertDialog createWaypointsDialog() {
|
public AlertDialog createWaypointsDialog() {
|
||||||
final List<Object> points = getPoints();
|
final List<Object> points = getPoints();
|
||||||
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
final List<LocationPointWrapper> deletedPoints = new ArrayList<WaypointHelper.LocationPointWrapper>();
|
||||||
|
@ -377,14 +383,14 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
btn.setEnabled(running[0] == -1);
|
btn.setEnabled(running[0] == -1);
|
||||||
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
v.findViewById(R.id.ProgressBar).setVisibility(position == running[0] ? View.VISIBLE : View.GONE);
|
||||||
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
running[0] = position;
|
running[0] = position;
|
||||||
thisAdapter.notifyDataSetInvalidated();
|
thisAdapter.notifyDataSetInvalidated();
|
||||||
if(type == WaypointHelper.POI && isChecked) {
|
if (type == WaypointHelper.POI && isChecked) {
|
||||||
selectPoi(running, thisAdapter, type, isChecked);
|
selectPoi(running, thisAdapter, type, isChecked);
|
||||||
} else {
|
} else {
|
||||||
enableType(running, thisAdapter, type, isChecked);
|
enableType(running, thisAdapter, type, isChecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,12 +417,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
listView.setAdapter(listAdapter);
|
listView.setAdapter(listAdapter);
|
||||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> adapterView, View view, int item, long l) {
|
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);
|
LocationPointWrapper ps = (LocationPointWrapper) listAdapter.getItem(item);
|
||||||
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
showOnMap(app, ctx, ps.getPoint(), WaypointDialogFragment.this);
|
||||||
}
|
}
|
||||||
|
@ -425,7 +431,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
|
||||||
builder.setView(listView);
|
builder.setView(listView);
|
||||||
builder.setNeutralButton(R.string.flat_list_waypoints, new OnClickListener() {
|
builder.setNeutralButton(R.string.flat_list_waypoints, new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
showWaypointsDialogFlat(getActivity());
|
showWaypointsDialogFlat(getActivity());
|
||||||
|
@ -442,7 +448,7 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
builder.setNegativeButton(ctx.getString(R.string.default_buttons_cancel), null);
|
||||||
return builder.create();
|
return builder.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Object> getPoints() {
|
protected List<Object> getPoints() {
|
||||||
final List<Object> points = new ArrayList<Object>();
|
final List<Object> points = new ArrayList<Object>();
|
||||||
for (int i = 0; i < WaypointHelper.MAX; i++) {
|
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) {
|
private static void showOnMap(OsmandApplication app, Activity a, LocationPoint locationPoint, DialogFragment dialog) {
|
||||||
if(!(a instanceof MapActivity)) {
|
if (!(a instanceof MapActivity)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MapActivity ctx = (MapActivity) a;
|
MapActivity ctx = (MapActivity) a;
|
||||||
|
@ -475,12 +481,12 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
final double dist = MapUtils.getDistance(ctx.getMapView().getLatitude(), ctx.getMapView().getLongitude(),
|
||||||
locationPoint.getLatitude(), locationPoint.getLongitude());
|
locationPoint.getLatitude(), locationPoint.getLongitude());
|
||||||
double t = 10;
|
double t = 10;
|
||||||
if(dist < t) {
|
if (dist < t) {
|
||||||
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
app.getAppCustomization().showLocationPoint(ctx, locationPoint);
|
||||||
} else {
|
} else {
|
||||||
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
thread.startMoving(locationPoint.getLatitude(), locationPoint.getLongitude(), fZoom, true);
|
||||||
}
|
}
|
||||||
if(di) {
|
if (di) {
|
||||||
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
ctx.getMapLayers().getContextMenuLayer().setSelectedObject(locationPoint);
|
||||||
ctx.getMapLayers()
|
ctx.getMapLayers()
|
||||||
.getContextMenuLayer()
|
.getContextMenuLayer()
|
||||||
|
@ -492,6 +498,4 @@ public class WaypointDialogHelper implements OsmAndLocationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
264
OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java
Normal file
264
OsmAnd/src/net/osmand/plus/sherpafy/WaypointDialogHelper.java
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,7 +39,7 @@ public class MapMenuControls extends MapControls {
|
||||||
// double lat = activity.getMapView().getLatitude();
|
// double lat = activity.getMapView().getLatitude();
|
||||||
// double lon = activity.getMapView().getLongitude();
|
// double lon = activity.getMapView().getLongitude();
|
||||||
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
// MainMenuActivity.backToMainMenuDialog(activity, new LatLon(lat, lon));
|
||||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,7 +26,8 @@ public class SmallMapMenuControls extends MapControls {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
notifyClicked();
|
notifyClicked();
|
||||||
mapActivity.getMapActions().openOptionsMenuAsList();
|
//mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
|
mapActivity.getMapActions().openOptionsMenuAsDrawer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue