Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore zoom FABs elevation in onConfigurationChange #2447

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
Loading