Improve night view

This commit is contained in:
Victor Shcherb 2012-08-29 22:20:05 +02:00
parent ea95f78199
commit 618533467c
6 changed files with 45 additions and 20 deletions

View file

@ -62,11 +62,14 @@
<category android:name="android.intent.category.DEFAULT"></category>
<data android:scheme="geo"></data>
</intent-filter>
<!-- requires read permission -->
<!--
<intent-filter android:label="OsmAnd">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/postal-address_v2" />
</intent-filter>
-->
</activity>
<activity android:name="net.osmand.plus.development.TestVoiceActivity"></activity>
<activity android:name="net.osmand.plus.activities.LocalIndexesActivity" android:label="@string/local_index_descr_title"></activity>
@ -76,15 +79,6 @@
<intent-filter><action android:name="net.osmand.plus.NavigationService"></action></intent-filter>
</service>
<receiver android:name="net.osmand.plus.OnNavigationServiceAlarmReceiver"/>
<!-- Used for install referrer tracking -->
<receiver android:name="com.google.android.apps.analytics.AnalyticsReceiver"
android:exported="true">
<intent-filter>
<action android:name="com.android.vending.INSTALL_REFERRER" />
</intent-filter>
</receiver>
<activity android:name="net.osmand.plus.activities.OsmandBidForFixActivity"></activity>

View file

@ -10,6 +10,7 @@ import net.osmand.plus.activities.ApplicationMode;
import net.osmand.plus.activities.MapActivity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.RectF;
@ -42,6 +43,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private Handler showUIHandler;
private boolean showZoomLevel = false;
private int shadowColor = Color.WHITE;
private Button zoomInButton;
@ -203,7 +205,7 @@ public class MapControlsLayer extends OsmandMapLayer {
zoomShadow.draw(canvas);
ShadowText.draw(zoomText, canvas, zoomInButton.getLeft() + (zoomInButton.getWidth() - length - 2) / 2,
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint);
zoomInButton.getTop() + 4 * scaleCoefficient, zoomTextPaint, shadowColor);
}
private void hideZoomLevelInTime(){
@ -436,7 +438,7 @@ public class MapControlsLayer extends OsmandMapLayer {
rulerDrawable.draw(canvas);
Rect bounds = rulerDrawable.getBounds();
cacheRulerText.draw(canvas, bounds.left + (bounds.width() - cacheRulerTextLen) / 2, bounds.bottom - 8 * scaleCoefficient,
rulerTextPaint);
rulerTextPaint, shadowColor);
}
}

View file

@ -2,6 +2,7 @@ package net.osmand.plus.views;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
@ -11,6 +12,7 @@ public abstract class MapInfoControl extends View implements MapControlUpdateabl
int width = 0;
int height = 0;
Rect padding = new Rect();
int shadowColor = Color.WHITE;
public MapInfoControl(Context ctx) {
super(ctx);
@ -46,7 +48,15 @@ public abstract class MapInfoControl extends View implements MapControlUpdateabl
}
protected void drawShadowText(Canvas cv, String text, float centerX, float centerY, Paint textPaint) {
ShadowText.draw(text, cv, centerX, centerY, textPaint);
ShadowText.draw(text, cv, centerX, centerY, textPaint, shadowColor);
}
public void setShadowColor(int shadowColor) {
this.shadowColor = shadowColor;
}
public int getShadowColor() {
return shadowColor;
}
@Override

View file

@ -602,6 +602,7 @@ public class MapInfoLayer extends OsmandMapLayer {
public void onDraw(Canvas canvas, RectF latlonBounds, RectF tilesRect, DrawSettings nightMode) {
boolean bold = routeLayer.getHelper().isFollowingMode();
int color = !nightMode.isNightMode() ? Color.BLACK : Color.BLACK;
int shadowColor = nightMode.isNightMode() ? Color.TRANSPARENT : Color.WHITE;
if(paintText.getColor() != color) {
paintText.setColor(color);
topText.setTextColor(color);
@ -616,9 +617,12 @@ public class MapInfoLayer extends OsmandMapLayer {
paintSmallText.setFakeBoldText(bold);
paintSmallSubText.setFakeBoldText(bold);
}
if(topText.getShadowColor() != shadowColor) {
topText.setShadowColor(shadowColor);
}
// update data on draw
rightStack.updateInfo();
leftStack.updateInfo();
rightStack.updateInfo(shadowColor);
leftStack.updateInfo(shadowColor);
lanesControl.updateInfo();
alarmControl.updateInfo();
for (int i = 0; i < statusBar.getChildCount(); i++) {
@ -742,6 +746,7 @@ public class MapInfoLayer extends OsmandMapLayer {
private static class TopTextView extends TextView implements MapControlUpdateable {
private final RoutingHelper routingHelper;
private final MapActivity map;
private int shadowColor = Color.WHITE;
public TopTextView(RoutingHelper routingHelper, MapActivity map) {
super(map);
@ -754,7 +759,15 @@ public class MapInfoLayer extends OsmandMapLayer {
@Override
protected void onDraw(Canvas canvas) {
ShadowText.draw(getText().toString(), canvas, getWidth() / 2, getHeight() - 4 * scaleCoefficient,
getPaint());
getPaint(), shadowColor);
}
public void setShadowColor(int shadowColor) {
this.shadowColor = shadowColor;
}
public int getShadowColor() {
return shadowColor;
}
@Override

View file

@ -72,13 +72,19 @@ public class MapStackControl extends ViewGroup {
this.cacheStackDrawables.clear();
}
public void updateInfo() {
public void updateInfo(int shadowColor) {
for (MapInfoControl v : stackViews) {
v.updateInfo();
if(v.getShadowColor() != shadowColor) {
v.setShadowColor(shadowColor);
}
}
// update even if collapsed to know if view becomes visible
for (MapInfoControl v : collapsedViews) {
v.updateInfo();
if(v.getShadowColor() != shadowColor) {
v.setShadowColor(shadowColor);
}
}
}

View file

@ -17,13 +17,13 @@ public class ShadowText {
public void draw(Canvas cv, float centerX, float centerY, Paint textPaint) {
draw(text, cv, centerX, centerY, textPaint);
public void draw(Canvas cv, float centerX, float centerY, Paint textPaint, int shadowColor) {
draw(text, cv, centerX, centerY, textPaint, shadowColor);
}
public static void draw(String text, Canvas cv, float centerX, float centerY, Paint textPaint) {
public static void draw(String text, Canvas cv, float centerX, float centerY, Paint textPaint, int shadowColor) {
int c = textPaint.getColor();
textPaint.setStyle(Style.STROKE);
textPaint.setColor(Color.WHITE);
textPaint.setColor(shadowColor);
textPaint.setStrokeWidth(4);
cv.drawText(text, centerX, centerY, textPaint);
// reset