Fix day/night colors in configure map, waypoints, context menu

This commit is contained in:
Alexey Kulish 2015-12-14 20:58:50 +03:00
parent 0d5f82a757
commit d05eead459
19 changed files with 250 additions and 111 deletions

View file

@ -298,6 +298,7 @@
android:src="@drawable/map_action_fav_dark"/> android:src="@drawable/map_action_fav_dark"/>
<View <View
android:id="@+id/divider_hor_1"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
@ -313,6 +314,7 @@
android:src="@drawable/map_action_flag_dark"/> android:src="@drawable/map_action_flag_dark"/>
<View <View
android:id="@+id/divider_hor_2"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>
@ -328,6 +330,7 @@
android:src="@drawable/map_action_gshare_dark"/> android:src="@drawable/map_action_gshare_dark"/>
<View <View
android:id="@+id/divider_hor_3"
android:layout_width="1dp" android:layout_width="1dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/dashboard_divider"/> android:background="?attr/dashboard_divider"/>

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="primary_text_light">#de000000</color>
<color name="secondary_text_light">#8a000000</color>
<color name="primary_text_dark">#ffffffff</color>
<color name="secondary_text_dark">#b3ffffff</color>
<color name="audio_video_icon_color">#128a89</color> <color name="audio_video_icon_color">#128a89</color>
<color name="created_poi_icon_color">#4caf50</color> <color name="created_poi_icon_color">#4caf50</color>
<color name="osm_bug_unresolved_icon_color">#d44a4a</color> <color name="osm_bug_unresolved_icon_color">#d44a4a</color>

View file

@ -1,8 +1,6 @@
package net.osmand; package net.osmand;
import java.util.Date;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.content.res.Configuration; import android.content.res.Configuration;
@ -11,6 +9,11 @@ import android.text.format.DateFormat;
import android.view.View; import android.view.View;
import android.view.ViewParent; import android.view.ViewParent;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import net.osmand.plus.R;
import java.util.Date;
public class AndroidUtils { public class AndroidUtils {
@ -77,4 +80,20 @@ public class AndroidUtils {
view.setBackgroundDrawable(ctx.getResources().getDrawable(night ? darkResId : lightResId)); view.setBackgroundDrawable(ctx.getResources().getDrawable(night ? darkResId : lightResId));
} }
} }
public static void setDashButtonBackground(Context ctx, View view, boolean night) {
setBackground(ctx, view, night, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
}
public static void setTextPrimaryColor(Context ctx, TextView textView, boolean night) {
textView.setTextColor(night ?
ctx.getResources().getColor(R.color.primary_text_dark)
: ctx.getResources().getColor(R.color.primary_text_light));
}
public static void setTextSecondaryColor(Context ctx, TextView textView, boolean night) {
textView.setTextColor(night ?
ctx.getResources().getColor(R.color.secondary_text_dark)
: ctx.getResources().getColor(R.color.secondary_text_light));
}
} }

View file

@ -14,6 +14,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.plus.activities.actions.AppModeDialog; import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.dialogs.ConfigureMapMenu;
@ -330,7 +331,7 @@ public class ContextMenuAdapter {
Integer lid = getLayoutId(position); Integer lid = getLayoutId(position);
if (lid == R.layout.mode_toggles) { if (lid == R.layout.mode_toggles) {
final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>(); final Set<ApplicationMode> selected = new LinkedHashSet<ApplicationMode>();
return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, false, new View.OnClickListener() { return AppModeDialog.prepareAppModeDrawerView(activity, visibleModes, selected, allModes, true, new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
if (selected.size() > 0) { if (selected.size() > 0) {
@ -348,6 +349,9 @@ public class ContextMenuAdapter {
convertView.setTag(lid); convertView.setTag(lid);
} }
TextView tv = (TextView) convertView.findViewById(R.id.title); TextView tv = (TextView) convertView.findViewById(R.id.title);
if (!isCategory(position)) {
AndroidUtils.setTextPrimaryColor(ctx, tv, !holoLight);
}
tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position)); tv.setText(isCategory(position) ? getItemName(position).toUpperCase() : getItemName(position));
if (layoutId == R.layout.simple_list_menu_item) { if (layoutId == R.layout.simple_list_menu_item) {

View file

@ -763,6 +763,7 @@ public class MapActivity extends AccessibleActivity implements DownloadEvents,
mapLayers.getMapInfoLayer().recreateControls(); mapLayers.getMapInfoLayer().recreateControls();
} }
mapLayers.updateLayers(mapView); mapLayers.updateLayers(mapView);
mapActions.updateDrawerMenu();
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity()); mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());
app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() { app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() {

View file

@ -4,6 +4,8 @@ import android.app.Activity;
import android.app.Dialog; import android.app.Dialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
@ -797,15 +799,19 @@ public class MapActivityActions implements DialogProvider {
menu.show(); menu.show();
} }
protected void updateDrawerMenu() { protected void updateDrawerMenu() {
boolean nightMode = getMyApplication().getDaynightHelper().isNightMode();
final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems); final ListView menuItemsListView = (ListView) mapActivity.findViewById(R.id.menuItems);
if (nightMode) {
menuItemsListView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
menuItemsListView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
menuItemsListView.setDivider(null); menuItemsListView.setDivider(null);
final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu(); final ContextMenuAdapter contextMenuAdapter = createMainOptionsMenu();
contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item); contextMenuAdapter.setDefaultLayoutId(R.layout.simple_list_menu_item);
final ArrayAdapter<?> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity, final ArrayAdapter<?> simpleListAdapter = contextMenuAdapter.createListAdapter(mapActivity,
settings.OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME); !nightMode);
menuItemsListView.setAdapter(simpleListAdapter); menuItemsListView.setAdapter(simpleListAdapter);
menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { menuItemsListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override

View file

@ -95,7 +95,8 @@ public class DashWaypointsFragment extends DashLocationFragment {
LocationPointWrapper ps = allPoints.get(i); LocationPointWrapper ps = allPoints.get(i);
View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null); View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
favorites.addView(dv); favorites.addView(dv);
View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(), getActivity(), null, ps, null); View v = WaypointDialogHelper.updateWaypointItemView(false, null, getMyApplication(),
getActivity(), null, ps, null, !getMyApplication().getSettings().isLightContent());
favorites.addView(v); favorites.addView(v);
} }

View file

@ -2,12 +2,15 @@ package net.osmand.plus.dashboard;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Intent; import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction; import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.animation.Animation; import android.view.animation.Animation;
@ -57,9 +60,13 @@ import net.osmand.plus.views.OsmandMapTileView;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
/** /**
*/ */
@ -124,6 +131,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
private final int[] running = new int[]{-1}; private final int[] running = new int[]{-1};
private List<LocationPointWrapper> deletedPoints = new ArrayList<>(); private List<LocationPointWrapper> deletedPoints = new ArrayList<>();
private Drawable gradientToolbar; private Drawable gradientToolbar;
boolean nightMode;
public DashFragmentData[] getFragmentsData() { public DashFragmentData[] getFragmentsData() {
return fragmentsData; return fragmentsData;
@ -136,9 +144,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
CONFIGURE_SCREEN, CONFIGURE_SCREEN,
CONFIGURE_MAP, CONFIGURE_MAP,
LIST_MENU, LIST_MENU,
ROUTE_SETTINGS,
DASHBOARD DASHBOARD
} }
private Map<DashboardActionButtonType, DashboardActionButton> actionButtons = new HashMap<>();
public enum DashboardActionButtonType {
MY_LOCATION,
NAVIGATE
}
private class DashboardActionButton {
private Drawable icon;
private View.OnClickListener onClickListener;
}
public DashboardOnMap(MapActivity ma) { public DashboardOnMap(MapActivity ma) {
this.mapActivity = ma; this.mapActivity = ma;
} }
@ -181,7 +202,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener); dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener); dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
initActionButton(); initActionButtons();
dashboardView.addView(actionButton); dashboardView.addView(actionButton);
} }
@ -312,7 +333,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
private void initActionButton() { private void initActionButtons() {
actionButton = new ImageView(mapActivity); actionButton = new ImageView(mapActivity);
int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size); int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size);
int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding); int topPad = (int) mapActivity.getResources().getDimension(R.dimen.dashboard_map_top_padding);
@ -325,11 +346,13 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT; params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
actionButton.setLayoutParams(params); actionButton.setLayoutParams(params);
actionButton.setScaleType(ScaleType.CENTER); actionButton.setScaleType(ScaleType.CENTER);
actionButton.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.map_my_location));
actionButton.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue)); actionButton.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue));
hideActionButton(); hideActionButton();
actionButton.setOnClickListener(new View.OnClickListener() {
DashboardActionButton myLocationButton = new DashboardActionButton();
myLocationButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_my_location);
myLocationButton.onClickListener = new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (getMyApplication().accessibilityEnabled()) { if (getMyApplication().accessibilityEnabled()) {
@ -339,9 +362,38 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
hideDashboard(); hideDashboard();
} }
}); };
DashboardActionButton navigateButton = new DashboardActionButton();
navigateButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_start_navigation);
navigateButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
hideDashboard();
}
};
actionButtons.put(DashboardActionButtonType.MY_LOCATION, myLocationButton);
actionButtons.put(DashboardActionButtonType.NAVIGATE, navigateButton);
} }
private void setActionButton(DashboardType type) {
DashboardActionButton button = null;
if (type == DashboardType.DASHBOARD
|| type == DashboardType.LIST_MENU
|| type == DashboardType.CONFIGURE_SCREEN) {
button = actionButtons.get(DashboardActionButtonType.MY_LOCATION);
} else if (type == DashboardType.ROUTE_SETTINGS) {
button = actionButtons.get(DashboardActionButtonType.NAVIGATE);
}
if (button != null) {
actionButton.setImageDrawable(button.icon);
actionButton.setOnClickListener(button.onClickListener);
}
}
private void hideActionButton() { private void hideActionButton() {
actionButton.setVisibility(View.GONE); actionButton.setVisibility(View.GONE);
@ -403,6 +455,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
if (visible == this.visible && type == visibleType) { if (visible == this.visible && type == visibleType) {
return; return;
} }
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
this.previousVisibleType = prevItem; this.previousVisibleType = prevItem;
this.visible = visible; this.visible = visible;
boolean refresh = this.visibleType == type; boolean refresh = this.visibleType == type;
@ -419,6 +472,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
mapActivity.disableDrawer(); mapActivity.disableDrawer();
dashboardView.setVisibility(View.VISIBLE); dashboardView.setVisibility(View.VISIBLE);
if (isActionButtonVisible()) { if (isActionButtonVisible()) {
setActionButton(visibleType);
actionButton.setVisibility(View.VISIBLE); actionButton.setVisibility(View.VISIBLE);
} else { } else {
hideActionButton(); hideActionButton();
@ -444,6 +498,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
updateListAdapter(); updateListAdapter();
updateListBackgroundHeight(); updateListBackgroundHeight();
} }
applyDayNightMode();
} }
mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE); mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE); mapActivity.findViewById(R.id.MapHudButtonsOverlay).setVisibility(View.INVISIBLE);
@ -466,18 +521,41 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
} }
private void applyDayNightMode() {
if (nightMode) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
}
}
private int dpToPx(float dp) {
Resources r = mapActivity.getResources();
return (int) TypedValue.applyDimension(
COMPLEX_UNIT_DIP,
dp,
r.getDisplayMetrics()
);
}
private void updateListAdapter() { private void updateListAdapter() {
ContextMenuAdapter cm = null; ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) { if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running, ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType); DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter); listAdapter);
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
} else if (DashboardType.WAYPOINTS_EDIT == visibleType) { } else if (DashboardType.WAYPOINTS_EDIT == visibleType) {
deletedPoints.clear(); deletedPoints.clear();
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running, ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType); DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running, OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter); listAdapter);
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
@ -497,8 +575,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
public void updateListAdapter(ContextMenuAdapter cm) { public void updateListAdapter(ContextMenuAdapter cm) {
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings() boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
.isLightContent()); if (this.nightMode != nightMode) {
this.nightMode = nightMode;
applyDayNightMode();
}
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, !nightMode);
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter); OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
updateListAdapter(listAdapter, listener); updateListAdapter(listAdapter, listener);
} }
@ -765,7 +847,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
} }
private boolean isActionButtonVisible() { private boolean isActionButtonVisible() {
return visibleType == DashboardType.DASHBOARD || visibleType == DashboardType.LIST_MENU || visibleType == DashboardType.CONFIGURE_SCREEN; return visibleType == DashboardType.DASHBOARD
|| visibleType == DashboardType.LIST_MENU
|| visibleType == DashboardType.ROUTE_SETTINGS
|| visibleType == DashboardType.CONFIGURE_SCREEN;
} }
private boolean isBackButtonVisible() { private boolean isBackButtonVisible() {

View file

@ -16,7 +16,7 @@ import android.widget.ImageButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.data.FavouritePoint; import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint; import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -59,10 +59,12 @@ public class WaypointDialogHelper {
} }
public static void updatePointInfoView(final OsmandApplication app, final Activity activity, public static void updatePointInfoView(final OsmandApplication app, final Activity activity,
View localView, final LocationPointWrapper ps, final boolean mapCenter) { View localView, final LocationPointWrapper ps,
final boolean mapCenter, final boolean nightMode) {
WaypointHelper wh = app.getWaypointHelper(); WaypointHelper wh = app.getWaypointHelper();
final LocationPoint point = ps.getPoint(); final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text); TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
AndroidUtils.setTextPrimaryColor(activity, text, nightMode);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow); TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
localView.setOnClickListener(new View.OnClickListener() { localView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -112,7 +114,7 @@ public class WaypointDialogHelper {
public ArrayAdapter<Object> getWaypointsDrawerAdapter( public ArrayAdapter<Object> getWaypointsDrawerAdapter(
final boolean edit, final List<LocationPointWrapper> deletedPoints, final boolean edit, final List<LocationPointWrapper> deletedPoints,
final MapActivity ctx, final int[] running, final boolean flat) { final MapActivity ctx, final int[] running, final boolean flat, final boolean nightMode) {
final List<Object> points; final List<Object> points;
if(flat) { if(flat) {
points = new ArrayList<Object>(waypointHelper.getAllPoints()); points = new ArrayList<Object>(waypointHelper.getAllPoints());
@ -130,12 +132,12 @@ public class WaypointDialogHelper {
boolean labelView = (getItem(position) instanceof Integer); boolean labelView = (getItem(position) instanceof Integer);
if (getItem(position) instanceof RadiusItem) { if (getItem(position) instanceof RadiusItem) {
final int type = ((RadiusItem) getItem(position)).type; final int type = ((RadiusItem) getItem(position)).type;
v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter); v = createItemForRadiusProximity(ctx, type, running, position, thisAdapter, nightMode);
} else if (labelView) { } else if (labelView) {
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter); v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter, nightMode);
} else { } else {
LocationPointWrapper point = (LocationPointWrapper) getItem(position); LocationPointWrapper point = (LocationPointWrapper) getItem(position);
v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this); v = updateWaypointItemView(edit, deletedPoints, app, ctx, v, point, this, nightMode);
} }
return v; return v;
} }
@ -148,18 +150,18 @@ public class WaypointDialogHelper {
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints, public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
final OsmandApplication app, final Activity ctx, View v, final LocationPointWrapper point, final OsmandApplication app, final Activity ctx, View v, final LocationPointWrapper point,
final ArrayAdapter adapter) { final ArrayAdapter adapter, final boolean nightMode) {
if (v == null || v.findViewById(R.id.info_close) == null) { if (v == null || v.findViewById(R.id.info_close) == null) {
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null); v = ctx.getLayoutInflater().inflate(R.layout.waypoint_reached, null);
} }
updatePointInfoView(app, ctx, v, point, true); updatePointInfoView(app, ctx, v, point, true, nightMode);
View remove = v.findViewById(R.id.info_close); View remove = v.findViewById(R.id.info_close);
if (!edit) { if (!edit) {
remove.setVisibility(View.GONE); remove.setVisibility(View.GONE);
} else { } else {
remove.setVisibility(View.VISIBLE); remove.setVisibility(View.VISIBLE);
((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon( ((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_action_gremove_dark)); R.drawable.ic_action_gremove_dark, !nightMode));
remove.setOnClickListener(new View.OnClickListener() { remove.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
@ -178,12 +180,13 @@ public class WaypointDialogHelper {
protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running, protected View createItemForRadiusProximity(final FragmentActivity ctx, final int type, final int[] running,
final int position, final ArrayAdapter<Object> thisAdapter) { final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) {
View v; View v;
IconsCache iconsCache = app.getIconsCache(); IconsCache iconsCache = app.getIconsCache();
v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null); v = ctx.getLayoutInflater().inflate(R.layout.drawer_list_radius, null);
AndroidUtils.setTextPrimaryColor(mapActivity, (TextView) v.findViewById(R.id.title), nightMode);
final TextView radius = (TextView) v.findViewById(R.id.description); final TextView radius = (TextView) v.findViewById(R.id.description);
((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_poi_radius_dark)); ((ImageView) v.findViewById(R.id.waypoint_icon)).setImageDrawable(iconsCache.getContentIcon(R.drawable.ic_poi_radius_dark, !nightMode));
radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app)); radius.setText(OsmAndFormatter.getFormattedDistance(waypointHelper.getSearchDeviationRadius(type), app));
radius.setOnClickListener(new View.OnClickListener() { radius.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -196,7 +199,7 @@ public class WaypointDialogHelper {
} }
protected View createItemForCategory(final FragmentActivity ctx, final int type, final int[] running, protected View createItemForCategory(final FragmentActivity ctx, final int type, final int[] running,
final int position, final ArrayAdapter<Object> thisAdapter) { final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) {
View v; View v;
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null); v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item); final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
@ -222,6 +225,7 @@ public class WaypointDialogHelper {
}); });
TextView tv = (TextView) v.findViewById(R.id.header_text); TextView tv = (TextView) v.findViewById(R.id.header_text);
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(getHeader(type, checked, ctx)); tv.setText(getHeader(type, checked, ctx));
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -1,7 +1,6 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -15,7 +14,7 @@ public abstract class BaseMenuController {
private MapActivity mapActivity; private MapActivity mapActivity;
private boolean portraitMode; private boolean portraitMode;
private boolean largeDevice; private boolean largeDevice;
private boolean light; private boolean nightMode;
public BaseMenuController(MapActivity mapActivity) { public BaseMenuController(MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
@ -25,7 +24,7 @@ public abstract class BaseMenuController {
private void init() { private void init() {
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity); portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity); largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
light = mapActivity.getMyApplication().getSettings().isLightContent(); updateNightMode();
} }
public MapActivity getMapActivity() { public MapActivity getMapActivity() {
@ -38,7 +37,11 @@ public abstract class BaseMenuController {
} }
public boolean isLight() { public boolean isLight() {
return light; return !nightMode;
}
public void updateNightMode() {
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
} }
public boolean isLandscapeLayout() { public boolean isLandscapeLayout() {
@ -75,7 +78,7 @@ public abstract class BaseMenuController {
} }
protected Drawable getIcon(int iconId) { protected Drawable getIcon(int iconId) {
return getIcon(iconId, R.color.icon_color, R.color.icon_color_light); return getIcon(iconId, isLight() ? R.color.icon_color : R.color.icon_color_light);
} }
protected Drawable getIcon(int iconId, int colorId) { protected Drawable getIcon(int iconId, int colorId) {
@ -92,13 +95,4 @@ public abstract class BaseMenuController {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache(); IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId); return iconsCache.getIcon(iconId, isLight() ? colorLightId : colorDarkId);
} }
protected int getResIdFromAttribute(final int attr) {
if (attr == 0)
return 0;
final TypedValue typedvalueattr = new TypedValue();
getMapActivity().getTheme().resolveAttribute(attr, typedvalueattr, true);
return typedvalueattr.resourceId;
}
} }

View file

@ -644,6 +644,14 @@ public class MapContextMenu extends MenuTitleController {
} }
} }
public boolean isNightMode() {
if (menuController != null) {
return !menuController.isLight();
} else {
return mapActivity.getMyApplication().getDaynightHelper().isNightMode();
}
}
public boolean hasHiddenBottomInfo() { public boolean hasHiddenBottomInfo() {
return getCurrentMenuState() == MenuState.HEADER_ONLY; return getCurrentMenuState() == MenuState.HEADER_ONLY;
} }

View file

@ -29,6 +29,7 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint; import net.osmand.data.QuadPoint;
@ -90,6 +91,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private int origMarkerY; private int origMarkerY;
private boolean customMapCenter; private boolean customMapCenter;
private boolean moving; private boolean moving;
private boolean nightMode;
private float skipHalfScreenStateLimit; private float skipHalfScreenStateLimit;
@ -149,6 +151,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (!menu.isActive()) { if (!menu.isActive()) {
return view; return view;
} }
nightMode = menu.isNightMode();
mainView = view.findViewById(R.id.context_menu_main); mainView = view.findViewById(R.id.context_menu_main);
leftTitleButtonController = menu.getLeftTitleButtonController(); leftTitleButtonController = menu.getLeftTitleButtonController();
@ -173,7 +176,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
} }
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
// Left title button // Left title button
final Button leftTitleButton = (Button) view.findViewById(R.id.title_button); final Button leftTitleButton = (Button) view.findViewById(R.id.title_button);
@ -212,7 +214,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (titleProgressController != null) { if (titleProgressController != null) {
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton); final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark, progressButton.setImageDrawable(iconsCache.getIcon(R.drawable.ic_action_remove_dark,
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
progressButton.setOnClickListener(new View.OnClickListener() { progressButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -333,6 +335,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
View topShadowView = view.findViewById(R.id.context_menu_top_shadow); View topShadowView = view.findViewById(R.id.context_menu_top_shadow);
topShadowView.setOnTouchListener(slideTouchListener); topShadowView.setOnTouchListener(slideTouchListener);
View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all); View topShadowAllView = view.findViewById(R.id.context_menu_top_shadow_all);
AndroidUtils.setBackground(getMapActivity(), topShadowAllView, nightMode, R.drawable.bg_map_context_menu_light,
R.drawable.bg_map_context_menu_dark);
topShadowAllView.setOnTouchListener(new View.OnTouchListener() { topShadowAllView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
public boolean onTouch(View v, MotionEvent event) { public boolean onTouch(View v, MotionEvent event) {
@ -345,6 +349,25 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
buildHeader(); buildHeader();
AndroidUtils.setTextPrimaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.context_menu_line1), nightMode);
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.context_menu_line2), nightMode);
((Button) view.findViewById(R.id.title_button_top_right))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.distance), nightMode);
((Button) view.findViewById(R.id.title_button))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.title_button_right_text), nightMode);
((Button) view.findViewById(R.id.title_button_right))
.setTextColor(!nightMode ? getResources().getColor(R.color.map_widget_blue) : getResources().getColor(R.color.osmand_orange));
AndroidUtils.setTextSecondaryColor(getMapActivity(),
(TextView) view.findViewById(R.id.progressTitle), nightMode);
// FAB // FAB
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view); fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
if (menu.fabVisible()) { if (menu.fabVisible()) {
@ -363,17 +386,27 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
fabView.setVisibility(View.GONE); fabView.setVisibility(View.GONE);
} }
if (!menu.buttonsVisible()) {
View buttonsTopBorder = view.findViewById(R.id.buttons_top_border); View buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
AndroidUtils.setBackground(getMapActivity(), buttonsTopBorder, nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
if (!menu.buttonsVisible()) {
View buttons = view.findViewById(R.id.context_menu_buttons); View buttons = view.findViewById(R.id.context_menu_buttons);
buttonsTopBorder.setVisibility(View.GONE); buttonsTopBorder.setVisibility(View.GONE);
buttons.setVisibility(View.GONE); buttons.setVisibility(View.GONE);
} }
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_1), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_2), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
AndroidUtils.setBackground(getMapActivity(), mainView.findViewById(R.id.divider_hor_3), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
// Action buttons // Action buttons
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button); final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(), buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(),
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonFavorite, nightMode);
buttonFavorite.setOnClickListener(new View.OnClickListener() { buttonFavorite.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -383,7 +416,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button); final ImageButton buttonWaypoint = (ImageButton) view.findViewById(R.id.context_menu_route_button);
buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_flag_dark, buttonWaypoint.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_flag_dark,
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonWaypoint, nightMode);
buttonWaypoint.setOnClickListener(new View.OnClickListener() { buttonWaypoint.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -393,7 +427,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button); final ImageButton buttonShare = (ImageButton) view.findViewById(R.id.context_menu_share_button);
buttonShare.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_gshare_dark, buttonShare.setImageDrawable(iconsCache.getIcon(R.drawable.map_action_gshare_dark,
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonShare, nightMode);
buttonShare.setOnClickListener(new View.OnClickListener() { buttonShare.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -403,7 +438,8 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
final ImageButton buttonMore = (ImageButton) view.findViewById(R.id.context_menu_more_button); final ImageButton buttonMore = (ImageButton) view.findViewById(R.id.context_menu_more_button);
buttonMore.setImageDrawable(iconsCache.getIcon(R.drawable.map_overflow_menu_white, buttonMore.setImageDrawable(iconsCache.getIcon(R.drawable.map_overflow_menu_white,
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
AndroidUtils.setDashButtonBackground(getMapActivity(), buttonMore, nightMode);
buttonMore.setOnClickListener(new View.OnClickListener() { buttonMore.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
@ -413,6 +449,11 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
buildBottomView(); buildBottomView();
view.findViewById(R.id.context_menu_bottom_scroll).setBackgroundColor(nightMode ?
getResources().getColor(R.color.ctx_menu_info_view_bg_dark) : getResources().getColor(R.color.ctx_menu_info_view_bg_light));
view.findViewById(R.id.context_menu_bottom_view).setBackgroundColor(nightMode ?
getResources().getColor(R.color.ctx_menu_info_view_bg_dark) : getResources().getColor(R.color.ctx_menu_info_view_bg_light));
getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false); getMapActivity().getMapLayers().getMapControlsLayer().setControlsClickable(false);
return view; return view;
@ -606,7 +647,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private void buildHeader() { private void buildHeader() {
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout); final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view); final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
@ -617,7 +657,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
iconLayout.setVisibility(View.VISIBLE); iconLayout.setVisibility(View.VISIBLE);
} else if (iconId != 0) { } else if (iconId != 0) {
iconView.setImageDrawable(iconsCache.getIcon(iconId, iconView.setImageDrawable(iconsCache.getIcon(iconId,
light ? R.color.osmand_orange : R.color.osmand_orange_dark)); !nightMode ? R.color.osmand_orange : R.color.osmand_orange_dark));
iconLayout.setVisibility(View.VISIBLE); iconLayout.setVisibility(View.VISIBLE);
} else { } else {
iconLayout.setVisibility(View.GONE); iconLayout.setVisibility(View.GONE);
@ -669,10 +709,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public void rebuildMenu() { public void rebuildMenu() {
IconsCache iconsCache = getMyApplication().getIconsCache(); IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button); final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(), buttonFavorite.setImageDrawable(iconsCache.getIcon(menu.getFavActionIconId(),
light ? R.color.icon_color : R.color.dashboard_subheader_text_dark)); !nightMode ? R.color.icon_color : R.color.dashboard_subheader_text_dark));
buildHeader(); buildHeader();

View file

@ -34,7 +34,7 @@ public class MenuBuilder {
protected OsmandApplication app; protected OsmandApplication app;
protected LinkedList<PlainMenuItem> plainMenuItems; protected LinkedList<PlainMenuItem> plainMenuItems;
private boolean firstRow; private boolean firstRow;
private boolean light; protected boolean light;
public class PlainMenuItem { public class PlainMenuItem {
private int iconId; private int iconId;
@ -66,6 +66,10 @@ public class MenuBuilder {
light = app.getSettings().isLightContent(); light = app.getSettings().isLightContent();
} }
public void setLight(boolean light) {
this.light = light;
}
public void build(View view) { public void build(View view) {
firstRow = true; firstRow = true;
if (needBuildPlainMenuItems()) { if (needBuildPlainMenuItems()) {

View file

@ -65,6 +65,7 @@ public abstract class MenuController extends BaseMenuController {
this.pointDescription = pointDescription; this.pointDescription = pointDescription;
this.builder = builder; this.builder = builder;
this.currentMenuState = getInitialMenuState(); this.currentMenuState = getInitialMenuState();
this.builder.setLight(isLight());
} }
public void build(View rootView) { public void build(View rootView) {
@ -287,7 +288,7 @@ public abstract class MenuController extends BaseMenuController {
public Drawable getLeftIcon() { public Drawable getLeftIcon() {
if (leftIconId != 0) { if (leftIconId != 0) {
return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor)); return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
} else { } else {
return null; return null;
} }

View file

@ -53,7 +53,6 @@ public class AmenityMenuBuilder extends MenuBuilder {
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix, protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix,
int textColor, boolean isWiki, boolean isText, boolean needLinks, int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl) { boolean isPhoneNumber, boolean isUrl) {
boolean light = app.getSettings().isLightContent();
if (!isFirstRow()) { if (!isFirstRow()) {
buildRowDivider(view, false); buildRowDivider(view, false);

View file

@ -1,6 +1,5 @@
package net.osmand.plus.mapcontextmenu.builders; package net.osmand.plus.mapcontextmenu.builders;
import android.content.res.Resources;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.View; import android.view.View;
@ -49,10 +48,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
int gpxSmallTextMargin = (int) ll.getResources().getDimension(R.dimen.gpx_small_text_margin); int gpxSmallTextMargin = (int) ll.getResources().getDimension(R.dimen.gpx_small_text_margin);
float gpxTextSize = ll.getResources().getDimension(R.dimen.default_desc_text_size); float gpxTextSize = ll.getResources().getDimension(R.dimen.default_desc_text_size);
TypedValue typedValue = new TypedValue(); int textColor = app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark);
Resources.Theme theme = app.getTheme();
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
int textColor = typedValue.data;
buildIcon(ll, gpxSmallIconMargin, R.drawable.ic_small_point); buildIcon(ll, gpxSmallIconMargin, R.drawable.ic_small_point);
buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor, "" + item.analysis.wptPoints); buildTextView(ll, gpxSmallTextMargin, gpxTextSize, textColor, "" + item.analysis.wptPoints);

View file

@ -4,7 +4,6 @@ import android.os.Bundle;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -120,52 +119,24 @@ public class MapRouteInfoMenuFragment extends Fragment {
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn3), nightMode, AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn3), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark); R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
((TextView) mainView.findViewById(R.id.ViaView)).setTextColor(nightMode ? AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.ViaView), nightMode);
ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark) AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.ViaSubView), nightMode);
: ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light)); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.toTitle), nightMode);
((TextView) mainView.findViewById(R.id.ViaSubView)).setTextColor(nightMode ? AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode);
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode);
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
((TextView) mainView.findViewById(R.id.toTitle)).setTextColor(nightMode ? AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode);
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode);
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light)); AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Info), nightMode);
((TextView) mainView.findViewById(R.id.fromTitle)).setTextColor(nightMode ? AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Next), nightMode);
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark) AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Prev), nightMode);
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
((TextView) mainView.findViewById(R.id.InfoTextView)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.ToLayout), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Info), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Next), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.Prev), nightMode,
R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
((TextView) mainView.findViewById(R.id.DistanceText)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light));
((TextView) mainView.findViewById(R.id.DistanceTitle)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
((TextView) mainView.findViewById(R.id.DurationText)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.primary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.primary_text_light));
((TextView) mainView.findViewById(R.id.DurationTitle)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceText), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationTitle), nightMode);
} }
public static boolean showInstance(final MapActivity mapActivity) { public static boolean showInstance(final MapActivity mapActivity) {

View file

@ -255,8 +255,7 @@ public class MapControlsLayer extends OsmandMapLayer {
TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button); TextView routeGoButton = (TextView) main.findViewById(R.id.map_go_route_button);
routeGoButton.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null); routeGoButton.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getIcon(R.drawable.map_start_navigation, R.color.color_myloc_distance), null, null, null);
routeGoButton.setText(mapActivity.getString(R.string.shared_string_go)); routeGoButton.setText(mapActivity.getString(R.string.shared_string_go));
routeGoButton.setTextColor(nightMode ? AndroidUtils.setTextSecondaryColor(mapActivity, routeGoButton, nightMode);
ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_dark) : ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_light));
AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark); AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
routeGoButton.setOnClickListener(new View.OnClickListener() { routeGoButton.setOnClickListener(new View.OnClickListener() {
@Override @Override

View file

@ -321,7 +321,7 @@ public class MapInfoWidgetsFactory {
boolean updated = updateVisibility(waypointInfoBar, true); boolean updated = updateVisibility(waypointInfoBar, true);
// pass top bar to make it clickable // pass top bar to make it clickable
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar, WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,
pnt, true); pnt, true, !map.getMyApplication().getSettings().isLightContent());
if (updated || changed) { if (updated || changed) {
ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more); ImageView all = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_more);
ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close); ImageView remove = (ImageView) waypointInfoBar.findViewById(R.id.waypoint_close);