commit
45987d34b4
42 changed files with 872 additions and 278 deletions
|
@ -56,7 +56,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<RadioButton
|
||||
<android.support.v7.widget.AppCompatRadioButton
|
||||
android:id="@+id/compound_button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
71
OsmAnd/res/layout/dialog_list_item_with_compound_button.xml
Normal file
71
OsmAnd/res/layout/dialog_list_item_with_compound_button.xml
Normal 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>
|
||||
|
|
@ -6,46 +6,57 @@
|
|||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
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">
|
||||
|
||||
<TextView
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/shared_string_name"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/Name"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"
|
||||
android:text="">
|
||||
|
||||
<requestFocus/>
|
||||
</EditText>
|
||||
|
||||
<TextView
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:scrollHorizontally="true"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:text="@string/edit_tilesource_choose_existing"/>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/TileSourceSpinner"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="5dp"
|
||||
android:layout_marginRight="5dp"/>
|
||||
android:layout_marginLeft="@dimen/text_margin_small"
|
||||
android:layout_marginRight="@dimen/text_margin_small"/>
|
||||
|
||||
<TextView
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:text="@string/edit_tilesource_url_to_load"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/URLToLoad"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="5"
|
||||
|
@ -53,43 +64,52 @@
|
|||
android:text=""/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit_tilesource_minzoom"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/MinZoom"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/edit_tilesource_maxzoom"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/MaxZoom"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""/>
|
||||
|
||||
<TextView
|
||||
android:layout_marginTop="@dimen/content_padding_half"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/edit_tilesource_expiration_time"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/ExpirationTime"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""/>
|
||||
|
||||
<CheckBox
|
||||
<android.support.v7.widget.AppCompatCheckBox
|
||||
android:id="@+id/EllipticMercator"
|
||||
android:layout_width="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"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -454,13 +454,13 @@
|
|||
<color name="profile_icon_color_yellow_light">#F0B400</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_purple_dark">#B3732EEB</color>
|
||||
<color name="profile_icon_color_green_dark">#B30EBE92</color>
|
||||
<color name="profile_icon_color_blue_dark">#B3007EB3</color>
|
||||
<color name="profile_icon_color_red_dark">#B3FF2200</color>
|
||||
<color name="profile_icon_color_yellow_dark">#B3F0B400</color>
|
||||
<color name="profile_icon_color_magenta_dark">#B3CC0063</color>
|
||||
<color name="profile_icon_color_blue_dark_default">#237BFF</color>
|
||||
<color name="profile_icon_color_purple_dark">#732EEB</color>
|
||||
<color name="profile_icon_color_green_dark">#0EBE92</color>
|
||||
<color name="profile_icon_color_blue_dark">#007EB3</color>
|
||||
<color name="profile_icon_color_red_dark">#FF2200</color>
|
||||
<color name="profile_icon_color_yellow_dark">#F0B400</color>
|
||||
<color name="profile_icon_color_magenta_dark">#CC0063</color>
|
||||
|
||||
<color name="profile_icon_color_inactive">#727272</color>
|
||||
|
||||
|
|
|
@ -54,6 +54,8 @@ public class ContextMenuAdapter {
|
|||
@LayoutRes
|
||||
private int DEFAULT_LAYOUT_ID = R.layout.list_menu_item_native;
|
||||
List<ContextMenuItem> items = new ArrayList<>();
|
||||
private boolean profileDependent = false;
|
||||
private boolean nightMode;
|
||||
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
|
||||
|
||||
public int length() {
|
||||
|
@ -86,6 +88,18 @@ public class ContextMenuAdapter {
|
|||
|
||||
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) {
|
||||
this.DEFAULT_LAYOUT_ID = defaultLayoutId;
|
||||
}
|
||||
|
@ -163,6 +177,8 @@ public class ContextMenuAdapter {
|
|||
final ContextMenuItem item = getItem(position);
|
||||
int layoutId = item.getLayout();
|
||||
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) {
|
||||
final Set<ApplicationMode> selected = new LinkedHashSet<>();
|
||||
return AppModeDialog.prepareAppModeDrawerView((Activity) getContext(),
|
||||
|
@ -332,6 +348,8 @@ public class ContextMenuAdapter {
|
|||
} else {
|
||||
colorRes = 0;
|
||||
}
|
||||
} else if (profileDependent) {
|
||||
colorRes = currentModeColorRes;
|
||||
}
|
||||
final Drawable drawable = mIconsCache.getIcon(item.getIcon(), colorRes);
|
||||
((AppCompatImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
|
||||
|
@ -384,6 +402,9 @@ public class ContextMenuAdapter {
|
|||
} else if (ch != null) {
|
||||
ch.setVisibility(View.GONE);
|
||||
}
|
||||
if (profileDependent) {
|
||||
UiUtilities.setupCompoundButton(nightMode, currentModeColor, ch);
|
||||
}
|
||||
}
|
||||
|
||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||
|
@ -412,6 +433,7 @@ public class ContextMenuAdapter {
|
|||
} else if (seekBar != null) {
|
||||
seekBar.setVisibility(View.GONE);
|
||||
}
|
||||
UiUtilities.setupSeekBar(app, seekBar, nightMode, profileDependent);
|
||||
}
|
||||
|
||||
View progressBar = convertView.findViewById(R.id.ProgressBar);
|
||||
|
|
114
OsmAnd/src/net/osmand/plus/DialogListItemAdapter.java
Normal file
114
OsmAnd/src/net/osmand/plus/DialogListItemAdapter.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package net.osmand.plus;
|
|||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
|
@ -16,11 +17,15 @@ import android.support.annotation.DrawableRes;
|
|||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v4.widget.TintableCompoundButton;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -320,6 +325,75 @@ public class UiUtilities {
|
|||
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) {
|
||||
setupDialogButton(nightMode, buttonView, buttonType, buttonView.getContext().getString(buttonTextId));
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ package net.osmand.plus.activities;
|
|||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
|
@ -22,6 +23,7 @@ import net.osmand.plus.ContextMenuAdapter;
|
|||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.GPXUtilities.GPXFile;
|
||||
import net.osmand.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -267,7 +269,7 @@ public class MapActivityLayers {
|
|||
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);
|
||||
}
|
||||
list.add(poiFilters.getCustomPOIFilter());
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(isNightMode(app));
|
||||
|
||||
final ArrayAdapter<ContextMenuItem> listAdapter = adapter.createListAdapter(activity, !isNightMode(app));
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, getThemeRes(app)));
|
||||
|
@ -491,80 +495,85 @@ public class MapActivityLayers {
|
|||
items[i++] = entry.getValue();
|
||||
}
|
||||
|
||||
builder.setSingleChoiceItems(items, selectedItem, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String layerKey = entriesMapList.get(which).getKey();
|
||||
switch (layerKey) {
|
||||
case layerOsmVector:
|
||||
settings.MAP_ONLINE_DATA.set(false);
|
||||
updateMapSource(mapView, null);
|
||||
updateItem(it, adapter, null);
|
||||
break;
|
||||
case layerEditInstall:
|
||||
OsmandRasterMapsPlugin.defineNewEditLayer(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
OsmandApplication app = getApplication();
|
||||
boolean nightMode = isNightMode(app);
|
||||
int themeRes = getThemeRes(app);
|
||||
int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
items, nightMode, selectedItem, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
String layerKey = entriesMapList.get(which).getKey();
|
||||
switch (layerKey) {
|
||||
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
|
||||
public boolean publish(TileSourceTemplate object) {
|
||||
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());
|
||||
@Override
|
||||
public boolean publish(TileSourceTemplate object) {
|
||||
settings.MAP_TILE_SOURCES.set(object.getName());
|
||||
settings.MAP_ONLINE_DATA.set(true);
|
||||
updateItem(it, adapter, template.getName());
|
||||
if(it != null) {
|
||||
it.setDescription(object.getName());
|
||||
}
|
||||
updateMapSource(mapView, settings.MAP_TILE_SOURCES);
|
||||
} else {
|
||||
selectMapLayer(mapView, it, adapter);
|
||||
return true;
|
||||
}
|
||||
} 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;
|
||||
@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);
|
||||
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.show();
|
||||
dialogAdapter.setDialog(builder.show());
|
||||
}
|
||||
|
||||
private void updateItem(@Nullable ContextMenuItem item,
|
||||
|
|
|
@ -17,6 +17,7 @@ import android.preference.PreferenceCategory;
|
|||
import android.preference.PreferenceGroup;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -809,12 +810,13 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
}
|
||||
});
|
||||
|
||||
int selectedModeColor = ContextCompat.getColor(app, mode.getIconColorInfo().getColor(nightMode));
|
||||
if (!defaultSpeedOnly) {
|
||||
setupSpeedSlider(SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
setupSpeedSlider(SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
setupSpeedSlider(SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView);
|
||||
setupSpeedSlider(app, SpeedSliderType.DEFAULT_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
setupSpeedSlider(app, SpeedSliderType.MIN_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
setupSpeedSlider(app, SpeedSliderType.MAX_SPEED, speedUnits, minValue, defaultValue, maxValue, min, max, seekbarView, nightMode, selectedModeColor);
|
||||
} 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_container).setVisibility(View.GONE);
|
||||
seekbarView.findViewById(R.id.max_speed_div).setVisibility(View.GONE);
|
||||
|
@ -831,9 +833,10 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
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 min, final int max, View seekbarView) {
|
||||
final int min, final int max, View seekbarView, final boolean nightMode,
|
||||
final int activeColor) {
|
||||
View seekbarLayout;
|
||||
int titleId;
|
||||
final int[] speedValue;
|
||||
|
@ -915,5 +918,6 @@ public class SettingsNavigationActivity extends SettingsBaseActivity {
|
|||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
UiUtilities.setupSeekBar(speedSeekBar, activeColor, nightMode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.activities.actions;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import android.app.Activity;
|
||||
|
@ -55,4 +56,12 @@ public class OsmAndAction {
|
|||
public void showDialog() {
|
||||
mapActivity.showDialog(getDialogID());
|
||||
}
|
||||
|
||||
public boolean isNightMode() {
|
||||
return mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
}
|
||||
|
||||
public int getThemeRes() {
|
||||
return isNightMode() ? R.style.OsmandDarkTheme : R.style.OsmandLightTheme;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,14 @@ import android.content.pm.PackageManager;
|
|||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ListView;
|
||||
|
@ -24,6 +25,7 @@ import android.widget.Toast;
|
|||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
|
@ -111,11 +113,16 @@ public class StartGPSStatus extends OsmAndAction {
|
|||
final int dp12 = AndroidUtils.dpToPx(mapActivity, 12f);
|
||||
final int dp8 = AndroidUtils.dpToPx(mapActivity, 8f);
|
||||
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);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.setMargins(dp24, dp8, dp8, dp24);
|
||||
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 ArrayAdapter<GpsStatusApps> adapter = new ArrayAdapter<GpsStatusApps>(mapActivity, layout, GpsStatusApps.values()) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.res.ColorStateList;
|
|||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.LayoutRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.CompoundButtonCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
@ -12,12 +13,14 @@ import android.widget.CompoundButton.OnCheckedChangeListener;
|
|||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
||||
public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescription {
|
||||
|
||||
private boolean checked;
|
||||
private ColorStateList buttonTintList;
|
||||
private OnCheckedChangeListener onCheckedChangeListener;
|
||||
@ColorRes private int compoundButtonColorId;
|
||||
|
||||
private CompoundButton compoundButton;
|
||||
|
||||
|
@ -40,7 +43,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
boolean descriptionLinksClickable,
|
||||
boolean checked,
|
||||
ColorStateList buttonTintList,
|
||||
OnCheckedChangeListener onCheckedChangeListener) {
|
||||
OnCheckedChangeListener onCheckedChangeListener,
|
||||
@ColorRes int compoundButtonColorId) {
|
||||
super(customView,
|
||||
layoutId,
|
||||
tag,
|
||||
|
@ -57,6 +61,7 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
this.checked = checked;
|
||||
this.buttonTintList = buttonTintList;
|
||||
this.onCheckedChangeListener = onCheckedChangeListener;
|
||||
this.compoundButtonColorId = compoundButtonColorId;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
|
@ -65,6 +70,10 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
compoundButton.setChecked(checked);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
|
||||
this.compoundButtonColorId = compoundButtonColorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inflate(OsmandApplication app, ViewGroup container, boolean nightMode) {
|
||||
|
@ -72,8 +81,12 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
compoundButton = (CompoundButton) view.findViewById(R.id.compound_button);
|
||||
if (compoundButton != null) {
|
||||
compoundButton.setChecked(checked);
|
||||
CompoundButtonCompat.setButtonTintList(compoundButton, buttonTintList);
|
||||
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 ColorStateList buttonTintList;
|
||||
protected OnCheckedChangeListener onCheckedChangeListener;
|
||||
@ColorRes protected int compoundButtonColorId = INVALID_ID;
|
||||
|
||||
public Builder setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
|
@ -98,6 +112,11 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
return this;
|
||||
}
|
||||
|
||||
public Builder setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
|
||||
this.compoundButtonColorId = compoundButtonColorId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BottomSheetItemWithCompoundButton create() {
|
||||
return new BottomSheetItemWithCompoundButton(customView,
|
||||
layoutId,
|
||||
|
@ -114,7 +133,8 @@ public class BottomSheetItemWithCompoundButton extends BottomSheetItemWithDescri
|
|||
descriptionLinksClickable,
|
||||
checked,
|
||||
buttonTintList,
|
||||
onCheckedChangeListener);
|
||||
onCheckedChangeListener,
|
||||
compoundButtonColorId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package net.osmand.plus.dialogs;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.DialogInterface.OnMultiChoiceClickListener;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
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.OnRowItemClick;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
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.ListStringPreference;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
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);
|
||||
|
||||
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 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);
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
.setId(SHOW_CATEGORY_ID)
|
||||
|
@ -360,7 +368,7 @@ public class ConfigureMapMenu {
|
|||
.setIcon(R.drawable.ic_action_bus_dark)
|
||||
.setSecondaryIcon(R.drawable.ic_action_additional_option)
|
||||
.setSelected(transportSelected)
|
||||
.setColor(transportSelected ? R.color.osmand_orange : ContextMenuItem.INVALID_ID)
|
||||
.setColor(transportSelected ? selectedProfileColorRes : ContextMenuItem.INVALID_ID)
|
||||
.setListener(new ContextMenuAdapter.OnRowItemClick() {
|
||||
ArrayAdapter<CharSequence> adapter;
|
||||
boolean transportSelectedInner = transportSelected;
|
||||
|
@ -374,7 +382,7 @@ public class ConfigureMapMenu {
|
|||
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
|
||||
if (btn != null && btn.getVisibility() == View.VISIBLE) {
|
||||
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();
|
||||
return false;
|
||||
} else {
|
||||
|
@ -395,7 +403,7 @@ public class ConfigureMapMenu {
|
|||
refreshMapComplete(activity);
|
||||
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||
} else {
|
||||
ad.getItem(pos).setColorRes(R.color.osmand_orange);
|
||||
ad.getItem(pos).setColorRes(selectedProfileColorRes);
|
||||
showTransportDialog(ad, pos);
|
||||
}
|
||||
ad.notifyDataSetChanged();
|
||||
|
@ -437,7 +445,7 @@ public class ConfigureMapMenu {
|
|||
View v = super.getView(position, convertView, parent);
|
||||
final ImageView icon = (ImageView) v.findViewById(R.id.icon);
|
||||
if (checkedItems[position]) {
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange));
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], selectedProfileColorRes));
|
||||
} else {
|
||||
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
|
||||
}
|
||||
|
@ -452,12 +460,13 @@ public class ConfigureMapMenu {
|
|||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
checkedItems[position] = isChecked;
|
||||
if (checkedItems[position]) {
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], R.color.osmand_orange));
|
||||
icon.setImageDrawable(app.getUIUtilities().getIcon(iconIds[position], selectedProfileColorRes));
|
||||
} else {
|
||||
icon.setImageDrawable(app.getUIUtilities().getThemedIcon(iconIds[position]));
|
||||
}
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, check);
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
@ -481,7 +490,7 @@ public class ConfigureMapMenu {
|
|||
ContextMenuItem item = ad.getItem(pos);
|
||||
if (item != null) {
|
||||
item.setSelected(transportSelectedInner);
|
||||
item.setColorRes(transportSelectedInner ? R.color.osmand_orange : ContextMenuItem.INVALID_ID);
|
||||
item.setColorRes(transportSelectedInner ? selectedProfileColorRes : ContextMenuItem.INVALID_ID);
|
||||
ad.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
@ -553,6 +562,11 @@ public class ConfigureMapMenu {
|
|||
private void createRenderingAttributeItems(List<RenderingRuleProperty> customRules,
|
||||
final ContextMenuAdapter adapter, final MapActivity activity,
|
||||
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)
|
||||
.setId(MAP_RENDERING_CATEGORY_ID)
|
||||
.setCategory(true).setLayout(R.layout.list_group_title_with_switch).createItem());
|
||||
|
@ -595,19 +609,22 @@ public class ConfigureMapMenu {
|
|||
items[0] += sunriseSunsetTime;
|
||||
}
|
||||
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.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;
|
||||
}
|
||||
}).createItem());
|
||||
|
@ -649,10 +666,12 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
bld.setTitle(R.string.map_magnifier);
|
||||
bld.setSingleChoiceItems(values.toArray(new String[values.size()]), i,
|
||||
new DialogInterface.OnClickListener() {
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
values.toArray(new String[values.size()]), nightMode, i, app, selectedProfileColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
int p = tlist.get(which);
|
||||
mapDensity.set(p / 100.0f);
|
||||
view.setComplexZoom(view.getZoom(), view.getSettingsMapDensity());
|
||||
|
@ -665,17 +684,17 @@ public class ConfigureMapMenu {
|
|||
.getSettings().MAP_DENSITY.get())
|
||||
+ " %");
|
||||
ad.notifyDataSetInvalidated();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
bld.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
bld.show();
|
||||
}
|
||||
);
|
||||
bld.setAdapter(dialogAdapter, null);
|
||||
dialogAdapter.setDialog(bld.show());
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
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) {
|
||||
adapter.addItem(props);
|
||||
}
|
||||
|
@ -700,18 +719,20 @@ public class ConfigureMapMenu {
|
|||
selected = i;
|
||||
}
|
||||
}
|
||||
b.setSingleChoiceItems(txtNames, selected, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
view.getSettings().TEXT_SCALE.set(txtValues[which]);
|
||||
refreshMapComplete(activity);
|
||||
adapter.getItem(pos).setDescription(getScale(activity));
|
||||
ad.notifyDataSetInvalidated();
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
txtNames, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
view.getSettings().TEXT_SCALE.set(txtValues[which]);
|
||||
refreshMapComplete(activity);
|
||||
adapter.getItem(pos).setDescription(getScale(activity));
|
||||
ad.notifyDataSetInvalidated();
|
||||
}
|
||||
});
|
||||
b.setAdapter(dialogAdapter, null);
|
||||
b.setNegativeButton(R.string.shared_string_dismiss, null);
|
||||
b.show();
|
||||
dialogAdapter.setDialog(b.show());
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
@ -758,6 +779,9 @@ public class ConfigureMapMenu {
|
|||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View v = super.getView(position, convertView, parent);
|
||||
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) {
|
||||
checkedTextView.setChecked(true);
|
||||
v.findViewById(R.id.topDivider).setVisibility(View.VISIBLE);
|
||||
|
@ -768,6 +792,7 @@ public class ConfigureMapMenu {
|
|||
SwitchCompat check = (SwitchCompat) v.findViewById(R.id.check);
|
||||
check.setChecked(transliterateNames);
|
||||
check.setOnCheckedChangeListener(translitChangdListener);
|
||||
UiUtilities.setupCompoundButton(nightMode, selectedProfileColor, check);
|
||||
} else {
|
||||
checkedTextView.setChecked(position == selectedLanguageIndex);
|
||||
v.findViewById(R.id.topDivider).setVisibility(View.GONE);
|
||||
|
@ -811,17 +836,17 @@ public class ConfigureMapMenu {
|
|||
}).createItem());
|
||||
|
||||
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) {
|
||||
adapter.addItem(props);
|
||||
}
|
||||
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) {
|
||||
adapter.addItem(props);
|
||||
}
|
||||
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) {
|
||||
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,
|
||||
"routes", null, adapter, activity, true, ROUTES_ID, themeRes, nightMode);
|
||||
"routes", null, adapter, activity, true, ROUTES_ID, themeRes, nightMode, selectedProfileColor);
|
||||
if (props != null) {
|
||||
adapter.addItem(props);
|
||||
}
|
||||
|
@ -841,7 +866,7 @@ public class ConfigureMapMenu {
|
|||
if (getCustomRenderingPropertiesSize(customRules) > 0) {
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.rendering_category_others, activity)
|
||||
.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 String id,
|
||||
final int themeRes,
|
||||
final boolean nightMode) {
|
||||
final boolean nightMode,
|
||||
@ColorInt final int selectedProfileColor) {
|
||||
|
||||
final List<RenderingRuleProperty> ps = new ArrayList<>();
|
||||
final List<OsmandSettings.CommonPreference<Boolean>> prefs = new ArrayList<>();
|
||||
|
@ -947,7 +973,7 @@ public class ConfigureMapMenu {
|
|||
activity.getMapLayers().updateLayers(activity.getMapView());
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
@ -987,7 +1013,7 @@ public class ConfigureMapMenu {
|
|||
public boolean onRowItemClick(ArrayAdapter<ContextMenuItem> a, View view, int itemId,
|
||||
int pos) {
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
@ -1031,7 +1057,8 @@ public class ConfigureMapMenu {
|
|||
boolean useDefault,
|
||||
final List<RenderingRuleProperty> customRulesIncluded,
|
||||
final int themeRes,
|
||||
final boolean nightMode) {
|
||||
final boolean nightMode,
|
||||
@ColorInt final int selectedProfileColor) {
|
||||
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
|
||||
boolean[] checkedItems = new boolean[prefs.size()];
|
||||
|
@ -1048,13 +1075,16 @@ public class ConfigureMapMenu {
|
|||
vals[i] = propertyName;
|
||||
}
|
||||
|
||||
bld.setMultiChoiceItems(vals, checkedItems, new OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
tempPrefs[which] = isChecked;
|
||||
}
|
||||
});
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(
|
||||
vals, nightMode, checkedItems, activity.getMyApplication(), selectedProfileColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
tempPrefs[which] = !tempPrefs[which];
|
||||
}
|
||||
}
|
||||
);
|
||||
bld.setAdapter(dialogAdapter, null);
|
||||
|
||||
bld.setTitle(category);
|
||||
|
||||
|
@ -1110,6 +1140,8 @@ public class ConfigureMapMenu {
|
|||
|
||||
final AlertDialog dialog = bld.create();
|
||||
|
||||
dialogAdapter.setDialog(dialog);
|
||||
|
||||
if (customRulesIncluded != null) {
|
||||
for (RenderingRuleProperty p : customRulesIncluded) {
|
||||
if (!p.isBoolean()) {
|
||||
|
@ -1209,10 +1241,11 @@ public class ConfigureMapMenu {
|
|||
}
|
||||
|
||||
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) {
|
||||
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,
|
||||
final ContextMenuAdapter adapter, final MapActivity activity,
|
||||
@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) {
|
||||
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;
|
||||
|
@ -1241,7 +1274,7 @@ public class ConfigureMapMenu {
|
|||
|
||||
private ContextMenuItem createRenderingProperty(final ContextMenuAdapter adapter, final MapActivity activity,
|
||||
@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();
|
||||
String propertyName = SettingsActivity.getStringPropertyName(view.getContext(), p.getAttrName(),
|
||||
p.getName());
|
||||
|
@ -1300,23 +1333,25 @@ public class ConfigureMapMenu {
|
|||
possibleValuesString[j + 1] = SettingsActivity.getStringPropertyValue(view.getContext(),
|
||||
p.getPossibleValues()[j]);
|
||||
}
|
||||
|
||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 0) {
|
||||
pref.set("");
|
||||
} else {
|
||||
pref.set(p.getPossibleValues()[which - 1]);
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
possibleValuesString, nightMode, i, app, currentProfileColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
if (which == 0) {
|
||||
pref.set("");
|
||||
} 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.show();
|
||||
b.setAdapter(dialogAdapter, null);
|
||||
dialogAdapter.setDialog(b.show());
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
|
|
@ -22,8 +22,11 @@ public class RasterMapMenu {
|
|||
private static final String TAG = "RasterMapMenu";
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
|
||||
final RasterMapType type) {
|
||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(nightMode);
|
||||
createLayersItems(adapter, mapActivity, type);
|
||||
return adapter;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.osmand.OsmAndCollator;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MenuBottomSheetDialogFragment;
|
||||
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
|
||||
|
@ -53,7 +54,6 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
private LinearLayout stylesContainer;
|
||||
private BottomSheetItemTitleWithDescrAndButton descrItem;
|
||||
private View.OnClickListener onStyleClickListener;
|
||||
private ColorStateList rbColorList;
|
||||
|
||||
private TreeMap<String, String> stylesMap;
|
||||
private String selectedStyle;
|
||||
|
@ -78,8 +78,6 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
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)));
|
||||
|
||||
descrItem = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
|
||||
|
@ -215,7 +213,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
|
||||
RadioButton rb = (RadioButton) view.findViewById(R.id.compound_button);
|
||||
rb.setChecked(selected);
|
||||
CompoundButtonCompat.setButtonTintList(rb, rbColorList);
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), rb, nightMode, true);
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
@ -224,7 +222,7 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
@ColorInt
|
||||
private int getStyleTitleColor(boolean 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;
|
||||
return getResolvedColor(colorId);
|
||||
}
|
||||
|
|
|
@ -224,7 +224,8 @@ public class GpxUiHelper {
|
|||
|
||||
public static AlertDialog selectGPXFiles(List<String> selectedGpxList, final Activity activity,
|
||||
final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||
int dialogThemeRes) {
|
||||
int dialogThemeRes,
|
||||
boolean nightMode) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
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));
|
||||
|
||||
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,
|
||||
|
@ -253,7 +254,7 @@ public class GpxUiHelper {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -500,7 +501,8 @@ public class GpxUiHelper {
|
|||
final CallbackWithObject<GPXFile[]> callbackWithObject,
|
||||
final List<GPXInfo> list,
|
||||
final ContextMenuAdapter adapter,
|
||||
final int themeRes) {
|
||||
final int themeRes,
|
||||
final boolean nightMode) {
|
||||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(activity);
|
||||
final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
|
||||
|
@ -559,6 +561,7 @@ public class GpxUiHelper {
|
|||
item.setSelected(isChecked);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(app, ch, nightMode, true);
|
||||
} else {
|
||||
final SwitchCompat ch = ((SwitchCompat) v.findViewById(R.id.toggle_item));
|
||||
ch.setVisibility(View.VISIBLE);
|
||||
|
@ -571,6 +574,7 @@ public class GpxUiHelper {
|
|||
item.setSelected(isChecked);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(app, ch, nightMode, true);
|
||||
}
|
||||
v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.osmand.map.TileSourceManager;
|
|||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.BaseOsmAndFragment;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
|
@ -59,6 +60,8 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
|
|||
final int backgroundColor = ContextCompat.getColor(getActivity(),
|
||||
nightMode ? R.color.activity_background_color_dark : R.color.activity_background_color_light);
|
||||
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);
|
||||
view.findViewById(R.id.mapillary_filters_linear_layout).setBackgroundColor(backgroundColor);
|
||||
|
@ -71,7 +74,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
|
|||
int toggleIconId;
|
||||
if (selected) {
|
||||
toggleIconId = R.drawable.ic_action_view;
|
||||
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
toggleIconColorId = currentModeColorRes;
|
||||
} else {
|
||||
toggleIconId = R.drawable.ic_action_hide;
|
||||
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());
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(nightMode, currentModeColor, toggle);
|
||||
|
||||
|
||||
final Button reloadTile = (Button) view.findViewById(R.id.button_reload_tile);
|
||||
|
@ -244,6 +248,7 @@ public class MapillaryFiltersFragment extends BaseOsmAndFragment {
|
|||
pano.setChecked(!pano.isChecked());
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(nightMode, currentModeColor, pano);
|
||||
|
||||
|
||||
final Button apply = (Button) view.findViewById(R.id.button_apply);
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.mapmarkers;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
|
@ -10,7 +9,6 @@ import android.os.Build;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.widget.CompoundButtonCompat;
|
||||
import android.support.v7.widget.ListPopupWindow;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.SpannableString;
|
||||
|
@ -52,6 +50,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
|
||||
private int helpImgHeight;
|
||||
private boolean shadowVisible;
|
||||
private boolean usedOnMap = false;
|
||||
|
||||
public void setListener(DirectionIndicationFragmentListener listener) {
|
||||
this.listener = listener;
|
||||
|
@ -61,6 +60,8 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
final OsmandSettings settings = getSettings();
|
||||
boolean nightMode = isNightMode(usedOnMap);
|
||||
|
||||
helpImgHeight = getResources().getDimensionPixelSize(R.dimen.action_bar_image_height);
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), distanceIndicationToggle, nightMode, true);
|
||||
|
||||
mainView.findViewById(R.id.top_bar_row).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -178,6 +180,7 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
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);
|
||||
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);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), showLinesToggle, nightMode, true);
|
||||
|
||||
final CompoundButton oneTapActiveToggle = (CompoundButton) mainView.findViewById(R.id.one_tap_active_switch);
|
||||
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);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), oneTapActiveToggle, nightMode, true);
|
||||
|
||||
final CompoundButton keepPassedToggle = (CompoundButton) mainView.findViewById(R.id.keep_passed_switch);
|
||||
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);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), keepPassedToggle, nightMode, true);
|
||||
|
||||
return mainView;
|
||||
}
|
||||
|
@ -379,12 +385,9 @@ public class DirectionIndicationDialogFragment extends BaseOsmAndDialogFragment
|
|||
}
|
||||
|
||||
private void updateMarkerModeRow(int rowId, int radioButtonId, boolean checked, boolean active) {
|
||||
boolean night = !getSettings().isLightContent();
|
||||
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);
|
||||
CompoundButtonCompat.setButtonTintList(rb, ColorStateList.valueOf(ContextCompat.getColor(getContext(), colorId)));
|
||||
UiUtilities.setupCompoundButton(getMyApplication(), rb, isNightMode(usedOnMap), true);
|
||||
mainView.findViewById(rowId).setEnabled(active);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,9 +6,10 @@ import android.content.DialogInterface;
|
|||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.view.View;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.LinearLayout;
|
||||
|
@ -452,14 +453,15 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
Context themedContext = UiUtilities.getThemedContext(uiCtx, nightMode);
|
||||
AlertDialog.Builder dlg = new AlertDialog.Builder(themedContext);
|
||||
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.setPositiveButton(R.string.shared_string_ok, onclick);
|
||||
dlg.setNegativeButton(R.string.shared_string_cancel, null);
|
||||
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 int[] minutes, final ValueHolder<Boolean> choice,
|
||||
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++) {
|
||||
if (i < secondsLength) {
|
||||
|
@ -521,13 +524,16 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
ll.setOrientation(LinearLayout.VERTICAL);
|
||||
ll.addView(tv);
|
||||
ll.addView(sp);
|
||||
int textColorPrimary = ContextCompat.getColor(app, nightMode ? R.color.text_color_primary_dark : R.color.text_color_primary_light);
|
||||
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.setTextColor(textColorPrimary);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
lp.setMargins(dp24, dp8, dp24, 0);
|
||||
cb.setLayoutParams(lp);
|
||||
cb.setPadding(dp8, 0, 0, 0);
|
||||
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
@Override
|
||||
|
@ -536,11 +542,11 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(app, cb, nightMode, true);
|
||||
ll.addView(cb);
|
||||
}
|
||||
|
||||
if (showTrackSelection) {
|
||||
final OsmandApplication app = (OsmandApplication) uiCtx.getApplicationContext();
|
||||
View divider = new View(uiCtx);
|
||||
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, AndroidUtils.dpToPx(uiCtx, 1f));
|
||||
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));
|
||||
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.setTextColor(textColorPrimary);
|
||||
lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,
|
||||
LayoutParams.WRAP_CONTENT);
|
||||
lp.setMargins(dp24, dp8 * 2, dp24, 0);
|
||||
cb.setLayoutParams(lp);
|
||||
cb.setPadding(dp8, 0, 0, 0);
|
||||
cb.setChecked(app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null);
|
||||
cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
||||
|
||||
|
@ -562,6 +570,7 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
|
|||
app.getSelectedGpxHelper().selectGpxFile(app.getSavingTrackHelper().getCurrentGpx(), isChecked, false);
|
||||
}
|
||||
});
|
||||
UiUtilities.setupCompoundButton(app, cb, nightMode, true);
|
||||
ll.addView(cb);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,16 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
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 net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.OsmandSettings.CommonPreference;
|
||||
|
@ -22,19 +26,27 @@ public class OsmNotesMenu {
|
|||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity) {
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(nightMode);
|
||||
createLayersItems(adapter, mapActivity);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (plugin == null) {
|
||||
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 showZoomLevelStringId = R.string.show_from_zoom_level;
|
||||
final int showClosedNotesStringId = R.string.show_closed_notes;
|
||||
|
@ -57,11 +69,11 @@ public class OsmNotesMenu {
|
|||
} else if (itemId == showZoomLevelStringId) {
|
||||
int checked = Arrays.asList(zoomIntValues).indexOf(showOsmBugsZoomPref.get());
|
||||
|
||||
new AlertDialog.Builder(mapActivity)
|
||||
.setTitle(R.string.show_from_zoom_level)
|
||||
.setSingleChoiceItems(zoomStrings, checked, new DialogInterface.OnClickListener() {
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
zoomStrings, nightMode, checked, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
showOsmBugsZoomPref.set(zoomIntValues[which]);
|
||||
ContextMenuItem item = adapter.getItem(position);
|
||||
if (item != null) {
|
||||
|
@ -69,11 +81,14 @@ public class OsmNotesMenu {
|
|||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
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) {
|
||||
showClosedOsmBugsPref.set(isChecked);
|
||||
mapActivity.refreshMap();
|
||||
|
@ -83,12 +98,11 @@ public class OsmNotesMenu {
|
|||
};
|
||||
|
||||
boolean showOsmBugs = showOsmBugsPref.get();
|
||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
int toggleIconColorId;
|
||||
if (showOsmBugs) {
|
||||
toggleIconColorId = nightMode ? R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
} else {
|
||||
toggleIconColorId = nightMode ? R.color.icon_color_default_dark : R.color.icon_color_default_light;
|
||||
toggleIconColorId = ContextMenuItem.INVALID_ID;
|
||||
}
|
||||
|
||||
adapter.addItem(new ContextMenuItem.ItemBuilder()
|
||||
|
@ -132,4 +146,15 @@ public class OsmNotesMenu {
|
|||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
|
||||
@Override
|
||||
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)) {
|
||||
items.add(new TitleItem(getString(R.string.select_base_profile_dialog_title)));
|
||||
items.add(new LongDescriptionItem(getString(R.string.select_base_profile_dialog_message)));
|
||||
|
@ -103,15 +103,14 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
final Drawable drawableIcon;
|
||||
if (isSelected) {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
.getIcon(profile.getIconRes(), activeColorRes);
|
||||
} else {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(activeColorRes)
|
||||
.setChecked(isSelected)
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
|
@ -143,15 +142,14 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
final Drawable drawableIcon;
|
||||
if (isSelected) {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), nightMode
|
||||
? R.color.active_color_primary_dark
|
||||
: R.color.active_color_primary_light);
|
||||
.getIcon(profile.getIconRes(), activeColorRes);
|
||||
} else {
|
||||
drawableIcon = getMyApplication().getUIUtilities()
|
||||
.getIcon(profile.getIconRes(), R.color.icon_color_default_light);
|
||||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(activeColorRes)
|
||||
.setChecked(isSelected)
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
|
@ -189,6 +187,7 @@ public class SelectProfileBottomSheetDialogFragment extends MenuBottomSheetDialo
|
|||
}
|
||||
|
||||
items.add(new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(activeColorRes)
|
||||
.setChecked(icon.getResStringId().equals(selectedIconRes))
|
||||
.setButtonTintList(isSelected
|
||||
? ColorStateList.valueOf(getResolvedColor(getActiveColorId()))
|
||||
|
|
|
@ -5,7 +5,9 @@ import android.content.DialogInterface;
|
|||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatCheckBox;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -26,6 +28,7 @@ import net.osmand.map.TileSourceManager.TileSourceTemplate;
|
|||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -433,16 +436,22 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
names[i] = downloaded.get(i).getName();
|
||||
}
|
||||
final boolean[] selected = new boolean[downloaded.size()];
|
||||
builder.setMultiChoiceItems(names, selected, new DialogInterface.OnMultiChoiceClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
|
||||
selected[which] = isChecked;
|
||||
if (entriesMap.containsKey(downloaded.get(which).getName()) && isChecked) {
|
||||
Toast.makeText(activity, R.string.tile_source_already_installed, Toast.LENGTH_SHORT).show();
|
||||
boolean nightMode = isNightMode(activity, app);
|
||||
int themeResId = getThemeRes(activity, app);
|
||||
int selectedProfileColor = ContextCompat.getColor(app, app.getSettings().getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createMultiChoiceAdapter(names, nightMode, selected, app,
|
||||
selectedProfileColor, themeResId, new View.OnClickListener() {
|
||||
@Override
|
||||
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.setTitle(R.string.select_tile_source_to_install);
|
||||
builder.setPositiveButton(R.string.shared_string_apply, new DialogInterface.OnClickListener() {
|
||||
|
@ -467,8 +476,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
builder.show();
|
||||
dialogAdapter.setDialog(builder.show());
|
||||
}
|
||||
};
|
||||
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
|
@ -478,6 +486,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
final OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
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",
|
||||
"png", 17, 5, 256, 16, 32000);
|
||||
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 maxZoom = (EditText) view.findViewById(R.id.MaxZoom);
|
||||
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);
|
||||
|
||||
final ArrayList<String> templates = new ArrayList<>(entriesMap.keySet());
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
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.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.helpers.AvoidSpecificRoads;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.router.GeneralRouter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -39,6 +39,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem.INVALID_ID;
|
||||
|
||||
|
||||
public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFragment {
|
||||
|
||||
|
@ -57,6 +59,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
|||
private List<LatLon> removedImpassableRoads;
|
||||
private LinearLayout stylesContainer;
|
||||
private boolean hideImpassableRoads;
|
||||
@ColorRes private int compoundButtonColorId = INVALID_ID;
|
||||
|
||||
public AvoidRoadsBottomSheetDialogFragment() {
|
||||
}
|
||||
|
@ -229,6 +232,7 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
|||
|
||||
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
|
||||
item[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(compoundButtonColorId)
|
||||
.setChecked(selected)
|
||||
.setTitle(parameterName)
|
||||
.setLayoutId(R.layout.bottom_sheet_item_with_switch_no_icon)
|
||||
|
@ -245,6 +249,10 @@ public class AvoidRoadsBottomSheetDialogFragment extends MenuBottomSheetDialogFr
|
|||
compoundButtons.add(item[0]);
|
||||
}
|
||||
}
|
||||
|
||||
public void setCompoundButtonColorId(@ColorRes int compoundButtonColorId) {
|
||||
this.compoundButtonColorId = compoundButtonColorId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.routepreparationmenu;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
|
@ -59,6 +60,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
private RoutingHelper routingHelper;
|
||||
private RoutingOptionsHelper routingOptionsHelper;
|
||||
private ApplicationMode applicationMode;
|
||||
@ColorRes private int selectedModeColorId;
|
||||
private MapActivity mapActivity;
|
||||
|
||||
@Override
|
||||
|
@ -70,6 +72,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
routingOptionsHelper = app.getRoutingOptionsHelper();
|
||||
mapActivity = getMapActivity();
|
||||
applicationMode = routingHelper.getAppMode();
|
||||
selectedModeColorId = applicationMode.getIconColorInfo().getColor(nightMode);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,6 +140,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
boolean active = !routingHelper.getVoiceRouter().isMuteForMode(applicationMode);
|
||||
final BottomSheetItemWithCompoundButton[] muteSoundItem = new BottomSheetItemWithCompoundButton[1];
|
||||
muteSoundItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(selectedModeColorId)
|
||||
.setChecked(active)
|
||||
.setDescription(getString(R.string.voice_announcements))
|
||||
.setIcon(getContentIcon(active ? optionsItem.getActiveIconId() : optionsItem.getDisabledIconId()))
|
||||
|
@ -160,6 +164,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
private BaseBottomSheetItem createTimeConditionalRoutingItem(final LocalRoutingParameter optionsItem) {
|
||||
final BottomSheetItemWithCompoundButton[] timeConditionalRoutingItem = new BottomSheetItemWithCompoundButton[1];
|
||||
timeConditionalRoutingItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(selectedModeColorId)
|
||||
.setChecked(settings.ENABLE_TIME_CONDITIONAL_ROUTING.get())
|
||||
.setIcon(getContentIcon((optionsItem.getActiveIconId())))
|
||||
.setTitle(getString(R.string.temporary_conditional_routing))
|
||||
|
@ -195,6 +200,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
fragment.setUsedOnMap(true);
|
||||
fragment.setArguments(args);
|
||||
fragment.setTargetFragment(RouteOptionsBottomSheet.this, ShowAlongTheRouteBottomSheet.REQUEST_CODE);
|
||||
fragment.setAppMode(applicationMode);
|
||||
fragment.show(fm, ShowAlongTheRouteBottomSheet.TAG);
|
||||
updateMenu();
|
||||
}
|
||||
|
@ -204,6 +210,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
private BaseBottomSheetItem createRouteSimulationItem(final LocalRoutingParameter optionsItem) {
|
||||
final BottomSheetItemWithCompoundButton[] simulateNavigationItem = new BottomSheetItemWithCompoundButton[1];
|
||||
simulateNavigationItem[0] = (BottomSheetItemWithCompoundButton) new BottomSheetItemWithCompoundButton.Builder()
|
||||
.setCompoundButtonColorId(selectedModeColorId)
|
||||
.setChecked(settings.simulateNavigation)
|
||||
.setIcon(getContentIcon(R.drawable.ic_action_start_navigation))
|
||||
.setTitle(getString(R.string.simulate_navigation))
|
||||
|
@ -240,6 +247,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment();
|
||||
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
|
||||
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
|
||||
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||
updateMenu();
|
||||
}
|
||||
|
@ -259,6 +267,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
routingOptionsHelper.addNewRouteMenuParameter(applicationMode, optionsItem);
|
||||
AvoidRoadsBottomSheetDialogFragment avoidRoadsFragment = new AvoidRoadsBottomSheetDialogFragment(true);
|
||||
avoidRoadsFragment.setTargetFragment(RouteOptionsBottomSheet.this, AvoidRoadsBottomSheetDialogFragment.REQUEST_CODE);
|
||||
avoidRoadsFragment.setCompoundButtonColorId(selectedModeColorId);
|
||||
avoidRoadsFragment.show(mapActivity.getSupportFragmentManager(), AvoidRoadsBottomSheetDialogFragment.TAG);
|
||||
updateMenu();
|
||||
}
|
||||
|
@ -313,6 +322,7 @@ public class RouteOptionsBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
if (parameter != null) {
|
||||
final BottomSheetItemWithCompoundButton[] item = new BottomSheetItemWithCompoundButton[1];
|
||||
BottomSheetItemWithCompoundButton.Builder builder = new BottomSheetItemWithCompoundButton.Builder();
|
||||
builder.setCompoundButtonColorId(selectedModeColorId);
|
||||
int iconId = -1;
|
||||
if (parameter.routingParameter != null || parameter instanceof RoutingOptionsHelper.OtherLocalRoutingParameter) {
|
||||
builder.setTitle(parameter.getText(mapActivity));
|
||||
|
|
|
@ -4,14 +4,16 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.AppCompatCheckedTextView;
|
||||
import android.util.TypedValue;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.GPXUtilities;
|
||||
|
@ -21,6 +23,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -144,26 +147,33 @@ public class RoutingOptionsHelper {
|
|||
entries[k] = mapActivity.getResources().getString(R.string.install_more);
|
||||
adapter.addItem(itemBuilder.setTitle(entries[k]).createItem());
|
||||
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
|
||||
bld.setSingleChoiceItems(entries, selected, new DialogInterface.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String value = entrieValues[which];
|
||||
if (MORE_VALUE.equals(value)) {
|
||||
final Intent intent = new Intent(mapActivity, DownloadActivity.class);
|
||||
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);
|
||||
boolean nightMode = isNightMode(app);
|
||||
Context themedContext = UiUtilities.getThemedContext(mapActivity, nightMode);
|
||||
int themeRes = getThemeRes(app);
|
||||
ApplicationMode selectedAppMode = app.getRoutingHelper().getAppMode();
|
||||
int selectedModeColor = ContextCompat.getColor(app, selectedAppMode.getIconColorInfo().getColor(nightMode));
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
entries, nightMode, selected, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
String value = entrieValues[which];
|
||||
if (MORE_VALUE.equals(value)) {
|
||||
final Intent intent = new Intent(mapActivity, DownloadActivity.class);
|
||||
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();
|
||||
}
|
||||
});
|
||||
bld.show();
|
||||
);
|
||||
AlertDialog.Builder bld = new AlertDialog.Builder(themedContext);
|
||||
bld.setAdapter(dialogAdapter, null);
|
||||
dialogAdapter.setDialog(bld.show());
|
||||
}
|
||||
|
||||
public String getVoiceProviderName(Context ctx, String value) {
|
||||
|
@ -315,8 +325,10 @@ public class RoutingOptionsHelper {
|
|||
selectedIndex = 0;
|
||||
}
|
||||
|
||||
final boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
final boolean nightMode = isNightMode(app);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
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.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;
|
||||
}
|
||||
|
@ -590,6 +605,17 @@ public class RoutingOptionsHelper {
|
|||
|
||||
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 {
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.osmand.plus.routepreparationmenu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
@ -21,6 +20,8 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
|
@ -54,6 +55,7 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
|||
|
||||
private MapActivity mapActivity;
|
||||
private WaypointHelper waypointHelper;
|
||||
private ApplicationMode appMode;
|
||||
|
||||
private ExpandableListView expListView;
|
||||
private ExpandableListAdapter adapter;
|
||||
|
@ -206,6 +208,17 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
|||
setupHeightAndBackground(getView());
|
||||
}
|
||||
}
|
||||
|
||||
public void setAppMode(ApplicationMode appMode) {
|
||||
this.appMode = appMode;
|
||||
}
|
||||
|
||||
public ApplicationMode getAppMode() {
|
||||
if (appMode == null) {
|
||||
setAppMode(app.getSettings().getApplicationMode());
|
||||
}
|
||||
return appMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoutingDataUpdate() {
|
||||
|
@ -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() {
|
||||
@Override
|
||||
|
@ -496,21 +511,28 @@ public class ShowAlongTheRouteBottomSheet extends MenuBottomSheetDialogFragment
|
|||
selected = i;
|
||||
}
|
||||
}
|
||||
new AlertDialog.Builder(mapActivity)
|
||||
.setSingleChoiceItems(names, selected, new DialogInterface.OnClickListener() {
|
||||
int selectedProfileColor = ContextCompat.getColor(app, getAppMode().getIconColorInfo().getColor(nightMode));
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
names, nightMode, selected, app, selectedProfileColor, themeRes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
int value = WaypointHelper.SEARCH_RADIUS_VALUES[i];
|
||||
public void onClick(View v) {
|
||||
int which = (int) v.getTag();
|
||||
int value = WaypointHelper.SEARCH_RADIUS_VALUES[which];
|
||||
if (waypointHelper.getSearchDeviationRadius(type) != value) {
|
||||
waypointHelper.setSearchDeviationRadius(type, value);
|
||||
recalculatePoints(type);
|
||||
dialogInterface.dismiss();
|
||||
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)
|
||||
.show();
|
||||
.setAdapter(dialogAdapter, null)
|
||||
.create();
|
||||
dialogAdapter.setDialog(dialog);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
private void enableType(final int type,
|
||||
|
|
|
@ -34,6 +34,7 @@ import android.support.v7.widget.RecyclerView;
|
|||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -295,13 +296,13 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
|
||||
ApplicationMode appMode = getSelectedAppMode();
|
||||
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) {
|
||||
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
|
||||
BooleanPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, currentScreenType.profileDependent);
|
||||
} else if (preference instanceof EditTextPreference) {
|
||||
EditTextPreferenceBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
|
||||
} else if (preference instanceof MultiSelectBooleanPreference) {
|
||||
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode);
|
||||
MultiSelectPreferencesBottomSheet.showInstance(fragmentManager, preference.getKey(), this, false, appMode, currentScreenType.profileDependent);
|
||||
} else {
|
||||
super.onDisplayPreferenceDialog(preference);
|
||||
}
|
||||
|
@ -353,6 +354,15 @@ public abstract class BaseSettingsFragment extends PreferenceFragmentCompat impl
|
|||
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")
|
||||
|
|
|
@ -131,6 +131,7 @@ public class ConfigureProfileFragment extends BaseSettingsFragment {
|
|||
|
||||
SwitchCompat switchView = switchContainer.findViewById(R.id.switchWidget);
|
||||
switchView.setChecked(isChecked);
|
||||
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
|
||||
|
||||
TextView title = switchContainer.findViewById(R.id.switchButtonText);
|
||||
title.setText(isChecked ? R.string.shared_string_on : R.string.shared_string_off);
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.content.DialogInterface;
|
|||
import android.content.pm.ActivityInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
@ -339,6 +340,9 @@ public class GeneralProfileSettingsFragment extends BaseSettingsFragment impleme
|
|||
desc.setVisibility(View.GONE);
|
||||
}
|
||||
title.setChecked(position == selected);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
UiUtilities.setupCompoundButtonDrawable(app, isNightMode(), getActiveProfileColor(), title.getCheckMarkDrawable());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
|
||||
public class ScreenAlertsFragment extends BaseSettingsFragment {
|
||||
|
||||
|
@ -77,6 +78,7 @@ public class ScreenAlertsFragment extends BaseSettingsFragment {
|
|||
|
||||
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
|
||||
switchView.setChecked(checked);
|
||||
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
|
||||
|
||||
TextView title = switchContainer.findViewById(R.id.switchButtonText);
|
||||
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.TextView;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.settings.preferences.ListPreferenceEx;
|
||||
import net.osmand.plus.settings.preferences.SwitchPreferenceEx;
|
||||
|
||||
|
@ -63,6 +64,7 @@ public class TurnScreenOnFragment extends BaseSettingsFragment {
|
|||
|
||||
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
|
||||
switchView.setChecked(checked);
|
||||
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
|
||||
|
||||
TextView title = switchContainer.findViewById(R.id.switchButtonText);
|
||||
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
|
||||
|
|
|
@ -19,6 +19,7 @@ import net.osmand.AndroidUtils;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
|
@ -70,6 +71,7 @@ public class VoiceAnnouncesFragment extends BaseSettingsFragment {
|
|||
|
||||
SwitchCompat switchView = (SwitchCompat) switchContainer.findViewById(R.id.switchWidget);
|
||||
switchView.setChecked(checked);
|
||||
UiUtilities.setupCompoundButton(isNightMode(), getActiveProfileColor(), switchView);
|
||||
|
||||
TextView title = switchContainer.findViewById(R.id.switchButtonText);
|
||||
title.setText(checked ? R.string.shared_string_on : R.string.shared_string_off);
|
||||
|
|
|
@ -21,6 +21,7 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
|||
private String prefId;
|
||||
private Preference preference;
|
||||
private ApplicationMode appMode;
|
||||
private boolean profileDependent;
|
||||
|
||||
protected void setAppMode(ApplicationMode appMode) {
|
||||
this.appMode = appMode;
|
||||
|
@ -94,4 +95,12 @@ public abstract class BasePreferenceBottomSheet extends MenuBottomSheetDialogFra
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setProfileDependent(boolean profileDependent) {
|
||||
this.profileDependent = profileDependent;
|
||||
}
|
||||
|
||||
public boolean isProfileDependent() {
|
||||
return profileDependent;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,9 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
}
|
||||
})
|
||||
.create();
|
||||
if (isProfileDependent()) {
|
||||
preferenceBtn[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
|
||||
}
|
||||
items.add(preferenceBtn[0]);
|
||||
|
||||
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,
|
||||
@Nullable ApplicationMode appMode) {
|
||||
@Nullable ApplicationMode appMode, boolean profileDependent) {
|
||||
try {
|
||||
if (fm.findFragmentByTag(BooleanPreferenceBottomSheet.TAG) == null) {
|
||||
Bundle args = new Bundle();
|
||||
|
@ -140,6 +143,7 @@ public class BooleanPreferenceBottomSheet extends BasePreferenceBottomSheet {
|
|||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setAppMode(appMode);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setProfileDependent(profileDependent);
|
||||
fragment.show(fm, BooleanPreferenceBottomSheet.TAG);
|
||||
}
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -87,6 +87,9 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
|
|||
})
|
||||
.setTag(prefId)
|
||||
.create();
|
||||
if (isProfileDependent()) {
|
||||
item[0].setCompoundButtonColorId(getAppMode().getIconColorInfo().getColor(nightMode));
|
||||
}
|
||||
items.add(item[0]);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +161,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
|
|||
}
|
||||
|
||||
public static boolean showInstance(@NonNull FragmentManager fragmentManager, String prefId, Fragment target,
|
||||
boolean usedOnMap, @Nullable ApplicationMode appMode) {
|
||||
boolean usedOnMap, @Nullable ApplicationMode appMode, boolean profileDependent) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, prefId);
|
||||
|
@ -169,6 +172,7 @@ public class MultiSelectPreferencesBottomSheet extends BasePreferenceBottomSheet
|
|||
fragment.setAppMode(appMode);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
fragment.setProfileDependent(profileDependent);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
return false;
|
||||
|
|
|
@ -56,7 +56,8 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
|
|||
final BaseBottomSheetItem[] preferenceItem = new BottomSheetItemWithCompoundButton[1];
|
||||
preferenceItem[0] = new BottomSheetItemWithCompoundButton.Builder()
|
||||
.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])
|
||||
.setTag(i)
|
||||
.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,
|
||||
boolean usedOnMap, @Nullable ApplicationMode appMode) {
|
||||
boolean usedOnMap, @Nullable ApplicationMode appMode, boolean profileDependent) {
|
||||
try {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(PREFERENCE_ID, key);
|
||||
|
@ -135,6 +136,7 @@ public class SingleSelectPreferenceBottomSheet extends BasePreferenceBottomSheet
|
|||
fragment.setUsedOnMap(usedOnMap);
|
||||
fragment.setAppMode(appMode);
|
||||
fragment.setTargetFragment(target, 0);
|
||||
fragment.setProfileDependent(profileDependent);
|
||||
fragment.show(fragmentManager, TAG);
|
||||
return true;
|
||||
} catch (RuntimeException e) {
|
||||
|
|
|
@ -37,8 +37,11 @@ public class ContourLinesMenu {
|
|||
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
||||
}
|
||||
boolean nightMode = isNightMode(mapActivity.getMyApplication());
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(nightMode);
|
||||
createLayersItems(adapter, mapActivity);
|
||||
return adapter;
|
||||
}
|
||||
|
@ -175,7 +178,7 @@ public class ContourLinesMenu {
|
|||
R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
} else {
|
||||
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()
|
||||
.setTitleId(toggleActionStringId, mapActivity)
|
||||
|
@ -326,6 +329,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) {
|
||||
mapActivity.getDashboard().hideDashboard(false);
|
||||
|
|
|
@ -32,8 +32,11 @@ public class HillshadeMenu {
|
|||
if (plugin != null && !plugin.isActive() && !plugin.needsInstallation()) {
|
||||
OsmandPlugin.enablePlugin(mapActivity, mapActivity.getMyApplication(), plugin, true);
|
||||
}
|
||||
boolean nightMode = mapActivity.getMyApplication().getDaynightHelper().isNightModeForMapControls();
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter();
|
||||
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
|
||||
adapter.setProfileDependent(true);
|
||||
adapter.setNightMode(nightMode);
|
||||
createLayersItems(adapter, mapActivity);
|
||||
return adapter;
|
||||
}
|
||||
|
@ -97,7 +100,7 @@ public class HillshadeMenu {
|
|||
R.color.active_color_primary_dark : R.color.active_color_primary_light;
|
||||
} else {
|
||||
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()
|
||||
.setTitleId(toggleActionStringId, mapActivity)
|
||||
|
|
|
@ -4,7 +4,9 @@ import android.app.Activity;
|
|||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
|
@ -13,6 +15,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.DialogListItemAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -359,7 +362,9 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
final Runnable callback) {
|
||||
final String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
||||
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);
|
||||
|
||||
List<String> possibleValuesList = new ArrayList<>(Arrays.asList(p.getPossibleValues()));
|
||||
|
@ -382,18 +387,22 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
possibleValues[j]);
|
||||
}
|
||||
|
||||
b.setSingleChoiceItems(possibleValuesString, i, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (which == 0) {
|
||||
pref.set("");
|
||||
} else {
|
||||
pref.set(possibleValues[which - 1]);
|
||||
int selectedModeColor = ContextCompat.getColor(app, settings.getApplicationMode().getIconColorInfo().getColor(nightMode));
|
||||
DialogListItemAdapter dialogAdapter = DialogListItemAdapter.createSingleChoiceAdapter(
|
||||
possibleValuesString, nightMode, i, app, selectedModeColor, themeRes, new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
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.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
@Override
|
||||
|
@ -403,7 +412,8 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
}
|
||||
}
|
||||
});
|
||||
b.show();
|
||||
b.setAdapter(dialogAdapter, null);
|
||||
dialogAdapter.setDialog(b.show());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -420,4 +430,15 @@ public class SRTMPlugin extends OsmandPlugin {
|
|||
activity.updateMapSettings();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import net.osmand.plus.OsmandSettings.LayerTransparencySeekbarMode;
|
|||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
import net.osmand.plus.UiUtilities;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivity.ShowQuickSearchMode;
|
||||
import net.osmand.plus.base.ContextMenuFragment.MenuState;
|
||||
|
@ -969,6 +970,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
}
|
||||
boolean nightMode = app.getDaynightHelper().isNightModeForMapControls();
|
||||
UiUtilities.setupSeekBar(app, transparencyBar, nightMode, true);
|
||||
}
|
||||
|
||||
public void hideTransparencyBar() {
|
||||
|
|
|
@ -1085,7 +1085,7 @@ public class MapInfoWidgetsFactory {
|
|||
Bundle args = new Bundle();
|
||||
args.putInt(ShowAlongTheRouteBottomSheet.EXPAND_TYPE_KEY, pnt.type);
|
||||
fragment.setArguments(args);
|
||||
fragment.setUsedOnMap(false);
|
||||
fragment.setUsedOnMap(true);
|
||||
fragment.show(map.getSupportFragmentManager(), ShowAlongTheRouteBottomSheet.TAG);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
|
@ -490,6 +491,8 @@ public class MapWidgetRegistry {
|
|||
|
||||
final boolean selected = r.visibleCollapsed(mode) || r.visible(mode);
|
||||
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()
|
||||
.setIcon(r.getDrawableMenu())
|
||||
.setSelected(selected)
|
||||
|
@ -530,7 +533,7 @@ public class MapWidgetRegistry {
|
|||
MenuItem menuItem = menu.add(R.id.single_selection_group, id, i, titleId)
|
||||
.setChecked(id == checkedId);
|
||||
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.setGroupVisible(R.id.single_selection_group, true);
|
||||
|
@ -779,6 +782,9 @@ public class MapWidgetRegistry {
|
|||
|
||||
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
|
||||
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.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.app_modes_choose, map)
|
||||
.setLayout(R.layout.mode_toggles).createItem());
|
||||
|
|
Loading…
Reference in a new issue