Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-01-22 15:10:00 +01:00
commit 807e547e1b
8 changed files with 61 additions and 16 deletions

View file

@ -63,7 +63,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginLeft="8dp" android:layout_marginLeft="16dp"
android:layout_marginRight="56dp"/> android:layout_marginRight="56dp"/>
<View <View
@ -88,6 +88,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/number_of_contributors" android:text="@string/number_of_contributors"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/> android:textSize="@dimen/default_sub_text_size"/>
<TextView <TextView
@ -120,6 +121,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/number_of_edits" android:text="@string/number_of_edits"
android:textColor="?android:textColorSecondary"
android:textSize="@dimen/default_sub_text_size"/> android:textSize="@dimen/default_sub_text_size"/>
<TextView <TextView

View file

@ -34,6 +34,7 @@
<ListView <ListView
android:id="@android:id/list" android:id="@android:id/list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:drawSelectorOnTop="true" />
</LinearLayout> </LinearLayout>

View file

@ -40,4 +40,10 @@
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible"/>
</LinearLayout> </LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?attr/dashboard_divider"/>
</LinearLayout> </LinearLayout>

View file

@ -96,6 +96,7 @@
android:layout_width="280dp" android:layout_width="280dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_gravity="left" android:layout_gravity="left"
android:background="?attr/bg_color"/> android:background="?attr/bg_color"
android:drawSelectorOnTop="true" />
</android.support.v4.widget.DrawerLayout> </android.support.v4.widget.DrawerLayout>

View file

@ -5,14 +5,14 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center" android:gravity="center"
android:paddingRight="0dp" android:background="@android:drawable/list_selector_background">
style="?android:attr/spinnerItemStyle">
<TextView <TextView
android:text="@string/reports_for" android:text="@string/reports_for"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textSize="@dimen/default_sub_text_size"/> android:textSize="@dimen/default_sub_text_size"
android:textColor="?android:textColorSecondary"/>
<TextView <TextView
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"

View file

@ -19,6 +19,7 @@ import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.map.WorldRegion; import net.osmand.map.WorldRegion;
@ -253,7 +254,7 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
public MonthsForReportsAdapter(Context context) { public MonthsForReportsAdapter(Context context) {
super(context, android.R.layout.simple_spinner_item); super(context, android.R.layout.simple_spinner_item);
Calendar startDate = Calendar.getInstance(); Calendar startDate = Calendar.getInstance();
startDate.set(Calendar.MONTH, Calendar.JUNE); startDate.set(Calendar.MONTH, Calendar.SEPTEMBER);
startDate.set(Calendar.YEAR, 2015); startDate.set(Calendar.YEAR, 2015);
startDate.set(Calendar.DAY_OF_MONTH, 1); startDate.set(Calendar.DAY_OF_MONTH, 1);
startDate.set(Calendar.HOUR_OF_DAY, 0); startDate.set(Calendar.HOUR_OF_DAY, 0);
@ -288,7 +289,11 @@ public class ReportsFragment extends BaseOsmAndFragment implements SearchSelecti
StringBuilder response = new StringBuilder(); StringBuilder response = new StringBuilder();
error = NetworkUtils.sendGetRequest(params[0], null, response); error = NetworkUtils.sendGetRequest(params[0], null, response);
if (error == null) { 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); LOG.error(error);
return null; return null;

View file

@ -1,7 +1,9 @@
package net.osmand.plus.views; package net.osmand.plus.views;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -15,21 +17,25 @@ public class DoubleTapScaleDetector {
private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class); private static final Log LOG = PlatformUtil.getLog(DoubleTapScaleDetector.class);
private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout(); private static final int DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout();
private static final int DOUBLE_TAP_MIN_TIME = 40; 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; private final DoubleTapZoomListener listener;
protected final Context ctx; protected final Context ctx;
private int displayHeightPx;
private boolean isDoubleTapping = false; private boolean isDoubleTapping = false;
private float scale; private float scale;
private MotionEvent firstDown; private MotionEvent firstDown;
private MotionEvent firstUp; private MotionEvent firstUp;
private int mDoubleTapSlopSquare; private int mDoubleTapSlopSquare;
public DoubleTapScaleDetector(Context ctx, DoubleTapZoomListener listener) { public DoubleTapScaleDetector(Activity ctx, DoubleTapZoomListener listener) {
this.ctx = ctx; this.ctx = ctx;
this.listener = listener; this.listener = listener;
Point size = new Point();
ctx.getWindowManager().getDefaultDisplay().getSize(size);
displayHeightPx = size.x;
final ViewConfiguration configuration = ViewConfiguration.get(ctx); final ViewConfiguration configuration = ViewConfiguration.get(ctx);
int doubleTapSlop = configuration.getScaledTouchSlop(); int doubleTapSlop = configuration.getScaledTouchSlop();
mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop; mDoubleTapSlopSquare = doubleTapSlop * doubleTapSlop;
@ -63,7 +69,7 @@ public class DoubleTapScaleDetector {
} else if (event.getAction() == MotionEvent.ACTION_MOVE) { } else if (event.getAction() == MotionEvent.ACTION_MOVE) {
if (isDoubleTapping) { if (isDoubleTapping) {
float delta = convertPxToDp((int) (firstDown.getY() - event.getY())); float delta = convertPxToDp((int) (firstDown.getY() - event.getY()));
float scaleDelta = delta / DP_PER_1X; float scaleDelta = delta / (displayHeightPx / SCALE_PER_SCREEN);
scale = 1 - scaleDelta; scale = 1 - scaleDelta;
listener.onZoomingOrRotating(scale, 0); listener.onZoomingOrRotating(scale, 0);
return true; return true;
@ -99,6 +105,14 @@ public class DoubleTapScaleDetector {
return toReturn; return toReturn;
} }
public float getCenterX() {
return firstUp.getX();
}
public float getCenterY() {
return firstUp.getY();
}
public interface DoubleTapZoomListener { public interface DoubleTapZoomListener {
public void onZoomStarted(PointF centerPoint); public void onZoomStarted(PointF centerPoint);

View file

@ -11,6 +11,7 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.Point;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.RectF; import android.graphics.RectF;
import android.os.Handler; import android.os.Handler;
@ -170,13 +171,15 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
}; };
private int displayHeightPx;
public OsmandMapTileView(Activity activity, int w, int h) { public OsmandMapTileView(Activity activity, int w, int h) {
this.activity = activity; this.activity = activity;
init(activity, w, h); init(activity, w, h);
} }
// ///////////////////////////// INITIALIZING UI PART /////////////////////////////////// // ///////////////////////////// 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(); application = (OsmandApplication) ctx.getApplicationContext();
settings = application.getSettings(); settings = application.getSettings();
@ -213,7 +216,7 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
animatedDraggingThread = new AnimateDraggingMapThread(this); animatedDraggingThread = new AnimateDraggingMapThread(this);
gestureDetector = new GestureDetector(ctx, new MapExplorer(this, new MapTileViewOnGestureListener())); gestureDetector = new GestureDetector(ctx, new MapExplorer(this, new MapTileViewOnGestureListener()));
multiTouchSupport = new MultiTouchSupport(ctx, new MapTileViewMultiTouchZoomListener()); 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); WindowManager mgr = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
dm = new DisplayMetrics(); dm = new DisplayMetrics();
@ -224,6 +227,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
setPixelDimensions(w, h).build(); setPixelDimensions(w, h).build();
currentViewport.setDensity(dm.density); currentViewport.setDensity(dm.density);
currentViewport.setMapDensity(getSettingsMapDensity()); currentViewport.setMapDensity(getSettingsMapDensity());
Point size = new Point();
ctx.getWindowManager().getDefaultDisplay().getSize(size);
displayHeightPx = size.x;
} }
public void setView(View view) { public void setView(View view) {
@ -576,8 +583,10 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
} }
if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) { if (showMapPosition || animatedDraggingThread.isAnimatingZoom()) {
drawMapPosition(canvas, c.x, c.y); drawMapPosition(canvas, c.x, c.y);
} else if (multiTouchSupport.isInZoomMode() || doubleTapScaleDetector.isInZoomMode()) { } else if (multiTouchSupport.isInZoomMode()) {
drawMapPosition(canvas, multiTouchSupport.getCenterPoint().x, multiTouchSupport.getCenterPoint().y); 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); 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) { private void refreshBufferImage(final DrawSettings drawSettings) {
if (mapRenderer != null) { if (mapRenderer != null) {
return; return;
@ -773,7 +787,9 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
if (!multiTouchSupport.onTouchEvent(event)) { if (!multiTouchSupport.onTouchEvent(event)) {
/* return */ /* return */
doubleTapScaleDetector.onTouchEvent(event); doubleTapScaleDetector.onTouchEvent(event);
gestureDetector.onTouchEvent(event); if (!doubleTapScaleDetector.isInZoomMode()) {
gestureDetector.onTouchEvent(event);
}
} }
return true; return true;
} }