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"/>
|
android:textSize="@dimen/map_button_text_size"/>
|
||||||
</FrameLayout>
|
</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
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -22,10 +22,13 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
<ImageView
|
<ImageView
|
||||||
|
android:src="@drawable/ic_action_opacity"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
<SeekBar
|
<SeekBar
|
||||||
|
android:id="@+id/seekbar"
|
||||||
style="?android:attr/progressBarStyleHorizontal"
|
style="?android:attr/progressBarStyleHorizontal"
|
||||||
|
android:max="255"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import android.widget.CompoundButton;
|
||||||
import android.widget.CompoundButton.OnCheckedChangeListener;
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
import android.widget.SeekBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.osmand.AndroidUtils;
|
import net.osmand.AndroidUtils;
|
||||||
|
@ -37,6 +38,10 @@ public class ContextMenuAdapter {
|
||||||
public boolean onContextMenuClick(ArrayAdapter<?> adapter, int itemId, int pos, boolean isChecked);
|
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 static abstract class OnRowItemClick implements OnContextMenuClick {
|
||||||
|
|
||||||
public OnRowItemClick() {
|
public OnRowItemClick() {
|
||||||
|
@ -73,8 +78,10 @@ public class ContextMenuAdapter {
|
||||||
final TIntArrayList items = new TIntArrayList();
|
final TIntArrayList items = new TIntArrayList();
|
||||||
final TIntArrayList isCategory = new TIntArrayList();
|
final TIntArrayList isCategory = new TIntArrayList();
|
||||||
final ArrayList<String> itemNames = new ArrayList<String>();
|
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 selectedList = new TIntArrayList();
|
||||||
|
final TIntArrayList progressList = new TIntArrayList();
|
||||||
final TIntArrayList loadingList = new TIntArrayList();
|
final TIntArrayList loadingList = new TIntArrayList();
|
||||||
final TIntArrayList layoutIds = new TIntArrayList();
|
final TIntArrayList layoutIds = new TIntArrayList();
|
||||||
final TIntArrayList iconList = new TIntArrayList();
|
final TIntArrayList iconList = new TIntArrayList();
|
||||||
|
@ -114,6 +121,10 @@ public class ContextMenuAdapter {
|
||||||
return checkListeners.get(i);
|
return checkListeners.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public OnIntegerValueChangedListener getIntegerLister(int i) {
|
||||||
|
return integerListeners.get(i);
|
||||||
|
}
|
||||||
|
|
||||||
public String getItemName(int pos) {
|
public String getItemName(int pos) {
|
||||||
return itemNames.get(pos);
|
return itemNames.get(pos);
|
||||||
}
|
}
|
||||||
|
@ -134,6 +145,10 @@ public class ContextMenuAdapter {
|
||||||
return selectedList.get(pos);
|
return selectedList.get(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProgress(int pos) {
|
||||||
|
return progressList.get(pos);
|
||||||
|
}
|
||||||
|
|
||||||
public int getLoading(int pos) {
|
public int getLoading(int pos) {
|
||||||
return loadingList.get(pos);
|
return loadingList.get(pos);
|
||||||
}
|
}
|
||||||
|
@ -142,6 +157,10 @@ public class ContextMenuAdapter {
|
||||||
selectedList.set(pos, s);
|
selectedList.set(pos, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setProgress(int pos, int s) {
|
||||||
|
progressList.set(pos, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Drawable getImage(OsmandApplication ctx, int pos, boolean light) {
|
public Drawable getImage(OsmandApplication ctx, int pos, boolean light) {
|
||||||
int lst = iconList.get(pos);
|
int lst = iconList.get(pos);
|
||||||
|
@ -189,12 +208,14 @@ public class ContextMenuAdapter {
|
||||||
int id;
|
int id;
|
||||||
String name;
|
String name;
|
||||||
int selected = -1;
|
int selected = -1;
|
||||||
|
int progress = -1;
|
||||||
int layout = -1;
|
int layout = -1;
|
||||||
int loading = -1;
|
int loading = -1;
|
||||||
boolean cat;
|
boolean cat;
|
||||||
int pos = -1;
|
int pos = -1;
|
||||||
String description = "";
|
String description = "";
|
||||||
private OnContextMenuClick checkBoxListener;
|
private OnContextMenuClick checkBoxListener;
|
||||||
|
private OnIntegerValueChangedListener integerListener;
|
||||||
|
|
||||||
private Item() {
|
private Item() {
|
||||||
}
|
}
|
||||||
|
@ -220,6 +241,11 @@ public class ContextMenuAdapter {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item progress(int progress) {
|
||||||
|
this.progress = progress;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public Item loading(int loading) {
|
public Item loading(int loading) {
|
||||||
this.loading = loading;
|
this.loading = loading;
|
||||||
return this;
|
return this;
|
||||||
|
@ -240,6 +266,11 @@ public class ContextMenuAdapter {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Item listenInteger(OnIntegerValueChangedListener l) {
|
||||||
|
this.integerListener = l;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public void reg() {
|
public void reg() {
|
||||||
if (pos >= items.size() || pos < 0) {
|
if (pos >= items.size() || pos < 0) {
|
||||||
pos = items.size();
|
pos = items.size();
|
||||||
|
@ -248,11 +279,13 @@ public class ContextMenuAdapter {
|
||||||
itemNames.add(pos, name);
|
itemNames.add(pos, name);
|
||||||
itemDescription.add(pos, description);
|
itemDescription.add(pos, description);
|
||||||
selectedList.insert(pos, selected);
|
selectedList.insert(pos, selected);
|
||||||
|
progressList.insert(pos, progress);
|
||||||
loadingList.insert(pos, loading);
|
loadingList.insert(pos, loading);
|
||||||
layoutIds.insert(pos, layout);
|
layoutIds.insert(pos, layout);
|
||||||
iconList.insert(pos, icon);
|
iconList.insert(pos, icon);
|
||||||
iconListLight.insert(pos, lightIcon);
|
iconListLight.insert(pos, lightIcon);
|
||||||
checkListeners.add(pos, checkBoxListener);
|
checkListeners.add(pos, checkBoxListener);
|
||||||
|
integerListeners.add(pos, integerListener);
|
||||||
isCategory.insert(pos, cat ? 1 : 0);
|
isCategory.insert(pos, cat ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -276,9 +309,11 @@ public class ContextMenuAdapter {
|
||||||
items.removeAt(pos);
|
items.removeAt(pos);
|
||||||
itemNames.remove(pos);
|
itemNames.remove(pos);
|
||||||
selectedList.removeAt(pos);
|
selectedList.removeAt(pos);
|
||||||
|
progressList.removeAt(pos);
|
||||||
iconList.removeAt(pos);
|
iconList.removeAt(pos);
|
||||||
iconListLight.removeAt(pos);
|
iconListLight.removeAt(pos);
|
||||||
checkListeners.remove(pos);
|
checkListeners.remove(pos);
|
||||||
|
integerListeners.remove(pos);
|
||||||
isCategory.removeAt(pos);
|
isCategory.removeAt(pos);
|
||||||
layoutIds.removeAt(pos);
|
layoutIds.removeAt(pos);
|
||||||
loadingList.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) {
|
if (convertView.findViewById(R.id.ProgressBar) != null) {
|
||||||
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
|
ProgressBar bar = (ProgressBar) convertView.findViewById(R.id.ProgressBar);
|
||||||
if (loadingList.get(position) == 1) {
|
if (loadingList.get(position) == 1) {
|
||||||
|
@ -424,4 +487,4 @@ public class ContextMenuAdapter {
|
||||||
return convertView;
|
return convertView;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -51,7 +51,7 @@ import net.osmand.plus.dashboard.tools.DashFragmentData;
|
||||||
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
import net.osmand.plus.dashboard.tools.DashboardSettingsDialogFragment;
|
||||||
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
import net.osmand.plus.dashboard.tools.TransactionBuilder;
|
||||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
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.download.DownloadActivity;
|
||||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
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.helpers.WaypointHelper.LocationPointWrapper;
|
||||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
|
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
|
||||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
|
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;
|
||||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||||
import net.osmand.plus.views.DownloadedRegionsLayer;
|
import net.osmand.plus.views.DownloadedRegionsLayer;
|
||||||
|
@ -157,6 +158,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
LIST_MENU,
|
LIST_MENU,
|
||||||
ROUTE_PREFERENCES,
|
ROUTE_PREFERENCES,
|
||||||
DASHBOARD,
|
DASHBOARD,
|
||||||
|
OVERLAY_MAP,
|
||||||
UNDERLAY_MAP
|
UNDERLAY_MAP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,6 +356,8 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
tv.setText(R.string.shared_string_settings);
|
tv.setText(R.string.shared_string_settings);
|
||||||
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
|
} else if (visibleType == DashboardType.UNDERLAY_MAP) {
|
||||||
tv.setText(R.string.map_underlay);
|
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);
|
ImageView edit = (ImageView) dashboardView.findViewById(R.id.toolbar_edit);
|
||||||
edit.setVisibility(View.GONE);
|
edit.setVisibility(View.GONE);
|
||||||
|
@ -723,7 +727,9 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
||||||
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
|
OnItemClickListener listener = routePreferencesMenu.getItemClickListener(listAdapter);
|
||||||
updateListAdapter(listAdapter, listener);
|
updateListAdapter(listAdapter, listener);
|
||||||
} else if (DashboardType.UNDERLAY_MAP == visibleType) {
|
} 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) {
|
if (cm != null) {
|
||||||
updateListAdapter(cm);
|
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.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.AdapterView;
|
import android.widget.AdapterView;
|
||||||
|
@ -31,7 +32,7 @@ import net.osmand.plus.Version;
|
||||||
import net.osmand.plus.activities.DownloadTilesDialog;
|
import net.osmand.plus.activities.DownloadTilesDialog;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.activities.MapActivityLayers;
|
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.MapTileLayer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
@ -144,7 +145,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
public void selectMapOverlayLayer(final OsmandMapTileView mapView,
|
||||||
final CommonPreference<String> mapPref, final CommonPreference<Integer> transparencyPref,
|
final CommonPreference<String> mapPref,
|
||||||
final MapActivity activity){
|
final MapActivity activity){
|
||||||
final OsmandSettings settings = app.getSettings();
|
final OsmandSettings settings = app.getSettings();
|
||||||
final MapActivityLayers layers = activity.getMapLayers();
|
final MapActivityLayers layers = activity.getMapLayers();
|
||||||
|
@ -158,30 +159,30 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
items[i] = app.getString(R.string.install_more);
|
items[i] = app.getString(R.string.install_more);
|
||||||
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener(){
|
builder.setSingleChoiceItems(items, -1, new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
if (which == items.length - 1){
|
if (which == items.length - 1) {
|
||||||
installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
installMapLayers(activity, new ResultMatcher<TileSourceTemplate>() {
|
||||||
TileSourceTemplate template = null;
|
TileSourceTemplate template = null;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean publish(TileSourceTemplate object) {
|
public boolean publish(TileSourceTemplate object) {
|
||||||
if(object == null){
|
if (object == null) {
|
||||||
if(count == 1){
|
if (count == 1) {
|
||||||
mapPref.set(template.getName());
|
mapPref.set(template.getName());
|
||||||
layers.getMapControlsLayer().showTransparencyBar(transparencyPref);
|
|
||||||
updateMapLayers(mapView, mapPref, layers);
|
updateMapLayers(mapView, mapPref, layers);
|
||||||
} else {
|
} else {
|
||||||
selectMapOverlayLayer(mapView, mapPref, transparencyPref, activity);
|
selectMapOverlayLayer(mapView, mapPref, activity);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
count ++;
|
count++;
|
||||||
template = object;
|
template = object;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return false;
|
return false;
|
||||||
|
@ -189,18 +190,19 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mapPref.set(keys.get(which));
|
mapPref.set(keys.get(which));
|
||||||
layers.getMapControlsLayer().showTransparencyBar(transparencyPref);
|
|
||||||
updateMapLayers(mapView, mapPref, layers);
|
updateMapLayers(mapView, mapPref, layers);
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
builder.show();
|
builder.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
final MapActivityLayers layers = mapActivity.getMapLayers();
|
||||||
OnContextMenuClick listener = new OnContextMenuClick() {
|
OnContextMenuClick listener = new OnContextMenuClick() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -208,22 +210,17 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
if (itemId == R.string.layer_map) {
|
if (itemId == R.string.layer_map) {
|
||||||
layers.selectMapLayer(mapView);
|
layers.selectMapLayer(mapView);
|
||||||
} else if(itemId == R.string.layer_overlay){
|
} else if(itemId == R.string.layer_overlay){
|
||||||
if(overlayLayer.getMap() != null){
|
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.OVERLAY_MAP);
|
||||||
settings.MAP_OVERLAY.set(null);
|
return false;
|
||||||
updateMapLayers(mapView, null, layers);
|
|
||||||
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
|
|
||||||
} else {
|
|
||||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity);
|
|
||||||
}
|
|
||||||
} else if(itemId == R.string.layer_underlay){
|
} 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 false;
|
||||||
}
|
}
|
||||||
return true;
|
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();
|
iconColor(R.drawable.ic_layer_top_dark).listen(listener).position(14).reg();
|
||||||
adapter.item(R.string.layer_underlay)
|
adapter.item(R.string.layer_underlay)
|
||||||
.iconColor(R.drawable.ic_layer_bottom_dark).listen(listener).position(15).reg();
|
.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}"));
|
ts.getUrlTemplate().replace("{$x}", "{1}").replace("{$y}", "{2}").replace("{$z}", "{0}"));
|
||||||
elliptic.setChecked(ts.isEllipticYTile());
|
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.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.widget.ImageButton;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import net.londatiga.android.ActionItem;
|
import net.londatiga.android.ActionItem;
|
||||||
|
@ -68,8 +65,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
// private RulerControl rulerControl;
|
// private RulerControl rulerControl;
|
||||||
// private List<MapControls> allControls = new ArrayList<MapControls>();
|
// private List<MapControls> allControls = new ArrayList<MapControls>();
|
||||||
|
|
||||||
private SeekBar transparencyBar;
|
|
||||||
private LinearLayout transparencyBarLayout;
|
|
||||||
private static CommonPreference<Integer> settingsToTransparency;
|
private static CommonPreference<Integer> settingsToTransparency;
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
@ -109,7 +104,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
@Override
|
@Override
|
||||||
public void initLayer(final OsmandMapTileView view) {
|
public void initLayer(final OsmandMapTileView view) {
|
||||||
initTopControls();
|
initTopControls();
|
||||||
initTransparencyBar();
|
|
||||||
initZooms();
|
initZooms();
|
||||||
initDasboardRelatedControls();
|
initDasboardRelatedControls();
|
||||||
updateControls(view.getCurrentRotatedTileBox(), null);
|
updateControls(view.getCurrentRotatedTileBox(), null);
|
||||||
|
@ -589,58 +583,6 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
return false;
|
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 {
|
private class MapHudButton {
|
||||||
View iv;
|
View iv;
|
||||||
int bgDark;
|
int bgDark;
|
||||||
|
|
Loading…
Reference in a new issue