mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1266369 - FloatingToolbarTextSelection: Add an offset to the content rect to avoid overlap. r=ahunt
MozReview-Commit-ID: HNkTOAS7toJ --HG-- extra : rebase_source : abac9b07dc349624139b241dfaed708be7b0b6f6
This commit is contained in:
parent
788773e232
commit
e3ba50f742
@ -9,6 +9,7 @@ import android.app.Activity;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ActionMode;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -33,9 +34,14 @@ import ch.boye.httpclientandroidlib.util.TextUtils;
|
||||
public class FloatingToolbarTextSelection implements TextSelection, GeckoEventListener {
|
||||
private static final String LOGTAG = "GeckoFloatTextSelection";
|
||||
|
||||
// This is an additional offset we add to the height of the selection. This will avoid that the
|
||||
// floating toolbar overlays the bottom handle(s).
|
||||
private static final int HANDLES_OFFSET_DP = 20;
|
||||
|
||||
private final Activity activity;
|
||||
private final LayerView layerView;
|
||||
private final int[] locationInWindow;
|
||||
private final float handlesOffset;
|
||||
|
||||
private ActionMode actionMode;
|
||||
private FloatingActionModeCallback actionModeCallback;
|
||||
@ -46,6 +52,9 @@ public class FloatingToolbarTextSelection implements TextSelection, GeckoEventLi
|
||||
this.activity = activity;
|
||||
this.layerView = layerView;
|
||||
this.locationInWindow = new int[2];
|
||||
|
||||
this.handlesOffset = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
|
||||
HANDLES_OFFSET_DP, activity.getResources().getDisplayMetrics());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -187,7 +196,7 @@ public class FloatingToolbarTextSelection implements TextSelection, GeckoEventLi
|
||||
(int) (x * zoomFactor + locationInWindow[0]),
|
||||
(int) (y * zoomFactor + locationInWindow[1] + layerView.getSurfaceTranslation()),
|
||||
(int) ((x + width) * zoomFactor + locationInWindow[0]),
|
||||
(int) ((y + height) * zoomFactor + locationInWindow[1] + layerView.getSurfaceTranslation()));
|
||||
(int) ((y + height) * zoomFactor + locationInWindow[1] + layerView.getSurfaceTranslation() + handlesOffset));
|
||||
} catch (JSONException e) {
|
||||
Log.w(LOGTAG, "Could not calculate content rect", e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user