This commit is contained in:
GaidamakUA 2015-12-15 18:46:47 +02:00
commit 56bf62e942
30 changed files with 398 additions and 124 deletions

View file

@ -50,6 +50,7 @@
</android.support.v7.widget.Toolbar>
<ScrollView
android:id="@+id/editor_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/ctx_menu_info_view_bg"
@ -211,6 +212,7 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/description_info_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"

View file

@ -3,13 +3,14 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="350dp"
android:layout_height="match_parent"
android:background="?attr/left_menu_view_bg">
android:background="@android:color/transparent">
<LinearLayout
android:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:background="?attr/left_menu_view_bg"
android:clickable="true"
android:orientation="vertical">

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

@ -208,6 +208,7 @@
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/description_info_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"

View file

@ -918,8 +918,8 @@
<string name="poi_wheelchair_no">Недоступно для инвалидных кресел</string>
<string name="poi_wheelchair_limited">Инвалидные кресла: ограничено</string>
<string name="poi_wholesale">Опт</string>
<string name="poi_parking_underground">Подземный(ая)</string>
<string name="poi_parking_multi_storey">Многоэтажный(ая)</string>
<string name="poi_parking_underground">Тип: подземная</string>
<string name="poi_parking_multi_storey">Тип: многоэтажная</string>
<string name="poi_bicycle_parking_anchors">Закреплённое кольцо</string>
<string name="poi_bicycle_parking_stands">Стойка</string>
@ -1122,7 +1122,7 @@
<string name="poi_farmland">Сельскохозяйственные угодья</string>
<string name="poi_logging">Вырубка</string>
<string name="poi_sand">Песок</string>
<string name="poi_village_green">Общественная территория в центре населённого пункта</string>
<string name="poi_village_green">Общественная территория</string>
<string name="poi_brownfield">Земли под застройку (использованные ранее)</string>
<string name="poi_greenfield">Земли под застройку</string>
<string name="poi_bunker_silo">Сооружение для хранения силоса</string>
@ -2545,4 +2545,15 @@
<string name="poi_billiards">Бильярд</string>
<string name="poi_microwave_oven_yes">Микроволновая печь: присутствует</string>
<string name="poi_microwave_oven_no">Микроволновая печь: отсутствует</string>
<string name="poi_water_heater_yes">Водонагреватель: присутствует</string>
<string name="poi_water_heater_no">Водонагреватель: отсутствует</string>
<string name="poi_parking_surface">Тип: на поверхности</string>
<string name="poi_parking_garage_boxes">Тип: гаражи</string>
<string name="poi_parking_carports">Тип: навес</string>
<string name="poi_dojo">Додзё</string>
</resources>

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

@ -1163,8 +1163,8 @@
<string name="poi_trade_tile">Tile supplies</string>
<string name="poi_population">Population</string>
<string name="poi_parking_underground">Underground</string>
<string name="poi_parking_multi_storey">Multi-storey</string>
<string name="poi_parking_underground">Type: underground</string>
<string name="poi_parking_multi_storey">Type: multi-storey</string>
<string name="poi_bicycle_parking_anchors">Anchors</string>
<string name="poi_bicycle_parking_stands">Stands</string>
@ -2539,4 +2539,15 @@
<string name="poi_billiards">Billiards</string>
<string name="poi_microwave_oven_yes">Microwave oven: yes</string>
<string name="poi_microwave_oven_no">Microwave oven: no</string>
<string name="poi_water_heater_yes">Water heater: yes</string>
<string name="poi_water_heater_no">Water heater: no</string>
<string name="poi_parking_surface">Type: surface</string>
<string name="poi_parking_garage_boxes">Type: garage boxes</string>
<string name="poi_parking_carports">Type: carports</string>
<string name="poi_dojo">Dojo</string>
</resources>

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,27 @@ 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));
}
public static void setHintTextSecondaryColor(Context ctx, TextView textView, boolean night) {
textView.setHintTextColor(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

@ -1018,7 +1018,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void takePhoto(final double lat, final double lon, final MapActivity mapActivity) {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
takePhotoInternalOrExternal(lat, lon, mapActivity);
if (AV_EXTERNAL_PHOTO_CAM.get()) {
takePhotoExternal(lat, lon, mapActivity);
} else {
takePhotoInternalOrExternal(lat, lon, mapActivity);
}
} else {
actionLat = lat;
actionLon = lon;

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,49 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks {
}
}
private void applyDayNightMode() {
if (nightMode) {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_dark));
}
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.bg_color_light));
}
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
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 +583,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 +855,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

@ -7,16 +7,19 @@ import android.support.v7.app.AlertDialog;
import android.support.v7.app.AlertDialog.Builder;
import android.view.View;
import android.widget.LinearLayout;
import net.osmand.CallbackWithObject;
import net.osmand.StateChangedListener;
import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.GPXUtilities.GPXFile;
import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.GpxUiHelper;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
@ -35,7 +38,7 @@ import net.osmand.util.MapUtils;
import java.lang.ref.WeakReference;
import java.util.List;
public class MapContextMenu extends MenuTitleController {
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode> {
private MapActivity mapActivity;
private MapMultiSelectionMenu mapMultiSelectionMenu;
@ -55,6 +58,8 @@ public class MapContextMenu extends MenuTitleController {
private LatLon myLocation;
private Float heading;
private boolean inLocationUpdate = false;
private boolean appModeChanged;
private boolean appModeListenerAdded;
private int favActionIconId;
@ -67,6 +72,10 @@ public class MapContextMenu extends MenuTitleController {
public void setMapActivity(MapActivity mapActivity) {
this.mapActivity = mapActivity;
if (!appModeListenerAdded) {
mapActivity.getMyApplication().getSettings().APPLICATION_MODE.addListener(this);
appModeListenerAdded = true;
}
if (mapMultiSelectionMenu == null) {
mapMultiSelectionMenu = new MapMultiSelectionMenu(mapActivity);
@ -199,6 +208,7 @@ public class MapContextMenu extends MenuTitleController {
}
boolean needAcquireMenuController = menuController == null
|| appModeChanged
|| !update
|| this.object == null && object != null
|| this.object != null && object == null
@ -208,6 +218,7 @@ public class MapContextMenu extends MenuTitleController {
this.object = object;
active = true;
appModeChanged = false;
if (needAcquireMenuController) {
acquireMenuController();
@ -232,7 +243,11 @@ public class MapContextMenu extends MenuTitleController {
public void show() {
if (!isVisible()) {
if (!MapContextMenuFragment.showInstance(this, mapActivity)) {
boolean wasInit = true;
if (appModeChanged) {
wasInit = init(latLon, pointDescription, object);
}
if (wasInit && !MapContextMenuFragment.showInstance(this, mapActivity)) {
active = false;
}
}
@ -295,6 +310,11 @@ public class MapContextMenu extends MenuTitleController {
}
}
@Override
public void stateChanged(ApplicationMode change) {
appModeChanged = active;
}
private void clearSelectedObject(Object object) {
if (object != null) {
for (OsmandMapLayer l : mapActivity.getMapView().getLayers()) {
@ -644,6 +664,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);
}
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 buttonsTopBorder = view.findViewById(R.id.buttons_top_border);
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

@ -16,12 +16,14 @@ public abstract class PointEditor {
private boolean portraitMode;
private boolean largeDevice;
private boolean nightMode;
public PointEditor(MapActivity mapActivity) {
this.app = mapActivity.getMyApplication();
this.mapActivity = mapActivity;
portraitMode = AndroidUiHelper.isOrientationPortrait(mapActivity);
largeDevice = AndroidUiHelper.isXLargeDevice(mapActivity);
updateNightMode();
}
public void setMapActivity(MapActivity mapActivity) {
@ -36,6 +38,14 @@ public abstract class PointEditor {
return !portraitMode && !largeDevice;
}
public boolean isLight() {
return !nightMode;
}
public void updateNightMode() {
nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightMode();
}
public int getSlideInAnimation() {
if (isLandscapeLayout()) {
return R.anim.slide_in_left;

View file

@ -56,6 +56,32 @@ public abstract class PointEditorFragment extends Fragment {
view = inflater.inflate(R.layout.point_editor_fragment, container, false);
getEditor().updateNightMode();
if (getEditor().isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !getEditor().isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), view.findViewById(R.id.title_view), !getEditor().isLight(),
R.drawable.bg_point_editor_view_light, R.drawable.bg_point_editor_view_dark);
}
View editorScrollView = view.findViewById(R.id.editor_scroll_view);
if (editorScrollView != null) {
if (getEditor().isLight()) {
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
editorScrollView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
}
View descriptionInfoView = view.findViewById(R.id.description_info_view);
if (descriptionInfoView != null) {
if (getEditor().isLight()) {
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
descriptionInfoView.setBackgroundColor(getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
}
Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
toolbar.setTitle(getToolbarTitle());
toolbar.setNavigationIcon(getMyApplication().getIconsCache().getIcon(R.drawable.abc_ic_ab_back_mtrl_am_alpha));
@ -99,15 +125,21 @@ public abstract class PointEditorFragment extends Fragment {
}
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextPrimaryColor(view.getContext(), headerCaption, !getEditor().isLight());
headerCaption.setText(getHeaderCaption());
TextView nameCaption = (TextView) view.findViewById(R.id.name_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), nameCaption, !getEditor().isLight());
nameCaption.setText(getNameCaption());
TextView categoryCaption = (TextView) view.findViewById(R.id.category_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), categoryCaption, !getEditor().isLight());
categoryCaption.setText(getCategoryCaption());
nameEdit = (EditText) view.findViewById(R.id.name_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), nameEdit, !getEditor().isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), nameEdit, !getEditor().isLight());
nameEdit.setText(getNameInitValue());
AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) view.findViewById(R.id.category_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), categoryEdit, !getEditor().isLight());
categoryEdit.setText(getCategoryInitValue());
categoryEdit.setFocusable(false);
categoryEdit.setOnTouchListener(new View.OnTouchListener() {
@ -124,6 +156,8 @@ public abstract class PointEditorFragment extends Fragment {
});
EditText descriptionEdit = (EditText) view.findViewById(R.id.description_edit);
AndroidUtils.setTextPrimaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
AndroidUtils.setHintTextSecondaryColor(view.getContext(), descriptionEdit, !getEditor().isLight());
if (getDescriptionInitValue() != null) {
descriptionEdit.setText(getDescriptionInitValue());
}
@ -143,9 +177,8 @@ public abstract class PointEditorFragment extends Fragment {
public Drawable getRowIcon(int iconId) {
IconsCache iconsCache = getMyApplication().getIconsCache();
boolean light = getMyApplication().getSettings().isLightContent();
return iconsCache.getIcon(iconId,
light ? R.color.icon_color : R.color.icon_color_light);
getEditor().isLight() ? R.color.icon_color : R.color.icon_color_light);
}
@Override

View file

@ -162,6 +162,7 @@ public class MapMultiSelectionMenu extends BaseMenuController {
this.latLon = latLon;
createCollection(selectedObjects);
updateNightMode();
MapMultiSelectionMenuFragment.showInstance(getMapActivity());
getMapActivity().refreshMap();
}

View file

@ -19,6 +19,7 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.IconsCache;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
@ -44,6 +45,13 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
menu = ((MapActivity) getActivity()).getContextMenu().getMultiSelectionMenu();
view = inflater.inflate(R.layout.menu_obj_selection_fragment, container, false);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), view, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter();
@ -134,6 +142,7 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
private void buildHeader(View view, MenuObject item, MapActivity mapActivity) {
AndroidUtils.setBackground(mapActivity, view, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
IconsCache iconsCache = mapActivity.getMyApplication().getIconsCache();
final View iconLayout = view.findViewById(R.id.context_menu_icon_layout);
final ImageView iconView = (ImageView) view.findViewById(R.id.context_menu_icon_view);
@ -152,10 +161,12 @@ public class MapMultiSelectionMenuFragment extends Fragment implements AdapterVi
// Text line 1
TextView line1 = (TextView) view.findViewById(R.id.context_menu_line1);
AndroidUtils.setTextPrimaryColor(mapActivity, line1, !menu.isLight());
line1.setText(item.getTitleStr());
// Text line 2
TextView line2 = (TextView) view.findViewById(R.id.context_menu_line2);
AndroidUtils.setTextSecondaryColor(mapActivity, line2, !menu.isLight());
line2.setText(item.getTypeStr());
Drawable slIcon = item.getTypeIcon();
line2.setCompoundDrawablesWithIntrinsicBounds(slIcon, null, null, null);

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

@ -14,6 +14,7 @@ import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.other.ShareMenu.ShareItem;
@ -40,6 +41,18 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.share_menu_fragment, container, false);
View mainView = view.findViewById(R.id.main_view);
if (menu.isLandscapeLayout()) {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_left_menu_light, R.drawable.bg_left_menu_dark);
} else {
AndroidUtils.setBackground(view.getContext(), mainView, !menu.isLight(),
R.drawable.bg_bottom_menu_light, R.drawable.bg_bottom_menu_dark);
}
TextView headerCaption = (TextView) view.findViewById(R.id.header_caption);
AndroidUtils.setTextSecondaryColor(view.getContext(), headerCaption, !menu.isLight());
ListView listView = (ListView) view.findViewById(R.id.list);
listAdapter = createAdapter();
listView.setAdapter(listAdapter);
@ -88,11 +101,13 @@ public class ShareMenuFragment extends Fragment implements OnItemClickListener {
if (v == null) {
v = menu.getMapActivity().getLayoutInflater().inflate(R.layout.share_list_item, null);
}
AndroidUtils.setBackground(v.getContext(), v, !menu.isLight(), R.drawable.expandable_list_item_background_light, R.drawable.expandable_list_item_background_dark);
final ShareItem item = getItem(position);
ImageView icon = (ImageView) v.findViewById(R.id.icon);
icon.setImageDrawable(menu.getMapActivity().getMyApplication()
.getIconsCache().getContentIcon(item.getIconResourceId()));
.getIconsCache().getContentIcon(item.getIconResourceId(), menu.isLight()));
TextView name = (TextView) v.findViewById(R.id.name);
AndroidUtils.setTextPrimaryColor(v.getContext(), name, !menu.isLight());
name.setText(getContext().getText(item.getTitleResourceId()));
return v;
}

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

@ -320,8 +320,8 @@ public class MapInfoWidgetsFactory {
updateVisibility(addressTextShadow, false);
boolean updated = updateVisibility(waypointInfoBar, true);
// pass top bar to make it clickable
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,
pnt, true);
WaypointDialogHelper.updatePointInfoView(map.getMyApplication(), map, topBar,
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);