Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
807e547e1b
8 changed files with 61 additions and 16 deletions
|
@ -63,7 +63,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="56dp"/>
|
||||
|
||||
<View
|
||||
|
@ -88,6 +88,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/number_of_contributors"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
|
@ -120,6 +121,7 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/number_of_edits"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
|
||||
<TextView
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
<ListView
|
||||
android:id="@android:id/list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
android:layout_height="wrap_content"
|
||||
android:drawSelectorOnTop="true" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
@ -40,4 +40,10 @@
|
|||
android:visibility="gone"
|
||||
tools:visibility="visible"/>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/dashboard_divider"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -96,6 +96,7 @@
|
|||
android:layout_width="280dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="left"
|
||||
android:background="?attr/bg_color"/>
|
||||
android:background="?attr/bg_color"
|
||||
android:drawSelectorOnTop="true" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
|
@ -5,14 +5,14 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:paddingRight="0dp"
|
||||
style="?android:attr/spinnerItemStyle">
|
||||
android:background="@android:drawable/list_selector_background">
|
||||
|
||||
<TextView
|
||||
android:text="@string/reports_for"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="@dimen/default_sub_text_size"/>
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
android:textColor="?android:textColorSecondary"/>
|
||||
|
||||
<TextView
|
||||
android:textColor="?android:textColorPrimary"
|
||||
|
|
|
@ -19,6 +19,7 @@ import android.widget.Spinner;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.map.WorldRegion;
|
||||
|
@ -253,7 +254,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
public MonthsForReportsAdapter(Context context) {
|
||||
super(context, android.R.layout.simple_spinner_item);
|
||||
Calendar startDate = Calendar.getInstance();
|
||||
startDate.set(Calendar.MONTH, Calendar.JUNE);
|
||||
startDate.set(Calendar.MONTH, Calendar.SEPTEMBER);
|
||||
startDate.set(Calendar.YEAR, 2015);
|
||||
startDate.set(Calendar.DAY_OF_MONTH, 1);
|
||||
startDate.set(Calendar.HOUR_OF_DAY, 0);
|
||||
|
@ -288,7 +289,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
|
|||
StringBuilder response = new StringBuilder();
|
||||
error = NetworkUtils.sendGetRequest(params[0], null, response);
|
||||
if (error == null) {
|
||||
return gson.fromJson(response.toString(), protocolClass);
|
||||
try {
|
||||
return gson.fromJson(response.toString(), protocolClass);
|
||||
} catch (JsonSyntaxException e) {
|
||||
error = e.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
LOG.error(error);
|
||||
return null;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -15,21 +17,25 @@ public class DoubleTapScaleDetector {
|
|||
private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class);
|
||||
private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout();
|
||||
private static final int DOUBLE_TAP_MIN_TIME = 40;
|
||||
private static final int DP_PER_1X = 200;
|
||||
private static final int SCALE_PER_SCREEN = 8;
|
||||
|
||||
private final DoubleTapZoomListener listener;
|
||||
protected final Context ctx;
|
||||
|
||||
private int displayHeightPx;
|
||||
|
||||
private boolean isDoubleTapping = false;
|
||||
private float scale;
|
||||
private MotionEvent firstDown;
|
||||
private MotionEvent firstUp;
|
||||
private int mDoubleTapSlopSquare;
|
||||
|
||||
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) {
|
||||
public DoubleTapScaleDetector(Activity ctx, DoubleTapZoomListener listener) {
|
||||
this.ctx = ctx;
|
||||
this.listener = listener;
|
||||
|
||||
Point size = new Point();
|
||||
ctx.getWindowManager().getDefaultDisplay().getSize(size);
|
||||
displayHeightPx = size.x;
|
||||
final ViewConfiguration configuration = ViewConfiguration.get(ctx);
|
||||
int doubleTapSlop = configuration.getScaledTouchSlop();
|
||||
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
|
||||
|
@ -63,7 +69,7 @@ public class DoubleTapScaleDetector {
|
|||
} else if (event.getAction() == MotionEvent.ACTION_MOVE) {
|
||||
if (isDoubleTapping) {
|
||||
float delta = convertPxToDp((int) (firstDown.getY() - event.getY()));
|
||||
float scaleDelta = delta / DP_PER_1X;
|
||||
float scaleDelta = delta / (displayHeightPx / SCALE_PER_SCREEN);
|
||||
scale = 1 - scaleDelta;
|
||||
listener.onZoomingOrRotating(scale, 0);
|
||||
return true;
|
||||
|
@ -99,6 +105,14 @@ public class DoubleTapScaleDetector {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
public float getCenterX() {
|
||||
return firstUp.getX();
|
||||
}
|
||||
|
||||
public float getCenterY() {
|
||||
return firstUp.getY();
|
||||
}
|
||||
|
||||
public interface DoubleTapZoomListener {
|
||||
public void onZoomStarted(PointF centerPoint);
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.RectF;
|
||||
import android.os.Handler;
|
||||
|
@ -170,13 +171,15 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
}
|
||||
};
|
||||
|
||||
private int displayHeightPx;
|
||||
|
||||
public OsmandMapTileView(Activity activity, int w, int h) {
|
||||
this.activity = activity;
|
||||
init(activity, w, h);
|
||||
}
|
||||
|
||||
// ///////////////////////////// INITIALIZING UI PART ///////////////////////////////////
|
||||
public void init(Context ctx, int w, int h) {
|
||||
public void init(Activity ctx, int w, int h) {
|
||||
application = (OsmandApplication) ctx.getApplicationContext();
|
||||
settings = application.getSettings();
|
||||
|
||||
|
@ -213,7 +216,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
animatedDraggingThread = new AnimateDraggingMapThread(this);
|
||||
gestureDetector = new GestureDetector(ctx, new MapExplorer(this, new MapTileViewOnGestureListener()));
|
||||
multiTouchSupport = new MultiTouchSupport(ctx, new MapTileViewMultiTouchZoomListener());
|
||||
doubleTapScaleDetector = new DoubleTapScaleDetector(ctx, new MapTileViewMultiTouchZoomListener());
|
||||
doubleTapScaleDetector = new DoubleTapScaleDetector(activity, new MapTileViewMultiTouchZoomListener());
|
||||
|
||||
WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
|
||||
dm = new DisplayMetrics();
|
||||
|
@ -224,6 +227,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
setPixelDimensions(w, h).build();
|
||||
currentViewport.setDensity(dm.density);
|
||||
currentViewport.setMapDensity(getSettingsMapDensity());
|
||||
|
||||
Point size = new Point();
|
||||
ctx.getWindowManager().getDefaultDisplay().getSize(size);
|
||||
displayHeightPx = size.x;
|
||||
}
|
||||
|
||||
public void setView(View view) {
|
||||
|
@ -576,8 +583,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
}
|
||||
if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
|
||||
drawMapPosition(canvas, c.x, c.y);
|
||||
} else if (multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) {
|
||||
} else if (multiTouchSupport.isInZoomMode()) {
|
||||
drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y);
|
||||
} else if (doubleTapScaleDetector.isInZoomMode()) {
|
||||
drawScale(canvas, doubleTapScaleDetector.getCenterX(), doubleTapScaleDetector.getCenterY());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -586,6 +595,11 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
canvas.drawCircle(x, y, 7 * dm.density, paintCenter);
|
||||
}
|
||||
|
||||
protected void drawScale(Canvas canvas, float x, float y) {
|
||||
canvas.drawLine(x - 10, y, x + 10, y, paintCenter);
|
||||
canvas.drawLine(x, y + 200, x, y -200, paintCenter);
|
||||
}
|
||||
|
||||
private void refreshBufferImage(final DrawSettings drawSettings) {
|
||||
if (mapRenderer != null) {
|
||||
return;
|
||||
|
@ -773,7 +787,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
if (!multiTouchSupport.onTouchEvent(event)) {
|
||||
/* return */
|
||||
doubleTapScaleDetector.onTouchEvent(event);
|
||||
gestureDetector.onTouchEvent(event);
|
||||
if (!doubleTapScaleDetector.isInZoomMode()) {
|
||||
gestureDetector.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue