Merge pull request #8141 from osmandapp/ProfileColor

Profile Colors
This commit is contained in:
max-klaus 2019-12-27 17:38:42 +03:00 committed by GitHub
commit 45987d34b4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 872 additions and 278 deletions

View file

@ -56,7 +56,7 @@
</LinearLayout> </LinearLayout>
<RadioButton <android.support.v7.widget.AppCompatRadioButton
android:id="@+id/compound_button" android:id="@+id/compound_button"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:orientation="vertical">
<View
android:background="?attr/dashboard_divider"
android:id="@+id/topDivider"
android:layout_height="1dp"
android:layout_width="wrap_content"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeightSmall"
android:background="?attr/selectableItemBackground"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="@dimen/context_menu_padding_margin_large"
android:layout_marginRight="@dimen/context_menu_padding_margin_large">
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/radio"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="false"
android:focusable="false"
android:visibility="gone"
android:layout_gravity="center"/>
<android.support.v7.widget.AppCompatCheckBox
android:id="@+id/checkbox"
android:checkMark="?android:attr/listChoiceIndicatorMultiple"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:clickable="false"
android:focusable="false"
android:visibility="gone"
android:layout_gravity="center"/>
</FrameLayout>
<TextView
android:id="@+id/text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical|start"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size_large"
android:text="Item title"/>
</LinearLayout>
<View
android:background="?attr/dashboard_divider"
android:id="@+id/bottomDivider"
android:layout_height="1dp"
android:layout_marginTop="@dimen/list_header_padding"
android:layout_width="wrap_content"
android:visibility="gone"/>
</LinearLayout>

View file

@ -6,46 +6,57 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:paddingLeft="@dimen/context_menu_padding_margin_large"
android:paddingRight="@dimen/context_menu_padding_margin_large"
android:paddingTop="@dimen/context_menu_padding_margin_large"
android:paddingBottom="@dimen/context_menu_padding_margin_large"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/shared_string_name"/> android:text="@string/shared_string_name"/>
<EditText <EditText
android:id="@+id/Name" android:id="@+id/Name"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="@dimen/text_margin_small"
android:layout_marginRight="5dp" android:layout_marginRight="@dimen/text_margin_small"
android:text=""> android:text="">
<requestFocus/> <requestFocus/>
</EditText> </EditText>
<TextView <TextView
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:ellipsize="end" android:ellipsize="end"
android:scrollHorizontally="true" android:scrollHorizontally="true"
android:layout_marginTop="@dimen/content_padding_half"
android:text="@string/edit_tilesource_choose_existing"/> android:text="@string/edit_tilesource_choose_existing"/>
<Spinner <Spinner
android:id="@+id/TileSourceSpinner" android:id="@+id/TileSourceSpinner"
android:textColor="?android:textColorPrimary"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="5dp" android:layout_marginLeft="@dimen/text_margin_small"
android:layout_marginRight="5dp"/> android:layout_marginRight="@dimen/text_margin_small"/>
<TextView <TextView
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/content_padding_half"
android:text="@string/edit_tilesource_url_to_load"/> android:text="@string/edit_tilesource_url_to_load"/>
<EditText <EditText
android:id="@+id/URLToLoad" android:id="@+id/URLToLoad"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:lines="5" android:lines="5"
@ -53,43 +64,52 @@
android:text=""/> android:text=""/>
<TextView <TextView
android:layout_marginTop="@dimen/content_padding_half"
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/edit_tilesource_minzoom"/> android:text="@string/edit_tilesource_minzoom"/>
<EditText <EditText
android:id="@+id/MinZoom" android:id="@+id/MinZoom"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=""/> android:text=""/>
<TextView <TextView
android:layout_marginTop="@dimen/content_padding_half"
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/edit_tilesource_maxzoom"/> android:text="@string/edit_tilesource_maxzoom"/>
<EditText <EditText
android:id="@+id/MaxZoom" android:id="@+id/MaxZoom"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=""/> android:text=""/>
<TextView <TextView
android:layout_marginTop="@dimen/content_padding_half"
android:textColor="?android:textColorSecondary"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:text="@string/edit_tilesource_expiration_time"/> android:text="@string/edit_tilesource_expiration_time"/>
<EditText <EditText
android:id="@+id/ExpirationTime" android:id="@+id/ExpirationTime"
android:textColor="?android:textColorPrimary"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text=""/> android:text=""/>
<CheckBox <android.support.v7.widget.AppCompatCheckBox
android:id="@+id/EllipticMercator" android:id="@+id/EllipticMercator"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginRight="5dp" android:layout_marginTop="@dimen/content_padding_half"
android:text="@string/edit_tilesource_elliptic_tile"/> android:text="@string/edit_tilesource_elliptic_tile"/>
</LinearLayout> </LinearLayout>

View file

@ -454,13 +454,13 @@
<color name="profile_icon_color_yellow_light">#F0B400</color> <color name="profile_icon_color_yellow_light">#F0B400</color>
<color name="profile_icon_color_magenta_light">#CC0063</color> <color name="profile_icon_color_magenta_light">#CC0063</color>
<color name="profile_icon_color_blue_dark_default">#B3237BFF</color> <color name="profile_icon_color_blue_dark_default">#237BFF</color>
<color name="profile_icon_color_purple_dark">#B3732EEB</color> <color name="profile_icon_color_purple_dark">#732EEB</color>
<color name="profile_icon_color_green_dark">#B30EBE92</color> <color name="profile_icon_color_green_dark">#0EBE92</color>
<color name="profile_icon_color_blue_dark">#B3007EB3</color> <color name="profile_icon_color_blue_dark">#007EB3</color>
<color name="profile_icon_color_red_dark">#B3FF2200</color> <color name="profile_icon_color_red_dark">#FF2200</color>
<color name="profile_icon_color_yellow_dark">#B3F0B400</color> <color name="profile_icon_color_yellow_dark">#F0B400</color>
<color name="profile_icon_color_magenta_dark">#B3CC0063</color> <color name="profile_icon_color_magenta_dark">#CC0063</color>
<color name="profile_icon_color_inactive">#727272</color> <color name="profile_icon_color_inactive">#727272</color>

View file

@ -54,6 +54,8 @@ public class ContextMenuAdapter {
@LayoutRes @LayoutRes
private int DEFAULT_LAYOUT_ID = R.layout.list_menu_item_native; private int DEFAULT_LAYOUT_ID = R.layout.list_menu_item_native;
List<ContextMenuItem> items = new ArrayList<>(); List<ContextMenuItem> items = new ArrayList<>();
private boolean profileDependent = false;
private boolean nightMode;
private ConfigureMapMenu.OnClickListener changeAppModeListener = null; private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
public int length() { public int length() {
@ -86,6 +88,18 @@ public class ContextMenuAdapter {
public void clearAdapter() { items.clear(); } public void clearAdapter() { items.clear(); }
public boolean isProfileDependent() {
return profileDependent;
}
public void setProfileDependent(boolean profileDependent) {
this.profileDependent = profileDependent;
}
public void setNightMode(boolean nightMode) {
this.nightMode = nightMode;
}
public void setDefaultLayoutId(int defaultLayoutId) { public void setDefaultLayoutId(int defaultLayoutId) {
this.DEFAULT_LAYOUT_ID = defaultLayoutId; this.DEFAULT_LAYOUT_ID = defaultLayoutId;
} }
@ -163,6 +177,8 @@ public class ContextMenuAdapter {
final ContextMenuItem item = getItem(position); final ContextMenuItem item = getItem(position);
int layoutId = item.getLayout(); int layoutId = item.getLayout();
layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID; layoutId = layoutId != ContextMenuItem.INVALID_ID ? layoutId : DEFAULT_LAYOUT_ID;
int currentModeColorRes = app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
int currentModeColor = ContextCompat.getColor(app, currentModeColorRes);
if (layoutId == R.layout.mode_toggles) { if (layoutId == R.layout.mode_toggles) {
final Set<ApplicationMode> selected = new LinkedHashSet<>(); final Set<ApplicationMode> selected = new LinkedHashSet<>();
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(), return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
@ -332,6 +348,8 @@ public class ContextMenuAdapter {
} else { } else {
colorRes = 0; colorRes = 0;
} }
} else if (profileDependent) {
colorRes = currentModeColorRes;
} }
final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes); final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable); ((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
@ -384,6 +402,9 @@ public class ContextMenuAdapter {
} else if (ch != null) { } else if (ch != null) {
ch.setVisibility(View.GONE); ch.setVisibility(View.GONE);
} }
if (profileDependent) {
UiUtilities.setupCompoundButton(nightMode, currentModeColor, ch);
}
} }
if (convertView.findViewById(R.id.seekbar) != null) { if (convertView.findViewById(R.id.seekbar) != null) {
@ -412,6 +433,7 @@ public class ContextMenuAdapter {
} else if (seekBar != null) { } else if (seekBar != null) {
seekBar.setVisibility(View.GONE); seekBar.setVisibility(View.GONE);
} }
UiUtilities.setupSeekBar(app, seekBar, nightMode, profileDependent);
} }
View progressBar = convertView.findViewById(R.id.ProgressBar); View progressBar = convertView.findViewById(R.id.ProgressBar);

View file

@ -0,0 +1,114 @@
package net.osmand.plus;
import android.support.annotation.ColorInt;
import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CompoundButton;
import android.widget.TextView;
public class DialogListItemAdapter extends BaseAdapter {
public static final int INVALID_ID = -1;
private String[] mData;
private boolean multiChoice;
private boolean nightMode;
private int selected = INVALID_ID;
private boolean checkedItems[];
private OsmandApplication app;
@ColorInt private int compoundButtonColor = INVALID_ID;
private AlertDialog dialog;
private View.OnClickListener listener;
private LayoutInflater inflater;
public static DialogListItemAdapter createSingleChoiceAdapter(String[] mData, boolean nightMode, int selected, OsmandApplication app,
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
return new DialogListItemAdapter(mData, selected, null, nightMode, app, compoundButtonColor, themeRes, listener, false);
}
public static DialogListItemAdapter createMultiChoiceAdapter(String[] mData, boolean nightMode, boolean checkedItems[], OsmandApplication app,
@ColorInt int compoundButtonColor, int themeRes, final View.OnClickListener listener) {
return new DialogListItemAdapter(mData, INVALID_ID, checkedItems, nightMode, app, compoundButtonColor, themeRes, listener, true);
}
private DialogListItemAdapter(String[] mData, int selected, boolean[] checkedItems, boolean nightMode, OsmandApplication app,
int compoundButtonColor, int themeRes, final View.OnClickListener listener, boolean multiChoice) {
this.mData = mData;
this.selected = selected;
this.checkedItems = checkedItems;
this.nightMode = nightMode;
this.multiChoice = multiChoice;
this.app = app;
this.compoundButtonColor = compoundButtonColor;
this.listener = listener;
inflater = LayoutInflater.from(new ContextThemeWrapper(app, themeRes));
}
@Override
public int getCount() {
return mData.length;
}
@Override
public Object getItem(int position) {
return mData[position];
}
@Override
public long getItemId(int position) {
return 0;
}
public void setDialog(AlertDialog dialog) {
this.dialog = dialog;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View view;
if (convertView == null) {
view = inflater.inflate(R.layout.dialog_list_item_with_compound_button, null);
} else {
view = convertView;
}
View button = view.findViewById(R.id.button);
button.setTag(position);
final CompoundButton cb;
if (multiChoice) {
cb = view.findViewById(R.id.checkbox);
view.findViewById(R.id.radio).setVisibility(View.INVISIBLE);
cb.setChecked(checkedItems[position]);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onClick(v);
cb.setChecked(!cb.isChecked());
}
});
} else {
cb = view.findViewById(R.id.radio);
view.findViewById(R.id.checkbox).setVisibility(View.INVISIBLE);
cb.setChecked(position == selected);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
listener.onClick(v);
dialog.dismiss();
}
});
}
cb.setVisibility(View.VISIBLE);
if (compoundButtonColor != INVALID_ID) {
UiUtilities.setupCompoundButton(nightMode, compoundButtonColor, cb);
}
TextView text = view.findViewById(R.id.text);
text.setText(mData[position]);
return view;
}
}

View file

@ -3,6 +3,7 @@ package net.osmand.plus;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
@ -16,11 +17,15 @@ import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat; import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v4.widget.TintableCompoundButton;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.support.v7.widget.SwitchCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -320,6 +325,75 @@ public class UiUtilities {
return screenOrientation; return screenOrientation;
} }
public static void setupCompoundButtonDrawable(Context ctx, boolean nightMode, @ColorInt int activeColor, Drawable drawable) {
int inactiveColor = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light);
int[][] states = new int[][] {
new int[] {-android.R.attr.state_checked},
new int[] {android.R.attr.state_checked}
};
ColorStateList csl = new ColorStateList(states, new int[]{inactiveColor, activeColor});
DrawableCompat.setTintList(DrawableCompat.wrap(drawable), csl);
}
public static void setupCompoundButton(OsmandApplication app, CompoundButton compoundButton, boolean nightMode, boolean profileDependent) {
if (compoundButton == null) {
return;
}
int activeColor = profileDependent ?
app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode) :
nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
setupCompoundButton(nightMode, ContextCompat.getColor(app, activeColor), compoundButton);
}
public static void setupCompoundButton(boolean nightMode, @ColorInt int activeColor, CompoundButton compoundButton) {
if (compoundButton == null) {
return;
}
Context ctx = compoundButton.getContext();
int inactiveColorPrimary = ContextCompat.getColor(ctx, nightMode ? R.color.icon_color_default_dark : R.color.icon_color_secondary_light);
int inactiveColorSecondary = getColorWithAlpha(inactiveColorPrimary, 0.45f);
int[][] states = new int[][] {
new int[] {-android.R.attr.state_checked},
new int[] {android.R.attr.state_checked}
};
if (compoundButton instanceof SwitchCompat) {
SwitchCompat sc = (SwitchCompat) compoundButton;
int[] thumbColors = new int[] {
inactiveColorPrimary, activeColor
};
int[] trackColors = new int[] {
inactiveColorSecondary, inactiveColorSecondary
};
DrawableCompat.setTintList(DrawableCompat.wrap(sc.getThumbDrawable()), new ColorStateList(states, thumbColors));
DrawableCompat.setTintList(DrawableCompat.wrap(sc.getTrackDrawable()), new ColorStateList(states, trackColors));
} else if (compoundButton instanceof TintableCompoundButton) {
ColorStateList csl = new ColorStateList(states, new int[]{inactiveColorPrimary, activeColor});
((TintableCompoundButton) compoundButton).setSupportButtonTintList(csl);
}
compoundButton.setBackgroundColor(Color.TRANSPARENT);
}
public static void setupSeekBar(OsmandApplication app, SeekBar seekBar, boolean nightMode, boolean profileDependent) {
int activeColor = ContextCompat.getColor(app, profileDependent ?
app.getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode) :
nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light);
setupSeekBar(seekBar, activeColor, nightMode);
}
public static void setupSeekBar(SeekBar seekBar, @ColorInt int activeColor, boolean nightMode) {
int backgroundColor = ContextCompat.getColor(seekBar.getContext(),
nightMode ? R.color.icon_color_secondary_dark : R.color.icon_color_default_light);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
LayerDrawable progressBarDrawable = (LayerDrawable) seekBar.getProgressDrawable();
Drawable backgroundDrawable = progressBarDrawable.getDrawable(0);
Drawable progressDrawable = progressBarDrawable.getDrawable(2);
backgroundDrawable.setColorFilter(backgroundColor, PorterDuff.Mode.SRC_IN);
progressDrawable.setColorFilter(activeColor, PorterDuff.Mode.SRC_IN);
seekBar.getThumb().setColorFilter(activeColor, PorterDuff.Mode.SRC_IN);
}
}
public static void setupDialogButton(boolean nightMode, View buttonView, DialogButtonType buttonType, @StringRes int buttonTextId) { public static void setupDialogButton(boolean nightMode, View buttonView, DialogButtonType buttonType, @StringRes int buttonTextId) {
setupDialogButton(nightMode, buttonView, buttonType, buttonView.getContext().getString(buttonTextId)); setupDialogButton(nightMode, buttonView, buttonType, buttonView.getContext().getString(buttonTextId));
} }

View file

@ -4,6 +4,7 @@ package net.osmand.plus.activities;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.view.View; import android.view.View;
@ -22,6 +23,7 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.GPXUtilities.GPXFile; import net.osmand.GPXUtilities.GPXFile;
import net.osmand.GPXUtilities.WptPt; import net.osmand.GPXUtilities.WptPt;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -267,7 +269,7 @@ public class MapActivityLayers {
return true; return true;
} }
}; };
return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject, getThemeRes(getApplication())); return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject, getThemeRes(getApplication()), isNightMode(getApplication()));
} }
@ -283,6 +285,8 @@ public class MapActivityLayers {
addFilterToList(adapter, list, f, true); addFilterToList(adapter, list, f, true);
} }
list.add(poiFilters.getCustomPOIFilter()); list.add(poiFilters.getCustomPOIFilter());
adapter.setProfileDependent(true);
adapter.setNightMode(isNightMode(app));
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app)); final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app));
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app))); AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app)));
@ -491,80 +495,85 @@ public class MapActivityLayers {
items[i++] = entry.getValue(); items[i++] = entry.getValue();
} }
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() { OsmandApplication app = getApplication();
@Override boolean nightMode = isNightMode(app);
public void onClick(DialogInterface dialog, int which) { int themeRes = getThemeRes(app);
String layerKey = entriesMapList.get(which).getKey(); int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
switch (layerKey) { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
case layerOsmVector: items, nightMode, selectedItem, app, selectedModeColor, themeRes, new View.OnClickListener() {
settings.MAP_ONLINE_DATA.set(false); @Override
updateMapSource(mapView, null); public void onClick(View v) {
updateItem(it, adapter, null); int which = (int) v.getTag();
break; String layerKey = entriesMapList.get(which).getKey();
case layerEditInstall: switch (layerKey) {
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() { case layerOsmVector:
settings.MAP_ONLINE_DATA.set(false);
updateMapSource(mapView, null);
updateItem(it, adapter, null);
break;
case layerEditInstall:
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {
@Override @Override
public boolean publish(TileSourceTemplate object) { public boolean publish(TileSourceTemplate object) {
settings.MAP_TILE_SOURCES.set(object.getName()); settings.MAP_TILE_SOURCES.set(object.getName());
settings.MAP_ONLINE_DATA.set(true);
if(it != null) {
it.setDescription(object.getName());
}
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
return true;
}
@Override
public boolean isCancelled() {
return false;
}
});
break;
case layerInstallMore:
OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
TileSourceTemplate template = null;
int count = 0;
@Override
public boolean publish(TileSourceTemplate object) {
if (object == null) {
if (count == 1) {
settings.MAP_TILE_SOURCES.set(template.getName());
settings.MAP_ONLINE_DATA.set(true); settings.MAP_ONLINE_DATA.set(true);
updateItem(it, adapter, template.getName()); if(it != null) {
it.setDescription(object.getName());
}
updateMapSource(mapView, settings.MAP_TILE_SOURCES); updateMapSource(mapView, settings.MAP_TILE_SOURCES);
} else { return true;
selectMapLayer(mapView, it, adapter);
} }
} else {
count++;
template = object;
}
return false;
}
@Override @Override
public boolean isCancelled() { public boolean isCancelled() {
return false; return false;
} }
});
break; });
default: break;
settings.MAP_TILE_SOURCES.set(layerKey); case layerInstallMore:
settings.MAP_ONLINE_DATA.set(true); OsmandRasterMapsPlugin.installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
updateItem(it, adapter, layerKey); TileSourceTemplate template = null;
updateMapSource(mapView, settings.MAP_TILE_SOURCES); int count = 0;
break;
@Override
public boolean publish(TileSourceTemplate object) {
if (object == null) {
if (count == 1) {
settings.MAP_TILE_SOURCES.set(template.getName());
settings.MAP_ONLINE_DATA.set(true);
updateItem(it, adapter, template.getName());
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
} else {
selectMapLayer(mapView, it, adapter);
}
} else {
count++;
template = object;
}
return false;
}
@Override
public boolean isCancelled() {
return false;
}
});
break;
default:
settings.MAP_TILE_SOURCES.set(layerKey);
settings.MAP_ONLINE_DATA.set(true);
updateItem(it, adapter, layerKey);
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
break;
}
}
} }
);
dialog.dismiss(); builder.setAdapter(dialogAdapter, null);
}
});
builder.setNegativeButton(R.string.shared_string_dismiss, null); builder.setNegativeButton(R.string.shared_string_dismiss, null);
builder.show(); dialogAdapter.setDialog(builder.show());
} }
private void updateItem(@Nullable ContextMenuItem item, private void updateItem(@Nullable ContextMenuItem item,

View file

@ -17,6 +17,7 @@ import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup; import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen; import android.preference.PreferenceScreen;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -809,12 +810,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
} }
}); });
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
if (!defaultSpeedOnly) { if (!defaultSpeedOnly) {
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView); setupSpeedSlider(app, SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
setupSpeedSlider(SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView); setupSpeedSlider(app, SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
setupSpeedSlider(SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView); setupSpeedSlider(app, SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
} else { } else {
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED_ONLY, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView); setupSpeedSlider(app, SpeedSliderType.DEFAULT_SPEED_ONLY, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
seekbarView.findViewById(R.id.default_speed_div).setVisibility(View.GONE); seekbarView.findViewById(R.id.default_speed_div).setVisibility(View.GONE);
seekbarView.findViewById(R.id.default_speed_container).setVisibility(View.GONE); seekbarView.findViewById(R.id.default_speed_container).setVisibility(View.GONE);
seekbarView.findViewById(R.id.max_speed_div).setVisibility(View.GONE); seekbarView.findViewById(R.id.max_speed_div).setVisibility(View.GONE);
@ -831,9 +833,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
MAX_SPEED, MAX_SPEED,
} }
private static void setupSpeedSlider(final SpeedSliderType type, String speedUnits, private static void setupSpeedSlider(final OsmandApplication app, final SpeedSliderType type, String speedUnits,
final int[] minValue, final int[] defaultValue, final int[] maxValue, final int[] minValue, final int[] defaultValue, final int[] maxValue,
final int min, final int max, View seekbarView) { final int min, final int max, View seekbarView, final boolean nightMode,
final int activeColor) {
View seekbarLayout; View seekbarLayout;
int titleId; int titleId;
final int[] speedValue; final int[] speedValue;
@ -915,5 +918,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
public void onStopTrackingTouch(SeekBar seekBar) { public void onStopTrackingTouch(SeekBar seekBar) {
} }
}); });
UiUtilities.setupSeekBar(speedSeekBar, activeColor, nightMode);
} }
} }

View file

@ -2,6 +2,7 @@ package net.osmand.plus.activities.actions;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.views.OsmandMapTileView;
import android.app.Activity; import android.app.Activity;
@ -55,4 +56,12 @@ public class OsmAndAction {
public void showDialog() { public void showDialog() {
mapActivity.showDialog(getDialogID()); mapActivity.showDialog(getDialogID());
} }
public boolean isNightMode() {
return mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
}
public int getThemeRes() {
return isNightMode() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
} }

View file

@ -9,13 +9,14 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.PackageManager.NameNotFoundException;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckBox;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener; import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams; import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView; import android.widget.ListView;
@ -24,6 +25,7 @@ import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
@ -111,11 +113,16 @@ public class StartGPSStatus extends OsmAndAction {
final int dp12 = AndroidUtils.dpToPx(mapActivity, 12f); final int dp12 = AndroidUtils.dpToPx(mapActivity, 12f);
final int dp8 = AndroidUtils.dpToPx(mapActivity, 8f); final int dp8 = AndroidUtils.dpToPx(mapActivity, 8f);
lv.setPadding(0, dp8, 0, dp8); lv.setPadding(0, dp8, 0, dp8);
final CheckBox cb = new CheckBox(activity); final AppCompatCheckBox cb = new AppCompatCheckBox(activity);
cb.setText(R.string.shared_string_remember_my_choice); cb.setText(R.string.shared_string_remember_my_choice);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
lp.setMargins(dp24, dp8, dp8, dp24); lp.setMargins(dp24, dp8, dp8, dp24);
cb.setLayoutParams(lp); cb.setLayoutParams(lp);
cb.setPadding(dp8, 0, 0, 0);
int textColorPrimary = ContextCompat.getColor(activity, isNightMode() ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
int selectedModeColor = ContextCompat.getColor(activity, getSettings().getApplicationMode().getIconColorInfo().getColor(isNightMode()));
cb.setTextColor(textColorPrimary);
UiUtilities.setupCompoundButton(isNightMode(), selectedModeColor, cb);
final int layout = R.layout.list_menu_item_native; final int layout = R.layout.list_menu_item_native;
final ArrayAdapter<GpsStatusApps> adapter = new ArrayAdapter<GpsStatusApps>(mapActivity, layout, GpsStatusApps.values()) { final ArrayAdapter<GpsStatusApps> adapter = new ArrayAdapter<GpsStatusApps>(mapActivity, layout, GpsStatusApps.values()) {

View file

@ -4,6 +4,7 @@ import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.support.annotation.ColorRes; import android.support.annotation.ColorRes;
import android.support.annotation.LayoutRes; import android.support.annotation.LayoutRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.widget.CompoundButtonCompat; import android.support.v4.widget.CompoundButtonCompat;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -12,12 +13,14 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescription { public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescription {
private boolean checked; private boolean checked;
private ColorStateList buttonTintList; private ColorStateList buttonTintList;
private OnCheckedChangeListener onCheckedChangeListener; private OnCheckedChangeListener onCheckedChangeListener;
@ColorRes private int compoundButtonColorId;
private CompoundButton compoundButton; private CompoundButton compoundButton;
@ -40,7 +43,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
boolean descriptionLinksClickable, boolean descriptionLinksClickable,
boolean checked, boolean checked,
ColorStateList buttonTintList, ColorStateList buttonTintList,
OnCheckedChangeListener onCheckedChangeListener) { OnCheckedChangeListener onCheckedChangeListener,
@ColorRes int compoundButtonColorId) {
super(customView, super(customView,
layoutId, layoutId,
tag, tag,
@ -57,6 +61,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
this.checked = checked; this.checked = checked;
this.buttonTintList = buttonTintList; this.buttonTintList = buttonTintList;
this.onCheckedChangeListener = onCheckedChangeListener; this.onCheckedChangeListener = onCheckedChangeListener;
this.compoundButtonColorId = compoundButtonColorId;
} }
public void setChecked(boolean checked) { public void setChecked(boolean checked) {
@ -66,14 +71,22 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
} }
} }
public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
this.compoundButtonColorId = compoundButtonColorId;
}
@Override @Override
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) { public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
super.inflate(app, container, nightMode); super.inflate(app, container, nightMode);
compoundButton = (CompoundButton) view.findViewById(R.id.compound_button); compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
if (compoundButton != null) { if (compoundButton != null) {
compoundButton.setChecked(checked); compoundButton.setChecked(checked);
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
compoundButton.setOnCheckedChangeListener(onCheckedChangeListener); compoundButton.setOnCheckedChangeListener(onCheckedChangeListener);
if (compoundButtonColorId != INVALID_ID) {
UiUtilities.setupCompoundButton(nightMode, ContextCompat.getColor(app, compoundButtonColorId), compoundButton);
} else {
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
}
} }
} }
@ -82,6 +95,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
protected boolean checked; protected boolean checked;
protected ColorStateList buttonTintList; protected ColorStateList buttonTintList;
protected OnCheckedChangeListener onCheckedChangeListener; protected OnCheckedChangeListener onCheckedChangeListener;
@ColorRes protected int compoundButtonColorId = INVALID_ID;
public Builder setChecked(boolean checked) { public Builder setChecked(boolean checked) {
this.checked = checked; this.checked = checked;
@ -98,6 +112,11 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
return this; return this;
} }
public Builder setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
this.compoundButtonColorId = compoundButtonColorId;
return this;
}
public BottomSheetItemWithCompoundButton create() { public BottomSheetItemWithCompoundButton create() {
return new BottomSheetItemWithCompoundButton(customView, return new BottomSheetItemWithCompoundButton(customView,
layoutId, layoutId,
@ -114,7 +133,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
descriptionLinksClickable, descriptionLinksClickable,
checked, checked,
buttonTintList, buttonTintList,
onCheckedChangeListener); onCheckedChangeListener,
compoundButtonColorId);
} }
} }
} }

View file

@ -2,8 +2,9 @@ package net.osmand.plus.dialogs;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.DialogInterface.OnMultiChoiceClickListener;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.support.annotation.ColorInt;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
@ -32,6 +33,7 @@ import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuAdapter.OnRowItemClick; import net.osmand.plus.ContextMenuAdapter.OnRowItemClick;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -39,6 +41,7 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
import net.osmand.plus.OsmandSettings.ListStringPreference; import net.osmand.plus.OsmandSettings.ListStringPreference;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivityLayers; import net.osmand.plus.activities.MapActivityLayers;
import net.osmand.plus.activities.PluginActivity; import net.osmand.plus.activities.PluginActivity;
@ -143,7 +146,9 @@ public class ConfigureMapMenu {
} }
} }
} }
createLayersItems(customRules, adapter, ma, themeRes); adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
createLayersItems(customRules, adapter, ma, themeRes, nightMode);
createRenderingAttributeItems(customRules, adapter, ma, themeRes, nightMode); createRenderingAttributeItems(customRules, adapter, ma, themeRes, nightMode);
return adapter; return adapter;
@ -289,9 +294,12 @@ public class ConfigureMapMenu {
} }
} }
private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter, final MapActivity activity, final int themeRes) { private void createLayersItems(List<RenderingRuleProperty> customRules, ContextMenuAdapter adapter,
final MapActivity activity, final int themeRes, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication(); final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
final int selectedProfileColorRes = settings.getApplicationMode().getIconColorInfo().getColor(nightMode);
final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes);
LayerMenuListener l = new LayerMenuListener(activity, adapter); LayerMenuListener l = new LayerMenuListener(activity, adapter);
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
.setId(SHOW_CATEGORY_ID) .setId(SHOW_CATEGORY_ID)
@ -360,7 +368,7 @@ public class ConfigureMapMenu {
.setIcon(R.drawable.ic_action_bus_dark) .setIcon(R.drawable.ic_action_bus_dark)
.setSecondaryIcon(R.drawable.ic_action_additional_option) .setSecondaryIcon(R.drawable.ic_action_additional_option)
.setSelected(transportSelected) .setSelected(transportSelected)
.setColor(transportSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID) .setColor(transportSelected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID)
.setListener(new ContextMenuAdapter.OnRowItemClick() { .setListener(new ContextMenuAdapter.OnRowItemClick() {
ArrayAdapter<CharSequence> adapter; ArrayAdapter<CharSequence> adapter;
boolean transportSelectedInner = transportSelected; boolean transportSelectedInner = transportSelected;
@ -374,7 +382,7 @@ public class ConfigureMapMenu {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item); CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) { if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked()); btn.setChecked(!btn.isChecked());
adapter.getItem(position).setColorRes(btn.isChecked() ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); adapter.getItem(position).setColorRes(btn.isChecked() ? selectedProfileColorRes : ContextMenuItem.INVALID_ID);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
return false; return false;
} else { } else {
@ -395,7 +403,7 @@ public class ConfigureMapMenu {
refreshMapComplete(activity); refreshMapComplete(activity);
activity.getMapLayers().updateLayers(activity.getMapView()); activity.getMapLayers().updateLayers(activity.getMapView());
} else { } else {
ad.getItem(pos).setColorRes(R.color.osmand_orange); ad.getItem(pos).setColorRes(selectedProfileColorRes);
showTransportDialog(ad, pos); showTransportDialog(ad, pos);
} }
ad.notifyDataSetChanged(); ad.notifyDataSetChanged();
@ -437,7 +445,7 @@ public class ConfigureMapMenu {
View v = super.getView(position, convertView, parent); View v = super.getView(position, convertView, parent);
final ImageView icon = (ImageView) v.findViewById(R.id.icon); final ImageView icon = (ImageView) v.findViewById(R.id.icon);
if (checkedItems[position]) { if (checkedItems[position]) {
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange)); icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], selectedProfileColorRes));
} else { } else {
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position])); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
} }
@ -452,12 +460,13 @@ public class ConfigureMapMenu {
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
checkedItems[position] = isChecked; checkedItems[position] = isChecked;
if (checkedItems[position]) { if (checkedItems[position]) {
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange)); icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], selectedProfileColorRes));
} else { } else {
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position])); icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
} }
} }
}); });
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, check);
return v; return v;
} }
}; };
@ -481,7 +490,7 @@ public class ConfigureMapMenu {
ContextMenuItem item = ad.getItem(pos); ContextMenuItem item = ad.getItem(pos);
if (item != null) { if (item != null) {
item.setSelected(transportSelectedInner); item.setSelected(transportSelectedInner);
item.setColorRes(transportSelectedInner ? R.color.osmand_orange : ContextMenuItem.INVALID_ID); item.setColorRes(transportSelectedInner ? selectedProfileColorRes : ContextMenuItem.INVALID_ID);
ad.notifyDataSetChanged(); ad.notifyDataSetChanged();
} }
@ -553,6 +562,11 @@ public class ConfigureMapMenu {
private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules, private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity, final ContextMenuAdapter adapter, final MapActivity activity,
final int themeRes, final boolean nightMode) { final int themeRes, final boolean nightMode) {
final OsmandApplication app = activity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final int selectedProfileColorRes = settings.APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode);
final int selectedProfileColor = ContextCompat.getColor(app, selectedProfileColorRes);
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_widget_map_rendering, activity)
.setId(MAP_RENDERING_CATEGORY_ID) .setId(MAP_RENDERING_CATEGORY_ID)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
@ -595,19 +609,22 @@ public class ConfigureMapMenu {
items[0] += sunriseSunsetTime; items[0] += sunriseSunsetTime;
} }
int i = view.getSettings().DAYNIGHT_MODE.get().ordinal(); int i = view.getSettings().DAYNIGHT_MODE.get().ordinal();
bld.setSingleChoiceItems(items, i, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
refreshMapComplete(activity);
dialog.dismiss();
activity.getDashboard().refreshContent(true);
// adapter.getItem(pos).setDescription(s, getDayNightDescr(activity));
// ad.notifyDataSetInvalidated();
}
});
bld.setNegativeButton(R.string.shared_string_dismiss, null); bld.setNegativeButton(R.string.shared_string_dismiss, null);
bld.show(); DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
items, nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override
public void onClick(View v) {
int which = (int) v.getTag();
view.getSettings().DAYNIGHT_MODE.set(OsmandSettings.DayNightMode.values()[which]);
refreshMapComplete(activity);
activity.getDashboard().refreshContent(true);
// adapter.getItem(pos).setDescription(s, getDayNightDescr(activity));
// ad.notifyDataSetInvalidated();
}
}
);
bld.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(bld.show());
return false; return false;
} }
}).createItem()); }).createItem());
@ -649,10 +666,12 @@ public class ConfigureMapMenu {
} }
bld.setTitle(R.string.map_magnifier); bld.setTitle(R.string.map_magnifier);
bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i, bld.setNegativeButton(R.string.shared_string_dismiss, null);
new DialogInterface.OnClickListener() { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
values.toArray(new String[values.size()]), nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(View v) {
int which = (int) v.getTag();
int p = tlist.get(which); int p = tlist.get(which);
mapDensity.set(p / 100.0f); mapDensity.set(p / 100.0f);
view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity()); view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
@ -665,17 +684,17 @@ public class ConfigureMapMenu {
.getSettings().MAP_DENSITY.get()) .getSettings().MAP_DENSITY.get())
+ " %"); + " %");
ad.notifyDataSetInvalidated(); ad.notifyDataSetInvalidated();
dialog.dismiss();
} }
}); }
bld.setNegativeButton(R.string.shared_string_dismiss, null); );
bld.show(); bld.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(bld.show());
return false; return false;
} }
}).createItem()); }).createItem());
ContextMenuItem props; ContextMenuItem props;
props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, themeRes); props = createRenderingProperty(customRules, adapter, activity, R.drawable.ic_action_intersection, ROAD_STYLE_ATTR, ROAD_STYLE_ID, app, selectedProfileColor, nightMode, themeRes);
if (props != null) { if (props != null) {
adapter.addItem(props); adapter.addItem(props);
} }
@ -700,18 +719,20 @@ public class ConfigureMapMenu {
selected = i; selected = i;
} }
} }
b.setSingleChoiceItems(txtNames, selected, new DialogInterface.OnClickListener() { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
@Override txtNames, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() {
public void onClick(DialogInterface dialog, int which) { @Override
view.getSettings().TEXT_SCALE.set(txtValues[which]); public void onClick(View v) {
refreshMapComplete(activity); int which = (int) v.getTag();
adapter.getItem(pos).setDescription(getScale(activity)); view.getSettings().TEXT_SCALE.set(txtValues[which]);
ad.notifyDataSetInvalidated(); refreshMapComplete(activity);
dialog.dismiss(); adapter.getItem(pos).setDescription(getScale(activity));
} ad.notifyDataSetInvalidated();
}); }
});
b.setAdapter(dialogAdapter, null);
b.setNegativeButton(R.string.shared_string_dismiss, null); b.setNegativeButton(R.string.shared_string_dismiss, null);
b.show(); dialogAdapter.setDialog(b.show());
return false; return false;
} }
}).createItem()); }).createItem());
@ -758,6 +779,9 @@ public class ConfigureMapMenu {
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
View v = super.getView(position, convertView, parent); View v = super.getView(position, convertView, parent);
AppCompatCheckedTextView checkedTextView = (AppCompatCheckedTextView) v.findViewById(R.id.text1); AppCompatCheckedTextView checkedTextView = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
UiUtilities.setupCompoundButtonDrawable(app, nightMode, selectedProfileColor, checkedTextView.getCheckMarkDrawable());
}
if (position == selectedLanguageIndex && position > 0) { if (position == selectedLanguageIndex && position > 0) {
checkedTextView.setChecked(true); checkedTextView.setChecked(true);
v.findViewById(R.id.topDivider).setVisibility(View.VISIBLE); v.findViewById(R.id.topDivider).setVisibility(View.VISIBLE);
@ -768,6 +792,7 @@ public class ConfigureMapMenu {
SwitchCompat check = (SwitchCompat) v.findViewById(R.id.check); SwitchCompat check = (SwitchCompat) v.findViewById(R.id.check);
check.setChecked(transliterateNames); check.setChecked(transliterateNames);
check.setOnCheckedChangeListener(translitChangdListener); check.setOnCheckedChangeListener(translitChangdListener);
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, check);
} else { } else {
checkedTextView.setChecked(position == selectedLanguageIndex); checkedTextView.setChecked(position == selectedLanguageIndex);
v.findViewById(R.id.topDivider).setVisibility(View.GONE); v.findViewById(R.id.topDivider).setVisibility(View.GONE);
@ -811,17 +836,17 @@ public class ConfigureMapMenu {
}).createItem()); }).createItem());
props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark, props = createProperties(customRules, null, R.string.rendering_category_transport, R.drawable.ic_action_bus_dark,
"transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID, themeRes, nightMode); "transport", null, adapter, activity, true, TRANSPORT_RENDERING_ID, themeRes, nightMode, selectedProfileColor);
if (props != null) { if (props != null) {
adapter.addItem(props); adapter.addItem(props);
} }
props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark, props = createProperties(customRules, null, R.string.rendering_category_details, R.drawable.ic_action_layers_dark,
"details", null, adapter, activity, true, DETAILS_ID, themeRes, nightMode); "details", null, adapter, activity, true, DETAILS_ID, themeRes, nightMode, selectedProfileColor);
if (props != null) { if (props != null) {
adapter.addItem(props); adapter.addItem(props);
} }
props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide, props = createProperties(customRules, null, R.string.rendering_category_hide, R.drawable.ic_action_hide,
"hide", null, adapter, activity, true, HIDE_ID, themeRes, nightMode); "hide", null, adapter, activity, true, HIDE_ID, themeRes, nightMode, selectedProfileColor);
if (props != null) { if (props != null) {
adapter.addItem(props); adapter.addItem(props);
} }
@ -833,7 +858,7 @@ public class ConfigureMapMenu {
} }
} }
props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes, props = createProperties(customRules, customRulesIncluded, R.string.rendering_category_routes, R.drawable.ic_action_map_routes,
"routes", null, adapter, activity, true, ROUTES_ID, themeRes, nightMode); "routes", null, adapter, activity, true, ROUTES_ID, themeRes, nightMode, selectedProfileColor);
if (props != null) { if (props != null) {
adapter.addItem(props); adapter.addItem(props);
} }
@ -841,7 +866,7 @@ public class ConfigureMapMenu {
if (getCustomRenderingPropertiesSize(customRules) > 0) { if (getCustomRenderingPropertiesSize(customRules) > 0) {
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity) adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity)
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem()); .setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
createCustomRenderingProperties(adapter, activity, customRules, themeRes); createCustomRenderingProperties(adapter, activity, customRules, app, selectedProfileColor, nightMode, themeRes);
} }
} }
@ -898,7 +923,8 @@ public class ConfigureMapMenu {
final boolean useDescription, final boolean useDescription,
final String id, final String id,
final int themeRes, final int themeRes,
final boolean nightMode) { final boolean nightMode,
@ColorInt final int selectedProfileColor) {
final List<RenderingRuleProperty> ps = new ArrayList<>(); final List<RenderingRuleProperty> ps = new ArrayList<>();
final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>(); final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>();
@ -947,7 +973,7 @@ public class ConfigureMapMenu {
activity.getMapLayers().updateLayers(activity.getMapView()); activity.getMapLayers().updateLayers(activity.getMapView());
} else { } else {
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs, showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs,
useDescription, defaultSettings, true, customRulesIncluded, themeRes, nightMode); useDescription, defaultSettings, true, customRulesIncluded, themeRes, nightMode, selectedProfileColor);
} }
return false; return false;
} }
@ -987,7 +1013,7 @@ public class ConfigureMapMenu {
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> a, View view, int itemId, public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> a, View view, int itemId,
int pos) { int pos) {
showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs, showPreferencesDialog(adapter, a, pos, activity, activity.getString(strId), ps, prefs,
useDescription, defaultSettings, false, customRulesIncluded, themeRes, nightMode); useDescription, defaultSettings, false, customRulesIncluded, themeRes, nightMode, selectedProfileColor);
return false; return false;
} }
}); });
@ -1031,7 +1057,8 @@ public class ConfigureMapMenu {
boolean useDefault, boolean useDefault,
final List<RenderingRuleProperty> customRulesIncluded, final List<RenderingRuleProperty> customRulesIncluded,
final int themeRes, final int themeRes,
final boolean nightMode) { final boolean nightMode,
@ColorInt final int selectedProfileColor) {
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes)); AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
boolean[] checkedItems = new boolean[prefs.size()]; boolean[] checkedItems = new boolean[prefs.size()];
@ -1048,13 +1075,16 @@ public class ConfigureMapMenu {
vals[i] = propertyName; vals[i] = propertyName;
} }
bld.setMultiChoiceItems(vals, checkedItems, new OnMultiChoiceClickListener() { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(
vals, nightMode, checkedItems, activity.getMyApplication(), selectedProfileColor, themeRes, new View.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) { public void onClick(View v) {
tempPrefs[which] = isChecked; int which = (int) v.getTag();
} tempPrefs[which] = !tempPrefs[which];
}); }
}
);
bld.setAdapter(dialogAdapter, null);
bld.setTitle(category); bld.setTitle(category);
@ -1110,6 +1140,8 @@ public class ConfigureMapMenu {
final AlertDialog dialog = bld.create(); final AlertDialog dialog = bld.create();
dialogAdapter.setDialog(dialog);
if (customRulesIncluded != null) { if (customRulesIncluded != null) {
for (RenderingRuleProperty p : customRulesIncluded) { for (RenderingRuleProperty p : customRulesIncluded) {
if (!p.isBoolean()) { if (!p.isBoolean()) {
@ -1209,10 +1241,11 @@ public class ConfigureMapMenu {
} }
private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity, private void createCustomRenderingProperties(final ContextMenuAdapter adapter, final MapActivity activity,
List<RenderingRuleProperty> customRules, final int themeRes) { List<RenderingRuleProperty> customRules, final OsmandApplication app, final int currentProfileColor,
final boolean nightMode, final int themeRes) {
for (final RenderingRuleProperty p : customRules) { for (final RenderingRuleProperty p : customRules) {
if (isPropertyAccepted(p)) { if (isPropertyAccepted(p)) {
adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName(), themeRes)); adapter.addItem(createRenderingProperty(adapter, activity, 0, p, CUSTOM_RENDERING_ITEMS_ID_SCHEME + p.getName(), app, currentProfileColor, nightMode, themeRes));
} }
} }
} }
@ -1230,10 +1263,10 @@ public class ConfigureMapMenu {
private ContextMenuItem createRenderingProperty(final List<RenderingRuleProperty> customRules, private ContextMenuItem createRenderingProperty(final List<RenderingRuleProperty> customRules,
final ContextMenuAdapter adapter, final MapActivity activity, final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final String attrName, String id, @DrawableRes final int icon, final String attrName, String id,
final int themeRes) { final OsmandApplication app, final int currentProfileColor, final boolean nightMode, final int themeRes) {
for (final RenderingRuleProperty p : customRules) { for (final RenderingRuleProperty p : customRules) {
if (p.getAttrName().equals(attrName)) { if (p.getAttrName().equals(attrName)) {
return createRenderingProperty(adapter, activity, icon, p, id, themeRes); return createRenderingProperty(adapter, activity, icon, p, id, app, currentProfileColor, nightMode, themeRes);
} }
} }
return null; return null;
@ -1241,7 +1274,7 @@ public class ConfigureMapMenu {
private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity, private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity,
@DrawableRes final int icon, final RenderingRuleProperty p, final String id, @DrawableRes final int icon, final RenderingRuleProperty p, final String id,
final int themeRes) { final OsmandApplication app, final int currentProfileColor, final boolean nightMode, final int themeRes) {
final OsmandMapTileView view = activity.getMapView(); final OsmandMapTileView view = activity.getMapView();
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(), String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
p.getName()); p.getName());
@ -1300,23 +1333,25 @@ public class ConfigureMapMenu {
possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(view.getContext(), possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(view.getContext(),
p.getPossibleValues()[j]); p.getPossibleValues()[j]);
} }
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() { possibleValuesString, nightMode, i, app, currentProfileColor, themeRes, new View.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(View v) {
if (which == 0) { int which = (int) v.getTag();
pref.set(""); if (which == 0) {
} else { pref.set("");
pref.set(p.getPossibleValues()[which - 1]); } else {
pref.set(p.getPossibleValues()[which - 1]);
}
refreshMapComplete(activity);
String description = SettingsActivity.getStringPropertyValue(activity, pref.get());
adapter.getItem(pos).setDescription(description);
}
} }
refreshMapComplete(activity); );
String description = SettingsActivity.getStringPropertyValue(activity, pref.get());
adapter.getItem(pos).setDescription(description);
dialog.dismiss();
}
});
b.setNegativeButton(R.string.shared_string_dismiss, null); b.setNegativeButton(R.string.shared_string_dismiss, null);
b.show(); b.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(b.show());
return false; return false;
} }
}) })

View file

@ -22,8 +22,11 @@ public class RasterMapMenu {
private static final String TAG = "RasterMapMenu"; private static final String TAG = "RasterMapMenu";
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity, public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
final RasterMapType type) { final RasterMapType type) {
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
ContextMenuAdapter adapter = new ContextMenuAdapter(); ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
createLayersItems(adapter, mapActivity, type); createLayersItems(adapter, mapActivity, type);
return adapter; return adapter;
} }

View file

@ -24,6 +24,7 @@ import net.osmand.OsmAndCollator;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.MenuBottomSheetDialogFragment; import net.osmand.plus.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem; import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
@ -53,7 +54,6 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
private LinearLayout stylesContainer; private LinearLayout stylesContainer;
private BottomSheetItemTitleWithDescrAndButton descrItem; private BottomSheetItemTitleWithDescrAndButton descrItem;
private View.OnClickListener onStyleClickListener; private View.OnClickListener onStyleClickListener;
private ColorStateList rbColorList;
private TreeMap<String, String> stylesMap; private TreeMap<String, String> stylesMap;
private String selectedStyle; private String selectedStyle;
@ -78,8 +78,6 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
selectedStyle = RendererRegistry.DEFAULT_RENDER; selectedStyle = RendererRegistry.DEFAULT_RENDER;
} }
rbColorList = AndroidUtils.createCheckedColorStateList(context, R.color.icon_color_default_light, getActiveColorId());
items.add(new TitleItem(getString(R.string.map_widget_renderer))); items.add(new TitleItem(getString(R.string.map_widget_renderer)));
descrItem = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder() descrItem = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
@ -215,7 +213,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
RadioButton rb = (RadioButton) view.findViewById(R.id.compound_button); RadioButton rb = (RadioButton) view.findViewById(R.id.compound_button);
rb.setChecked(selected); rb.setChecked(selected);
CompoundButtonCompat.setButtonTintList(rb, rbColorList); UiUtilities.setupCompoundButton(getMyApplication(), rb, nightMode, true);
counter++; counter++;
} }
@ -224,7 +222,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
@ColorInt @ColorInt
private int getStyleTitleColor(boolean selected) { private int getStyleTitleColor(boolean selected) {
int colorId = selected int colorId = selected
? getActiveColorId() ? getMyApplication() != null ? getMyApplication().getSettings().APPLICATION_MODE.get().getIconColorInfo().getColor(nightMode) : getActiveColorId()
: nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light; : nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light;
return getResolvedColor(colorId); return getResolvedColor(colorId);
} }

View file

@ -224,7 +224,8 @@ public class GpxUiHelper {
public static AlertDialog selectGPXFiles(List<String> selectedGpxList, final Activity activity, public static AlertDialog selectGPXFiles(List<String> selectedGpxList, final Activity activity,
final CallbackWithObject<GPXFile[]> callbackWithObject, final CallbackWithObject<GPXFile[]> callbackWithObject,
int dialogThemeRes) { int dialogThemeRes,
boolean nightMode) {
OsmandApplication app = (OsmandApplication) activity.getApplication(); OsmandApplication app = (OsmandApplication) activity.getApplication();
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
final List<GPXInfo> allGpxList = getSortedGPXFilesInfo(dir, selectedGpxList, false); final List<GPXInfo> allGpxList = getSortedGPXFilesInfo(dir, selectedGpxList, false);
@ -234,7 +235,7 @@ public class GpxUiHelper {
allGpxList.add(0, new GPXInfo(activity.getString(R.string.show_current_gpx_title), 0, 0)); allGpxList.add(0, new GPXInfo(activity.getString(R.string.show_current_gpx_title), 0, 0));
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(allGpxList, selectedGpxList, true); final ContextMenuAdapter adapter = createGpxContextMenuAdapter(allGpxList, selectedGpxList, true);
return createDialog(activity, true, true, true, callbackWithObject, allGpxList, adapter, dialogThemeRes); return createDialog(activity, true, true, true, callbackWithObject, allGpxList, adapter, dialogThemeRes, nightMode);
} }
public static AlertDialog selectGPXFile(final Activity activity, public static AlertDialog selectGPXFile(final Activity activity,
@ -253,7 +254,7 @@ public class GpxUiHelper {
} }
final ContextMenuAdapter adapter = createGpxContextMenuAdapter(list, null, showCurrentGpx); final ContextMenuAdapter adapter = createGpxContextMenuAdapter(list, null, showCurrentGpx);
return createDialog(activity, showCurrentGpx, multipleChoice, false, callbackWithObject, list, adapter, dialogThemeRes); return createDialog(activity, showCurrentGpx, multipleChoice, false, callbackWithObject, list, adapter, dialogThemeRes, nightMode);
} }
return null; return null;
} }
@ -500,7 +501,8 @@ public class GpxUiHelper {
final CallbackWithObject<GPXFile[]> callbackWithObject, final CallbackWithObject<GPXFile[]> callbackWithObject,
final List<GPXInfo> list, final List<GPXInfo> list,
final ContextMenuAdapter adapter, final ContextMenuAdapter adapter,
final int themeRes) { final int themeRes,
final boolean nightMode) {
final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandApplication app = (OsmandApplication) activity.getApplication();
final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity); final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity);
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR); final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
@ -559,6 +561,7 @@ public class GpxUiHelper {
item.setSelected(isChecked); item.setSelected(isChecked);
} }
}); });
UiUtilities.setupCompoundButton(app, ch, nightMode, true);
} else { } else {
final SwitchCompat ch = ((SwitchCompat) v.findViewById(R.id.toggle_item)); final SwitchCompat ch = ((SwitchCompat) v.findViewById(R.id.toggle_item));
ch.setVisibility(View.VISIBLE); ch.setVisibility(View.VISIBLE);
@ -571,6 +574,7 @@ public class GpxUiHelper {
item.setSelected(isChecked); item.setSelected(isChecked);
} }
}); });
UiUtilities.setupCompoundButton(app, ch, nightMode, true);
} }
v.findViewById(R.id.check_item).setVisibility(View.VISIBLE); v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
} }

View file

@ -30,6 +30,7 @@ import net.osmand.map.TileSourceManager;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment; import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.resources.ResourceManager; import net.osmand.plus.resources.ResourceManager;
@ -59,6 +60,8 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
final int backgroundColor = ContextCompat.getColor(getActivity(), final int backgroundColor = ContextCompat.getColor(getActivity(),
nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light); nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM); final DateFormat dateFormat = SimpleDateFormat.getDateInstance(DateFormat.MEDIUM);
final int currentModeColorRes = getMyApplication().getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode);
final int currentModeColor = ContextCompat.getColor(getActivity(), currentModeColorRes);
final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null); final View view = View.inflate(new ContextThemeWrapper(getContext(), themeRes), R.layout.fragment_mapillary_filters, null);
view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor); view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor);
@ -71,7 +74,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
int toggleIconId; int toggleIconId;
if (selected) { if (selected) {
toggleIconId = R.drawable.ic_action_view; toggleIconId = R.drawable.ic_action_view;
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; toggleIconColorId = currentModeColorRes;
} else { } else {
toggleIconId = R.drawable.ic_action_hide; toggleIconId = R.drawable.ic_action_hide;
toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
@ -96,6 +99,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
toggle.setChecked(!toggle.isChecked()); toggle.setChecked(!toggle.isChecked());
} }
}); });
UiUtilities.setupCompoundButton(nightMode, currentModeColor, toggle);
final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile); final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile);
@ -244,6 +248,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
pano.setChecked(!pano.isChecked()); pano.setChecked(!pano.isChecked());
} }
}); });
UiUtilities.setupCompoundButton(nightMode, currentModeColor, pano);
final Button apply = (Button) view.findViewById(R.id.button_apply); final Button apply = (Button) view.findViewById(R.id.button_apply);

View file

@ -2,7 +2,6 @@ package net.osmand.plus.mapmarkers;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.LayerDrawable;
@ -10,7 +9,6 @@ import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.widget.CompoundButtonCompat;
import android.support.v7.widget.ListPopupWindow; import android.support.v7.widget.ListPopupWindow;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.SpannableString; import android.text.SpannableString;
@ -52,6 +50,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
private int helpImgHeight; private int helpImgHeight;
private boolean shadowVisible; private boolean shadowVisible;
private boolean usedOnMap = false;
public void setListener(DirectionIndicationFragmentListener listener) { public void setListener(DirectionIndicationFragmentListener listener) {
this.listener = listener; this.listener = listener;
@ -61,6 +60,8 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
@Override @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
final OsmandSettings settings = getSettings(); final OsmandSettings settings = getSettings();
boolean nightMode = isNightMode(usedOnMap);
helpImgHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_image_height); helpImgHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_image_height);
mainView = UiUtilities.getInflater(getContext(), !settings.isLightContent()).inflate(R.layout.fragment_direction_indication_dialog, container); mainView = UiUtilities.getInflater(getContext(), !settings.isLightContent()).inflate(R.layout.fragment_direction_indication_dialog, container);
@ -151,6 +152,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
updateSelection(true); updateSelection(true);
} }
}); });
UiUtilities.setupCompoundButton(getMyApplication(), distanceIndicationToggle, nightMode, true);
mainView.findViewById(R.id.top_bar_row).setOnClickListener(new View.OnClickListener() { mainView.findViewById(R.id.top_bar_row).setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -178,6 +180,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
updateChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS, showArrowsToggle); updateChecked(settings.SHOW_ARROWS_TO_FIRST_MARKERS, showArrowsToggle);
} }
}); });
UiUtilities.setupCompoundButton(getMyApplication(), showArrowsToggle, nightMode, true);
final CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch); final CompoundButton showLinesToggle = (CompoundButton) mainView.findViewById(R.id.show_guide_line_switch);
showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get()); showLinesToggle.setChecked(settings.SHOW_LINES_TO_FIRST_MARKERS.get());
@ -187,6 +190,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
updateChecked(settings.SHOW_LINES_TO_FIRST_MARKERS, showLinesToggle); updateChecked(settings.SHOW_LINES_TO_FIRST_MARKERS, showLinesToggle);
} }
}); });
UiUtilities.setupCompoundButton(getMyApplication(), showLinesToggle, nightMode, true);
final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch); final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch);
oneTapActiveToggle.setChecked(settings.SELECT_MARKER_ON_SINGLE_TAP.get()); oneTapActiveToggle.setChecked(settings.SELECT_MARKER_ON_SINGLE_TAP.get());
@ -196,6 +200,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
updateChecked(settings.SELECT_MARKER_ON_SINGLE_TAP, oneTapActiveToggle); updateChecked(settings.SELECT_MARKER_ON_SINGLE_TAP, oneTapActiveToggle);
} }
}); });
UiUtilities.setupCompoundButton(getMyApplication(), oneTapActiveToggle, nightMode, true);
final CompoundButton keepPassedToggle = (CompoundButton) mainView.findViewById(R.id.keep_passed_switch); final CompoundButton keepPassedToggle = (CompoundButton) mainView.findViewById(R.id.keep_passed_switch);
keepPassedToggle.setChecked(settings.KEEP_PASSED_MARKERS_ON_MAP.get()); keepPassedToggle.setChecked(settings.KEEP_PASSED_MARKERS_ON_MAP.get());
@ -205,6 +210,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
updateChecked(settings.KEEP_PASSED_MARKERS_ON_MAP, keepPassedToggle); updateChecked(settings.KEEP_PASSED_MARKERS_ON_MAP, keepPassedToggle);
} }
}); });
UiUtilities.setupCompoundButton(getMyApplication(), keepPassedToggle, nightMode, true);
return mainView; return mainView;
} }
@ -379,12 +385,9 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
} }
private void updateMarkerModeRow(int rowId, int radioButtonId, boolean checked, boolean active) { private void updateMarkerModeRow(int rowId, int radioButtonId, boolean checked, boolean active) {
boolean night = !getSettings().isLightContent();
RadioButton rb = (RadioButton) mainView.findViewById(radioButtonId); RadioButton rb = (RadioButton) mainView.findViewById(radioButtonId);
int colorId = active ? night ? R.color.active_color_primary_dark : R.color.active_color_primary_light
: night ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
rb.setChecked(checked); rb.setChecked(checked);
CompoundButtonCompat.setButtonTintList(rb, ColorStateList.valueOf(ContextCompat.getColor(getContext(), colorId))); UiUtilities.setupCompoundButton(getMyApplication(), rb, isNightMode(usedOnMap), true);
mainView.findViewById(rowId).setEnabled(active); mainView.findViewById(rowId).setEnabled(active);
} }

View file

@ -6,9 +6,10 @@ import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener; import android.content.DialogInterface.OnClickListener;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckBox;
import android.view.View; import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -452,14 +453,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
Context themedContext = UiUtilities.getThemedContext(uiCtx, nightMode); Context themedContext = UiUtilities.getThemedContext(uiCtx, nightMode);
AlertDialog.Builder dlg = new AlertDialog.Builder(themedContext); AlertDialog.Builder dlg = new AlertDialog.Builder(themedContext);
dlg.setTitle(title); dlg.setTitle(title);
LinearLayout ll = createIntervalChooseLayout(themedContext, patternMsg, seconds, minutes, choice, v, showTrackSelection, nightMode); LinearLayout ll = createIntervalChooseLayout(app, themedContext, patternMsg, seconds, minutes, choice, v, showTrackSelection, nightMode);
dlg.setView(ll); dlg.setView(ll);
dlg.setPositiveButton(R.string.shared_string_ok, onclick); dlg.setPositiveButton(R.string.shared_string_ok, onclick);
dlg.setNegativeButton(R.string.shared_string_cancel, null); dlg.setNegativeButton(R.string.shared_string_cancel, null);
dlg.show(); dlg.show();
} }
public static LinearLayout createIntervalChooseLayout(final Context uiCtx, public static LinearLayout createIntervalChooseLayout(final OsmandApplication app,
final Context uiCtx,
final String patternMsg, final int[] seconds, final String patternMsg, final int[] seconds,
final int[] minutes, final ValueHolder<Boolean> choice, final int[] minutes, final ValueHolder<Boolean> choice,
final ValueHolder<Integer> v, final ValueHolder<Integer> v,
@ -503,6 +505,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
} }
}); });
UiUtilities.setupSeekBar(app, sp, nightMode, true);
for (int i = 0; i < secondsLength + minutesLength - 1; i++) { for (int i = 0; i < secondsLength + minutesLength - 1; i++) {
if (i < secondsLength) { if (i < secondsLength) {
@ -521,13 +524,16 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
ll.setOrientation(LinearLayout.VERTICAL); ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(tv); ll.addView(tv);
ll.addView(sp); ll.addView(sp);
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
if (choice != null) { if (choice != null) {
final CheckBox cb = new CheckBox(uiCtx); final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
cb.setText(R.string.shared_string_remember_my_choice); cb.setText(R.string.shared_string_remember_my_choice);
cb.setTextColor(textColorPrimary);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT); LayoutParams.WRAP_CONTENT);
lp.setMargins(dp24, dp8, dp24, 0); lp.setMargins(dp24, dp8, dp24, 0);
cb.setLayoutParams(lp); cb.setLayoutParams(lp);
cb.setPadding(dp8, 0, 0, 0);
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override @Override
@ -536,11 +542,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
} }
}); });
UiUtilities.setupCompoundButton(app, cb, nightMode, true);
ll.addView(cb); ll.addView(cb);
} }
if (showTrackSelection) { if (showTrackSelection) {
final OsmandApplication app = (OsmandApplication) uiCtx.getApplicationContext();
View divider = new View(uiCtx); View divider = new View(uiCtx);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtils.dpToPx(uiCtx, 1f)); LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtils.dpToPx(uiCtx, 1f));
lp.setMargins(0, dp8 * 2, 0, 0); lp.setMargins(0, dp8 * 2, 0, 0);
@ -548,12 +554,14 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
divider.setBackgroundColor(uiCtx.getResources().getColor(nightMode ? R.color.divider_color_dark : R.color.divider_color_light)); divider.setBackgroundColor(uiCtx.getResources().getColor(nightMode ? R.color.divider_color_dark : R.color.divider_color_light));
ll.addView(divider); ll.addView(divider);
final CheckBox cb = new CheckBox(uiCtx); final AppCompatCheckBox cb = new AppCompatCheckBox(uiCtx);
cb.setText(R.string.shared_string_show_on_map); cb.setText(R.string.shared_string_show_on_map);
cb.setTextColor(textColorPrimary);
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT); LayoutParams.WRAP_CONTENT);
lp.setMargins(dp24, dp8 * 2, dp24, 0); lp.setMargins(dp24, dp8 * 2, dp24, 0);
cb.setLayoutParams(lp); cb.setLayoutParams(lp);
cb.setPadding(dp8, 0, 0, 0);
cb.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null); cb.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() { cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@ -562,6 +570,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false); app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false);
} }
}); });
UiUtilities.setupCompoundButton(app, cb, nightMode, true);
ll.addView(cb); ll.addView(cb);
} }

View file

@ -1,12 +1,16 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog;
import android.view.ContextThemeWrapper;
import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.OsmandSettings.CommonPreference; import net.osmand.plus.OsmandSettings.CommonPreference;
@ -22,19 +26,27 @@ public class OsmNotesMenu {
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) { public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
ContextMenuAdapter adapter = new ContextMenuAdapter(); ContextMenuAdapter adapter = new ContextMenuAdapter();
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
createLayersItems(adapter, mapActivity); createLayersItems(adapter, mapActivity);
return adapter; return adapter;
} }
private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) { private static void createLayersItems(final ContextMenuAdapter adapter, final MapActivity mapActivity) {
final OsmandSettings settings = mapActivity.getMyApplication().getSettings(); final OsmandApplication app = mapActivity.getMyApplication();
final OsmandSettings settings = app.getSettings();
final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class); final OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
if (plugin == null) { if (plugin == null) {
return; return;
} }
final boolean nightMode = isNightMode(app);
final int themeRes = getThemeRes(app);
final int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
final int osmNotesStringId = R.string.layer_osm_bugs; final int osmNotesStringId = R.string.layer_osm_bugs;
final int showZoomLevelStringId = R.string.show_from_zoom_level; final int showZoomLevelStringId = R.string.show_from_zoom_level;
final int showClosedNotesStringId = R.string.show_closed_notes; final int showClosedNotesStringId = R.string.show_closed_notes;
@ -57,11 +69,11 @@ public class OsmNotesMenu {
} else if (itemId == showZoomLevelStringId) { } else if (itemId == showZoomLevelStringId) {
int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get()); int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
new AlertDialog.Builder(mapActivity) DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
.setTitle(R.string.show_from_zoom_level) zoomStrings, nightMode, checked, app, selectedModeColor, themeRes, new View.OnClickListener() {
.setSingleChoiceItems(zoomStrings, checked, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(View v) {
int which = (int) v.getTag();
showOsmBugsZoomPref.set(zoomIntValues[which]); showOsmBugsZoomPref.set(zoomIntValues[which]);
ContextMenuItem item = adapter.getItem(position); ContextMenuItem item = adapter.getItem(position);
if (item != null) { if (item != null) {
@ -69,11 +81,14 @@ public class OsmNotesMenu {
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
mapActivity.refreshMap(); mapActivity.refreshMap();
dialog.dismiss();
} }
}) }
.setNegativeButton(R.string.shared_string_dismiss, null) );
.show(); AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(mapActivity, themeRes))
.setTitle(R.string.show_from_zoom_level)
.setAdapter(dialogAdapter, null)
.setNegativeButton(R.string.shared_string_dismiss, null);
dialogAdapter.setDialog(b.show());
} else if (itemId == showClosedNotesStringId) { } else if (itemId == showClosedNotesStringId) {
showClosedOsmBugsPref.set(isChecked); showClosedOsmBugsPref.set(isChecked);
mapActivity.refreshMap(); mapActivity.refreshMap();
@ -83,12 +98,11 @@ public class OsmNotesMenu {
}; };
boolean showOsmBugs = showOsmBugsPref.get(); boolean showOsmBugs = showOsmBugsPref.get();
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
int toggleIconColorId; int toggleIconColorId;
if (showOsmBugs) { if (showOsmBugs) {
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light; toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
} else { } else {
toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; toggleIconColorId = ContextMenuItem.INVALID_ID;
} }
adapter.addItem(new ContextMenuItem.ItemBuilder() adapter.addItem(new ContextMenuItem.ItemBuilder()
@ -132,4 +146,15 @@ public class OsmNotesMenu {
} }
return res; return res;
} }
public static boolean isNightMode(OsmandApplication app) {
if (app == null) {
return false;
}
return app.getDaynightHelper().isNightModeForMapControls();
}
public static int getThemeRes(OsmandApplication app) {
return isNightMode(app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
} }

View file

@ -92,7 +92,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
@Override @Override
public void createMenuItems(Bundle savedInstanceState) { public void createMenuItems(Bundle savedInstanceState) {
int activeColorRes = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
if (type.equals(TYPE_BASE_APP_PROFILE)) { if (type.equals(TYPE_BASE_APP_PROFILE)) {
items.add(new TitleItem(getString(R.string.select_base_profile_dialog_title))); items.add(new TitleItem(getString(R.string.select_base_profile_dialog_title)));
items.add(new LongDescriptionItem(getString(R.string.select_base_profile_dialog_message))); items.add(new LongDescriptionItem(getString(R.string.select_base_profile_dialog_message)));
@ -103,15 +103,14 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
final Drawable drawableIcon; final Drawable drawableIcon;
if (isSelected) { if (isSelected) {
drawableIcon = getMyApplication().getUIUtilities() drawableIcon = getMyApplication().getUIUtilities()
.getIcon(profile.getIconRes(), nightMode .getIcon(profile.getIconRes(), activeColorRes);
? R.color.active_color_primary_dark
: R.color.active_color_primary_light);
} else { } else {
drawableIcon = getMyApplication().getUIUtilities() drawableIcon = getMyApplication().getUIUtilities()
.getIcon(profile.getIconRes(), R.color.icon_color_default_light); .getIcon(profile.getIconRes(), R.color.icon_color_default_light);
} }
items.add(new BottomSheetItemWithCompoundButton.Builder() items.add(new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(activeColorRes)
.setChecked(isSelected) .setChecked(isSelected)
.setButtonTintList(isSelected .setButtonTintList(isSelected
? ColorStateList.valueOf(getResolvedColor(getActiveColorId())) ? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
@ -143,15 +142,14 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
final Drawable drawableIcon; final Drawable drawableIcon;
if (isSelected) { if (isSelected) {
drawableIcon = getMyApplication().getUIUtilities() drawableIcon = getMyApplication().getUIUtilities()
.getIcon(profile.getIconRes(), nightMode .getIcon(profile.getIconRes(), activeColorRes);
? R.color.active_color_primary_dark
: R.color.active_color_primary_light);
} else { } else {
drawableIcon = getMyApplication().getUIUtilities() drawableIcon = getMyApplication().getUIUtilities()
.getIcon(profile.getIconRes(), R.color.icon_color_default_light); .getIcon(profile.getIconRes(), R.color.icon_color_default_light);
} }
items.add(new BottomSheetItemWithCompoundButton.Builder() items.add(new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(activeColorRes)
.setChecked(isSelected) .setChecked(isSelected)
.setButtonTintList(isSelected .setButtonTintList(isSelected
? ColorStateList.valueOf(getResolvedColor(getActiveColorId())) ? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
@ -189,6 +187,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
} }
items.add(new BottomSheetItemWithCompoundButton.Builder() items.add(new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(activeColorRes)
.setChecked(icon.getResStringId().equals(selectedIconRes)) .setChecked(icon.getResStringId().equals(selectedIconRes))
.setButtonTintList(isSelected .setButtonTintList(isSelected
? ColorStateList.valueOf(getResolvedColor(getActiveColorId())) ? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))

View file

@ -5,7 +5,9 @@ import android.content.DialogInterface;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckBox;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.View; import android.view.View;
import android.widget.AdapterView; import android.widget.AdapterView;
@ -26,6 +28,7 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuAdapter.ItemClickListener; import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -433,16 +436,22 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
names[i] = downloaded.get(i).getName(); names[i] = downloaded.get(i).getName();
} }
final boolean[] selected = new boolean[downloaded.size()]; final boolean[] selected = new boolean[downloaded.size()];
builder.setMultiChoiceItems(names, selected, new DialogInterface.OnMultiChoiceClickListener() { boolean nightMode = isNightMode(activity, app);
int themeResId = getThemeRes(activity, app);
@Override int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode));
public void onClick(DialogInterface dialog, int which, boolean isChecked) { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app,
selected[which] = isChecked; selectedProfileColor, themeResId, new View.OnClickListener() {
if (entriesMap.containsKey(downloaded.get(which).getName()) && isChecked) { @Override
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show(); public void onClick(View v) {
int which = (int) v.getTag();
selected[which] = !selected[which];
if (entriesMap.containsKey(downloaded.get(which).getName()) && selected[which]) {
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
}
}
} }
} );
}); builder.setAdapter(dialogAdapter, null);
builder.setNegativeButton(R.string.shared_string_cancel, null); builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.setTitle(R.string.select_tile_source_to_install); builder.setTitle(R.string.select_tile_source_to_install);
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() { builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
@ -467,8 +476,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
} }
} }
}); });
dialogAdapter.setDialog(builder.show());
builder.show();
} }
}; };
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
@ -478,6 +486,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final OsmandApplication app = (OsmandApplication) activity.getApplication(); final OsmandApplication app = (OsmandApplication) activity.getApplication();
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
final Map<String, String> entriesMap = settings.getTileSourceEntries(false); final Map<String, String> entriesMap = settings.getTileSourceEntries(false);
boolean nightMode = isNightMode(activity, app);
final int dp8 = AndroidUtils.dpToPx(app, 8f);
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png", TileSourceTemplate ts = new TileSourceTemplate("NewMapnik", "http://mapnik.osmand.net/{0}/{1}/{2}.png",
"png", 17, 5, 256, 16, 32000); "png", 17, 5, 256, 16, 32000);
final TileSourceTemplate[] result = new TileSourceTemplate[]{ts}; final TileSourceTemplate[] result = new TileSourceTemplate[]{ts};
@ -489,7 +500,10 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
final EditText minZoom = (EditText) view.findViewById(R.id.MinZoom); final EditText minZoom = (EditText) view.findViewById(R.id.MinZoom);
final EditText maxZoom = (EditText) view.findViewById(R.id.MaxZoom); final EditText maxZoom = (EditText) view.findViewById(R.id.MaxZoom);
final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime); final EditText expire = (EditText) view.findViewById(R.id.ExpirationTime);
final CheckBox elliptic = (CheckBox) view.findViewById(R.id.EllipticMercator); final AppCompatCheckBox elliptic = (AppCompatCheckBox) view.findViewById(R.id.EllipticMercator);
elliptic.setTextColor(textColorPrimary);
elliptic.setPadding(dp8, 0, 0, 0);
UiUtilities.setupCompoundButton(app, elliptic, nightMode, true);
updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic); updateTileSourceEditView(ts, name, urlToLoad, minZoom, maxZoom, expire, elliptic);
final ArrayList<String> templates = new ArrayList<>(entriesMap.keySet()); final ArrayList<String> templates = new ArrayList<>(entriesMap.keySet());

View file

@ -4,6 +4,7 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
@ -30,7 +31,6 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.SubtitleDividerItem;
import net.osmand.plus.dashboard.DashboardOnMap; import net.osmand.plus.dashboard.DashboardOnMap;
import net.osmand.plus.helpers.AvoidSpecificRoads; import net.osmand.plus.helpers.AvoidSpecificRoads;
import net.osmand.plus.routing.RoutingHelper;
import net.osmand.router.GeneralRouter; import net.osmand.router.GeneralRouter;
import java.io.Serializable; import java.io.Serializable;
@ -39,6 +39,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem.INVALID_ID;
public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment { public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
@ -57,6 +59,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
private List<LatLon> removedImpassableRoads; private List<LatLon> removedImpassableRoads;
private LinearLayout stylesContainer; private LinearLayout stylesContainer;
private boolean hideImpassableRoads; private boolean hideImpassableRoads;
@ColorRes private int compoundButtonColorId = INVALID_ID;
public AvoidRoadsBottomSheetDialogFragment() { public AvoidRoadsBottomSheetDialogFragment() {
} }
@ -229,6 +232,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(compoundButtonColorId)
.setChecked(selected) .setChecked(selected)
.setTitle(parameterName) .setTitle(parameterName)
.setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon) .setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon)
@ -246,6 +250,10 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
} }
} }
public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
this.compoundButtonColorId = compoundButtonColorId;
}
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();

View file

@ -2,6 +2,7 @@ package net.osmand.plus.routepreparationmenu;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.ColorRes;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
@ -59,6 +60,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private RoutingHelper routingHelper; private RoutingHelper routingHelper;
private RoutingOptionsHelper routingOptionsHelper; private RoutingOptionsHelper routingOptionsHelper;
private ApplicationMode applicationMode; private ApplicationMode applicationMode;
@ColorRes private int selectedModeColorId;
private MapActivity mapActivity; private MapActivity mapActivity;
@Override @Override
@ -70,6 +72,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingOptionsHelper = app.getRoutingOptionsHelper(); routingOptionsHelper = app.getRoutingOptionsHelper();
mapActivity = getMapActivity(); mapActivity = getMapActivity();
applicationMode = routingHelper.getAppMode(); applicationMode = routingHelper.getAppMode();
selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
} }
@Override @Override
@ -137,6 +140,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode); boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setChecked(active) .setChecked(active)
.setDescription(getString(R.string.voice_announcements)) .setDescription(getString(R.string.voice_announcements))
.setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId())) .setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()))
@ -160,6 +164,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) { private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.get()) .setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.get())
.setIcon(getContentIcon((optionsItem.getActiveIconId()))) .setIcon(getContentIcon((optionsItem.getActiveIconId())))
.setTitle(getString(R.string.temporary_conditional_routing)) .setTitle(getString(R.string.temporary_conditional_routing))
@ -195,6 +200,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
fragment.setUsedOnMap(true); fragment.setUsedOnMap(true);
fragment.setArguments(args); fragment.setArguments(args);
fragment.setTargetFragment(RouteOptionsBottomSheet.this, ShowAlongTheRouteBottomSheet.REQUEST_CODE); fragment.setTargetFragment(RouteOptionsBottomSheet.this, ShowAlongTheRouteBottomSheet.REQUEST_CODE);
fragment.setAppMode(applicationMode);
fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG); fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG);
updateMenu(); updateMenu();
} }
@ -204,6 +210,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) { private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1];
simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder() simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
.setCompoundButtonColorId(selectedModeColorId)
.setChecked(settings.simulateNavigation) .setChecked(settings.simulateNavigation)
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation)) .setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
.setTitle(getString(R.string.simulate_navigation)) .setTitle(getString(R.string.simulate_navigation))
@ -240,6 +247,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(); AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu(); updateMenu();
} }
@ -259,6 +267,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem); routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true); AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE); avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG); avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
updateMenu(); updateMenu();
} }
@ -313,6 +322,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
if (parameter != null) { if (parameter != null) {
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1]; final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder(); BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
builder.setCompoundButtonColorId(selectedModeColorId);
int iconId = -1; int iconId = -1;
if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) { if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) {
builder.setTitle(parameter.getText(mapActivity)); builder.setTitle(parameter.getText(mapActivity));

View file

@ -4,14 +4,16 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.AppCompatCheckedTextView;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.TextView;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.GPXUtilities; import net.osmand.GPXUtilities;
@ -21,6 +23,7 @@ import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -144,26 +147,33 @@ public class RoutingOptionsHelper {
entries[k] = mapActivity.getResources().getString(R.string.install_more); entries[k] = mapActivity.getResources().getString(R.string.install_more);
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem()); adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity); boolean nightMode = isNightMode(app);
bld.setSingleChoiceItems(entries, selected, new DialogInterface.OnClickListener() { Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
int themeRes = getThemeRes(app);
@Override ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
public void onClick(DialogInterface dialog, int which) { int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
String value = entrieValues[which]; DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
if (MORE_VALUE.equals(value)) { entries, nightMode, selected, app, selectedModeColor, themeRes, new View.OnClickListener() {
final Intent intent = new Intent(mapActivity, DownloadActivity.class); @Override
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB); public void onClick(View v) {
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag()); int which = (int) v.getTag();
mapActivity.startActivity(intent); String value = entrieValues[which];
} else { if (MORE_VALUE.equals(value)) {
if (callback != null) { final Intent intent = new Intent(mapActivity, DownloadActivity.class);
callback.processResult(value); intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
intent.putExtra(DownloadActivity.FILTER_CAT, DownloadActivityType.VOICE_FILE.getTag());
mapActivity.startActivity(intent);
} else {
if (callback != null) {
callback.processResult(value);
}
}
} }
} }
dialog.dismiss(); );
} AlertDialog.Builder bld = new AlertDialog.Builder(themedContext);
}); bld.setAdapter(dialogAdapter, null);
bld.show(); dialogAdapter.setDialog(bld.show());
} }
public String getVoiceProviderName(Context ctx, String value) { public String getVoiceProviderName(Context ctx, String value) {
@ -315,8 +325,10 @@ public class RoutingOptionsHelper {
selectedIndex = 0; selectedIndex = 0;
} }
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls(); final boolean nightMode = isNightMode(app);
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode); Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
final int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
AlertDialog.Builder builder = new AlertDialog.Builder(themedContext); AlertDialog.Builder builder = new AlertDialog.Builder(themedContext);
final int layout = R.layout.list_menu_item_native_singlechoice; final int layout = R.layout.list_menu_item_native_singlechoice;
@ -330,9 +342,12 @@ public class RoutingOptionsHelper {
v = UiUtilities.getInflater(mapActivity, nightMode).inflate(layout, parent, false); v = UiUtilities.getInflater(mapActivity, nightMode).inflate(layout, parent, false);
} }
final ContextMenuItem item = adapter.getItem(position); final ContextMenuItem item = adapter.getItem(position);
TextView tv = (TextView) v.findViewById(R.id.text1); AppCompatCheckedTextView tv = (AppCompatCheckedTextView) v.findViewById(R.id.text1);
tv.setText(item.getTitle()); tv.setText(item.getTitle());
tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f); tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 16f);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
UiUtilities.setupCompoundButtonDrawable(app, nightMode, selectedModeColor, tv.getCheckMarkDrawable());
}
return v; return v;
} }
@ -591,6 +606,17 @@ public class RoutingOptionsHelper {
return parameter; return parameter;
} }
public boolean isNightMode(OsmandApplication app) {
if (app == null) {
return false;
}
return app.getDaynightHelper().isNightModeForMapControls();
}
public int getThemeRes(OsmandApplication app) {
return isNightMode(app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
public static class LocalRoutingParameter { public static class LocalRoutingParameter {
public static final String KEY = "LocalRoutingParameter"; public static final String KEY = "LocalRoutingParameter";

View file

@ -1,7 +1,6 @@
package net.osmand.plus.routepreparationmenu; package net.osmand.plus.routepreparationmenu;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
@ -21,6 +20,8 @@ import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.ValueHolder; import net.osmand.ValueHolder;
import net.osmand.plus.ApplicationMode;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
@ -54,6 +55,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
private MapActivity mapActivity; private MapActivity mapActivity;
private WaypointHelper waypointHelper; private WaypointHelper waypointHelper;
private ApplicationMode appMode;
private ExpandableListView expListView; private ExpandableListView expListView;
private ExpandableListAdapter adapter; private ExpandableListAdapter adapter;
@ -207,6 +209,17 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
} }
public void setAppMode(ApplicationMode appMode) {
this.appMode = appMode;
}
public ApplicationMode getAppMode() {
if (appMode == null) {
setAppMode(app.getSettings().getApplicationMode());
}
return appMode;
}
@Override @Override
public void onRoutingDataUpdate() { public void onRoutingDataUpdate() {
updateAdapter(); updateAdapter();
@ -339,6 +352,8 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
} }
} }
}); });
int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(isNightMode(app)));
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, compoundButton);
convertView.setOnClickListener(new View.OnClickListener() { convertView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -496,21 +511,28 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
selected = i; selected = i;
} }
} }
new AlertDialog.Builder(mapActivity) int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode));
.setSingleChoiceItems(names, selected, new DialogInterface.OnClickListener() { DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
names, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialogInterface, int i) { public void onClick(View v) {
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i]; int which = (int) v.getTag();
int value = WaypointHelper.SEARCH_RADIUS_VALUES[which];
if (waypointHelper.getSearchDeviationRadius(type) != value) { if (waypointHelper.getSearchDeviationRadius(type) != value) {
waypointHelper.setSearchDeviationRadius(type, value); waypointHelper.setSearchDeviationRadius(type, value);
recalculatePoints(type); recalculatePoints(type);
dialogInterface.dismiss();
updateAdapter(); updateAdapter();
} }
} }
}).setTitle(app.getString(R.string.search_radius_proximity)) }
);
AlertDialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(mapActivity, themeRes))
.setTitle(app.getString(R.string.search_radius_proximity))
.setNegativeButton(R.string.shared_string_cancel, null) .setNegativeButton(R.string.shared_string_cancel, null)
.show(); .setAdapter(dialogAdapter, null)
.create();
dialogAdapter.setDialog(dialog);
dialog.show();
} }
private void enableType(final int type, private void enableType(final int type,

View file

@ -34,6 +34,7 @@ import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
@ -295,13 +296,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
ApplicationMode appMode = getSelectedAppMode(); ApplicationMode appMode = getSelectedAppMode();
if (preference instanceof ListPreferenceEx) { if (preference instanceof ListPreferenceEx) {
SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode); SingleSelectPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, currentScreenType.profileDependent);
} else if (preference instanceof SwitchPreferenceEx) { } else if (preference instanceof SwitchPreferenceEx) {
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode); BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, currentScreenType.profileDependent);
} else if (preference instanceof EditTextPreference) { } else if (preference instanceof EditTextPreference) {
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode); EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
} else if (preference instanceof MultiSelectBooleanPreference) { } else if (preference instanceof MultiSelectBooleanPreference) {
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode); MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, currentScreenType.profileDependent);
} else { } else {
super.onDisplayPreferenceDialog(preference); super.onDisplayPreferenceDialog(preference);
} }
@ -353,6 +354,15 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
AndroidUtils.setBackground(selectableView, drawable); AndroidUtils.setBackground(selectableView, drawable);
} }
} }
if (currentScreenType.profileDependent) {
View cb = holder.itemView.findViewById(R.id.switchWidget);
if (cb == null) {
cb = holder.findViewById(android.R.id.checkbox);
}
if (cb instanceof CompoundButton) {
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), (CompoundButton) cb);
}
}
} }
@SuppressLint("RestrictedApi") @SuppressLint("RestrictedApi")

View file

@ -131,6 +131,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
SwitchCompat switchView = switchContainer.findViewById(R.id.switchWidget); SwitchCompat switchView = switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(isChecked); switchView.setChecked(isChecked);
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
TextView title = switchContainer.findViewById(R.id.switchButtonText); TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(isChecked ? R.string.shared_string_on : R.string.shared_string_off); title.setText(isChecked ? R.string.shared_string_on : R.string.shared_string_off);

View file

@ -5,6 +5,7 @@ import android.content.DialogInterface;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.res.Configuration; import android.content.res.Configuration;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
@ -339,6 +340,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
desc.setVisibility(View.GONE); desc.setVisibility(View.GONE);
} }
title.setChecked(position == selected); title.setChecked(position == selected);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
UiUtilities.setupCompoundButtonDrawable(app, isNightMode(), getActiveProfileColor(), title.getCheckMarkDrawable());
}
return v; return v;
} }
}; };

View file

@ -16,6 +16,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
public class ScreenAlertsFragment extends BaseSettingsFragment { public class ScreenAlertsFragment extends BaseSettingsFragment {
@ -77,6 +78,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget); SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked); switchView.setChecked(checked);
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
TextView title = switchContainer.findViewById(R.id.switchButtonText); TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off); title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);

View file

@ -11,6 +11,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.settings.preferences.ListPreferenceEx; import net.osmand.plus.settings.preferences.ListPreferenceEx;
import net.osmand.plus.settings.preferences.SwitchPreferenceEx; import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
@ -63,6 +64,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget); SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked); switchView.setChecked(checked);
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
TextView title = switchContainer.findViewById(R.id.switchButtonText); TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off); title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);

View file

@ -19,6 +19,7 @@ import net.osmand.AndroidUtils;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.Version; import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.download.DownloadActivity; import net.osmand.plus.download.DownloadActivity;
@ -70,6 +71,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget); SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
switchView.setChecked(checked); switchView.setChecked(checked);
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
TextView title = switchContainer.findViewById(R.id.switchButtonText); TextView title = switchContainer.findViewById(R.id.switchButtonText);
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off); title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);

View file

@ -21,6 +21,7 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
private String prefId; private String prefId;
private Preference preference; private Preference preference;
private ApplicationMode appMode; private ApplicationMode appMode;
private boolean profileDependent;
protected void setAppMode(ApplicationMode appMode) { protected void setAppMode(ApplicationMode appMode) {
this.appMode = appMode; this.appMode = appMode;
@ -94,4 +95,12 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
} }
return null; return null;
} }
public void setProfileDependent(boolean profileDependent) {
this.profileDependent = profileDependent;
}
public boolean isProfileDependent() {
return profileDependent;
}
} }

View file

@ -80,6 +80,9 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
} }
}) })
.create(); .create();
if (isProfileDependent()) {
preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
}
items.add(preferenceBtn[0]); items.add(preferenceBtn[0]);
String description = switchPreference.getDescription(); String description = switchPreference.getDescription();
@ -129,7 +132,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
} }
public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap, public static void showInstance(@NonNull FragmentManager fm, String prefId, Fragment target, boolean usedOnMap,
@Nullable ApplicationMode appMode) { @Nullable ApplicationMode appMode, boolean profileDependent) {
try { try {
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) { if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
Bundle args = new Bundle(); Bundle args = new Bundle();
@ -140,6 +143,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
fragment.setUsedOnMap(usedOnMap); fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode); fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.setProfileDependent(profileDependent);
fragment.show(fm, BooleanPreferenceBottomSheet.TAG); fragment.show(fm, BooleanPreferenceBottomSheet.TAG);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -87,6 +87,9 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
}) })
.setTag(prefId) .setTag(prefId)
.create(); .create();
if (isProfileDependent()) {
item[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
}
items.add(item[0]); items.add(item[0]);
} }
} }
@ -158,7 +161,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
} }
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target, public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) { boolean usedOnMap, @Nullable ApplicationMode appMode, boolean profileDependent) {
try { try {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(PREFERENCE_ID, prefId); args.putString(PREFERENCE_ID, prefId);
@ -169,6 +172,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
fragment.setAppMode(appMode); fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.show(fragmentManager, TAG); fragment.show(fragmentManager, TAG);
fragment.setProfileDependent(profileDependent);
return true; return true;
} catch (RuntimeException e) { } catch (RuntimeException e) {
return false; return false;

View file

@ -56,7 +56,8 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1]; final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder() preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder()
.setChecked(i == selectedEntryIndex) .setChecked(i == selectedEntryIndex)
.setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light, getActiveColorId())) .setButtonTintList(AndroidUtils.createCheckedColorStateList(ctx, R.color.icon_color_default_light,
isProfileDependent() ? getAppMode().getIconColorInfo().getColor(nightMode) : getActiveColorId()))
.setTitle(entries[i]) .setTitle(entries[i])
.setTag(i) .setTag(i)
.setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left) .setLayoutId(R.layout.bottom_sheet_item_with_radio_btn_left)
@ -125,7 +126,7 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
} }
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target, public static boolean showInstance(@NonNull FragmentManager fragmentManager, String key, Fragment target,
boolean usedOnMap, @Nullable ApplicationMode appMode) { boolean usedOnMap, @Nullable ApplicationMode appMode, boolean profileDependent) {
try { try {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putString(PREFERENCE_ID, key); args.putString(PREFERENCE_ID, key);
@ -135,6 +136,7 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
fragment.setUsedOnMap(usedOnMap); fragment.setUsedOnMap(usedOnMap);
fragment.setAppMode(appMode); fragment.setAppMode(appMode);
fragment.setTargetFragment(target, 0); fragment.setTargetFragment(target, 0);
fragment.setProfileDependent(profileDependent);
fragment.show(fragmentManager, TAG); fragment.show(fragmentManager, TAG);
return true; return true;
} catch (RuntimeException e) { } catch (RuntimeException e) {

View file

@ -37,8 +37,11 @@ public class ContourLinesMenu {
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) { if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true); OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
} }
boolean nightMode = isNightMode(mapActivity.getMyApplication());
ContextMenuAdapter adapter = new ContextMenuAdapter(); ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
createLayersItems(adapter, mapActivity); createLayersItems(adapter, mapActivity);
return adapter; return adapter;
} }
@ -175,7 +178,7 @@ public class ContourLinesMenu {
R.color.active_color_primary_dark : R.color.active_color_primary_light; R.color.active_color_primary_dark : R.color.active_color_primary_light;
} else { } else {
toggleIconId = R.drawable.ic_action_hide; toggleIconId = R.drawable.ic_action_hide;
toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; toggleIconColorId = ContextMenuItem.INVALID_ID;
} }
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(toggleActionStringId, mapActivity) .setTitleId(toggleActionStringId, mapActivity)
@ -327,6 +330,13 @@ public class ContourLinesMenu {
} }
} }
public static boolean isNightMode(OsmandApplication app) {
if (app == null) {
return false;
}
return app.getDaynightHelper().isNightModeForMapControls();
}
public static void closeDashboard(MapActivity mapActivity) { public static void closeDashboard(MapActivity mapActivity) {
mapActivity.getDashboard().hideDashboard(false); mapActivity.getDashboard().hideDashboard(false);
} }

View file

@ -32,8 +32,11 @@ public class HillshadeMenu {
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) { if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true); OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
} }
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
ContextMenuAdapter adapter = new ContextMenuAdapter(); ContextMenuAdapter adapter = new ContextMenuAdapter();
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu); adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
adapter.setProfileDependent(true);
adapter.setNightMode(nightMode);
createLayersItems(adapter, mapActivity); createLayersItems(adapter, mapActivity);
return adapter; return adapter;
} }
@ -97,7 +100,7 @@ public class HillshadeMenu {
R.color.active_color_primary_dark : R.color.active_color_primary_light; R.color.active_color_primary_dark : R.color.active_color_primary_light;
} else { } else {
toggleIconId = R.drawable.ic_action_hide; toggleIconId = R.drawable.ic_action_hide;
toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light; toggleIconColorId = ContextMenuItem.INVALID_ID;
} }
contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder() contextMenuAdapter.addItem(new ContextMenuItem.ItemBuilder()
.setTitleId(toggleActionStringId, mapActivity) .setTitleId(toggleActionStringId, mapActivity)

View file

@ -4,7 +4,9 @@ import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.view.ContextThemeWrapper;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -13,6 +15,7 @@ import net.osmand.data.LatLon;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
import net.osmand.plus.DialogListItemAdapter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -359,7 +362,9 @@ public class SRTMPlugin extends OsmandPlugin {
final Runnable callback) { final Runnable callback) {
final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity, final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
p.getAttrName(), p.getName()); p.getAttrName(), p.getName());
AlertDialog.Builder b = new AlertDialog.Builder(activity); boolean nightMode = isNightMode(activity, app);
int themeRes = getThemeRes(activity, app);
AlertDialog.Builder b = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
b.setTitle(propertyDescr); b.setTitle(propertyDescr);
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues())); List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
@ -382,18 +387,22 @@ public class SRTMPlugin extends OsmandPlugin {
possibleValues[j]); possibleValues[j]);
} }
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() { int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
@Override DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
public void onClick(DialogInterface dialog, int which) { possibleValuesString, nightMode, i, app, selectedModeColor, themeRes, new View.OnClickListener() {
if (which == 0) {
pref.set(""); @Override
} else { public void onClick(View v) {
pref.set(possibleValues[which - 1]); int which = (int) v.getTag();
if (which == 0) {
pref.set("");
} else {
pref.set(possibleValues[which - 1]);
}
refreshMapComplete(activity);
}
} }
refreshMapComplete(activity); );
dialog.dismiss();
}
});
b.setNegativeButton(R.string.shared_string_dismiss, null); b.setNegativeButton(R.string.shared_string_dismiss, null);
b.setOnDismissListener(new DialogInterface.OnDismissListener() { b.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
@ -403,7 +412,8 @@ public class SRTMPlugin extends OsmandPlugin {
} }
} }
}); });
b.show(); b.setAdapter(dialogAdapter, null);
dialogAdapter.setDialog(b.show());
} }
@Override @Override
@ -420,4 +430,15 @@ public class SRTMPlugin extends OsmandPlugin {
activity.updateMapSettings(); activity.updateMapSettings();
activity.getMapView().refreshMap(true); activity.getMapView().refreshMap(true);
} }
private static boolean isNightMode(Activity activity, OsmandApplication app) {
if (activity == null || app == null) {
return false;
}
return activity instanceof MapActivity ? app.getDaynightHelper().isNightModeForMapControls() : !app.getSettings().isLightContent();
}
private static int getThemeRes(Activity activity, OsmandApplication app) {
return isNightMode(activity, app) ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
}
} }

View file

@ -44,6 +44,7 @@ import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.TargetPointsHelper.TargetPoint; import net.osmand.plus.TargetPointsHelper.TargetPoint;
import net.osmand.plus.UiUtilities;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode; import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
import net.osmand.plus.base.ContextMenuFragment.MenuState; import net.osmand.plus.base.ContextMenuFragment.MenuState;
@ -969,6 +970,8 @@ public class MapControlsLayer extends OsmandMapLayer {
} else { } else {
transparencyBarLayout.setVisibility(View.GONE); transparencyBarLayout.setVisibility(View.GONE);
} }
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
UiUtilities.setupSeekBar(app, transparencyBar, nightMode, true);
} }
public void hideTransparencyBar() { public void hideTransparencyBar() {

View file

@ -1085,7 +1085,7 @@ public class MapInfoWidgetsFactory {
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putInt(ShowAlongTheRouteBottomSheet.EXPAND_TYPE_KEY, pnt.type); args.putInt(ShowAlongTheRouteBottomSheet.EXPAND_TYPE_KEY, pnt.type);
fragment.setArguments(args); fragment.setArguments(args);
fragment.setUsedOnMap(false); fragment.setUsedOnMap(true);
fragment.show(map.getSupportFragmentManager(), ShowAlongTheRouteBottomSheet.TAG); fragment.show(map.getSupportFragmentManager(), ShowAlongTheRouteBottomSheet.TAG);
} }
}); });

View file

@ -4,6 +4,7 @@ import android.content.Context;
import android.support.annotation.DrawableRes; import android.support.annotation.DrawableRes;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
@ -490,6 +491,8 @@ public class MapWidgetRegistry {
final boolean selected = r.visibleCollapsed(mode) || r.visible(mode); final boolean selected = r.visibleCollapsed(mode) || r.visible(mode);
final String desc = mapActivity.getString(R.string.shared_string_collapse); final String desc = mapActivity.getString(R.string.shared_string_collapse);
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
final int currentModeColorRes = mode.getIconColorInfo().getColor(nightMode);
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder() ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder()
.setIcon(r.getDrawableMenu()) .setIcon(r.getDrawableMenu())
.setSelected(selected) .setSelected(selected)
@ -530,7 +533,7 @@ public class MapWidgetRegistry {
MenuItem menuItem = menu.add(R.id.single_selection_group, id, i, titleId) MenuItem menuItem = menu.add(R.id.single_selection_group, id, i, titleId)
.setChecked(id == checkedId); .setChecked(id == checkedId);
menuItem.setIcon(menuItem.isChecked() && selected menuItem.setIcon(menuItem.isChecked() && selected
? ic.getIcon(iconId, R.color.osmand_orange) : ic.getThemedIcon(iconId)); ? ic.getIcon(iconId, currentModeColorRes) : ic.getThemedIcon(iconId));
} }
menu.setGroupCheckable(R.id.single_selection_group, true, true); menu.setGroupCheckable(R.id.single_selection_group, true, true);
menu.setGroupVisible(R.id.single_selection_group, true); menu.setGroupVisible(R.id.single_selection_group, true);
@ -779,6 +782,9 @@ public class MapWidgetRegistry {
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) { public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
final ContextMenuAdapter cm = new ContextMenuAdapter(); final ContextMenuAdapter cm = new ContextMenuAdapter();
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
cm.setProfileDependent(true);
cm.setNightMode(nightMode);
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu); cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map) cm.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map)
.setLayout(R.layout.mode_toggles).createItem()); .setLayout(R.layout.mode_toggles).createItem());