зеркало из https://github.com/mozilla/gecko-dev.git
Bug 779930: Reflect the images for RTL. [r=wesj, r=mfinkle]
--HG-- extra : rebase_source : 7f5dc4524f3f049c2031fa78f8c13469bffee649
This commit is contained in:
Родитель
a982934db3
Коммит
af1dfafcd4
|
@ -947,6 +947,8 @@ MOZ_ANDROID_DRAWABLES += \
|
|||
mobile/android/base/resources/drawable/awesomebar_tab_unselected.xml \
|
||||
mobile/android/base/resources/drawable/desktop_notification.png \
|
||||
mobile/android/base/resources/drawable/highlight.xml \
|
||||
mobile/android/base/resources/drawable/handle_end_level.xml \
|
||||
mobile/android/base/resources/drawable/handle_start_level.xml \
|
||||
mobile/android/base/resources/drawable/menu_button.xml \
|
||||
mobile/android/base/resources/drawable/menu_item_checkmark.xml \
|
||||
mobile/android/base/resources/drawable/menu_level.xml \
|
||||
|
|
|
@ -105,6 +105,7 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||
}
|
||||
});
|
||||
} else if (event.equals("TextSelection:PositionHandles")) {
|
||||
final boolean rtl = message.getBoolean("rtl");
|
||||
final JSONArray positions = message.getJSONArray("positions");
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
|
@ -116,7 +117,7 @@ class TextSelection extends Layer implements GeckoEventListener {
|
|||
|
||||
TextSelectionHandle handle = getHandle(position.getString("handle"));
|
||||
handle.setVisibility(position.getBoolean("hidden") ? View.GONE : View.VISIBLE);
|
||||
handle.positionFromGecko(left, top);
|
||||
handle.positionFromGecko(left, top, rtl);
|
||||
}
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
|
|
|
@ -31,12 +31,16 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
|
||||
private int mLeft;
|
||||
private int mTop;
|
||||
private boolean mIsRTL;
|
||||
private PointF mGeckoPoint;
|
||||
private int mTouchStartX;
|
||||
private int mTouchStartY;
|
||||
|
||||
private RelativeLayout.LayoutParams mLayoutParams;
|
||||
|
||||
private static final int IMAGE_LEVEL_LTR = 0;
|
||||
private static final int IMAGE_LEVEL_RTL = 1;
|
||||
|
||||
TextSelectionHandle(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setOnTouchListener(this);
|
||||
|
@ -51,6 +55,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
else
|
||||
mHandleType = HandleType.END;
|
||||
|
||||
mIsRTL = false;
|
||||
mGeckoPoint = new PointF(0.0f, 0.0f);
|
||||
|
||||
mWidth = getResources().getDimensionPixelSize(R.dimen.text_selection_handle_width);
|
||||
|
@ -97,13 +102,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
return;
|
||||
}
|
||||
// Send x coordinate on the right side of the start handle, left side of the end handle.
|
||||
float left = (float) mLeft;
|
||||
if (mHandleType.equals(HandleType.START))
|
||||
left += mWidth - mShadow;
|
||||
else if (mHandleType.equals(HandleType.MIDDLE))
|
||||
left += (float) ((mWidth - mShadow) / 2);
|
||||
else
|
||||
left += mShadow;
|
||||
float left = (float) mLeft + adjustLeftForHandle();
|
||||
|
||||
PointF geckoPoint = new PointF(left, (float) mTop);
|
||||
geckoPoint = layerView.convertViewPointToLayerPoint(geckoPoint);
|
||||
|
@ -121,7 +120,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
setLayoutPosition();
|
||||
}
|
||||
|
||||
void positionFromGecko(int left, int top) {
|
||||
void positionFromGecko(int left, int top, boolean rtl) {
|
||||
LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||
if (layerView == null) {
|
||||
Log.e(LOGTAG, "Can't position handle because layerView is null");
|
||||
|
@ -129,6 +128,11 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
}
|
||||
|
||||
mGeckoPoint = new PointF((float) left, (float) top);
|
||||
if (mIsRTL != rtl) {
|
||||
mIsRTL = rtl;
|
||||
setImageLevel(mIsRTL ? IMAGE_LEVEL_RTL : IMAGE_LEVEL_LTR);
|
||||
}
|
||||
|
||||
ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
|
||||
repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
|
||||
}
|
||||
|
@ -137,19 +141,21 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||
PointF viewPoint = new PointF((mGeckoPoint.x * zoom) - x,
|
||||
(mGeckoPoint.y * zoom) - y);
|
||||
|
||||
mLeft = Math.round(viewPoint.x);
|
||||
if (mHandleType.equals(HandleType.START))
|
||||
mLeft -= mWidth - mShadow;
|
||||
else if (mHandleType.equals(HandleType.MIDDLE))
|
||||
mLeft -= (float) ((mWidth - mShadow) / 2);
|
||||
else
|
||||
mLeft -= mShadow;
|
||||
|
||||
mLeft = Math.round(viewPoint.x) - (int) adjustLeftForHandle();
|
||||
mTop = Math.round(viewPoint.y);
|
||||
|
||||
setLayoutPosition();
|
||||
}
|
||||
|
||||
private float adjustLeftForHandle() {
|
||||
if (mHandleType.equals(HandleType.START))
|
||||
return mIsRTL ? mShadow : mWidth - mShadow;
|
||||
else if (mHandleType.equals(HandleType.MIDDLE))
|
||||
return (float) ((mWidth - mShadow) / 2);
|
||||
else
|
||||
return mIsRTL ? mWidth - mShadow : mShadow;
|
||||
}
|
||||
|
||||
private void setLayoutPosition() {
|
||||
if (mLayoutParams == null) {
|
||||
mLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- LTR -->
|
||||
<item android:maxLevel="0" android:drawable="@drawable/handle_end"/>
|
||||
|
||||
<!-- RTL -->
|
||||
<item android:maxLevel="1" android:drawable="@drawable/handle_start"/>
|
||||
|
||||
</level-list>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<!-- LTR -->
|
||||
<item android:maxLevel="0" android:drawable="@drawable/handle_start"/>
|
||||
|
||||
<!-- RTL -->
|
||||
<item android:maxLevel="1" android:drawable="@drawable/handle_end"/>
|
||||
|
||||
</level-list>
|
|
@ -10,7 +10,7 @@
|
|||
<org.mozilla.gecko.TextSelectionHandle android:id="@+id/start_handle"
|
||||
android:layout_width="@dimen/text_selection_handle_width"
|
||||
android:layout_height="@dimen/text_selection_handle_height"
|
||||
android:src="@drawable/handle_start"
|
||||
android:src="@drawable/handle_start_level"
|
||||
android:visibility="gone"
|
||||
gecko:handleType="start"/>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
|||
<org.mozilla.gecko.TextSelectionHandle android:id="@+id/end_handle"
|
||||
android:layout_width="@dimen/text_selection_handle_width"
|
||||
android:layout_height="@dimen/text_selection_handle_height"
|
||||
android:src="@drawable/handle_end"
|
||||
android:src="@drawable/handle_end_level"
|
||||
android:visibility="gone"
|
||||
gecko:handleType="end"/>
|
||||
</merge>
|
||||
|
|
|
@ -2080,7 +2080,8 @@ var SelectionHandler = {
|
|||
sendMessageToJava({
|
||||
gecko: {
|
||||
type: "TextSelection:PositionHandles",
|
||||
positions: positions
|
||||
positions: positions,
|
||||
rtl: this._isRTL
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче