Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
3fc0f4dc27
5 changed files with 137 additions and 67 deletions
19
OsmAnd/res/layout/drawer_divider.xml
Normal file
19
OsmAnd/res/layout/drawer_divider.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="bottom"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<View
|
||||
android:id="@+id/divider"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="?attr/divider_color"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -21,6 +21,7 @@ import android.widget.ProgressBar;
|
|||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.plus.activities.HelpActivity;
|
||||
import net.osmand.plus.activities.actions.AppModeDialog;
|
||||
|
@ -138,6 +139,9 @@ public class ContextMenuAdapter {
|
|||
convertView = View.inflate(new ContextThemeWrapper(getContext(), themeRes), layoutId, null);
|
||||
convertView.setTag(layoutId);
|
||||
}
|
||||
if (item.getMinHeight() > 0) {
|
||||
convertView.setMinimumHeight(item.getMinHeight());
|
||||
}
|
||||
if (layoutId == R.layout.help_to_improve_item) {
|
||||
TextView feedbackButton = (TextView) convertView.findViewById(R.id.feedbackButton);
|
||||
Drawable pollIcon = app.getIconsCache().getThemedIcon(R.drawable.ic_action_big_poll);
|
||||
|
@ -171,18 +175,23 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
|
||||
TextView tv = (TextView) convertView.findViewById(R.id.title);
|
||||
tv.setText(item.getTitle());
|
||||
if (tv != null) {
|
||||
tv.setText(item.getTitle());
|
||||
}
|
||||
|
||||
if (this.layoutId == R.layout.simple_list_menu_item) {
|
||||
@ColorRes
|
||||
int color = lightTheme ? R.color.icon_color : R.color.dashboard_subheader_text_dark;
|
||||
Drawable drawable = mIconsCache.getIcon(item.getIcon(), color);
|
||||
float density = getContext().getResources().getDisplayMetrics().density;
|
||||
int paddingInPixels = (int) (24 * density);
|
||||
int drawableSizeInPixels = (int) (24 * density); // 32
|
||||
drawable.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels);
|
||||
tv.setCompoundDrawables(drawable, null, null, null);
|
||||
tv.setCompoundDrawablePadding(paddingInPixels);
|
||||
Drawable drawable = item.getIcon() != ContextMenuItem.INVALID_ID
|
||||
? mIconsCache.getIcon(item.getIcon(), color) : null;
|
||||
if (drawable != null && tv != null) {
|
||||
float density = getContext().getResources().getDisplayMetrics().density;
|
||||
int paddingInPixels = (int) (24 * density);
|
||||
int drawableSizeInPixels = (int) (24 * density); // 32
|
||||
drawable.setBounds(0, 0, drawableSizeInPixels, drawableSizeInPixels);
|
||||
tv.setCompoundDrawables(drawable, null, null, null);
|
||||
tv.setCompoundDrawablePadding(paddingInPixels);
|
||||
}
|
||||
} else {
|
||||
if (item.getIcon() != ContextMenuItem.INVALID_ID) {
|
||||
int colorRes = item.getColorRes();
|
||||
|
|
|
@ -33,6 +33,7 @@ public class ContextMenuItem {
|
|||
private final ContextMenuAdapter.ItemClickListener itemClickListener;
|
||||
private final ContextMenuAdapter.OnIntegerValueChangedListener integerListener;
|
||||
private final boolean hideDivider;
|
||||
private final int minHeight;
|
||||
|
||||
private ContextMenuItem(@StringRes int titleId,
|
||||
String title,
|
||||
|
@ -48,7 +49,8 @@ public class ContextMenuItem {
|
|||
String description,
|
||||
ContextMenuAdapter.ItemClickListener itemClickListener,
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener,
|
||||
boolean hideDivider) {
|
||||
boolean hideDivider,
|
||||
int minHeight) {
|
||||
this.titleId = titleId;
|
||||
this.title = title;
|
||||
this.mIcon = icon;
|
||||
|
@ -65,6 +67,7 @@ public class ContextMenuItem {
|
|||
this.itemClickListener = itemClickListener;
|
||||
this.integerListener = integerListener;
|
||||
this.hideDivider = hideDivider;
|
||||
this.minHeight = minHeight;
|
||||
}
|
||||
|
||||
@StringRes
|
||||
|
@ -178,6 +181,10 @@ public class ContextMenuItem {
|
|||
this.description = description;
|
||||
}
|
||||
|
||||
public int getMinHeight() {
|
||||
return minHeight;
|
||||
}
|
||||
|
||||
public static ItemBuilder createBuilder(String title) {
|
||||
return new ItemBuilder().setTitle(title);
|
||||
}
|
||||
|
@ -204,6 +211,7 @@ public class ContextMenuItem {
|
|||
private ContextMenuAdapter.OnIntegerValueChangedListener mIntegerListener = null;
|
||||
private boolean mSkipPaintingWithoutColor;
|
||||
private boolean mHideDivider;
|
||||
private int mMinHeight;
|
||||
|
||||
public ItemBuilder setTitleId(@StringRes int titleId, @Nullable Context context) {
|
||||
this.mTitleId = titleId;
|
||||
|
@ -289,10 +297,15 @@ public class ContextMenuItem {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder setMinHeight(int minHeight) {
|
||||
this.mMinHeight = minHeight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ContextMenuItem createItem() {
|
||||
return new ContextMenuItem(mTitleId, mTitle, mIcon, mColorRes, mSecondaryIcon,
|
||||
mSelected, mProgress, mLayout, mLoading, mIsCategory, mSkipPaintingWithoutColor,
|
||||
mPosition, mDescription, mItemClickListener, mIntegerListener, mHideDivider);
|
||||
mPosition, mDescription, mItemClickListener, mIntegerListener, mHideDivider, mMinHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.ListView;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -30,6 +31,7 @@ import net.osmand.plus.ApplicationMode;
|
|||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuAdapter.ItemClickListener;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
import net.osmand.plus.ContextMenuItem.ItemBuilder;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
|
@ -269,7 +271,7 @@ 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() : iadapter;
|
||||
ContextMenuItem.ItemBuilder itemBuilder = new ContextMenuItem.ItemBuilder();
|
||||
ItemBuilder itemBuilder = new ItemBuilder();
|
||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_search, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_search_dark).createItem());
|
||||
adapter.addItem(itemBuilder.setTitleId(R.string.context_menu_item_directions_from, mapActivity)
|
||||
|
@ -567,10 +569,11 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public ContextMenuAdapter createMainOptionsMenu() {
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
int viewHeight = mapView.getViewHeight();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter();
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.home, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.home, mapActivity)
|
||||
.setIcon(R.drawable.map_dashboard)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -582,7 +585,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
if (settings.USE_MAP_MARKERS.get()) {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.map_markers, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_flag_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -593,7 +596,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
} else {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.waypoints, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_intermediate)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -604,20 +607,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
}
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_fav_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
mapControlsLayer.doRoute(false);
|
||||
}
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
// Default actions (Layers, Configure Map screen, Settings, Search, Favorites)
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.search_button, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_search_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -636,53 +640,19 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_my_places, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_fav_dark)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
mapControlsLayer.doRoute(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_point_options, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_marker_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
String d = getString(R.string.index_settings);
|
||||
if (app.getDownloadThread().getIndexes().isDownloadedFromInternet) {
|
||||
List<IndexItem> updt = app.getDownloadThread().getIndexes().getItemsToUpdate();
|
||||
|
@ -690,7 +660,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
d += " (" + updt.size() + ")";
|
||||
}
|
||||
}
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.index_settings, null)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.index_settings, null)
|
||||
.setTitle(d).setIcon(R.drawable.ic_type_archive)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -704,7 +674,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
|
||||
if (Version.isGooglePlayEnabled(app) || Version.isDeveloperVersion(app)) {
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.osm_live, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_osm_live)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -717,7 +687,20 @@ public class MapActivityActions implements DialogProvider {
|
|||
}).createItem());
|
||||
}
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
/*
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.show_point_options, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_marker_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getMapLayers().getContextMenuLayer().showContextMenu(mapView.getLatitude(), mapView.getLongitude(), true);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
*/
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.prefs_plugins, mapActivity)
|
||||
.setIcon(R.drawable.ic_extension_dark)
|
||||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
|
@ -730,8 +713,18 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.layer_map_appearance, mapActivity)
|
||||
.setIcon(R.drawable.ic_configure_screen_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_settings, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_settings)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -743,7 +736,21 @@ public class MapActivityActions implements DialogProvider {
|
|||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
|
||||
|
||||
/*
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
*/
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.shared_string_help, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_help)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
|
@ -757,6 +764,20 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
//////////// Others
|
||||
OsmandPlugin.registerOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
|
||||
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
|
||||
if (viewHeight > 0) {
|
||||
int listItemHeight = app.getResources().getDimensionPixelSize(R.dimen.list_item_height);
|
||||
int dividerHeight = viewHeight - optionsMenuHelper.length() * listItemHeight;
|
||||
if (dividerHeight > 0) {
|
||||
divider.setMinHeight(dividerHeight);
|
||||
} else if (dividerHeight < 0) {
|
||||
divider.setMinHeight(AndroidUtils.dpToPx(app, 16f));
|
||||
}
|
||||
}
|
||||
divider.setPosition(7);
|
||||
optionsMenuHelper.addItem(divider.createItem());
|
||||
|
||||
getMyApplication().getAppCustomization().prepareOptionsMenu(mapActivity, optionsMenuHelper);
|
||||
return optionsMenuHelper;
|
||||
}
|
||||
|
|
|
@ -287,6 +287,14 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
return null;
|
||||
}
|
||||
|
||||
public int getViewHeight() {
|
||||
if (view != null) {
|
||||
return view.getHeight();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public OsmandApplication getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue