From 44f9593edbec5a46a471ab71c5da06403e49968f Mon Sep 17 00:00:00 2001 From: GaidamakUA Date: Fri, 5 Feb 2016 18:19:55 +0200 Subject: [PATCH] Changing transparency in new menu. --- OsmAnd/res/layout/map_hud_bottom.xml | 23 ------ OsmAnd/res/layout/progress_list_item.xml | 3 + .../net/osmand/plus/ContextMenuAdapter.java | 67 +++++++++++++++- .../osmand/plus/dashboard/DashboardOnMap.java | 10 ++- .../osmand/plus/dialogs/RasterMapMenu.java | 75 ++++++++++++++++++ .../osmand/plus/dialogs/UnderlayMapMenu.java | 56 -------------- .../rastermaps/OsmandRasterMapsPlugin.java | 76 +++++++++++++------ .../osmand/plus/views/MapControlsLayer.java | 58 -------------- 8 files changed, 205 insertions(+), 163 deletions(-) create mode 100644 OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java delete mode 100644 OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java diff --git a/OsmAnd/res/layout/map_hud_bottom.xml b/OsmAnd/res/layout/map_hud_bottom.xml index 6088fe7e4c..5c084fffdb 100644 --- a/OsmAnd/res/layout/map_hud_bottom.xml +++ b/OsmAnd/res/layout/map_hud_bottom.xml @@ -62,29 +62,6 @@ android:textSize="@dimen/map_button_text_size"/> - - - - - - - diff --git a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java index fd19a1a540..08a0084a7c 100644 --- a/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java +++ b/OsmAnd/src/net/osmand/plus/ContextMenuAdapter.java @@ -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 itemNames = new ArrayList(); - final ArrayList checkListeners = new ArrayList(); + final ArrayList checkListeners = new ArrayList<>(); + final ArrayList 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) { @@ -424,4 +487,4 @@ public class ContextMenuAdapter { return convertView; } } -} +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java index 6d725d1fdf..8c2b27749f 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashboardOnMap.java @@ -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); diff --git a/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java new file mode 100644 index 0000000000..ab6f817357 --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/dialogs/RasterMapMenu.java @@ -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 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(); + } +} diff --git a/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java b/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java deleted file mode 100644 index db298af65e..0000000000 --- a/OsmAnd/src/net/osmand/plus/dialogs/UnderlayMapMenu.java +++ /dev/null @@ -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); -// } - } -} diff --git a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java index ec439323f0..a03ef5216d 100644 --- a/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java +++ b/OsmAnd/src/net/osmand/plus/rastermaps/OsmandRasterMapsPlugin.java @@ -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 mapPref, final CommonPreference transparencyPref, + final CommonPreference mapPref, final MapActivity activity){ final OsmandSettings settings = app.getSettings(); final MapActivityLayers layers = activity.getMapLayers(); @@ -158,30 +159,30 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { } items[i] = app.getString(R.string.install_more); - builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){ + builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (which == items.length - 1){ + if (which == items.length - 1) { installMapLayers(activity, new ResultMatcher() { TileSourceTemplate template = null; int count = 0; + @Override public boolean publish(TileSourceTemplate object) { - if(object == null){ - if(count == 1){ + 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 ++; + count++; template = object; } return false; } - + @Override public boolean isCancelled() { return false; @@ -189,18 +190,19 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin { }); } else { mapPref.set(keys.get(which)); - layers.getMapControlsLayer().showTransparencyBar(transparencyPref); updateMapLayers(mapView, mapPref, layers); } dialog.dismiss(); } - + }); builder.show(); } @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 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 + } } diff --git a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java index f383ca7527..ed46b40f1c 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapControlsLayer.java @@ -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 allControls = new ArrayList(); - private SeekBar transparencyBar; - private LinearLayout transparencyBarLayout; private static CommonPreference 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 transparenPreference) { - MapControlsLayer.settingsToTransparency = transparenPreference; - transparencyBarLayout.setVisibility(View.VISIBLE); - transparencyBar.setProgress(transparenPreference.get()); - } - - public void hideTransparencyBar(CommonPreference transparentPreference) { - if (settingsToTransparency == transparentPreference) { - transparencyBarLayout.setVisibility(View.GONE); - settingsToTransparency = null; - } - } - private class MapHudButton { View iv; int bgDark;