Transparency bar stays on the screen
This commit is contained in:
parent
3cf67d1fe0
commit
3954769eab
3 changed files with 47 additions and 35 deletions
|
@ -137,7 +137,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
if(object == null){
|
if(object == null){
|
||||||
if(count == 1){
|
if(count == 1){
|
||||||
mapPref.set(template.getName());
|
mapPref.set(template.getName());
|
||||||
layers.getMapControlsLayer().showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
layers.getMapControlsLayer().showTransparencyBar(transparencyPref, transparencyToChange);
|
||||||
updateMapLayers(mapView, mapPref, layers);
|
updateMapLayers(mapView, mapPref, layers);
|
||||||
} else {
|
} else {
|
||||||
selectMapOverlayLayer(mapView, mapPref, transparencyPref, activity, transparencyToChange);
|
selectMapOverlayLayer(mapView, mapPref, transparencyPref, activity, transparencyToChange);
|
||||||
|
@ -156,7 +156,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
mapPref.set(keys.get(which));
|
mapPref.set(keys.get(which));
|
||||||
layers.getMapControlsLayer().showAndHideTransparencyBar(transparencyPref, transparencyToChange);
|
layers.getMapControlsLayer().showTransparencyBar(transparencyPref, transparencyToChange);
|
||||||
updateMapLayers(mapView, mapPref, layers);
|
updateMapLayers(mapView, mapPref, layers);
|
||||||
}
|
}
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
|
@ -179,6 +179,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
if(overlayLayer.getMap() != null){
|
if(overlayLayer.getMap() != null){
|
||||||
settings.MAP_OVERLAY.set(null);
|
settings.MAP_OVERLAY.set(null);
|
||||||
updateMapLayers(mapView, null, layers);
|
updateMapLayers(mapView, null, layers);
|
||||||
|
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_OVERLAY_TRANSPARENCY);
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity,
|
selectMapOverlayLayer(mapView, settings.MAP_OVERLAY, settings.MAP_OVERLAY_TRANSPARENCY, mapActivity,
|
||||||
|
@ -188,6 +189,7 @@ public class OsmandRasterMapsPlugin extends OsmandPlugin {
|
||||||
if(underlayLayer.getMap() != null){
|
if(underlayLayer.getMap() != null){
|
||||||
settings.MAP_UNDERLAY.set(null);
|
settings.MAP_UNDERLAY.set(null);
|
||||||
updateMapLayers(mapView, null, layers);
|
updateMapLayers(mapView, null, layers);
|
||||||
|
layers.getMapControlsLayer().hideTransparencyBar(settings.MAP_TRANSPARENCY);
|
||||||
} else {
|
} else {
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
selectMapOverlayLayer(mapView, settings.MAP_UNDERLAY,settings.MAP_TRANSPARENCY,
|
||||||
|
|
|
@ -25,15 +25,13 @@ import android.view.ViewGroup.LayoutParams;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
import android.widget.ImageButton;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.SeekBar;
|
import android.widget.SeekBar;
|
||||||
|
|
||||||
public class MapControlsLayer extends OsmandMapLayer {
|
public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private static final int SHOW_SEEKBAR_MSG_ID = 2;
|
|
||||||
private static final int SHOW_SEEKBAR_DELAY = 7000;
|
|
||||||
private static final int SHOW_SEEKBAR_SECOND_DELAY = 25000;
|
|
||||||
|
|
||||||
private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3;
|
private static final int SHOW_ZOOM_LEVEL_MSG_ID = 3;
|
||||||
private static final int SHOW_ZOOM_LEVEL_DELAY = 2000;
|
private static final int SHOW_ZOOM_LEVEL_DELAY = 2000;
|
||||||
|
|
||||||
|
@ -58,11 +56,13 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
private Drawable rulerDrawable;
|
private Drawable rulerDrawable;
|
||||||
private TextPaint rulerTextPaint;
|
private TextPaint rulerTextPaint;
|
||||||
private final static double screenRulerPercent = 0.25;
|
private final static double screenRulerPercent = 0.25;
|
||||||
private SeekBar transparencyBar;
|
|
||||||
private CommonPreference<Integer> settingsToTransparency;
|
private CommonPreference<Integer> settingsToTransparency;
|
||||||
private BaseMapLayer[] transparencyLayers;
|
private BaseMapLayer[] transparencyLayers;
|
||||||
private float scaleCoefficient;
|
private float scaleCoefficient;
|
||||||
|
|
||||||
|
private SeekBar transparencyBar;
|
||||||
|
private LinearLayout transparencyBarLayout;
|
||||||
|
|
||||||
|
|
||||||
public MapControlsLayer(MapActivity activity){
|
public MapControlsLayer(MapActivity activity){
|
||||||
this.activity = activity;
|
this.activity = activity;
|
||||||
|
@ -134,6 +134,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private ApplicationMode cacheApplicationMode = null;
|
private ApplicationMode cacheApplicationMode = null;
|
||||||
private Drawable cacheAppModeIcon = null;
|
private Drawable cacheAppModeIcon = null;
|
||||||
|
|
||||||
private void drawApplicationMode(Canvas canvas) {
|
private void drawApplicationMode(Canvas canvas) {
|
||||||
ApplicationMode appMode = view.getSettings().getApplicationMode();
|
ApplicationMode appMode = view.getSettings().getApplicationMode();
|
||||||
if(appMode != cacheApplicationMode){
|
if(appMode != cacheApplicationMode){
|
||||||
|
@ -325,14 +326,15 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
///////////////// Transparency bar /////////////////////////
|
///////////////// Transparency bar /////////////////////////
|
||||||
private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
|
private void initTransparencyBar(final OsmandMapTileView view, FrameLayout parent) {
|
||||||
int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight();
|
int minimumHeight = view.getResources().getDrawable(R.drawable.map_zoom_in).getMinimumHeight();
|
||||||
android.widget.FrameLayout.LayoutParams params;
|
android.widget.FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT,
|
||||||
transparencyBar = new SeekBar(view.getContext());
|
|
||||||
transparencyBar.setVisibility(View.GONE);
|
|
||||||
transparencyBar.setMax(255);
|
|
||||||
params = new FrameLayout.LayoutParams((int) (scaleCoefficient * 100), LayoutParams.WRAP_CONTENT,
|
|
||||||
Gravity.BOTTOM | Gravity.CENTER);
|
Gravity.BOTTOM | Gravity.CENTER);
|
||||||
params.setMargins(0, 0, 0, minimumHeight + 3);
|
params.setMargins(0, 0, 0, minimumHeight + 3);
|
||||||
parent.addView(transparencyBar, params);
|
transparencyBarLayout = new LinearLayout(view.getContext());
|
||||||
|
transparencyBarLayout.setVisibility(View.GONE);
|
||||||
|
parent.addView(transparencyBarLayout, params);
|
||||||
|
|
||||||
|
transparencyBar = new SeekBar(view.getContext());
|
||||||
|
transparencyBar.setMax(255);
|
||||||
transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
transparencyBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -345,38 +347,45 @@ public class MapControlsLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
||||||
if(settingsToTransparency != null && transparencyLayers != null){
|
if (settingsToTransparency != null && transparencyLayers != null) {
|
||||||
settingsToTransparency.set(progress);
|
settingsToTransparency.set(progress);
|
||||||
for(BaseMapLayer base : transparencyLayers){
|
for (BaseMapLayer base : transparencyLayers) {
|
||||||
base.setAlpha(progress);
|
base.setAlpha(progress);
|
||||||
}
|
}
|
||||||
MapControlsLayer.this.view.refreshMap();
|
MapControlsLayer.this.view.refreshMap();
|
||||||
showAndHideTransparencyBar(settingsToTransparency, transparencyLayers, SHOW_SEEKBAR_SECOND_DELAY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
android.widget.LinearLayout.LayoutParams prms = new LinearLayout.LayoutParams((int) (scaleCoefficient * 100),
|
||||||
|
LayoutParams.WRAP_CONTENT);
|
||||||
|
transparencyBarLayout.addView(transparencyBar, prms);
|
||||||
|
ImageButton imageButton = new ImageButton(view.getContext());
|
||||||
|
prms = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||||
|
prms.setMargins((int) (2 * scaleCoefficient), (int) (2 * scaleCoefficient), 0, 0);
|
||||||
|
imageButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
transparencyBarLayout.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
imageButton.setContentDescription(view.getContext().getString(R.string.close));
|
||||||
|
imageButton.setBackgroundResource(R.drawable.headliner_close);
|
||||||
|
transparencyBarLayout.addView(imageButton, prms);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showAndHideTransparencyBar(CommonPreference<Integer> transparenPreference,
|
public void showTransparencyBar(CommonPreference<Integer> transparenPreference,
|
||||||
BaseMapLayer[] layerToChange) {
|
BaseMapLayer[] layerToChange) {
|
||||||
showAndHideTransparencyBar(transparenPreference, layerToChange, SHOW_SEEKBAR_DELAY);
|
transparencyBarLayout.setVisibility(View.VISIBLE);
|
||||||
}
|
|
||||||
private void showAndHideTransparencyBar(CommonPreference<Integer> transparenPreference,
|
|
||||||
BaseMapLayer[] layerToChange, int delay) {
|
|
||||||
transparencyBar.setVisibility(View.VISIBLE);
|
|
||||||
transparencyBar.setProgress(transparenPreference.get());
|
transparencyBar.setProgress(transparenPreference.get());
|
||||||
this.transparencyLayers = layerToChange;
|
this.transparencyLayers = layerToChange;
|
||||||
this.settingsToTransparency = transparenPreference;
|
this.settingsToTransparency = transparenPreference;
|
||||||
Message msg = Message.obtain(showUIHandler, new Runnable() {
|
}
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
transparencyBar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
public void hideTransparencyBar(CommonPreference<Integer> transparenPreference) {
|
||||||
msg.what = SHOW_SEEKBAR_MSG_ID;
|
if(this.settingsToTransparency == transparenPreference) {
|
||||||
showUIHandler.removeMessages(SHOW_SEEKBAR_MSG_ID);
|
transparencyBarLayout.setVisibility(View.GONE);
|
||||||
showUIHandler.sendMessageDelayed(msg, delay);
|
this.settingsToTransparency = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
Osmand-kernel/skia/skia_library
Submodule
1
Osmand-kernel/skia/skia_library
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit 358eae7150db67e5f10071ebb229c5c5b02e6a07
|
Loading…
Reference in a new issue