summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2016-01-29 21:36:00 +0100
committermvglasow <michael -at- vonglasow.com>2016-02-02 09:58:31 +0100
commit240555fb0da23a5014a2ab90ccb9bf47c49b3c5f (patch)
treef35631a40af74ef8cf3a6170635b7f586e6e0ce1
parent224945419dccb9e844c791e73e047c1add20d2dd (diff)
downloadnavit-240555fb0da23a5014a2ab90ccb9bf47c49b3c5f.tar.gz
Add:graphics_android:Use background_color attribute for system bar tint
Signed-off-by: mvglasow <michael -at- vonglasow.com>
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java16
-rw-r--r--navit/graphics/android/graphics_android.c33
2 files changed, 42 insertions, 7 deletions
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index b28ff8690..ed486054a 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -63,6 +63,7 @@ public class NavitGraphics
int pos_y;
int pos_wraparound;
int overlay_disabled;
+ int bgcolor;
float trackball_x, trackball_y;
View view;
SystemBarTintView navigationTintView;
@@ -79,6 +80,14 @@ public class NavitGraphics
private static long interval_for_long_press = 200L;
private Handler timer_handler = new Handler();
+
+ public void setBackgroundColor(int bgcolor) {
+ this.bgcolor = bgcolor;
+ if (navigationTintView != null)
+ navigationTintView.setBackgroundColor(bgcolor);
+ if (statusTintView != null)
+ statusTintView.setBackgroundColor(bgcolor);
+ }
public void SetCamera(int use_camera)
{
@@ -697,7 +706,7 @@ public class NavitGraphics
public SystemBarTintView(Context context) {
super(context);
- // TODO Auto-generated constructor stub
+ this.setBackgroundColor(bgcolor);
}
}
@@ -723,13 +732,8 @@ public class NavitGraphics
}
relativelayout.addView(view);
- // TODO get colors from config
navigationTintView = new SystemBarTintView(activity);
- navigationTintView.setBackgroundColor(Color.argb(160, 0, 0, 0));
-
statusTintView = new SystemBarTintView(activity);
- statusTintView.setBackgroundColor(Color.argb(160, 0, 0, 0));
-
frameLayout.addView(navigationTintView);
frameLayout.addView(statusTintView);
diff --git a/navit/graphics/android/graphics_android.c b/navit/graphics/android/graphics_android.c
index 2ef9400b4..2bf9ed952 100644
--- a/navit/graphics/android/graphics_android.c
+++ b/navit/graphics/android/graphics_android.c
@@ -39,7 +39,8 @@ struct graphics_priv {
jmethodID NavitGraphics_draw_polyline, NavitGraphics_draw_polygon, NavitGraphics_draw_rectangle,
NavitGraphics_draw_circle, NavitGraphics_draw_text, NavitGraphics_draw_image,
NavitGraphics_draw_image_warp, NavitGraphics_draw_mode, NavitGraphics_draw_drag,
- NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera;
+ NavitGraphics_overlay_disable, NavitGraphics_overlay_resize, NavitGraphics_SetCamera,
+ NavitGraphics_setBackgroundColor;
jclass PaintClass;
jmethodID Paint_init,Paint_setStrokeWidth,Paint_setARGB;
@@ -65,6 +66,7 @@ struct graphics_priv {
struct callback_list *cbl;
struct window win;
struct padding *padding;
+ jint bgcolor;
};
struct graphics_font_priv {
@@ -466,6 +468,18 @@ set_attr(struct graphics_priv *gra, struct attr *attr)
case attr_use_camera:
(*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_SetCamera, attr->u.num);
return 1;
+ case attr_background_color:
+ gra->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "set attr_background_color %04x %04x %04x %04x (%08x)\n",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, gra->bgcolor);
+ if (gra->NavitGraphics_setBackgroundColor != NULL)
+ (*jnienv)->CallVoidMethod(jnienv, gra->NavitGraphics, gra->NavitGraphics_setBackgroundColor, gra->bgcolor);
+ else
+ dbg(lvl_error, "NavitGraphics.setBackgroundColor not found, cannot set background color\n");
+ return 1;
default:
return 0;
}
@@ -814,6 +828,7 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
struct attr *attr;
int use_camera=0;
jmethodID cid;
+ jint android_bgcolor;
dbg(lvl_debug, "enter\n");
if (!event_request_system("android","graphics_android"))
@@ -830,6 +845,18 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
ret->padding->top = 0;
ret->padding->right = 0;
ret->padding->bottom = 0;
+ /* attr_background_color is the background color for system bars (API 17+ only) */
+ if ((attr=attr_search(attrs, NULL, attr_background_color))) {
+ ret->bgcolor = (attr->u.color->a / 0x101) << 24
+ | (attr->u.color->r / 0x101) << 16
+ | (attr->u.color->g / 0x101) << 8
+ | (attr->u.color->b / 0x101);
+ dbg(lvl_debug, "attr_background_color %04x %04x %04x %04x (%08x)\n",
+ attr->u.color->r, attr->u.color->g, attr->u.color->b, attr->u.color->a, ret->bgcolor);
+ } else {
+ /* default is the same as for OSD */
+ ret->bgcolor = 0x60000000;
+ }
if ((attr=attr_search(attrs, NULL, attr_use_camera))) {
use_camera=attr->u.num;
}
@@ -854,6 +881,10 @@ graphics_android_new(struct navit *nav, struct graphics_methods *meth, struct at
dbg(lvl_debug, "attr_has_menu_button=%d\n", attr->u.num);
g_free(attr);
}
+ ret->NavitGraphics_setBackgroundColor = (*jnienv)->GetMethodID(jnienv, ret->NavitGraphicsClass, "setBackgroundColor", "(I)V");
+ if (ret->NavitGraphics_setBackgroundColor != NULL) {
+ (*jnienv)->CallVoidMethod(jnienv, ret->NavitGraphics, ret->NavitGraphics_setBackgroundColor, ret->bgcolor);
+ }
dbg(lvl_debug,"returning %p\n",ret);
return ret;
} else {