Skip to content

Commit

Permalink
Merge branch 'fix_loss_of_fab_elevation'
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Dec 5, 2023
2 parents 4565b91 + 539f745 commit 310a21a
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/main/java/de/blau/android/views/ZoomControls.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Configuration;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.MotionEvent;
Expand All @@ -22,11 +24,16 @@

public class ZoomControls extends LinearLayout {

private static final String DEBUG_TAG = ZoomControls.class.getSimpleName();

private final FloatingActionButton zoomIn;
private final FloatingActionButton zoomOut;

private final Context context;

private float elevationIn = -1f;
private float elevationOut = -1f;

/**
* Construct a new zoom control view
*
Expand Down Expand Up @@ -130,4 +137,21 @@ private void setEnabled(@NonNull FloatingActionButton fab, boolean isEnabled) {
ThemeUtils.getStyleAttribColorValue(context, isEnabled ? R.attr.colorControlNormal : R.attr.colorPrimary, R.color.dark_grey));
}
}
}

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (elevationIn < 0f) {
elevationIn = zoomIn.getElevation();
elevationOut = zoomOut.getElevation();
}
}

@Override
protected void onConfigurationChanged(Configuration newConfig) {
// this is a workaround for https://github.com/MarcusWolschon/osmeditor4android/issues/965
Log.d(DEBUG_TAG, "onConfigurationChanged " + elevationIn + " " + elevationOut);
zoomIn.setElevation(elevationIn);
zoomOut.setElevation(elevationOut);
}
}

0 comments on commit 310a21a

Please sign in to comment.