Changing transparency in new menu.
This commit is contained in:
parent
d75f65d0e7
commit
44f9593edb
8 changed files with 205 additions and 163 deletions
|
@ -62,29 +62,6 @@
|
|||
android:textSize="@dimen/map_button_text_size"/>
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/map_transparency_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|center"
|
||||
android:layout_marginBottom="@dimen/map_button_size"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<SeekBar
|
||||
android:id="@+id/map_transparency_seekbar"
|
||||
android:layout_width="@dimen/map_trans_seek_size"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/map_transparency_hide"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:background="@drawable/btn_circle_transparent"
|
||||
android:src="@drawable/headliner_close"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -22,10 +22,13 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:src="@drawable/ic_action_opacity"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
<SeekBar
|
||||
android:id="@+id/seekbar"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:max="255"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.CompoundButton;
|
|||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
|
@ -37,6 +38,10 @@ public class ContextMenuAdapter {
|
|||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked);
|
||||
}
|
||||
|
||||
public interface OnIntegerValueChangedListener {
|
||||
public boolean onIntegerValueChangedListener(int newValue);
|
||||
}
|
||||
|
||||
public static abstract class OnRowItemClick implements OnContextMenuClick {
|
||||
|
||||
public OnRowItemClick() {
|
||||
|
@ -73,8 +78,10 @@ public class ContextMenuAdapter {
|
|||
final TIntArrayList items = new TIntArrayList();
|
||||
final TIntArrayList isCategory = new TIntArrayList();
|
||||
final ArrayList<String> itemNames = new ArrayList<String>();
|
||||
final ArrayList<OnContextMenuClick> checkListeners = new ArrayList<ContextMenuAdapter.OnContextMenuClick>();
|
||||
final ArrayList<OnContextMenuClick> checkListeners = new ArrayList<>();
|
||||
final ArrayList<OnIntegerValueChangedListener> integerListeners = new ArrayList<>();
|
||||
final TIntArrayList selectedList = new TIntArrayList();
|
||||
final TIntArrayList progressList = new TIntArrayList();
|
||||
final TIntArrayList loadingList = new TIntArrayList();
|
||||
final TIntArrayList layoutIds = new TIntArrayList();
|
||||
final TIntArrayList iconList = new TIntArrayList();
|
||||
|
@ -114,6 +121,10 @@ public class ContextMenuAdapter {
|
|||
return checkListeners.get(i);
|
||||
}
|
||||
|
||||
public OnIntegerValueChangedListener getIntegerLister(int i) {
|
||||
return integerListeners.get(i);
|
||||
}
|
||||
|
||||
public String getItemName(int pos) {
|
||||
return itemNames.get(pos);
|
||||
}
|
||||
|
@ -134,6 +145,10 @@ public class ContextMenuAdapter {
|
|||
return selectedList.get(pos);
|
||||
}
|
||||
|
||||
public int getProgress(int pos) {
|
||||
return progressList.get(pos);
|
||||
}
|
||||
|
||||
public int getLoading(int pos) {
|
||||
return loadingList.get(pos);
|
||||
}
|
||||
|
@ -142,6 +157,10 @@ public class ContextMenuAdapter {
|
|||
selectedList.set(pos, s);
|
||||
}
|
||||
|
||||
public void setProgress(int pos, int s) {
|
||||
progressList.set(pos, s);
|
||||
}
|
||||
|
||||
|
||||
public Drawable getImage(OsmandApplication ctx, int pos, boolean light) {
|
||||
int lst = iconList.get(pos);
|
||||
|
@ -189,12 +208,14 @@ public class ContextMenuAdapter {
|
|||
int id;
|
||||
String name;
|
||||
int selected = -1;
|
||||
int progress = -1;
|
||||
int layout = -1;
|
||||
int loading = -1;
|
||||
boolean cat;
|
||||
int pos = -1;
|
||||
String description = "";
|
||||
private OnContextMenuClick checkBoxListener;
|
||||
private OnIntegerValueChangedListener integerListener;
|
||||
|
||||
private Item() {
|
||||
}
|
||||
|
@ -220,6 +241,11 @@ public class ContextMenuAdapter {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Item progress(int progress) {
|
||||
this.progress = progress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item loading(int loading) {
|
||||
this.loading = loading;
|
||||
return this;
|
||||
|
@ -240,6 +266,11 @@ public class ContextMenuAdapter {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Item listenInteger(OnIntegerValueChangedListener l) {
|
||||
this.integerListener = l;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void reg() {
|
||||
if (pos >= items.size() || pos < 0) {
|
||||
pos = items.size();
|
||||
|
@ -248,11 +279,13 @@ public class ContextMenuAdapter {
|
|||
itemNames.add(pos, name);
|
||||
itemDescription.add(pos, description);
|
||||
selectedList.insert(pos, selected);
|
||||
progressList.insert(pos, progress);
|
||||
loadingList.insert(pos, loading);
|
||||
layoutIds.insert(pos, layout);
|
||||
iconList.insert(pos, icon);
|
||||
iconListLight.insert(pos, lightIcon);
|
||||
checkListeners.add(pos, checkBoxListener);
|
||||
integerListeners.add(pos, integerListener);
|
||||
isCategory.insert(pos, cat ? 1 : 0);
|
||||
}
|
||||
|
||||
|
@ -276,9 +309,11 @@ public class ContextMenuAdapter {
|
|||
items.removeAt(pos);
|
||||
itemNames.remove(pos);
|
||||
selectedList.removeAt(pos);
|
||||
progressList.removeAt(pos);
|
||||
iconList.removeAt(pos);
|
||||
iconListLight.removeAt(pos);
|
||||
checkListeners.remove(pos);
|
||||
integerListeners.remove(pos);
|
||||
isCategory.removeAt(pos);
|
||||
layoutIds.removeAt(pos);
|
||||
loadingList.removeAt(pos);
|
||||
|
@ -408,6 +443,34 @@ public class ContextMenuAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
if (convertView.findViewById(R.id.seekbar) != null) {
|
||||
SeekBar seekBar = (SeekBar) convertView.findViewById(R.id.seekbar);
|
||||
if(progressList.get(position) != -1) {
|
||||
seekBar.setProgress(getProgress(position));
|
||||
seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
OnIntegerValueChangedListener listener = getIntegerLister(position);
|
||||
progressList.set(position, progress);
|
||||
if (listener != null && fromUser) {
|
||||
listener.onIntegerValueChangedListener(progress);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
});
|
||||
seekBar.setVisibility(View.VISIBLE);
|
||||
} else if (seekBar != null) {
|
||||
seekBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
if (convertView.findViewById(R.id.ProgressBar) != null) {
|
||||
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
|
||||
if (loadingList.get(position) == 1) {
|
||||
|
|
|
@ -51,7 +51,7 @@ import net.osmand.plus.dashboard.tools.DashFragmentData;
|
|||
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
||||
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.dialogs.UnderlayMapMenu;
|
||||
import net.osmand.plus.dialogs.RasterMapMenu;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
|
@ -59,6 +59,7 @@ import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallback
|
|||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||
|
@ -157,6 +158,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
LIST_MENU,
|
||||
ROUTE_PREFERENCES,
|
||||
DASHBOARD,
|
||||
OVERLAY_MAP,
|
||||
UNDERLAY_MAP
|
||||
}
|
||||
|
||||
|
@ -354,6 +356,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
tv.setText(R.string.shared_string_settings);
|
||||
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
|
||||
tv.setText(R.string.map_underlay);
|
||||
} else if (visibleType == DashboardType.OVERLAY_MAP) {
|
||||
tv.setText(R.string.map_overlay);
|
||||
}
|
||||
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
|
||||
edit.setVisibility(View.GONE);
|
||||
|
@ -723,7 +727,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
|
||||
updateListAdapter(listAdapter, listener);
|
||||
} else if (DashboardType.UNDERLAY_MAP == visibleType) {
|
||||
cm = UnderlayMapMenu.createListAdapter(mapActivity);
|
||||
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.UNDERLAY);
|
||||
} else if (DashboardType.OVERLAY_MAP == visibleType) {
|
||||
cm = RasterMapMenu.createListAdapter(mapActivity, OsmandRasterMapsPlugin.RasterMapType.OVERLAY);
|
||||
}
|
||||
if (cm != null) {
|
||||
updateListAdapter(cm);
|
||||
|
|
75
OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
Normal file
75
OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
|
||||
public class RasterMapMenu {
|
||||
private static final String TAG = "RasterMapMenu";
|
||||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity mapActivity,
|
||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter(mapActivity, false);
|
||||
adapter.setDefaultLayoutId(R.layout.drawer_list_material_item);
|
||||
createLayersItems(adapter, mapActivity, type);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private static void createLayersItems(ContextMenuAdapter adapter,
|
||||
final MapActivity mapActivity,
|
||||
final OsmandRasterMapsPlugin.RasterMapType type) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
|
||||
final MapTileLayer rasterMapLayer;
|
||||
final OsmandSettings.CommonPreference<Integer> mapTransparencyPreference;
|
||||
if (type == OsmandRasterMapsPlugin.RasterMapType.OVERLAY) {
|
||||
rasterMapLayer = plugin.getOverlayLayer();
|
||||
mapTransparencyPreference = settings.MAP_OVERLAY_TRANSPARENCY;
|
||||
} else {
|
||||
rasterMapLayer = plugin.getUnderlayLayer();
|
||||
mapTransparencyPreference = settings.MAP_TRANSPARENCY;
|
||||
}
|
||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||
@Override
|
||||
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
|
||||
Log.v(TAG, "onRowItemClick(" + "adapter=" + adapter + ", view=" + view + ", itemId=" + itemId + ", pos=" + pos + ")");
|
||||
return super.onRowItemClick(adapter, view, itemId, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Log.v(TAG, "onContextMenuClick(" + "adapter=" + adapter + ", itemId=" + itemId + ", pos=" + pos + ", isChecked=" + isChecked + ")");
|
||||
if (itemId == R.string.shared_string_show) {
|
||||
plugin.toggleUnderlayState(mapActivity, type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.shared_string_show).listen(l).selected(rasterMapLayer != null && rasterMapLayer.getMap() != null ? 1 : 0).reg();
|
||||
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
|
||||
ContextMenuAdapter.OnIntegerValueChangedListener integerListener =
|
||||
new ContextMenuAdapter.OnIntegerValueChangedListener() {
|
||||
@Override
|
||||
public boolean onIntegerValueChangedListener(int newValue) {
|
||||
mapTransparencyPreference.set(newValue);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
return false;
|
||||
}
|
||||
};
|
||||
// android:max="255" in layout is expected
|
||||
adapter.item(R.string.underlay_transparency).layout(R.layout.progress_list_item)
|
||||
.progress(mapTransparencyPreference.get()).listenInteger(integerListener).reg();
|
||||
adapter.item(R.string.map_underlay).layout(R.layout.two_line_list_item).listen(l).reg();
|
||||
adapter.item(R.string.show_polygons).listen(l).reg();
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package net.osmand.plus.dialogs;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public class UnderlayMapMenu {
|
||||
private static final String TAG = "UnderlayMapMenu";
|
||||
|
||||
public static ContextMenuAdapter createListAdapter(final MapActivity ma) {
|
||||
ContextMenuAdapter adapter = new ContextMenuAdapter(ma, false);
|
||||
adapter.setDefaultLayoutId(R.layout.drawer_list_material_item);
|
||||
createLayersItems(adapter, ma);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private static void createLayersItems(ContextMenuAdapter adapter , MapActivity activity) {
|
||||
OsmandApplication app = activity.getMyApplication();
|
||||
OsmandSettings settings = app.getSettings();
|
||||
ContextMenuAdapter.OnRowItemClick l = new ContextMenuAdapter.OnRowItemClick() {
|
||||
@Override
|
||||
public boolean onRowItemClick(ArrayAdapter<?> adapter, View view, int itemId, int pos) {
|
||||
Log.v(TAG, "onRowItemClick(" + "adapter=" + adapter + ", view=" + view + ", itemId=" + itemId + ", pos=" + pos + ")");
|
||||
return super.onRowItemClick(adapter, view, itemId, pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked) {
|
||||
Log.v(TAG, "onContextMenuClick(" + "adapter=" + adapter + ", itemId=" + itemId + ", pos=" + pos + ", isChecked=" + isChecked + ")");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
adapter.item(R.string.shared_string_show).listen(l).reg();
|
||||
// String appMode = " [" + settings.getApplicationMode().toHumanString(view.getApplication()) +"] ";
|
||||
adapter.item(R.string.underlay_transparency).layout(R.layout.progress_list_item).reg();
|
||||
adapter.item(R.string.map_underlay).layout(R.layout.two_line_list_item).listen(l).reg();
|
||||
adapter.item(R.string.show_polygons).listen(l).reg();
|
||||
|
||||
// .selected(overlayLayer != null && overlayLayer.getMap() != null ? 1 : 0)
|
||||
|
||||
// if(underlayLayer.getMap() != null){
|
||||
// settings.MAP_UNDERLAY.set(null);
|
||||
// updateMapLayers(mapView, null, layers);
|
||||
// layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_TRANSPARENCY);
|
||||
// } else {
|
||||
// selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||
// mapActivity);
|
||||
// }
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.rastermaps;
|
|||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
@ -31,7 +32,7 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.activities.DownloadTilesDialog;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.MapActivityLayers;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap.DashboardType;
|
||||
import net.osmand.plus.views.MapTileLayer;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -144,7 +145,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
||||
final CommonPreference<String> mapPref, final CommonPreference<Integer> transparencyPref,
|
||||
final CommonPreference<String> mapPref,
|
||||
final MapActivity activity){
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
final MapActivityLayers layers = activity.getMapLayers();
|
||||
|
@ -165,15 +166,15 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||
TileSourceTemplate template = null;
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
public boolean publish(TileSourceTemplate object) {
|
||||
if (object == null) {
|
||||
if (count == 1) {
|
||||
mapPref.set(template.getName());
|
||||
layers.getMapControlsLayer().showTransparencyBar(transparencyPref);
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapPref, transparencyPref, activity);
|
||||
selectMapOverlayLayer(mapView, mapPref, activity);
|
||||
}
|
||||
} else {
|
||||
count++;
|
||||
|
@ -189,7 +190,6 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
});
|
||||
} else {
|
||||
mapPref.set(keys.get(which));
|
||||
layers.getMapControlsLayer().showTransparencyBar(transparencyPref);
|
||||
updateMapLayers(mapView, mapPref, layers);
|
||||
}
|
||||
dialog.dismiss();
|
||||
|
@ -200,7 +200,9 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView, ContextMenuAdapter adapter, final MapActivity mapActivity) {
|
||||
public void registerLayerContextMenuActions(final OsmandMapTileView mapView,
|
||||
ContextMenuAdapter adapter,
|
||||
final MapActivity mapActivity) {
|
||||
final MapActivityLayers layers = mapActivity.getMapLayers();
|
||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||
@Override
|
||||
|
@ -208,22 +210,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
if (itemId == R.string.layer_map) {
|
||||
layers.selectMapLayer(mapView);
|
||||
} else if(itemId == R.string.layer_overlay){
|
||||
if(overlayLayer.getMap() != null){
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
updateMapLayers(mapView, null, layers);
|
||||
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity);
|
||||
}
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP);
|
||||
return false;
|
||||
} else if(itemId == R.string.layer_underlay){
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardOnMap.DashboardType.UNDERLAY_MAP);
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.UNDERLAY_MAP);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
adapter.item(R.string.layer_overlay).selected(overlayLayer != null && overlayLayer.getMap() != null ? 1 : 0).
|
||||
adapter.item(R.string.layer_overlay).
|
||||
iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
||||
adapter.item(R.string.layer_underlay)
|
||||
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
||||
|
@ -414,4 +411,39 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
|||
ts.getUrlTemplate().replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}"));
|
||||
elliptic.setChecked(ts.isEllipticYTile());
|
||||
}
|
||||
|
||||
public MapTileLayer getUnderlayLayer() {
|
||||
return underlayLayer;
|
||||
}
|
||||
|
||||
public MapTileLayer getOverlayLayer() {
|
||||
return overlayLayer;
|
||||
}
|
||||
|
||||
public void toggleUnderlayState(@NonNull MapActivity mapActivity, @NonNull RasterMapType type) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
CommonPreference<String> mapTypePreference;
|
||||
ITileSource map;
|
||||
if (type == RasterMapType.OVERLAY) {
|
||||
mapTypePreference = settings.MAP_OVERLAY;
|
||||
map = overlayLayer.getMap();
|
||||
} else {
|
||||
mapTypePreference = settings.MAP_UNDERLAY;
|
||||
map = underlayLayer.getMap();
|
||||
}
|
||||
|
||||
if (map != null) {
|
||||
mapTypePreference.set(null);
|
||||
MapActivityLayers mapLayers = mapActivity.getMapLayers();
|
||||
updateMapLayers(mapView, null, mapLayers);
|
||||
} else {
|
||||
selectMapOverlayLayer(mapView, mapTypePreference,
|
||||
mapActivity);
|
||||
}
|
||||
}
|
||||
|
||||
public enum RasterMapType {
|
||||
OVERLAY,
|
||||
UNDERLAY
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,10 +17,7 @@ import android.support.v7.app.AlertDialog;
|
|||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.londatiga.android.ActionItem;
|
||||
|
@ -68,8 +65,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
// private RulerControl rulerControl;
|
||||
// private List<MapControls> allControls = new ArrayList<MapControls>();
|
||||
|
||||
private SeekBar transparencyBar;
|
||||
private LinearLayout transparencyBarLayout;
|
||||
private static CommonPreference<Integer> settingsToTransparency;
|
||||
private OsmandSettings settings;
|
||||
|
||||
|
@ -109,7 +104,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
@Override
|
||||
public void initLayer(final OsmandMapTileView view) {
|
||||
initTopControls();
|
||||
initTransparencyBar();
|
||||
initZooms();
|
||||
initDasboardRelatedControls();
|
||||
updateControls(view.getCurrentRotatedTileBox(), null);
|
||||
|
@ -589,58 +583,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
return false;
|
||||
}
|
||||
|
||||
// /////////////// Transparency bar /////////////////////////
|
||||
private void initTransparencyBar() {
|
||||
transparencyBarLayout = (LinearLayout) mapActivity.findViewById(R.id.map_transparency_layout);
|
||||
transparencyBar = (SeekBar) mapActivity.findViewById(R.id.map_transparency_seekbar);
|
||||
transparencyBar.setMax(255);
|
||||
if (settingsToTransparency != null) {
|
||||
transparencyBar.setProgress(settingsToTransparency.get());
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
}
|
||||
transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||
|
||||
@Override
|
||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||
if (settingsToTransparency != null) {
|
||||
settingsToTransparency.set(progress);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
}
|
||||
}
|
||||
});
|
||||
ImageButton imageButton = (ImageButton) mapActivity.findViewById(R.id.map_transparency_hide);
|
||||
imageButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
hideTransparencyBar(settingsToTransparency);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showTransparencyBar(CommonPreference<Integer> transparenPreference) {
|
||||
MapControlsLayer.settingsToTransparency = transparenPreference;
|
||||
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||
transparencyBar.setProgress(transparenPreference.get());
|
||||
}
|
||||
|
||||
public void hideTransparencyBar(CommonPreference<Integer> transparentPreference) {
|
||||
if (settingsToTransparency == transparentPreference) {
|
||||
transparencyBarLayout.setVisibility(View.GONE);
|
||||
settingsToTransparency = null;
|
||||
}
|
||||
}
|
||||
|
||||
private class MapHudButton {
|
||||
View iv;
|
||||
int bgDark;
|
||||
|
|
Loading…
Reference in a new issue