Add glow effect to widgets

This commit is contained in:
Victor Shcherb 2015-04-15 10:21:22 +03:00
parent 3f0c508f2b
commit 916d38199d
14 changed files with 359 additions and 156 deletions

View file

@ -22,7 +22,7 @@ public abstract class AbstractPoiType {
}
public String getIconKeyName() {
return keyName.replace(':', '_');
return getKeyName().replace(':', '_');
}

View file

@ -105,17 +105,31 @@
android:layout_width="@dimen/map_ruler_width"
android:layout_height="wrap_content"
android:layout_gravity="bottom" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/map_ruler_bottom_margin" >
<TextView
android:id="@+id/map_ruler_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/map_ruler_bottom_margin"
android:gravity="center_horizontal"
android:text="100 m"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/map_ruler_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:text="100 m"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/map_ruler_text_shadow"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:text="100 m"
android:textSize="@dimen/map_widget_text_size_small" />
</FrameLayout>
<ImageView
android:id="@+id/map_ruler_image"
android:layout_width="fill_parent"

View file

@ -44,20 +44,35 @@
android:background="@drawable/btn_round"
android:minHeight="@dimen/map_address_height" >
<TextView
android:id="@+id/map_address_text"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:shadowColor="@color/color_myloc_distance"
android:shadowRadius="10"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size"
android:textStyle="bold" >
</TextView>
android:layout_gravity="center" >
<TextView
android:id="@+id/map_address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
</TextView>
<TextView
android:id="@+id/map_address_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
</TextView>
</FrameLayout>
<LinearLayout
android:id="@+id/waypoint_info_bar"
@ -85,16 +100,33 @@
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/waypoint_text"
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="2"
android:textSize="18sp" />
android:layout_weight="1" >
<TextView
android:id="@+id/waypoint_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="Waypoint"
android:textColor="@color/color_black"
android:textSize="@dimen/map_button_text_size" />
<TextView
android:id="@+id/waypoint_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="Waypoint"
android:textColor="@color/color_black"
android:textSize="@dimen/map_button_text_size" />
</FrameLayout>
<ImageButton
android:id="@+id/waypoint_more"
@ -112,14 +144,12 @@
</LinearLayout>
</FrameLayout>
<!-- CENTER -->
<!-- CENTER -->
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@ -138,12 +168,11 @@
<ImageButton
android:id="@+id/map_compass_button"
android:layout_width="@dimen/map_small_button_size"
android:layout_marginLeft="@dimen/map_small_button_margin"
android:layout_height="@dimen/map_small_button_size"
android:layout_marginLeft="@dimen/map_small_button_margin"
android:background="@drawable/btn_inset_circle_trans"
android:src="@drawable/ic_action_test_light" />
</LinearLayout>
<LinearLayout
android:id="@+id/map_center_info"
@ -159,16 +188,32 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/map_lanes_dist_text"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
android:layout_weight="1" >
<TextView
android:id="@+id/map_lanes_dist_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/map_lanes_dist_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
</FrameLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"

View file

@ -11,27 +11,30 @@
<FrameLayout
android:id="@+id/map_alarm_warning"
android:layout_width="@dimen/map_alarm_size"
android:layout_height="@dimen/map_alarm_size"
android:layout_gravity="bottom|left"
android:layout_marginBottom="@dimen/map_alarm_bottom_margin"
android:layout_marginLeft="@dimen/map_button_shadow_margin"
android:layout_width="@dimen/map_alarm_size"
android:layout_height="@dimen/map_alarm_size">
android:layout_marginLeft="@dimen/map_button_shadow_margin" >
<ImageView
android:id="@+id/map_alarm_warning_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/warnings_limit" />
<TextView
android:id="@+id/map_alarm_warning_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textStyle="bold"
android:text="60"
android:textColor="@color/color_black"
android:textSize="@dimen/map_alarm_text_size"
android:text="60"/>
android:textStyle="bold" />
</FrameLayout>
<FrameLayout
android:id="@+id/map_app_mode_shadow"
android:layout_width="@dimen/map_button_shadow_width"
@ -60,18 +63,17 @@
<LinearLayout
android:id="@+id/map_transparency_layout"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:layout_marginBottom="@dimen/map_button_size"
android:orientation="horizontal" >
<SeekBar
android:id="@+id/map_transparency_seekbar"
android:layout_width="@dimen/map_trans_seek_size"
android:layout_height="wrap_content"
android:layout_width="@dimen/map_trans_seek_size"
android:layout_gravity="center"
/>
android:layout_gravity="center" />
<ImageButton
android:id="@+id/map_transparency_hide"
@ -103,30 +105,44 @@
android:layout_marginLeft="@dimen/map_button_spacing"
android:background="@drawable/btn_round"
android:src="@drawable/ic_action_test_light" />
<FrameLayout
android:id="@+id/map_ruler_layout"
android:layout_width="@dimen/map_ruler_width"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginLeft="@dimen/map_button_margin">
<TextView
android:id="@+id/map_ruler_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/map_ruler_bottom_margin"
android:text="100 m"
android:gravity="center_horizontal"
android:layout_gravity="bottom"
android:textSize="@dimen/map_widget_text_size_small"
/>
<ImageView
android:layout_marginLeft="@dimen/map_button_margin" >
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="@dimen/map_ruler_bottom_margin" >
<TextView
android:id="@+id/map_ruler_text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:text="100 m"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/map_ruler_text_shadow"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="center_horizontal"
android:text="100 m"
android:textSize="@dimen/map_widget_text_size_small" />
</FrameLayout>
<ImageView
android:id="@+id/map_ruler_image"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/ruler"
/>
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/ruler" />
</FrameLayout>
</LinearLayout>

View file

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:orientation="vertical" >
<!-- TOP ROW -->
@ -14,21 +14,37 @@
android:minHeight="@dimen/map_address_height" >
<!-- android:layout_weight="1" to show properly next turn -->
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" >
<TextView
android:id="@+id/map_address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
</TextView>
<TextView
android:id="@+id/map_address_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" >
</TextView>
</FrameLayout>
<TextView
android:id="@+id/map_address_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ellipsize="end"
android:maxLines="1"
android:shadowColor="@color/color_myloc_distance"
android:shadowRadius="10"
android:text="Long Street Name"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size"
android:textStyle="bold" >
</TextView>
<LinearLayout
android:id="@+id/waypoint_info_bar"
@ -56,23 +72,40 @@
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="@+id/waypoint_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_weight="1"
android:ellipsize="end"
android:maxLines="2"
android:textSize="18sp" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="4dp"
android:layout_weight="1" >
<TextView
android:id="@+id/waypoint_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="Waypoint"
android:textColor="@color/color_black"
android:textSize="@dimen/map_button_text_size" />
<TextView
android:id="@+id/waypoint_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="2"
android:text="Waypoint"
android:textColor="@color/color_black"
android:textSize="@dimen/map_button_text_size" />
</FrameLayout>
<ImageButton
android:id="@+id/waypoint_more"
android:layout_width="@dimen/map_address_height"
android:layout_height="@dimen/map_address_height"
android:background="@drawable/btn_circle_transparent"
android:src="@drawable/ic_overflow_menu_white" />
android:src="@drawable/ic_action_test_light" />
<ImageButton
android:id="@+id/waypoint_close"
@ -111,7 +144,9 @@
android:orientation="vertical" >
<include layout="@layout/map_hud_widget" />
<include layout="@layout/map_hud_widget" />
<include layout="@layout/map_hud_widget" />
</LinearLayout>
@ -147,7 +182,7 @@
android:layout_weight="0.6" >
</LinearLayout>
</LinearLayout>
<!-- RIGHT widgets colon -->
<LinearLayout
@ -184,6 +219,7 @@
android:orientation="vertical" >
<include layout="@layout/map_hud_widget" />
<include layout="@layout/map_hud_widget" />
</LinearLayout>
@ -197,7 +233,7 @@
</LinearLayout>
</FrameLayout>
</LinearLayout>
<!-- CENTER -->
<!-- CENTER -->
<LinearLayout
android:id="@+id/map_center_info"
@ -206,24 +242,40 @@
android:layout_gravity="top|center"
android:layout_marginTop="@dimen/map_button_margin"
android:background="@drawable/btn_round"
android:visibility="gone"
android:orientation="vertical" >
android:orientation="vertical"
android:visibility="gone" >
<ImageView
android:id="@+id/map_lanes"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/map_lanes_dist_text"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
android:layout_weight="1" >
<TextView
android:id="@+id/map_lanes_dist_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/map_lanes_dist_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
android:text="1048 km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
</FrameLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"

View file

@ -11,22 +11,24 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView android:id="@+id/widget_top_icon_text"
<TextView
android:id="@+id/widget_top_icon_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="2dp"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size"
android:visibility="gone"
/>
android:visibility="gone" />
<ImageView
android:id="@+id/widget_top_icon"
android:layout_width="@dimen/map_widget_image"
android:layout_height="@dimen/map_widget_image"
android:layout_marginTop="2dp"
android:layout_gravity="center"
android:src="@drawable/ic_action_test_light"
android:visibility="gone"
/>
android:visibility="gone" />
</FrameLayout>
<LinearLayout
@ -43,36 +45,63 @@
android:gravity="center"
android:src="@drawable/ic_action_test_light" />
<TextView
android:id="@+id/widget_text"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/map_widget_text_bottom_margin"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:maxLines="1"
android:minWidth="10dp"
android:shadowColor="@color/color_myloc_distance"
android:shadowRadius="10"
android:text="1048"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" />
android:layout_weight="1" >
<TextView
android:id="@+id/widget_text_small"
<TextView
android:id="@+id/widget_text_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:maxLines="1"
android:minWidth="10dp"
android:text="1048"
android:textColor="@color/color_white"
android:textSize="@dimen/map_widget_text_size" />
<TextView
android:id="@+id/widget_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:maxLines="1"
android:minWidth="10dp"
android:text="1048"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size" />
</FrameLayout>
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="@dimen/map_widget_text_bottom_margin"
android:layout_marginBottom="@dimen/map_widget_text_small_bottom_margin"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:maxLines="1"
android:shadowColor="@color/color_myloc_distance"
android:shadowRadius="10"
android:text="km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
android:layout_marginRight="4dp" >
<TextView
android:id="@+id/widget_text_small_shadow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="km"
android:textColor="@color/color_white"
android:textSize="@dimen/map_widget_text_size_small" />
<TextView
android:id="@+id/widget_text_small"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="km"
android:textColor="@color/color_black"
android:textSize="@dimen/map_widget_text_size_small" />
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -90,6 +90,7 @@
<dimen name="map_button_text_size">18sp</dimen>
<dimen name="map_alarm_text_size">25sp</dimen>
<dimen name="map_widget_text_bottom_margin">1sp</dimen>
<dimen name="map_widget_text_small_bottom_margin">3sp</dimen>
<dimen name="map_widget_icon_margin">4dp</dimen>
<dimen name="dash_margin">2dp</dimen>

View file

@ -60,6 +60,7 @@ public class WaypointDialogHelper {
WaypointHelper wh = app.getWaypointHelper();
final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
localView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -86,7 +87,11 @@ public class WaypointDialogHelper {
} else {
textDist.setText("");
}
text.setText(PointDescription.getSimpleName(point, app));
String descr = PointDescription.getSimpleName(point, app);
text.setText(descr);
if(textShadow != null) {
textShadow.setText(descr);
}
// ((Spannable) text.getText()).setSpan(
// new ForegroundColorSpan(ctx.getResources().getColor(R.color.color_distance)), 0, distance.length() - 1,
// 0);

View file

@ -173,8 +173,7 @@ public class MapControlsLayer extends OsmandMapLayer {
private void initTopControls() {
View configureMap = mapActivity.findViewById(R.id.map_layers_button);
controls.add(createHudButton((ImageView) configureMap, R.drawable.map_layer_dark).setIconColorId(0).setBg(
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night));
controls.add(createHudButton((ImageView) configureMap, R.drawable.map_layer_dark).setIconColorId(0));
configureMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -184,8 +183,7 @@ public class MapControlsLayer extends OsmandMapLayer {
});
View compass = mapActivity.findViewById(R.id.map_compass_button);
compassHud = createHudButton((ImageView) compass, R.drawable.map_compass).setIconColorId(0).setBg(
R.drawable.btn_inset_circle, R.drawable.btn_inset_circle_night);
compassHud = createHudButton((ImageView) compass, R.drawable.map_compass).setIconColorId(0);
compassHud.compass = true;
controls.add(compassHud);
compass.setOnClickListener(new View.OnClickListener() {

View file

@ -221,7 +221,7 @@ public class MapInfoLayer extends OsmandMapLayer {
if (!transparent && !nightMode) {
ts.textShadowColor = Color.TRANSPARENT;
}
ts.textShadowRadius = ts.textShadowColor == 0 ? 0 : 15;
ts.textShadowRadius = (int) (ts.textShadowColor == 0 ? 0 : 4 * view.getDensity());
if (transparent) {
ts.boxTop = R.drawable.btn_flat_transparent;
ts.rightRes = R.drawable.btn_left_round_transparent;

View file

@ -168,6 +168,7 @@ public class MapInfoWidgetsFactory {
private final MapActivity map;
private View topBar;
private TextView addressText;
private TextView addressTextShadow;
private OsmAndLocationProvider locationProvider;
private WaypointHelper waypointHelper;
private OsmandSettings settings;
@ -178,6 +179,7 @@ public class MapInfoWidgetsFactory {
public TopTextView(OsmandApplication app, MapActivity map) {
topBar = map.findViewById(R.id.map_top_bar);
addressText = (TextView) map.findViewById(R.id.map_address_text);
addressTextShadow = (TextView) map.findViewById(R.id.map_address_text_shadow);
waypointInfoBar = map.findViewById(R.id.waypoint_info_bar);
this.routingHelper = app.getRoutingHelper();
locationProvider = app.getLocationProvider();
@ -206,9 +208,11 @@ public class MapInfoWidgetsFactory {
}
public void updateTextColor(boolean nightMode, int textColor, int textShadowColor, boolean bold, int rad) {
updateTextColor(addressText, textColor, textShadowColor, bold, rad);
updateTextColor((TextView) waypointInfoBar.findViewById(R.id.waypoint_text), textColor, textShadowColor,
bold, rad);
TextInfoWidget.updateTextColor(addressText, addressTextShadow, textColor, textShadowColor, bold, rad);
TextInfoWidget.updateTextColor((TextView) waypointInfoBar.findViewById(R.id.waypoint_text),
(TextView) waypointInfoBar.findViewById(R.id.waypoint_text_shadow),
textColor, textShadowColor, bold, rad);
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);
all.setImageDrawable(map.getMyApplication().getIconsCache()
@ -217,11 +221,7 @@ public class MapInfoWidgetsFactory {
.getActionBarIcon(R.drawable.ic_action_remove_dark, !nightMode));
}
private void updateTextColor(TextView tv, int textColor, int textShadowColor, boolean textBold, int rad) {
tv.setTextColor(textColor);
tv.setShadowLayer(rad, 0, 0, textShadowColor);
tv.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
}
public boolean updateInfo(DrawSettings d) {
String text = null;
@ -266,22 +266,29 @@ public class MapInfoWidgetsFactory {
if(!showNextTurn && updateWaypoint()) {
updateVisibility(true);
updateVisibility(addressText, false);
updateVisibility(addressTextShadow, false);
} else if(text == null) {
updateVisibility(false);
} else {
updateVisibility(true);
updateVisibility(waypointInfoBar, false);
updateVisibility(addressText, true);
updateVisibility(addressTextShadow, true);
boolean update = turnDrawable.setTurnType(type[0]);
int h = addressText.getHeight() / 4 * 3;
if (h != turnDrawable.getBounds().bottom) {
turnDrawable.setBounds(0, 0, h, h);
}
if (update) {
if (type[0] != null) {
addressTextShadow.setCompoundDrawables(turnDrawable, null, null, null);
addressText.setCompoundDrawables(turnDrawable, null, null, null);
addressText.setCompoundDrawablePadding(4);
addressTextShadow.setCompoundDrawablePadding(4);
} else {
addressText.setCompoundDrawables(null, null, null, null);
addressTextShadow.setCompoundDrawables(null, null, null, null);
}
}
if (!text.equals(addressText.getText().toString())) {
@ -291,6 +298,7 @@ public class MapInfoWidgetsFactory {
topBar.setContentDescription(map.getResources().getString(R.string.map_widget_top_text));
}
addressText.setText(text);
addressTextShadow.setText(text);
return true;
}
}
@ -307,6 +315,7 @@ public class MapInfoWidgetsFactory {
return false;
} else {
updateVisibility(addressText, false);
updateVisibility(addressTextShadow, false);
boolean updated = updateVisibility(waypointInfoBar, true);
// pass top bar to make it clickable
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,

View file

@ -520,6 +520,7 @@ public class RouteInfoWidgetsFactory {
private OsmandSettings settings;
private ImageView lanesView;
private TextView lanesText;
private TextView lanesShadowText;
private OsmandApplication app;
private int dist;
private LanesDrawable lanesDrawable;
@ -529,6 +530,7 @@ public class RouteInfoWidgetsFactory {
public LanesControl(final MapActivity map, final OsmandMapTileView view) {
lanesView = (ImageView) map.findViewById(R.id.map_lanes);
lanesText = (TextView) map.findViewById(R.id.map_lanes_dist_text);
lanesShadowText = (TextView) map.findViewById(R.id.map_lanes_dist_text_shadow);
centerInfo = (View) map.findViewById(R.id.map_center_info);
progress = (View) map.findViewById(R.id.map_horizontal_progress);
lanesDrawable = new LanesDrawable(map, map.getMapView().getScaleCoefficient());
@ -541,9 +543,7 @@ public class RouteInfoWidgetsFactory {
}
public void updateTextSize(boolean isNight, int textColor, int textShadowColor, boolean textBold, int shadowRadius) {
lanesText.setTextColor(textColor);
lanesText.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
lanesText.setShadowLayer(shadowRadius, 0, 0, textShadowColor);
TextInfoWidget.updateTextColor(lanesText, lanesShadowText, textColor, textShadowColor, textBold, shadowRadius);
}
public boolean updateInfo(DrawSettings drawSettings) {
@ -604,13 +604,17 @@ public class RouteInfoWidgetsFactory {
this.dist = dist;
if(dist == 0) {
lanesText.setText("");
lanesShadowText.setText("");
} else {
lanesText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
lanesShadowText.setText(OsmAndFormatter.getFormattedDistance(dist, app));
}
lanesText.invalidate();
lanesShadowText.invalidate();
}
}
updateVisibility(lanesText, visible);
updateVisibility(lanesShadowText, visible);
updateVisibility(lanesView, visible);
updateVisibility(centerInfo, visible || progress.getVisibility() == View.VISIBLE);
return true;
@ -715,6 +719,7 @@ public class RouteInfoWidgetsFactory {
private View layout;
private ImageView icon;
private TextView text;
private TextView textShadow;
private MapActivity ma;
private String cacheRulerText;
private int maxWidth;
@ -728,13 +733,13 @@ public class RouteInfoWidgetsFactory {
layout = ma.findViewById(R.id.map_ruler_layout);
icon = (ImageView) ma.findViewById(R.id.map_ruler_image);
text = (TextView) ma.findViewById(R.id.map_ruler_text);
textShadow = (TextView) ma.findViewById(R.id.map_ruler_text_shadow);
maxWidth = ma.getResources().getDimensionPixelSize(R.dimen.map_ruler_width);
orientationPortrait = ScreenOrientationHelper.isOrientationPortrait(ma);
}
public void updateTextSize(boolean isNight, int textColor, int textShadowColor, int shadowRadius) {
text.setTextColor(textColor);
text.setShadowLayer(shadowRadius, 0, 0, textShadowColor);
TextInfoWidget.updateTextColor(text, textShadow, textColor, textShadowColor, false, 3);
icon.setBackgroundResource(isNight ? R.drawable.ruler_night : R.drawable.ruler);
}
@ -759,6 +764,7 @@ public class RouteInfoWidgetsFactory {
int cacheRulerDistPix = (int) (pixDensity * roundedDist);
cacheRulerText = OsmAndFormatter.getFormattedDistance((float) roundedDist, view.getApplication());
text.setText(cacheRulerText);
textShadow.setText(cacheRulerText);
ViewGroup.LayoutParams lp = layout.getLayoutParams();
lp.width = cacheRulerDistPix;
layout.setLayoutParams(lp);

View file

@ -4,6 +4,7 @@ import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
import android.app.Activity;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.view.View;
@ -17,7 +18,9 @@ public class TextInfoWidget {
private View view;
private ImageView imageView;
private TextView textView;
private TextView textViewShadow;
private TextView smallTextView;
private TextView smallTextViewShadow;
private ImageView topImageView;
private TextView topTextView;
private boolean explicitlyVisible;
@ -35,6 +38,8 @@ public class TextInfoWidget {
topTextView = (TextView) view.findViewById(R.id.widget_top_icon_text);
imageView = (ImageView) view.findViewById(R.id.widget_icon);
textView = (TextView) view.findViewById(R.id.widget_text);
textViewShadow = (TextView) view.findViewById(R.id.widget_text_shadow);
smallTextViewShadow = (TextView) view.findViewById(R.id.widget_text_small_shadow);
smallTextView = (TextView) view.findViewById(R.id.widget_text_small);
}
@ -121,13 +126,17 @@ public class TextInfoWidget {
// }
if(text == null) {
textView.setText("");
textViewShadow.setText("");
} else {
textView.setText(text);
textViewShadow.setText(text);
}
if(subtext == null) {
smallTextView.setText("");
smallTextViewShadow.setText("");
} else {
smallTextView.setText(subtext);
smallTextViewShadow.setText(subtext);
}
}
@ -172,14 +181,26 @@ public class TextInfoWidget {
}
public void updateTextColor(int textColor, int textShadowColor, boolean bold, int rad) {
updateTextColor(smallTextView, textColor, textShadowColor, bold, rad);
updateTextColor(textView, textColor, textShadowColor, bold, rad);
updateTextColor(topTextView, textColor, textShadowColor, bold, rad);
updateTextColor(smallTextView, smallTextViewShadow, textColor, textShadowColor, bold, rad);
updateTextColor(textView, textViewShadow, textColor, textShadowColor, bold, rad);
updateTextColor(topTextView, null, textColor, textShadowColor, bold, rad);
}
private void updateTextColor(TextView tv, int textColor, int textShadowColor, boolean textBold, int rad) {
public static void updateTextColor(TextView tv, TextView shadow, int textColor, int textShadowColor, boolean textBold, int rad) {
if(shadow != null) {
if(rad > 0) {
shadow.setVisibility(View.VISIBLE);
shadow.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
shadow.getPaint().setStrokeWidth(rad);
shadow.getPaint().setStyle(Style.STROKE);
shadow.setTextColor(textShadowColor);
// tv.getPaint().setStyle(Style.FILL);
} else {
// tv.getPaint().setStyle(Style.FILL_AND_STROKE);
shadow.setVisibility(View.GONE);
}
}
tv.setTextColor(textColor);
tv.setShadowLayer(rad, 0, 0, textShadowColor);
tv.setTypeface(Typeface.DEFAULT, textBold ? Typeface.BOLD : Typeface.NORMAL);
}

View file

@ -1,14 +1,15 @@
package net.osmand.plus.widgets;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Typeface;
import android.os.Build;
import android.support.v7.internal.text.AllCapsTransformationMethod;
import android.util.AttributeSet;
import android.widget.TextView;
import net.osmand.plus.R;
import net.osmand.plus.helpers.FontCache;
@ -71,7 +72,7 @@ public class TextViewEx extends TextView {
public static void setAllCapsCompat(TextView target, boolean allCaps) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
target.setAllCaps(allCaps);
updateAllCapsNewAPI(target, allCaps);
return;
}
@ -82,6 +83,11 @@ public class TextViewEx extends TextView {
}
}
@SuppressLint("NewApi")
private static void updateAllCapsNewAPI(TextView target, boolean allCaps) {
target.setAllCaps(allCaps);
}
public void setAllCapsCompat(boolean allCaps) {
setAllCapsCompat(this, allCaps);
}
@ -99,4 +105,5 @@ public class TextViewEx extends TextView {
}
setAllCapsCompat(target, true);
}
}