mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1332258 - Reset text fading gradient to null when text direction changed, r=sebastian
MozReview-Commit-ID: EaUUO8aegzj --HG-- extra : rebase_source : 47c719ec9d464208c48191e96c1227d0333dc083
This commit is contained in:
parent
ad2ebb3255
commit
b67796ca12
@ -4,6 +4,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
package org.mozilla.gecko.util;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Build;
|
||||
import android.support.v4.text.TextUtilsCompat;
|
||||
@ -11,6 +12,7 @@ import android.support.v4.view.MarginLayoutParamsCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
import org.mozilla.gecko.R;
|
||||
@ -72,4 +74,25 @@ public class ViewUtil {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RTL compatibility wrapper to force set TextDirection for JB mr1 and above
|
||||
*
|
||||
* @param textView
|
||||
* @param isRtl
|
||||
*/
|
||||
public static void setTextDirectionRtlCompat(TextView textView, boolean isRtl) {
|
||||
if (AppConstants.Versions.feature17Plus) {
|
||||
setTextDirectionRtlCompat17(textView, isRtl);
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||
private static void setTextDirectionRtlCompat17(TextView textView, boolean isRtl) {
|
||||
if (isRtl) {
|
||||
textView.setTextDirection(View.TEXT_DIRECTION_RTL);
|
||||
} else {
|
||||
textView.setTextDirection(View.TEXT_DIRECTION_LTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,12 @@ import android.graphics.Canvas;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Shader;
|
||||
import android.support.v4.text.BidiFormatter;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import org.mozilla.gecko.util.ViewUtil;
|
||||
|
||||
/**
|
||||
* Fades the end of the text by gecko:fadeWidth amount,
|
||||
* if the text is too long and requires an ellipsis.
|
||||
@ -49,10 +52,14 @@ public class FadedSingleColorTextView extends FadedTextView {
|
||||
@Override
|
||||
public void setText(CharSequence text, BufferType type) {
|
||||
super.setText(text, type);
|
||||
mIsTextDirectionRtl = BidiFormatter.getInstance().isRtl((String) text);
|
||||
if (mIsTextDirectionRtl) {
|
||||
setTextDirection(TEXT_DIRECTION_RTL);
|
||||
final boolean previousTextDirectionRtl = mIsTextDirectionRtl;
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
mIsTextDirectionRtl = BidiFormatter.getInstance().isRtl((String) text);
|
||||
}
|
||||
if (mIsTextDirectionRtl != previousTextDirectionRtl) {
|
||||
mTextGradient = null;
|
||||
}
|
||||
ViewUtil.setTextDirectionRtlCompat(this, mIsTextDirectionRtl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user