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

View file

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<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="created_poi_icon_color">#4caf50</color>
<color name="osm_bug_unresolved_icon_color">#d44a4a</color>

View file

@ -1,8 +1,6 @@
package net.osmand;
import java.util.Date;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Configuration;
@ -11,6 +9,11 @@ import android.text.format.DateFormat;
import android.view.View;
import android.view.ViewParent;
import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
import net.osmand.plus.R;
import java.util.Date;
public class AndroidUtils {
@ -77,4 +80,20 @@ public class AndroidUtils {
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.TextView;
import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil;
import net.osmand.plus.activities.actions.AppModeDialog;
import net.osmand.plus.dialogs.ConfigureMapMenu;
@ -330,7 +331,7 @@ public class ContextMenuAdapter {
Integer lid = getLayoutId(position);
if (lid == R.layout.mode_toggles) {
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
public void onClick(View view) {
if (selected.size() > 0) {
@ -348,6 +349,9 @@ public class ContextMenuAdapter {
convertView.setTag(lid);
}
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));
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.updateLayers(mapView);
mapActions.updateDrawerMenu();
mapView.setComplexZoom(mapView.getZoom(), mapView.getSettingsMapDensity());
app.getDaynightHelper().startSensorIfNeeded(new StateChangedListener<Boolean>() {

View file

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

View file

@ -95,7 +95,8 @@ public class DashWaypointsFragment extends DashLocationFragment {
LocationPointWrapper ps = allPoints.get(i);
View dv = getActivity().getLayoutInflater().inflate(R.layout.divider, null);
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);
}

View file

@ -2,12 +2,15 @@ package net.osmand.plus.dashboard;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.View;
import android.view.animation.Animation;
@ -57,9 +60,13 @@ import net.osmand.plus.views.OsmandMapTileView;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
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 List<LocationPointWrapper> deletedPoints = new ArrayList<>();
private Drawable gradientToolbar;
boolean nightMode;
public DashFragmentData[] getFragmentsData() {
return fragmentsData;
@ -136,9 +144,22 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
CONFIGURE_SCREEN,
CONFIGURE_MAP,
LIST_MENU,
ROUTE_SETTINGS,
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) {
this.mapActivity = ma;
}
@ -181,7 +202,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
dashboardView.findViewById(R.id.animateContent).setOnClickListener(listener);
dashboardView.findViewById(R.id.map_part_dashboard).setOnClickListener(listener);
initActionButton();
initActionButtons();
dashboardView.addView(actionButton);
}
@ -312,7 +333,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
private void initActionButton() {
private void initActionButtons() {
actionButton = new ImageView(mapActivity);
int btnSize = (int) mapActivity.getResources().getDimension(R.dimen.map_button_size);
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;
actionButton.setLayoutParams(params);
actionButton.setScaleType(ScaleType.CENTER);
actionButton.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.map_my_location));
actionButton.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue));
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
public void onClick(View v) {
if (getMyApplication().accessibilityEnabled()) {
@ -339,9 +362,38 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
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() {
actionButton.setVisibility(View.GONE);
@ -403,6 +455,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
if (visible == this.visible && type == visibleType) {
return;
}
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
this.previousVisibleType = prevItem;
this.visible = visible;
boolean refresh = this.visibleType == type;
@ -419,6 +472,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
mapActivity.disableDrawer();
dashboardView.setVisibility(View.VISIBLE);
if (isActionButtonVisible()) {
setActionButton(visibleType);
actionButton.setVisibility(View.VISIBLE);
} else {
hideActionButton();
@ -444,6 +498,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
updateListAdapter();
updateListBackgroundHeight();
}
applyDayNightMode();
}
mapActivity.findViewById(R.id.toolbar_back).setVisibility(isBackButtonVisible() ? View.VISIBLE : View.GONE);
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() {
ContextMenuAdapter cm = null;
if (DashboardType.WAYPOINTS == visibleType || DashboardType.WAYPOINTS_FLAT == visibleType) {
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(false, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType);
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter);
updateListAdapter(listAdapter, listener);
} else if (DashboardType.WAYPOINTS_EDIT == visibleType) {
deletedPoints.clear();
ArrayAdapter<Object> listAdapter = waypointDialogHelper.getWaypointsDrawerAdapter(true, deletedPoints, mapActivity, running,
DashboardType.WAYPOINTS_FLAT == visibleType);
DashboardType.WAYPOINTS_FLAT == visibleType, nightMode);
OnItemClickListener listener = waypointDialogHelper.getDrawerItemClickListener(mapActivity, running,
listAdapter);
updateListAdapter(listAdapter, listener);
@ -497,8 +575,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
public void updateListAdapter(ContextMenuAdapter cm) {
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, getMyApplication().getSettings()
.isLightContent());
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
if (this.nightMode != nightMode) {
this.nightMode = nightMode;
applyDayNightMode();
}
final ArrayAdapter<?> listAdapter = cm.createListAdapter(mapActivity, !nightMode);
OnItemClickListener listener = getOptionsMenuOnClickListener(cm, listAdapter);
updateListAdapter(listAdapter, listener);
}
@ -765,7 +847,10 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
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() {

View file

@ -16,7 +16,7 @@ import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.data.FavouritePoint;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.LocationPoint;
import net.osmand.data.PointDescription;
@ -59,10 +59,12 @@ public class WaypointDialogHelper {
}
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();
final LocationPoint point = ps.getPoint();
TextView text = (TextView) localView.findViewById(R.id.waypoint_text);
AndroidUtils.setTextPrimaryColor(activity, text, nightMode);
TextView textShadow = (TextView) localView.findViewById(R.id.waypoint_text_shadow);
localView.setOnClickListener(new View.OnClickListener() {
@Override
@ -112,7 +114,7 @@ public class WaypointDialogHelper {
public ArrayAdapter<Object> getWaypointsDrawerAdapter(
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;
if(flat) {
points = new ArrayList<Object>(waypointHelper.getAllPoints());
@ -130,12 +132,12 @@ public class WaypointDialogHelper {
boolean labelView = (getItem(position) instanceof Integer);
if (getItem(position) instanceof RadiusItem) {
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) {
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter);
v = createItemForCategory(ctx, (Integer) getItem(position), running, position, thisAdapter, nightMode);
} else {
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;
}
@ -148,18 +150,18 @@ public class WaypointDialogHelper {
public static View updateWaypointItemView(final boolean edit, final List<LocationPointWrapper> deletedPoints,
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) {
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);
if (!edit) {
remove.setVisibility(View.GONE);
} else {
remove.setVisibility(View.VISIBLE);
((ImageButton) remove).setImageDrawable(app.getIconsCache().getContentIcon(
R.drawable.ic_action_gremove_dark));
R.drawable.ic_action_gremove_dark, !nightMode));
remove.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
@ -178,12 +180,13 @@ public class WaypointDialogHelper {
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;
IconsCache iconsCache = app.getIconsCache();
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);
((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.setOnClickListener(new View.OnClickListener() {
@Override
@ -196,7 +199,7 @@ public class WaypointDialogHelper {
}
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;
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
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);
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(getHeader(type, checked, ctx));
v.setOnClickListener(new View.OnClickListener() {
@Override

View file

@ -1,7 +1,6 @@
package net.osmand.plus.mapcontextmenu;
import android.graphics.drawable.Drawable;
import android.util.TypedValue;
import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
@ -15,7 +14,7 @@ public abstract class BaseMenuController {
private MapActivity mapActivity;
private boolean portraitMode;
private boolean largeDevice;
private boolean light;
private boolean nightMode;
public BaseMenuController(MapActivity mapActivity) {
this.mapActivity = mapActivity;
@ -25,7 +24,7 @@ public abstract class BaseMenuController {
private void init() {
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
light = mapActivity.getMyApplication().getSettings().isLightContent();
updateNightMode();
}
public MapActivity getMapActivity() {
@ -38,7 +37,11 @@ public abstract class BaseMenuController {
}
public boolean isLight() {
return light;
return !nightMode;
}
public void updateNightMode() {
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
}
public boolean isLandscapeLayout() {
@ -75,7 +78,7 @@ public abstract class BaseMenuController {
}
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) {
@ -92,13 +95,4 @@ public abstract class BaseMenuController {
IconsCache iconsCache = getMapActivity().getMyApplication().getIconsCache();
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() {
return getCurrentMenuState() == MenuState.HEADER_ONLY;
}

View file

@ -29,6 +29,7 @@ import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.Location;
import net.osmand.data.LatLon;
import net.osmand.data.QuadPoint;
@ -90,6 +91,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private int origMarkerY;
private boolean customMapCenter;
private boolean moving;
private boolean nightMode;
private float skipHalfScreenStateLimit;
@ -149,6 +151,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
if (!menu.isActive()) {
return view;
}
nightMode = menu.isNightMode();
mainView = view.findViewById(R.id.context_menu_main);
leftTitleButtonController = menu.getLeftTitleButtonController();
@ -173,7 +176,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
}
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
// Left 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) {
final ImageView progressButton = (ImageView) view.findViewById(R.id.progressButton);
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() {
@Override
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);
topShadowView.setOnTouchListener(slideTouchListener);
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() {
@Override
public boolean onTouch(View v, MotionEvent event) {
@ -345,6 +349,25 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
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
fabView = (ImageView)view.findViewById(R.id.context_menu_fab_view);
if (menu.fabVisible()) {
@ -363,17 +386,27 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
fabView.setVisibility(View.GONE);
}
if (!menu.buttonsVisible()) {
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);
buttonsTopBorder.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
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
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() {
@Override
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);
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() {
@Override
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);
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() {
@Override
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);
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() {
@Override
public void onClick(View v) {
@ -413,6 +449,11 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
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);
return view;
@ -606,7 +647,6 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
private void buildHeader() {
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
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);
} else if (iconId != 0) {
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);
} else {
iconLayout.setVisibility(View.GONE);
@ -669,10 +709,9 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
public void rebuildMenu() {
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
final ImageButton buttonFavorite = (ImageButton) view.findViewById(R.id.context_menu_fav_button);
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();

View file

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

View file

@ -65,6 +65,7 @@ public abstract class MenuController extends BaseMenuController {
this.pointDescription = pointDescription;
this.builder = builder;
this.currentMenuState = getInitialMenuState();
this.builder.setLight(isLight());
}
public void build(View rootView) {
@ -287,7 +288,7 @@ public abstract class MenuController extends BaseMenuController {
public Drawable getLeftIcon() {
if (leftIconId != 0) {
return getIcon(leftIconId, getResIdFromAttribute(R.attr.contextMenuButtonColor));
return getIcon(leftIconId, isLight() ? R.color.map_widget_blue : R.color.osmand_orange);
} else {
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,
int textColor, boolean isWiki, boolean isText, boolean needLinks,
boolean isPhoneNumber, boolean isUrl) {
boolean light = app.getSettings().isLightContent();
if (!isFirstRow()) {
buildRowDivider(view, false);

View file

@ -1,6 +1,5 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.Gravity;
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);
float gpxTextSize = ll.getResources().getDimension(R.dimen.default_desc_text_size);
TypedValue typedValue = new TypedValue();
Resources.Theme theme = app.getTheme();
theme.resolveAttribute(android.R.attr.textColorSecondary, typedValue, true);
int textColor = typedValue.data;
int textColor = app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark);
buildIcon(ll, gpxSmallIconMargin, R.drawable.ic_small_point);
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.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -120,52 +119,24 @@ public class MapRouteInfoMenuFragment extends Fragment {
AndroidUtils.setBackground(ctx, mainView.findViewById(R.id.dividerBtn3), nightMode,
R.color.dashboard_divider_light, R.color.dashboard_divider_dark);
((TextView) mainView.findViewById(R.id.ViaView)).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.ViaSubView)).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.ViaView), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.ViaSubView), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.toTitle), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.fromTitle), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.InfoTextView), nightMode);
((TextView) mainView.findViewById(R.id.toTitle)).setTextColor(nightMode ?
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark)
: ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_light));
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.FromLayout), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.ViaLayout), nightMode);
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 ?
ContextCompat.getColorStateList(ctx, android.R.color.secondary_text_dark)
: 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.setDashButtonBackground(ctx, mainView.findViewById(R.id.Next), nightMode);
AndroidUtils.setDashButtonBackground(ctx, mainView.findViewById(R.id.Prev), nightMode);
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) {

View file

@ -255,8 +255,7 @@ public class MapControlsLayer extends OsmandMapLayer {
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.setText(mapActivity.getString(R.string.shared_string_go));
routeGoButton.setTextColor(nightMode ?
ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_dark) : ContextCompat.getColorStateList(mapActivity, android.R.color.secondary_text_light));
AndroidUtils.setTextSecondaryColor(mapActivity, routeGoButton, nightMode);
AndroidUtils.setBackground(mapActivity, routeGoButton, nightMode, R.drawable.dashboard_button_light, R.drawable.dashboard_button_dark);
routeGoButton.setOnClickListener(new View.OnClickListener() {
@Override

View file

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