Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-03-23 17:35:54 +01:00
commit 7727837d11
51 changed files with 402 additions and 358 deletions

View file

@ -2,7 +2,7 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<Switch
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="4dp"

View file

@ -2,7 +2,7 @@
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:text="@string/osmo_connect_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

View file

@ -68,7 +68,7 @@
android:textSize="16sp"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/liveUpdatesSwitch"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View file

@ -4,14 +4,15 @@
xmlns:osmand="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="40dp"
android:orientation="horizontal"
android:paddingLeft="@dimen/list_header_padding"
android:paddingRight="@dimen/list_header_padding">
<net.osmand.plus.widgets.TextViewEx
android:id="@+id/section_name"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
@ -30,9 +31,9 @@
android:layout_marginRight="12dp"
android:maxLines="1"
android:textSize="@dimen/default_desc_text_size"
android:visibility="gone"
osmand:typeface="@string/font_roboto_medium"
tools:text="600Mb"
tools:visibility="visible"
android:visibility="gone"/>
tools:visibility="visible"/>
</LinearLayout>

View file

@ -39,7 +39,7 @@
android:textSize="@dimen/default_desc_text_size"/>
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View file

@ -30,7 +30,7 @@
tools:text="Some title text" />
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="@dimen/list_item_height"
android:layout_marginLeft="11dp"

View file

@ -8,7 +8,7 @@
android:paddingLeft="@dimen/list_header_padding">
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View file

@ -23,7 +23,7 @@
android:paddingLeft="@dimen/list_content_padding">
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"

View file

@ -28,7 +28,7 @@
android:textSize="@dimen/default_list_text_size" />
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="@dimen/list_item_height"
android:layout_gravity="center_vertical"

View file

@ -26,7 +26,7 @@
android:paddingRight="16dp">
<TextView
android:id="@+id/section_name"
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
@ -34,7 +34,7 @@
tools:text="Live updates"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/liveUpdatesSwitch"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"

View file

@ -1,28 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="54dp"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:layout_gravity="center_vertical"
tools:text="Some title text" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/check_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:focusable="false"
android:layout_gravity="center_vertical" />
</LinearLayout>

View file

@ -1,46 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="54dp"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="54dp"
android:orientation="horizontal"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<ImageView
<android.support.v7.widget.AppCompatImageView
android:id="@+id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="32dp"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_gabout_dark" />
android:layout_marginBottom="16dp"
android:layout_marginRight="32dp"
android:layout_marginTop="16dp"
tools:src="@drawable/ic_action_gabout_dark"/>
<TextView
<android.support.v7.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="@dimen/default_list_text_size"
android:layout_weight="1"
android:layout_gravity="center_vertical"
tools:text="Some title text" />
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Some title text"/>
<ImageView
android:id="@+id/menu"
<android.support.v7.widget.AppCompatImageView
android:id="@+id/secondary_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="center_vertical"
tools:src="@drawable/ic_action_gabout_dark" />
android:layout_margin="16dp"
tools:src="@drawable/ic_action_gabout_dark"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="16dp"
android:focusable="false"
android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
android:focusable="false"/>
</LinearLayout>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/bg_color"
android:minHeight="54dp"
android:orientation="horizontal">
<TextView
android:id="@+id/title"
android:layout_width="0dp"
android:layout_marginLeft="16dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:textSize="@dimen/default_list_text_size"
tools:text="Some title text"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/description"
style="@style/Widget.AppCompat.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:inputType="textCapWords"
tools:text="topbar"
android:textColor="?colorAccent"
android:layout_marginLeft="16dp"
android:focusable="false"/>
</LinearLayout>

View file

@ -49,7 +49,7 @@
android:focusable="false" />
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="6dip"

View file

@ -40,7 +40,7 @@
<!-- android:button="@drawable/ic_btn_wocheckbox" -->
<CheckBox
android:id="@+id/check_item"
android:id="@+id/toggle_item"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="24dp"

View file

@ -5,8 +5,12 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.LayoutRes;
import android.support.annotation.StringRes;
import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
@ -51,7 +55,7 @@ public class ContextMenuAdapter {
//boolean return type needed to desribe if drawer needed to be close or not
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
return false;
@ -88,7 +92,8 @@ public class ContextMenuAdapter {
final TIntArrayList loadingList = new TIntArrayList();
final TIntArrayList layoutIds = new TIntArrayList();
final TIntArrayList iconList = new TIntArrayList();
final TIntArrayList iconListLight = new TIntArrayList();
final TIntArrayList lightIconList = new TIntArrayList();
final TIntArrayList secondaryLightIconList = new TIntArrayList();
final ArrayList<String> itemDescription = new ArrayList<String>();
private List<ApplicationMode> visibleModes = new ArrayList<ApplicationMode>();
private ConfigureMapMenu.OnClickListener changeAppModeListener = null;
@ -170,13 +175,22 @@ public class ContextMenuAdapter {
if (lst != 0) {
return ctx.getResources().getDrawable(lst);
}
int lstLight = iconListLight.get(pos);
int lstLight = lightIconList.get(pos);
if (lstLight != 0) {
return ctx.getIconsCache().getIcon(lstLight, light);
}
return null;
}
public Drawable getSecondaryImage(OsmandApplication ctx, int pos, boolean light) {
@DrawableRes
int secondaryDrawableId = secondaryLightIconList.get(pos);
if (secondaryDrawableId != 0) {
return ContextCompat.getDrawable(ctx, secondaryDrawableId);
}
return null;
}
public int getBackgroundColor(Context ctx, boolean holoLight) {
if (holoLight) {
return ctx.getResources().getColor(R.color.bg_color_light);
@ -206,12 +220,18 @@ public class ContextMenuAdapter {
}
public class Item {
@DrawableRes
int icon = 0;
@DrawableRes
int lightIcon = 0;
@DrawableRes
int secondaryLightIcon = 0;
@IdRes
int id;
String name;
int selected = -1;
int progress = -1;
@LayoutRes
int layout = -1;
int loading = -1;
boolean cat;
@ -223,16 +243,20 @@ public class ContextMenuAdapter {
private Item() {
}
public Item icon(int icon) {
public Item icon(@DrawableRes int icon) {
this.icon = icon;
return this;
}
public Item iconColor(int icon) {
public Item colorIcon(@DrawableRes int icon) {
this.lightIcon = icon;
return this;
}
public Item secondaryIconColor(@DrawableRes int icon) {
this.secondaryLightIcon = icon;
return this;
}
public Item position(int pos) {
this.pos = pos;
@ -254,7 +278,7 @@ public class ContextMenuAdapter {
return this;
}
public Item layout(int l) {
public Item layout(@LayoutRes int l) {
this.layout = l;
return this;
}
@ -286,7 +310,8 @@ public class ContextMenuAdapter {
loadingList.insert(pos, loading);
layoutIds.insert(pos, layout);
iconList.insert(pos, icon);
iconListLight.insert(pos, lightIcon);
lightIconList.insert(pos, lightIcon);
secondaryLightIconList.insert(pos, secondaryLightIcon);
checkListeners.add(pos, checkBoxListener);
integerListeners.add(pos, integerListener);
isCategory.insert(pos, cat ? 1 : 0);
@ -314,7 +339,8 @@ public class ContextMenuAdapter {
selectedList.removeAt(pos);
progressList.removeAt(pos);
iconList.removeAt(pos);
iconListLight.removeAt(pos);
lightIconList.removeAt(pos);
secondaryLightIconList.removeAt(pos);
checkListeners.remove(pos);
integerListeners.remove(pos);
isCategory.removeAt(pos);
@ -344,9 +370,8 @@ public class ContextMenuAdapter {
public ArrayAdapter<?> createListAdapter(final Activity activity, final boolean holoLight) {
final int layoutId = defaultLayoutId;
final OsmandApplication app = ((OsmandApplication) activity.getApplication());
ArrayAdapter<String> listAdapter = new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
return new ContextMenuArrayAdapter(activity, layoutId, R.id.title,
getItemNames(), app, holoLight);
return listAdapter;
}
public class ContextMenuArrayAdapter extends ArrayAdapter<String> {
@ -385,7 +410,7 @@ public class ContextMenuAdapter {
}
if (convertView == null || (!lid.equals(convertView.getTag()))) {
convertView = activity.getLayoutInflater().inflate(lid, parent, false);
AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
// AndroidUtils.setListItemBackground(ctx, convertView, !holoLight);
convertView.setTag(lid);
}
TextView tv = (TextView) convertView.findViewById(R.id.title);
@ -398,7 +423,7 @@ public class ContextMenuAdapter {
int color = activity.getResources()
.getColor(holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
Drawable imageId = app.getIconsCache().getPaintedContentIcon(
iconListLight.get(position), color);
lightIconList.get(position), color);
float density = activity.getResources().getDisplayMetrics().density;
int paddingInPixels = (int) (24 * density);
int drawableSizeInPixels = (int) (24 * density); // 32
@ -406,15 +431,31 @@ public class ContextMenuAdapter {
tv.setCompoundDrawables(imageId, null, null, null);
tv.setCompoundDrawablePadding(paddingInPixels);
} else {
Drawable imageId = getImage(app, position, holoLight);
if (imageId != null) {
Drawable drawable = getImage(app, position, holoLight);
if (drawable != null) {
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(imageId);
((ImageView) convertView.findViewById(R.id.icon)).setImageDrawable(drawable);
convertView.findViewById(R.id.icon).setVisibility(View.VISIBLE);
} else if (convertView.findViewById(R.id.icon) != null) {
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
}
}
@DrawableRes
int secondaryLightDrawable = secondaryLightIconList.get(position);
if (secondaryLightDrawable != 0) {
int color = ContextCompat.getColor(ctx,
holoLight ? R.color.icon_color : R.color.dashboard_subheader_text_dark);
Drawable drawable = getSecondaryImage(app, position, holoLight);
DrawableCompat.setTint(drawable, color);
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
imageView.setImageDrawable(drawable);
imageView.setVisibility(View.VISIBLE);
} else {
ImageView imageView = (ImageView) convertView.findViewById(R.id.secondary_icon);
if (imageView != null) {
imageView.setVisibility(View.GONE);
}
}
if (isCategory(position)) {
tv.setTypeface(Typeface.DEFAULT_BOLD);
@ -422,8 +463,8 @@ public class ContextMenuAdapter {
tv.setTypeface(null);
}
if (convertView.findViewById(R.id.check_item) != null) {
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.check_item);
if (convertView.findViewById(R.id.toggle_item) != null) {
final CompoundButton ch = (CompoundButton) convertView.findViewById(R.id.toggle_item);
if (selectedList.get(position) != -1) {
ch.setOnCheckedChangeListener(null);
ch.setVisibility(View.VISIBLE);

View file

@ -234,7 +234,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity);
name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
icon.setVisibility(View.VISIBLE);
ch.setVisibility(View.GONE);
return row;

View file

@ -171,7 +171,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
IconsCache iconsCache = getMyApplication().getIconsCache();
if (selectionMode) {
CheckBox ch = (CheckBox) v.findViewById(R.id.check_item);
CheckBox ch = (CheckBox) v.findViewById(R.id.toggle_item);
FavouritePoint model = favouritesAdapter.getChild(groupPosition, childPosition);
ch.setChecked(!ch.isChecked());
if (ch.isChecked()) {
@ -722,7 +722,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
View row = convertView;
boolean checkBox = row != null && row.findViewById(R.id.check_item) instanceof CheckBox;
boolean checkBox = row != null && row.findViewById(R.id.toggle_item) instanceof CheckBox;
boolean same = (selectionMode && checkBox) || (!selectionMode && !checkBox);
if (row == null || !same) {
LayoutInflater inflater = getActivity().getLayoutInflater();
@ -735,7 +735,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
label.setText(model.name.length() == 0 ? getString(R.string.shared_string_favorites) : model.name);
if (selectionMode) {
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
ch.setVisibility(View.VISIBLE);
ch.setChecked(groupsToDelete.contains(model));
@ -756,7 +756,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
}
});
} else {
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
ch.setVisibility(View.GONE);
}
final View ch = row.findViewById(R.id.options);
@ -821,7 +821,7 @@ public class FavoritesTreeFragment extends OsmandExpandableListFragment {
direction.setVisibility(View.VISIBLE);
direction.setImageDrawable(arrowImage);
final CheckBox ch = (CheckBox) row.findViewById(R.id.check_item);
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
if (selectionMode) {
ch.setVisibility(View.VISIBLE);
ch.setChecked(favoritesSelected.contains(model));

View file

@ -1,24 +1,12 @@
package net.osmand.plus.activities;
import java.util.ArrayList;
import java.util.List;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.dialogs.HelpArticleDialogFragment;
import org.apache.commons.logging.Log;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.DrawableRes;
import android.support.annotation.IdRes;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.Fragment;
@ -36,10 +24,23 @@ import android.widget.FrameLayout.LayoutParams;
import android.widget.ImageView;
import android.widget.TextView;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.Version;
import net.osmand.plus.dialogs.HelpArticleDialogFragment;
import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List;
public class HelpActivity extends OsmandActionBarActivity {
// public static final String DIALOG = "dialog";
@IdRes
public static final int DIALOG = 5;
final static HelpMenuCategory[] categories = HelpMenuCategory.values();
public static final String OSMAND_POLL_HTML = "http://osmand.net/android-poll.html";
@ -274,7 +275,7 @@ public class HelpActivity extends OsmandActionBarActivity {
LayoutInflater inflater = LayoutInflater.from(ctx);
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
}
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
TextView nameView = ((TextView) v.findViewById(R.id.title));
nameView.setText(titleId);
v.setOnClickListener(null);
TypedValue typedValue = new TypedValue();

View file

@ -255,7 +255,7 @@ public class IntermediatePointsDialog {
R.drawable.ic_action_intermediate;
tv.setCompoundDrawablesWithIntrinsicBounds(app.getIconsCache().getContentIcon(icon), null, null, null);
tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
ch.setVisibility(View.VISIBLE);
ch.setOnCheckedChangeListener(null);
ch.setChecked(checkedIntermediates[position]);

View file

@ -279,14 +279,14 @@ public class MapActivityActions implements DialogProvider {
public void contextMenuPoint(final double latitude, final double longitude, final ContextMenuAdapter iadapter, Object selectedObj) {
final ContextMenuAdapter adapter = iadapter == null ? new ContextMenuAdapter(mapActivity) : iadapter;
adapter.item(R.string.context_menu_item_search).iconColor(R.drawable.ic_action_search_dark).reg();
adapter.item(R.string.context_menu_item_search).colorIcon(R.drawable.ic_action_search_dark).reg();
if (!mapActivity.getRoutingHelper().isFollowingMode() && !mapActivity.getRoutingHelper().isRoutePlanningMode()) {
adapter.item(R.string.context_menu_item_directions_from).iconColor(
adapter.item(R.string.context_menu_item_directions_from).colorIcon(
R.drawable.ic_action_gdirections_dark).reg();
}
if (getMyApplication().getTargetPointsHelper().getPointToNavigate() != null &&
(mapActivity.getRoutingHelper().isFollowingMode() || mapActivity.getRoutingHelper().isRoutePlanningMode())) {
adapter.item(R.string.context_menu_item_last_intermediate_point).iconColor(
adapter.item(R.string.context_menu_item_last_intermediate_point).colorIcon(
R.drawable.ic_action_intermediate).reg();
}
OsmandPlugin.registerMapContextMenu(mapActivity, latitude, longitude, adapter, selectedObj);
@ -385,7 +385,7 @@ public class MapActivityActions implements DialogProvider {
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
((TextView) convertView.findViewById(R.id.title)).setText(name);
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
convertView.findViewById(R.id.check_item).setVisibility(View.GONE);
convertView.findViewById(R.id.toggle_item).setVisibility(View.GONE);
return convertView;
}
};
@ -593,7 +593,7 @@ public class MapActivityActions implements DialogProvider {
final OsmandApplication app = mapActivity.getMyApplication();
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter(app);
optionsMenuHelper.item(R.string.home).iconColor(R.drawable.map_dashboard)
optionsMenuHelper.item(R.string.home).colorIcon(R.drawable.map_dashboard)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -604,7 +604,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
if (settings.USE_MAP_MARKERS.get()) {
optionsMenuHelper.item(R.string.map_markers).iconColor(R.drawable.ic_action_flag_dark)
optionsMenuHelper.item(R.string.map_markers).colorIcon(R.drawable.ic_action_flag_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -614,7 +614,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
} else {
optionsMenuHelper.item(R.string.waypoints).iconColor(R.drawable.ic_action_intermediate)
optionsMenuHelper.item(R.string.waypoints).colorIcon(R.drawable.ic_action_intermediate)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -624,7 +624,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
}
optionsMenuHelper.item(R.string.get_directions).iconColor(R.drawable.ic_action_gdirections_dark)
optionsMenuHelper.item(R.string.get_directions).colorIcon(R.drawable.ic_action_gdirections_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -643,7 +643,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
optionsMenuHelper.item(R.string.search_button)
.iconColor(R.drawable.ic_action_search_dark)
.colorIcon(R.drawable.ic_action_search_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -661,7 +661,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.shared_string_my_places).iconColor(R.drawable.ic_action_fav_dark)
optionsMenuHelper.item(R.string.shared_string_my_places).colorIcon(R.drawable.ic_action_fav_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -674,7 +674,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
optionsMenuHelper.item(R.string.show_point_options).iconColor(R.drawable.ic_action_marker_dark)
optionsMenuHelper.item(R.string.show_point_options).colorIcon(R.drawable.ic_action_marker_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -684,7 +684,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.configure_map).iconColor(R.drawable.ic_action_layers_dark)
optionsMenuHelper.item(R.string.configure_map).colorIcon(R.drawable.ic_action_layers_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -694,7 +694,7 @@ public class MapActivityActions implements DialogProvider {
}
}).reg();
optionsMenuHelper.item(R.string.layer_map_appearance).iconColor(R.drawable.ic_configure_screen_dark)
optionsMenuHelper.item(R.string.layer_map_appearance).colorIcon(R.drawable.ic_configure_screen_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -711,7 +711,7 @@ public class MapActivityActions implements DialogProvider {
d += " (" + updt.size() + ")";
}
}
optionsMenuHelper.item(R.string.index_settings).name(d).iconColor(R.drawable.ic_type_archive)
optionsMenuHelper.item(R.string.index_settings).name(d).colorIcon(R.drawable.ic_type_archive)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -724,7 +724,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
if (Version.isGooglePlayEnabled(app)) {
optionsMenuHelper.item(R.string.osm_live).iconColor(R.drawable.ic_action_osm_live)
optionsMenuHelper.item(R.string.osm_live).colorIcon(R.drawable.ic_action_osm_live)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -736,7 +736,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
}
optionsMenuHelper.item(R.string.prefs_plugins).iconColor(R.drawable.ic_extension_dark)
optionsMenuHelper.item(R.string.prefs_plugins).colorIcon(R.drawable.ic_extension_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -749,7 +749,7 @@ public class MapActivityActions implements DialogProvider {
}).reg();
optionsMenuHelper.item(R.string.shared_string_settings).iconColor(R.drawable.ic_action_settings)
optionsMenuHelper.item(R.string.shared_string_settings).colorIcon(R.drawable.ic_action_settings)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -760,7 +760,7 @@ public class MapActivityActions implements DialogProvider {
return true;
}
}).reg();
optionsMenuHelper.item(R.string.shared_string_help).iconColor(R.drawable.ic_action_help)
optionsMenuHelper.item(R.string.shared_string_help).colorIcon(R.drawable.ic_action_help)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -774,7 +774,7 @@ public class MapActivityActions implements DialogProvider {
//////////// Others
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
// optionsMenuHelper.item(R.string.shared_string_exit).iconColor(R.drawable.ic_action_quit_dark )
// optionsMenuHelper.item(R.string.shared_string_exit).colorIcon(R.drawable.ic_action_quit_dark )
// .listen(new OnContextMenuClick() {
// @Override
// public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -262,7 +262,7 @@ public class MapActivityLayers {
OsmandApplication app = (OsmandApplication) getApplication();
final PoiFiltersHelper poiFilters = app.getPoiFilters();
final ContextMenuAdapter adapter = new ContextMenuAdapter(activity);
adapter.item(R.string.shared_string_search).iconColor(R.drawable.ic_action_search_dark).reg();
adapter.item(R.string.shared_string_search).colorIcon(R.drawable.ic_action_search_dark).reg();
final List<PoiUIFilter> list = new ArrayList<PoiUIFilter>();
list.add(poiFilters.getCustomPOIFilter());
for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {

View file

@ -126,7 +126,7 @@ public class StartGPSStatus extends OsmAndAction {
View v = mapActivity.getLayoutInflater().inflate(layout, null);
TextView tv = (TextView)v.findViewById(R.id.title);
tv.setText(getItem(position).stringRes);
v.findViewById(R.id.check_item).setVisibility(View.INVISIBLE);
v.findViewById(R.id.toggle_item).setVisibility(View.INVISIBLE);
return v;
}
};

View file

@ -591,7 +591,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.layer_recordings).selected(SHOW_RECORDINGS.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_micro_dark).listen(listener).position(12).reg();
.colorIcon(R.drawable.ic_action_micro_dark).listen(listener).position(12).reg();
}
@Override
@ -600,7 +600,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
if (isRecording()) {
return;
}
adapter.item(R.string.recording_context_menu_arecord).iconColor(R.drawable.ic_action_micro_dark)
adapter.item(R.string.recording_context_menu_arecord).colorIcon(R.drawable.ic_action_micro_dark)
.listen(new OnContextMenuClick() {
@Override
@ -609,7 +609,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true;
}
}).position(6).reg();
adapter.item(R.string.recording_context_menu_vrecord).iconColor(R.drawable.ic_action_video_dark)
adapter.item(R.string.recording_context_menu_vrecord).colorIcon(R.drawable.ic_action_video_dark)
.listen(new OnContextMenuClick() {
@Override
@ -618,7 +618,7 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
return true;
}
}).position(7).reg();
adapter.item(R.string.recording_context_menu_precord).iconColor(R.drawable.ic_action_photo_dark)
adapter.item(R.string.recording_context_menu_precord).colorIcon(R.drawable.ic_action_photo_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -9,6 +9,7 @@ import android.os.Build;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
@ -32,7 +33,6 @@ import android.widget.ListView;
import android.widget.ScrollView;
import android.widget.TextView;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
@ -204,7 +204,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
public void createDashboardView() {
baseColor = mapActivity.getResources().getColor(R.color.osmand_orange) & 0x00ffffff;
baseColor = ContextCompat.getColor(mapActivity, R.color.osmand_orange) & 0x00ffffff;
waypointDialogHelper = new WaypointDialogHelper(mapActivity);
waypointDialogHelper.setHelperCallbacks(this);
mapMarkerDialogHelper = new MapMarkerDialogHelper(mapActivity);
@ -357,7 +357,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
});
gradientToolbar = mapActivity.getResources().getDrawable(R.drawable.gradient_toolbar).mutate();
gradientToolbar = ContextCompat.getDrawable(mapActivity, R.drawable.gradient_toolbar).mutate();
if (AndroidUiHelper.isOrientationPortrait(mapActivity)) {
this.portrait = true;
scrollView.setScrollViewCallbacks(this);
@ -381,7 +381,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
fl.gravity = Gravity.BOTTOM;
shadowContainer.setLayoutParams(fl);
ImageView shadow = new ImageView(mapActivity);
shadow.setImageDrawable(mapActivity.getResources().getDrawable(R.drawable.bg_shadow_onmap));
shadow.setImageDrawable(ContextCompat.getDrawable(mapActivity, R.drawable.bg_shadow_onmap));
shadow.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
shadow.setScaleType(ScaleType.FIT_XY);
@ -542,22 +542,24 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
toolbar.getMenu().clear();
toolbar.inflateMenu(R.menu.refresh_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.action_refresh) {
MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry();
registry.resetToDefault();
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
toolbar.inflateMenu(R.menu.refresh_menu);
toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (menuItem.getItemId() == R.id.action_refresh) {
MapWidgetRegistry registry = mapActivity.getMapLayers().getMapWidgetRegistry();
registry.resetToDefault();
MapInfoLayer mil = mapActivity.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity));
}
updateListAdapter(registry.getViewConfigureMenuAdapter(mapActivity));
return false;
}
return false;
}
});
});
}
}
@ -574,12 +576,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
params.gravity = landscape ? Gravity.BOTTOM | Gravity.RIGHT : Gravity.TOP | Gravity.RIGHT;
actionButton.setLayoutParams(params);
actionButton.setScaleType(ScaleType.CENTER);
actionButton.setBackgroundDrawable(mapActivity.getResources().getDrawable(R.drawable.btn_circle_blue));
actionButton.setBackgroundResource(R.drawable.btn_circle_blue);
hideActionButton();
DashboardActionButton myLocationButton = new DashboardActionButton();
myLocationButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_my_location);
myLocationButton.icon = ContextCompat.getDrawable(mapActivity, R.drawable.map_my_location);
myLocationButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -593,7 +595,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
};
DashboardActionButton navigateButton = new DashboardActionButton();
navigateButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_start_navigation);
navigateButton.icon = ContextCompat.getDrawable(mapActivity, R.drawable.map_start_navigation);
navigateButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -603,7 +605,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
};
DashboardActionButton routeButton = new DashboardActionButton();
routeButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_directions);
routeButton.icon = ContextCompat.getDrawable(mapActivity, R.drawable.map_directions);
routeButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -643,7 +645,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
};
DashboardActionButton markersSelectionButton = new DashboardActionButton();
markersSelectionButton.icon = mapActivity.getResources().getDrawable(R.drawable.map_start_navigation);
markersSelectionButton.icon = ContextCompat.getDrawable(mapActivity, R.drawable.map_start_navigation);
markersSelectionButton.onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -862,43 +864,27 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
}
private void applyDayNightMode() {
if (nightMode) {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
listEmptyTextView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark));
}
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_dark));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
listView.setDivider(null);
}
final int backgroundColor;
backgroundColor = ContextCompat.getColor(mapActivity,
nightMode ? R.color.ctx_menu_info_view_bg_dark
: R.color.ctx_menu_info_view_bg_light);
Drawable dividerDrawable = new ColorDrawable(ContextCompat.getColor(mapActivity,
nightMode ? R.color.dashboard_divider_dark : R.color.dashboard_divider_light));
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(backgroundColor);
} else {
if (listBackgroundView != null) {
listBackgroundView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
} else {
listView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
listEmptyTextView.setBackgroundColor(mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light));
}
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION) {
Drawable d = new ColorDrawable(mapActivity.getResources().getColor(R.color.dashboard_divider_light));
listView.setDivider(d);
listView.setDividerHeight(dpToPx(1f));
} else {
listView.setDivider(null);
}
// listView.setBackgroundColor(backgroundColor);
listEmptyTextView.setBackgroundColor(backgroundColor);
}
if (visibleType != DashboardType.WAYPOINTS && visibleType != DashboardType.MAP_MARKERS
&& visibleType != DashboardType.MAP_MARKERS_SELECTION) {
listView.setDivider(dividerDrawable);
listView.setDividerHeight(dpToPx(1f));
} else {
listView.setDivider(null);
}
AndroidUtils.setTextSecondaryColor(mapActivity, listEmptyTextView, nightMode);
/*
listView.setOverscrollFooter(new ColorDrawable(
nightMode ? mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_dark)
: mapActivity.getResources().getColor(R.color.ctx_menu_info_view_bg_light)));
*/
}
private int dpToPx(float dp) {
@ -953,20 +939,20 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else {
if (DashboardType.CONFIGURE_SCREEN == visibleType) {
if (visibleType == DashboardType.CONFIGURE_SCREEN) {
cm = mapActivity.getMapLayers().getMapWidgetRegistry().getViewConfigureMenuAdapter(mapActivity);
} else if (DashboardType.CONFIGURE_MAP == visibleType) {
} else if (visibleType == DashboardType.CONFIGURE_MAP) {
cm = new ConfigureMapMenu().createListAdapter(mapActivity);
} else if (DashboardType.LIST_MENU == visibleType) {
} else if (visibleType == DashboardType.LIST_MENU) {
cm = mapActivity.getMapActions().createMainOptionsMenu();
} else if (DashboardType.ROUTE_PREFERENCES == visibleType) {
} else if (visibleType == DashboardType.ROUTE_PREFERENCES) {
RoutePreferencesMenu routePreferencesMenu = new RoutePreferencesMenu(mapActivity);
ArrayAdapter<LocalRoutingParameter> listAdapter = routePreferencesMenu.getRoutePreferencesDrawerAdapter(nightMode);
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
updateListAdapter(listAdapter, listener);
} else if (DashboardType.UNDERLAY_MAP == visibleType) {
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
} else if (DashboardType.OVERLAY_MAP == visibleType) {
} else if (visibleType == DashboardType.OVERLAY_MAP) {
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
}
if (cm != null) {
@ -1030,7 +1016,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
hideDashboard();
}
} else if (click != null) {
CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
if (btn != null && btn.getVisibility() == View.VISIBLE) {
btn.setChecked(!btn.isChecked());
} else {
@ -1314,10 +1300,12 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
setAlpha(dashboardView.findViewById(R.id.map_part_dashboard), malpha, baseColor);
gradientToolbar.setAlpha((int) ((1 - t) * 255));
setAlpha(dashboardView, (int) (t * 128), 0);
View toolbar = dashboardView.findViewById(R.id.toolbar);
if (t < 1) {
dashboardView.findViewById(R.id.toolbar).setBackgroundDrawable(gradientToolbar);
//noinspection deprecation
toolbar.setBackgroundDrawable(gradientToolbar);
} else {
dashboardView.findViewById(R.id.toolbar).setBackgroundColor(0xff000000 | baseColor);
toolbar.setBackgroundColor(0xff000000 | baseColor);
}
}
}
@ -1593,7 +1581,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} else if (listBackgroundView != null) {
tileBoxHeightPx = 3 * (mFlexibleSpaceImageHeight - mFlexibleBlurSpaceHeight) / 4;
}
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, mFlexibleBlurSpaceHeight * 3/2);
mapView.fitRectToMap(left, right, top, bottom, tileBoxWidthPx, tileBoxHeightPx, mFlexibleBlurSpaceHeight * 3 / 2);
}
}
}

View file

@ -99,9 +99,9 @@ public class DashboardSettingsDialogFragment extends DialogFragment
}
mapActivity.getDashboard().refreshDashboardFragments();
settings.SHOW_DASHBOARD_ON_START.set(
((CompoundButton) showDashboardOnStart.findViewById(R.id.check_item)).isChecked());
((CompoundButton) showDashboardOnStart.findViewById(R.id.toggle_item)).isChecked());
settings.SHOW_DASHBOARD_ON_MAP_SCREEN.set(
((CompoundButton) accessFromMap.findViewById(R.id.check_item)).isChecked());
((CompoundButton) accessFromMap.findViewById(R.id.toggle_item)).isChecked());
mapActivity.getMapLayers().getMapControlsLayer().initDasboardRelatedControls();
}
})
@ -121,7 +121,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment
final TextView subtextView = (TextView) view.findViewById(R.id.subtext);
textView.setText(text);
subtextView.setText(description);
final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.check_item);
final CompoundButton compoundButton = (CompoundButton) view.findViewById(R.id.toggle_item);
compoundButton.setChecked(pref.get());
textView.setTextColor(pref.get() ? textColorPrimary
: textColorSecondary);
@ -247,7 +247,7 @@ public class DashboardSettingsDialogFragment extends DialogFragment
this.dashFragmentAdapter = dashFragmentAdapter;
this.numberOfRowsTextView = (TextView) view.findViewById(R.id.numberOfRowsTextView);
this.textView = (TextView) view.findViewById(R.id.text);
this.compoundButton = (CompoundButton) view.findViewById(R.id.check_item);
this.compoundButton = (CompoundButton) view.findViewById(R.id.toggle_item);
colorBlue = ctx.getResources().getColor(R.color.dashboard_blue);
}

View file

@ -56,7 +56,7 @@ public class OsmandDevelopmentPlugin extends OsmandPlugin {
@Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
if (Version.isDeveloperVersion(mapActivity.getMyApplication())) {
helper.item(R.string.version_settings).iconColor(R.drawable.ic_action_gabout_dark)
helper.item(R.string.version_settings).colorIcon(R.drawable.ic_action_gabout_dark)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -172,20 +172,20 @@ public class ConfigureMapMenu {
adapter.item(R.string.shared_string_show).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
adapter.item(R.string.layer_poi).selected(settings.SELECTED_POI_FILTER_FOR_MAP.get() != null ? 1 : 0)
.iconColor(R.drawable.ic_action_info_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_info_dark).listen(l).reg();
adapter.item(R.string.layer_amenity_label).selected(settings.SHOW_POI_LABEL.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_text_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_text_dark).listen(l).reg();
adapter.item(R.string.shared_string_favorites).selected(settings.SHOW_FAVORITES.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_fav_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_fav_dark).listen(l).reg();
adapter.item(R.string.layer_gpx_layer).selected(
app.getSelectedGpxHelper().isShowingAnyGpxFiles() ? 1 : 0)
.iconColor(R.drawable.ic_action_polygom_dark)
.colorIcon(R.drawable.ic_action_polygom_dark)
.listen(l).reg();
adapter.item(R.string.layer_map).iconColor(R.drawable.ic_world_globe_dark)
adapter.item(R.string.layer_map).colorIcon(R.drawable.ic_world_globe_dark)
.listen(l).reg();
if(TransportRouteHelper.getInstance().routeIsCalculated()){
adapter.item(R.string.layer_transport_route).selected(1)
.iconColor(R.drawable.ic_action_bus_dark).listen(l).reg();
.colorIcon(R.drawable.ic_action_bus_dark).listen(l).reg();
}
OsmandPlugin.registerLayerContextMenu(activity.getMapView(), adapter, activity);

View file

@ -21,7 +21,7 @@ public class RasterMapMenu {
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
final OsmandRasterMapsPlugin.RasterMapType type) {
ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity, false);
adapter.setDefaultLayoutId(R.layout.list_item_basic);
adapter.setDefaultLayoutId(R.layout.list_item_icon_and_menu);
createLayersItems(adapter, mapActivity, type);
return adapter;
}
@ -129,7 +129,7 @@ public class RasterMapMenu {
// android:max="255" in layout is expected
contextMenuAdapter.item(mapTypeStringTransparency)
.layout(R.layout.progress_list_item)
.iconColor(R.drawable.ic_action_opacity)
.colorIcon(R.drawable.ic_action_opacity)
.progress(mapTransparencyPreference.get())
.listen(l)
.listenInteger(integerListener).reg();

View file

@ -675,7 +675,7 @@ public class DistanceCalculatorPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.delete_point).iconColor(R.drawable.ic_action_delete_dark).listen(listener).reg();
adapter.item(R.string.delete_point).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).reg();
}
}
}

View file

@ -399,7 +399,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
LayoutInflater inflater = LayoutInflater.from(ctx);
v = inflater.inflate(R.layout.download_item_list_section, parent, false);
}
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
TextView nameView = ((TextView) v.findViewById(R.id.title));
nameView.setText(section);
v.setOnClickListener(null);
TypedValue typedValue = new TypedValue();

View file

@ -955,7 +955,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
if (group.getSubfolder() != null) {
name.append(" ").append(group.getSubfolder());
}
TextView nameView = ((TextView) v.findViewById(R.id.section_name));
TextView nameView = ((TextView) v.findViewById(R.id.title));
TextView sizeView = ((TextView) v.findViewById(R.id.section_description));
List<LocalIndexInfo> list = data.get(group);
int size = 0;

View file

@ -208,7 +208,7 @@ public class GpxUiHelper {
s = s.replace('_', ' ');
adapter.item(s).selected(multipleChoice ? 0 : -1)
.iconColor(R.drawable.ic_action_polygom_dark).reg();
.colorIcon(R.drawable.ic_action_polygom_dark).reg();
//if there's some selected files - need to mark them as selected
if (selectedGpxList != null) {
@ -302,7 +302,7 @@ public class GpxUiHelper {
// tv.setCompoundDrawablesWithIntrinsicBounds(adapter.getImageId(position, light), 0, 0, 0);
// }
// tv.setCompoundDrawablePadding(padding);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
if (adapter.getSelection(position) == -1) {
ch.setVisibility(View.INVISIBLE);
} else {

View file

@ -271,7 +271,7 @@ public class MapMarkerDialogHelper {
protected View createItemForCategory(final ArrayAdapter<Object> listAdapter, final int type) {
View v = mapActivity.getLayoutInflater().inflate(R.layout.waypoint_header, null);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
v.findViewById(R.id.ProgressBar).setVisibility(View.GONE);
if (type == MARKERS_HISTORY) {

View file

@ -649,7 +649,7 @@ public class WaypointDialogHelper {
final int position, final ArrayAdapter<Object> thisAdapter, boolean nightMode) {
View v;
v = ctx.getLayoutInflater().inflate(R.layout.waypoint_header, null);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.toggle_item);
btn.setVisibility(waypointHelper.isTypeConfigurable(type) ? View.VISIBLE : View.GONE);
btn.setOnCheckedChangeListener(null);
final boolean checked = waypointHelper.isTypeEnabled(type);

View file

@ -352,12 +352,12 @@ public class LiveUpdatesFragment extends BaseOsmAndFragment implements InAppList
LayoutInflater inflater = LayoutInflater.from(ctx);
view = inflater.inflate(R.layout.list_group_title_with_switch, parent, false);
}
TextView nameView = ((TextView) view.findViewById(R.id.section_name));
TextView nameView = ((TextView) view.findViewById(R.id.title));
nameView.setText(group);
view.setOnClickListener(null);
final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.liveUpdatesSwitch);
final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.toggle_item);
View topShadowView = view.findViewById(R.id.bottomShadowView);
if (groupPosition == SHOULD_UPDATE_GROUP_POSITION) {
topShadowView.setVisibility(View.GONE);

View file

@ -62,7 +62,7 @@ public class LiveUpdatesSettingsDialogFragment extends DialogFragment {
final TextView regionNameTextView = (TextView) view.findViewById(R.id.regionNameTextView);
final TextView lastMapChangeTextView = (TextView) view.findViewById(R.id.lastMapChangeTextView);
final TextView lastUpdateTextView = (TextView) view.findViewById(R.id.lastUpdateTextView);
final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.liveUpdatesSwitch);
final SwitchCompat liveUpdatesSwitch = (SwitchCompat) view.findViewById(R.id.toggle_item);
final CheckBox downloadOverWiFiCheckBox = (CheckBox) view.findViewById(R.id.downloadOverWiFiSwitch);
final Spinner updateFrequencySpinner = (Spinner) view.findViewById(R.id.updateFrequencySpinner);
final Spinner updateTimesOfDaySpinner = (Spinner) view.findViewById(R.id.updateTimesOfDaySpinner);

View file

@ -295,19 +295,19 @@ public class RoutePreferencesMenu {
settings.putExtra(SettingsBaseActivity.INTENT_APP_MODE, routingHelper.getAppMode().getStringKey());
mapActivity.startActivity(settings);
} else if (obj instanceof MuteSoundRoutingParameter) {
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
btn.performClick();
} else if (obj instanceof VoiceGuidanceRoutingParameter) {
doSelectVoiceGuidance();
} else if (obj instanceof InterruptMusicRoutingParameter) {
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.check_item);
final CompoundButton btn = (CompoundButton) view.findViewById(R.id.toggle_item);
btn.performClick();
} else if (obj instanceof AvoidRoadsRoutingParameter) {
selectRestrictedRoads();
} else if (view.findViewById(R.id.GPXRouteSpinner) != null) {
showOptionsMenu((TextView) view.findViewById(R.id.GPXRouteSpinner));
} else {
CheckBox ch = (CheckBox) view.findViewById(R.id.check_item);
CheckBox ch = (CheckBox) view.findViewById(R.id.toggle_item);
if (ch != null) {
ch.setChecked(!ch.isChecked());
}
@ -330,7 +330,7 @@ public class RoutePreferencesMenu {
v.findViewById(R.id.select_button).setVisibility(View.GONE);
((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_volume_up, !nightMode));
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.toggle_item);
btn.setVisibility(View.VISIBLE);
btn.setChecked(!routingHelper.getVoiceRouter().isMute());
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -350,7 +350,7 @@ public class RoutePreferencesMenu {
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
((ImageView) v.findViewById(R.id.icon))
.setImageDrawable(app.getIconsCache().getContentIcon(R.drawable.ic_action_road_works_dark, !nightMode));
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
final TextView btn = (TextView) v.findViewById(R.id.select_button);
btn.setTextColor(btn.getLinkTextColors());
btn.setOnClickListener(new View.OnClickListener() {
@ -375,7 +375,7 @@ public class RoutePreferencesMenu {
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.findViewById(R.id.icon).setVisibility(View.GONE);
v.findViewById(R.id.description_text).setVisibility(View.GONE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
final TextView btn = (TextView) v.findViewById(R.id.select_button);
btn.setTextColor(btn.getLinkTextColors());
String voiceProvider = settings.VOICE_PROVIDER.get();
@ -409,7 +409,7 @@ public class RoutePreferencesMenu {
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
v.findViewById(R.id.select_button).setVisibility(View.GONE);
v.findViewById(R.id.icon).setVisibility(View.GONE);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.check_item);
final CompoundButton btn = (CompoundButton) v.findViewById(R.id.toggle_item);
btn.setVisibility(View.VISIBLE);
btn.setChecked(settings.INTERRUPT_MUSIC.get());
btn.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@ -448,7 +448,7 @@ public class RoutePreferencesMenu {
TextView titleView = (TextView) v.findViewById(R.id.title);
titleView.setText(R.string.routing_settings_2);
AndroidUtils.setTextPrimaryColor(mapActivity, titleView, nightMode);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
return v;
}
return inflateRoutingParameter(position);
@ -458,7 +458,7 @@ public class RoutePreferencesMenu {
View v = mapActivity.getLayoutInflater().inflate(R.layout.layers_list_activity_item, null);
AndroidUtils.setListItemBackground(mapActivity, v, nightMode);
final TextView tv = (TextView) v.findViewById(R.id.title);
final CheckBox ch = ((CheckBox) v.findViewById(R.id.check_item));
final CheckBox ch = ((CheckBox) v.findViewById(R.id.toggle_item));
final LocalRoutingParameter rp = getItem(position);
AndroidUtils.setTextPrimaryColor(mapActivity, tv, nightMode);
tv.setText(rp.getText(mapActivity));

View file

@ -140,12 +140,12 @@ public class OsmandMonitoringPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.context_menu_item_add_waypoint).iconColor(R.drawable.ic_action_gnew_label_dark)
adapter.item(R.string.context_menu_item_add_waypoint).colorIcon(R.drawable.ic_action_gnew_label_dark)
.listen(listener).reg();
if (selectedObj instanceof WptPt) {
WptPt pt = (WptPt) selectedObj;
if (app.getSelectedGpxHelper().getSelectedGPXFile(pt) != null) {
adapter.item(R.string.context_menu_item_edit_waypoint).iconColor(R.drawable.ic_action_edit_dark)
adapter.item(R.string.context_menu_item_edit_waypoint).colorIcon(R.drawable.ic_action_edit_dark)
.listen(listener).reg();
}
}

View file

@ -276,7 +276,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
v.findViewById(R.id.divider).setVisibility(View.GONE);
v.findViewById(R.id.options).setVisibility(View.GONE);
v.findViewById(R.id.stop).setVisibility(View.VISIBLE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
}
@Override
@ -801,7 +801,7 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
options.setVisibility(View.VISIBLE);
}
final CompoundButton checkItem = (CompoundButton) v.findViewById(R.id.check_item);
final CompoundButton checkItem = (CompoundButton) v.findViewById(R.id.toggle_item);
if (isSelectedGroup(groupPosition)) {
checkItem.setVisibility(View.VISIBLE);
v.findViewById(R.id.options).setVisibility(View.GONE);
@ -1356,6 +1356,6 @@ public class AvailableGPXFragment extends OsmandExpandableListFragment {
TextView descr = ((TextView) v.findViewById(R.id.description));
descr.setVisibility(View.GONE);
v.findViewById(R.id.check_item).setVisibility(View.GONE);
v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
}
}

View file

@ -216,15 +216,15 @@ public class OsmEditingPlugin extends OsmandPlugin {
isEditable = !amenity.getType().isWiki() && !poiType.isNotEditableOsm();
}
if (isEditable) {
adapter.item(R.string.poi_context_menu_modify).iconColor(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
adapter.item(R.string.poi_context_menu_delete).iconColor(R.drawable.ic_action_delete_dark).listen(listener).position(2).reg();
adapter.item(R.string.poi_context_menu_modify).colorIcon(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
adapter.item(R.string.poi_context_menu_delete).colorIcon(R.drawable.ic_action_delete_dark).listen(listener).position(2).reg();
} else if (selectedObj instanceof OpenstreetmapPoint && ((OpenstreetmapPoint) selectedObj).getAction() != Action.DELETE) {
adapter.item(R.string.poi_context_menu_modify_osm_change)
.iconColor(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
.colorIcon(R.drawable.ic_action_edit_dark).listen(listener).position(1).reg();
} else {
adapter.item(R.string.context_menu_item_create_poi).iconColor(R.drawable.ic_action_plus_dark).listen(listener).position(-1).reg();
adapter.item(R.string.context_menu_item_create_poi).colorIcon(R.drawable.ic_action_plus_dark).listen(listener).position(-1).reg();
}
adapter.item(R.string.context_menu_item_open_note).iconColor(R.drawable.ic_action_bug_dark).listen(listener).reg();
adapter.item(R.string.context_menu_item_open_note).colorIcon(R.drawable.ic_action_bug_dark).listen(listener).reg();
}
@Override
@ -240,7 +240,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
@Override
public void registerLayerContextMenuActions(OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
adapter.item(R.string.layer_osm_bugs).selected(settings.SHOW_OSM_BUGS.get() ? 1 : 0)
.iconColor(R.drawable.ic_action_bug_dark).listen(new OnContextMenuClick() {
.colorIcon(R.drawable.ic_action_bug_dark).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
@ -263,7 +263,7 @@ public class OsmEditingPlugin extends OsmandPlugin {
public void contextMenuFragment(final Activity la, final Fragment fragment, final Object info, ContextMenuAdapter adapter) {
if (fragment instanceof AvailableGPXFragment) {
adapter.item(R.string.local_index_mi_upload_gpx)
.iconColor(R.drawable.ic_action_export)
.colorIcon(R.drawable.ic_action_export)
.listen(new OnContextMenuClick() {
@Override

View file

@ -148,7 +148,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
}
private void setupHader(final View header) {
trackr = (CompoundButton) header.findViewById(R.id.card_content).findViewById(R.id.check_item);
trackr = (CompoundButton) header.findViewById(R.id.card_content).findViewById(R.id.toggle_item);
ImageButton share = (ImageButton) header.findViewById(R.id.share);
IconsCache cache = getMyApplication().getIconsCache();
@ -170,7 +170,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
}
View cardContent = header.findViewById(R.id.card_content);
View enableOsmo = header.findViewById(R.id.header_layout).findViewById(R.id.check_item);
View enableOsmo = header.findViewById(R.id.header_layout).findViewById(R.id.toggle_item);
View manage = header.findViewById(R.id.manage);
if (plugin != null && plugin.getService().isEnabled() ) {
cardContent.setVisibility(View.VISIBLE);
@ -184,7 +184,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
return;
}
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.check_item);
CompoundButton trackr = (CompoundButton) header.findViewById(R.id.toggle_item);
if (plugin != null && plugin.getTracker() != null) {
trackr.setChecked(plugin.getTracker().isEnabledTracker());
}
@ -286,7 +286,7 @@ public class DashOsMoFragment extends DashLocationFragment implements OsMoGroups
loc.getLongitude()) : null);
distances.add(dv);
final CompoundButton enableDevice = (CompoundButton) v.findViewById(R.id.check_item);
final CompoundButton enableDevice = (CompoundButton) v.findViewById(R.id.toggle_item);
enableDevice.setVisibility(View.GONE);
ImageView icon = (ImageView) v.findViewById(R.id.icon);
if (device.isEnabled()) {

View file

@ -544,7 +544,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
} else if (item.getItemId() == SHARE_ID) {
shareOsMoGroup(group.getVisibleName(app), group.getGroupId());
} else if (item.getItemId() == ON_OFF_ACTION_ID) {
CompoundButton bt = ((CompoundButton) MenuItemCompat.getActionView(item).findViewById(R.id.check_item));
CompoundButton bt = ((CompoundButton) MenuItemCompat.getActionView(item).findViewById(R.id.toggle_item));
onOffAction(bt);
}
return true;
@ -1228,7 +1228,7 @@ public class OsMoGroupsActivity extends OsmandExpandableListActivity implements
}
});
}
CompoundButton ci = (CompoundButton) row.findViewById(R.id.check_item);
CompoundButton ci = (CompoundButton) row.findViewById(R.id.toggle_item);
if (model.isMainGroup()) {
ci.setVisibility(View.GONE);
} else {

View file

@ -274,7 +274,7 @@ public class OsMoPlugin extends OsmandPlugin implements OsMoReactor {
@Override
public void registerOptionsMenuItems(final MapActivity mapActivity, ContextMenuAdapter helper) {
helper.item(R.string.osmo_groups).iconColor(R.drawable.ic_osmo_dark).position(6)
helper.item(R.string.osmo_groups).colorIcon(R.drawable.ic_osmo_dark).position(6)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {

View file

@ -227,7 +227,7 @@ public class ParkingPositionPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.context_menu_item_add_parking_point)
.iconColor( R.drawable.ic_action_parking_dark).listen(addListener).reg();
.colorIcon(R.drawable.ic_action_parking_dark).listen(addListener).reg();
}

View file

@ -255,11 +255,11 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
String overlayMapDescr = settings.MAP_OVERLAY.get();
overlayMapDescr = overlayMapDescr != null ? overlayMapDescr : mapActivity.getString(R.string.shared_string_none);
adapter.item(R.string.layer_overlay).layout(R.layout.drawer_list_doubleitem).description(overlayMapDescr)
.iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
.colorIcon(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
String underlayMapDescr = settings.MAP_UNDERLAY.get();
underlayMapDescr = underlayMapDescr != null ? underlayMapDescr : mapActivity.getString(R.string.shared_string_none);
adapter.item(R.string.layer_underlay).layout(R.layout.drawer_list_doubleitem).description(underlayMapDescr)
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
.colorIcon(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
}
@ -280,9 +280,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
return true;
}
};
adapter.item(R.string.context_menu_item_update_map).iconColor(R.drawable.ic_action_refresh_dark)
adapter.item(R.string.context_menu_item_update_map).colorIcon(R.drawable.ic_action_refresh_dark)
.listen(listener).reg();
adapter.item(R.string.shared_string_download_map).iconColor(R.drawable.ic_action_import)
adapter.item(R.string.shared_string_download_map).colorIcon(R.drawable.ic_action_import)
.listen(listener).reg();
}
}

View file

@ -2,8 +2,8 @@ package net.osmand.plus.routepointsnavigation;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.os.AsyncTask;
import android.widget.ArrayAdapter;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.RotatedTileBox;
@ -17,9 +17,6 @@ import net.osmand.plus.views.OsmandMapTileView;
import java.util.List;
/**
* Created by Barsik on 20.06.2014.
*/
public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider {
private final RoutePointsPlugin plugin;
@ -112,10 +109,10 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
};
if (plugin.getCurrentRoute().getPointStatus(point)){
adapter.item(R.string.mark_as_not_visited).iconColor(
adapter.item(R.string.mark_as_not_visited).colorIcon(
R.drawable.ic_action_gremove_dark).listen(listener).reg();
} else {
adapter.item(R.string.mark_as_visited).iconColor(
adapter.item(R.string.mark_as_visited).colorIcon(
R.drawable.ic_action_done).listen(listener).reg();
}
@ -123,11 +120,11 @@ public class RoutePointsLayer extends OsmandMapLayer implements ContextMenuLaye
if (routePoint != null) {
if (routePoint.isNextNavigate) {
adapter.item(R.string.navigate_to_next)
.iconColor(R.drawable.ic_action_gnext_dark).listen(listener)
.colorIcon(R.drawable.ic_action_gnext_dark).listen(listener)
.reg();
} else {
adapter.item(R.string.mark_as_current)
.iconColor(R.drawable.ic_action_signpost_dark)
.colorIcon(R.drawable.ic_action_signpost_dark)
.listen(listener).reg();
}
}

View file

@ -115,7 +115,7 @@ public class SRTMPlugin extends OsmandPlugin {
}
};
adapter.item(R.string.layer_hillshade).selected(HILLSHADE.get()? 1 : 0)
.iconColor( R.drawable.ic_action_hillshade_dark).listen(listener).position(13).layout(R.layout.drawer_list_item).reg();
.colorIcon(R.drawable.ic_action_hillshade_dark).listen(listener).position(13).layout(R.layout.drawer_list_item).reg();
}
@Override

View file

@ -143,7 +143,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
}
};
adapter.item(R.string.shared_string_show_description)
.iconColor(R.drawable.ic_action_note_dark).listen(listener)
.colorIcon(R.drawable.ic_action_note_dark).listen(listener)
.reg();
}
}

View file

@ -176,7 +176,7 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements ContextMenuL
}
};
adapter.item(R.string.avoid_road).iconColor(
adapter.item(R.string.avoid_road).colorIcon(
R.drawable.ic_action_road_works_dark).listen(listener).reg();
}
}

View file

@ -2,6 +2,8 @@ package net.osmand.plus.views.mapwidgets;
import android.content.Context;
import android.content.DialogInterface;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
@ -28,30 +30,30 @@ import java.util.Set;
import java.util.TreeSet;
public class MapWidgetRegistry {
private Set<MapWidgetRegInfo> left = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
private Set<MapWidgetRegInfo> right = new TreeSet<MapWidgetRegistry.MapWidgetRegInfo>();
private Map<ApplicationMode, Set<String>> visibleElementsFromSettings = new LinkedHashMap<ApplicationMode, Set<String>>();
private final OsmandSettings settings;
public MapWidgetRegistry(OsmandSettings settings) {
this.settings = settings;
for(ApplicationMode ms : ApplicationMode.values(settings) ) {
for (ApplicationMode ms : ApplicationMode.values(settings)) {
String mpf = settings.MAP_INFO_CONTROLS.getModeValue(ms);
if(mpf.equals("")) {
if (mpf.equals("")) {
visibleElementsFromSettings.put(ms, null);
} else {
LinkedHashSet<String> set = new LinkedHashSet<String>();
visibleElementsFromSettings.put(ms, set);
Collections.addAll(set, mpf.split(";"));
Collections.addAll(set, mpf.split(";"));
}
}
}
public void populateStackControl(LinearLayout stack,
ApplicationMode mode, boolean left, boolean expanded) {
public void populateStackControl(LinearLayout stack,
ApplicationMode mode, boolean left, boolean expanded) {
Set<MapWidgetRegInfo> s = left ? this.left : this.right;
for (MapWidgetRegInfo r : s) {
if (r.visible(mode) || r.widget.isExplicitlyVisible()) {
@ -60,14 +62,14 @@ public class MapWidgetRegistry {
}
if (expanded) {
for (MapWidgetRegInfo r : s) {
if (r.visibleCollapsed(mode) &&
if (r.visibleCollapsed(mode) &&
!r.widget.isExplicitlyVisible()) {
stack.addView(r.widget.getView());
}
}
}
}
public boolean hasCollapsibles(ApplicationMode mode) {
for (MapWidgetRegInfo r : left) {
if (r.visibleCollapsed(mode)) {
@ -81,8 +83,8 @@ public class MapWidgetRegistry {
}
return false;
}
public void updateInfo(ApplicationMode mode, DrawSettings drawSettings, boolean expanded) {
update(mode, drawSettings, expanded, left);
update(mode, drawSettings, expanded, right);
@ -95,8 +97,8 @@ public class MapWidgetRegistry {
}
}
}
public void removeSideWidgetInternal(TextInfoWidget widget) {
Iterator<MapWidgetRegInfo> it = left.iterator();
while (it.hasNext()) {
@ -111,24 +113,26 @@ public class MapWidgetRegistry {
}
}
}
public <T extends TextInfoWidget> T getSideWidget(Class<T> cl) {
for(MapWidgetRegInfo ri : left) {
if(cl.isInstance(ri)) {
for (MapWidgetRegInfo ri : left) {
if (cl.isInstance(ri)) {
return (T) ri.widget;
}
}
for(MapWidgetRegInfo ri : right) {
if(cl.isInstance(ri)) {
for (MapWidgetRegInfo ri : right) {
if (cl.isInstance(ri)) {
return (T) ri.widget;
}
}
return null;
}
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget, int drawableMenu,
int messageId, String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
public MapWidgetRegInfo registerSideWidgetInternal(TextInfoWidget widget,
@DrawableRes int drawableMenu,
@StringRes int messageId,
String key, boolean left, int priorityOrder) {
MapWidgetRegInfo ii = new MapWidgetRegInfo(key, widget, drawableMenu,
messageId, priorityOrder, left);
for (ApplicationMode ms : ApplicationMode.values(settings)) {
boolean collapse = ms.isWidgetCollapsible(key);
@ -155,14 +159,14 @@ public class MapWidgetRegistry {
if (widget != null) {
widget.setContentTitle(messageId);
}
if(left) {
if (left) {
this.left.add(ii);
} else {
this.right.add(ii);
}
return ii;
}
private void restoreModes(Set<String> set, Set<MapWidgetRegInfo> mi, ApplicationMode mode) {
for (MapWidgetRegInfo m : mi) {
if (m.visibleModes.contains(mode)) {
@ -174,7 +178,7 @@ public class MapWidgetRegistry {
}
}
}
public void changeVisibility(MapWidgetRegInfo m) {
ApplicationMode mode = settings.APPLICATION_MODE.get();
boolean visible = m.visible(mode);
@ -238,9 +242,9 @@ public class MapWidgetRegistry {
}
settings.MAP_INFO_CONTROLS.set(bs.toString());
}
private void resetDefault(ApplicationMode mode, Set<MapWidgetRegInfo> set ){
private void resetDefault(ApplicationMode mode, Set<MapWidgetRegInfo> set) {
for (MapWidgetRegInfo ri : set) {
ri.visibleCollapsible.remove(mode);
ri.visibleModes.remove(mode);
@ -253,7 +257,7 @@ public class MapWidgetRegistry {
}
}
}
public void resetToDefault() {
ApplicationMode appMode = settings.getApplicationMode();
resetDefault(appMode, left);
@ -262,7 +266,7 @@ public class MapWidgetRegistry {
this.visibleElementsFromSettings.put(appMode, null);
settings.MAP_INFO_CONTROLS.set("");
}
private void resetDefaultAppearance(ApplicationMode appMode) {
// settings.SHOW_RULER.resetToDefault();
settings.SHOW_DESTINATION_ARROW.resetToDefault();
@ -271,13 +275,13 @@ public class MapWidgetRegistry {
settings.CENTER_POSITION_ON_MAP.resetToDefault();
settings.MAP_MARKERS_MODE.resetToDefault();
}
public void addControlsAppearance(final MapActivity map, final ContextMenuAdapter cm, ApplicationMode mode) {
// addControlId(mil, cm, R.string.map_widget_show_ruler, settings.SHOW_RULER);
addControlId(map, cm, R.string.map_widget_show_destination_arrow, settings.SHOW_DESTINATION_ARROW);
addControlId(map, cm, R.string.map_widget_transparent, settings.TRANSPARENT_MAP_THEME);
addControlId(map, cm, R.string.always_center_position_on_map, settings.CENTER_POSITION_ON_MAP);
if(mode != ApplicationMode.DEFAULT) {
if (mode != ApplicationMode.DEFAULT) {
addControlId(map, cm, R.string.map_widget_top_text, settings.SHOW_STREET_NAME);
}
if (settings.USE_MAP_MARKERS.get()) {
@ -314,18 +318,18 @@ public class MapWidgetRegistry {
bld.show();
return false;
}
}).layout(R.layout.drawer_list_doubleitem).reg();
}).layout(R.layout.list_item_text_button).reg();
}
}
private void addControlId(final MapActivity map, ContextMenuAdapter cm, int stringId, OsmandPreference<Boolean> pref) {
cm.item(stringId).selected( pref.get() ? 1 : 0)
cm.item(stringId).selected(pref.get() ? 1 : 0)
// .icons(r.drawableDark, r.drawableLight)
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
.listen(new ApearanceOnContextMenuClick(pref, map)).reg();
}
class ApearanceOnContextMenuClick implements OnContextMenuClick {
private MapActivity map;
private OsmandPreference<Boolean> pref;
@ -333,49 +337,53 @@ public class MapWidgetRegistry {
this.pref = pref;
this.map = map;
}
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
pref.set(!pref.get());
map.updateApplicationModeSettings();
a.notifyDataSetChanged();;
a.notifyDataSetChanged();
;
return false;
}
};
}
public static boolean distChanged(int oldDist, int dist){
if(oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist)/oldDist) < 0.01){
;
public static boolean distChanged(int oldDist, int dist) {
if (oldDist != 0 && oldDist - dist < 100 && Math.abs(((float) dist - oldDist) / oldDist) < 0.01) {
return false;
}
return true;
}
public void addControls(MapActivity map, ContextMenuAdapter cm, ApplicationMode mode) {
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
cm.item(R.string.map_widget_right).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
addControls(map, cm, right, mode);
if(mode != ApplicationMode.DEFAULT) {
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
if (mode != ApplicationMode.DEFAULT) {
cm.item(R.string.map_widget_left).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
addControls(map, cm, left, mode);
}
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.drawer_list_sub_header).reg();
addControlsAppearance(map, cm, mode);
cm.item(R.string.map_widget_appearance_rem).setCategory(true).layout(R.layout.list_group_title_with_switch).reg();
addControlsAppearance(map, cm, mode);
}
public String getText(Context ctx, final ApplicationMode mode, final MapWidgetRegInfo r) {
return (r.visibleCollapsed(mode)? " + " : " ") + ctx.getString(r.messageId);
return (r.visibleCollapsed(mode) ? " + " : " ") + ctx.getString(r.messageId);
}
public Set<MapWidgetRegInfo> getRight() {
return right;
}
public Set<MapWidgetRegInfo> getLeft() {
return left;
}
private void addControls(final MapActivity map, final ContextMenuAdapter adapter, Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
private void addControls(final MapActivity map, final ContextMenuAdapter adapter,
Set<MapWidgetRegInfo> top, final ApplicationMode mode) {
for (final MapWidgetRegInfo r : top) {
if (mode == ApplicationMode.DEFAULT) {
if ("intermediate_distance".equals(r.key) || "distance".equals(r.key) || "time".equals(r.key)) {
@ -385,33 +393,35 @@ public class MapWidgetRegistry {
if ("map_marker_1st".equals(r.key) || "map_marker_2nd".equals(r.key)) {
continue;
}
adapter.item(r.messageId).selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0)
.iconColor(r.drawableMenu).listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
changeVisibility(r);
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
a.notifyDataSetChanged();
return false;
}
}).reg();
adapter.item(r.messageId)
.selected(r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0)
.colorIcon(r.drawableMenu)
.secondaryIconColor(R.drawable.ic_action_additional_option)
.listen(new OnContextMenuClick() {
@Override
public boolean onContextMenuClick(ArrayAdapter<?> a, int itemId, int pos, boolean isChecked) {
changeVisibility(r);
MapInfoLayer mil = map.getMapLayers().getMapInfoLayer();
if (mil != null) {
mil.recreateControls();
}
adapter.setItemName(pos, getText(mil.getMapActivity(), mode, r));
adapter.setSelection(pos, r.visibleCollapsed(mode) || r.visible(mode) ? 1 : 0);
a.notifyDataSetChanged();
return false;
}
})
.reg();
adapter.setItemName(adapter.length() - 1, getText(map, mode, r));
}
}
public static class MapWidgetRegInfo implements Comparable<MapWidgetRegInfo> {
public static class MapWidgetRegInfo implements Comparable<MapWidgetRegInfo> {
public final TextInfoWidget widget;
@DrawableRes
public final int drawableMenu;
@StringRes
public final int messageId;
public final String key;
public final boolean left;
@ -419,9 +429,9 @@ public class MapWidgetRegistry {
private final Set<ApplicationMode> visibleCollapsible = new LinkedHashSet<ApplicationMode>();
private final Set<ApplicationMode> visibleModes = new LinkedHashSet<ApplicationMode>();
private Runnable stateChangeListener = null;
public MapWidgetRegInfo(String key, TextInfoWidget widget, int drawableMenu,
int messageId, int priorityOrder, boolean left) {
public MapWidgetRegInfo(String key, TextInfoWidget widget, @DrawableRes int drawableMenu,
@StringRes int messageId, int priorityOrder, boolean left) {
this.key = key;
this.widget = widget;
this.drawableMenu = drawableMenu;
@ -429,29 +439,30 @@ public class MapWidgetRegistry {
this.priorityOrder = priorityOrder;
this.left = left;
}
public boolean visibleCollapsed(ApplicationMode mode){
public boolean visibleCollapsed(ApplicationMode mode) {
return visibleCollapsible.contains(mode);
}
public boolean visible(ApplicationMode mode){
public boolean visible(ApplicationMode mode) {
return visibleModes.contains(mode);
}
public MapWidgetRegInfo required(ApplicationMode... modes){
Collections.addAll(visibleModes, modes);
public MapWidgetRegInfo required(ApplicationMode... modes) {
Collections.addAll(visibleModes, modes);
return this;
}
public void setStateChangeListener(Runnable stateChangeListener) {
this.stateChangeListener = stateChangeListener;
}
@Override
public int hashCode() {
return messageId;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
@ -465,18 +476,19 @@ public class MapWidgetRegistry {
return false;
return true;
}
@Override
public int compareTo(MapWidgetRegInfo another) {
if (messageId == another.messageId) {
return 0;
}
if(priorityOrder == another.priorityOrder) {
if (priorityOrder == another.priorityOrder) {
return messageId - another.messageId;
}
return priorityOrder - another.priorityOrder;
}
}
public ContextMenuAdapter getViewConfigureMenuAdapter(final MapActivity map) {
final ContextMenuAdapter cm = new ContextMenuAdapter(map);
cm.setDefaultLayoutId(R.layout.list_item_icon_and_menu);