Restoring transparency bar.

This commit is contained in:
GaidamakUA 2016-02-08 17:04:27 +02:00
parent 235795a04c
commit 500216c9fb
3 changed files with 89 additions and 1 deletions

View file

@ -62,6 +62,29 @@
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"

View file

@ -10,6 +10,7 @@ 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.activities.MapActivityLayers;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
import net.osmand.plus.views.MapTileLayer;
@ -50,6 +51,12 @@ public class RasterMapMenu {
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) {
MapActivityLayers mapLayers = mapActivity.getMapLayers();
if (isChecked) {
mapLayers.getMapControlsLayer().showTransparencyBar(mapTransparencyPreference);
} else {
mapLayers.getMapControlsLayer().hideTransparencyBar(mapTransparencyPreference);
}
plugin.toggleUnderlayState(mapActivity, type);
}
return false;

View file

@ -17,7 +17,10 @@ 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;
@ -65,6 +68,8 @@ 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;
@ -104,6 +109,7 @@ public class MapControlsLayer extends OsmandMapLayer {
@Override
public void initLayer(final OsmandMapTileView view) {
initTopControls();
initTransparencyBar();
initZooms();
initDasboardRelatedControls();
updateControls(view.getCurrentRotatedTileBox(), null);
@ -313,7 +319,7 @@ public class MapControlsLayer extends OsmandMapLayer {
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
} else {
ActivityCompat.requestPermissions(mapActivity,
new String[] { Manifest.permission.ACCESS_FINE_LOCATION },
new String[]{Manifest.permission.ACCESS_FINE_LOCATION},
OsmAndLocationProvider.REQUEST_LOCATION_PERMISSION);
}
}
@ -586,6 +592,58 @@ 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;