summaryrefslogtreecommitdiff
path: root/core/java/android/webkit/WebTextView.java
diff options
context:
space:
mode:
authorLeon Scroggins <scroggo@google.com>2010-12-13 05:56:54 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-12-13 05:56:54 -0800
commitc5ab8b331d0383d928c57befb3829646adbab8a3 (patch)
tree70c2677295ac8e78c39cd1f6896c75d582350e29 /core/java/android/webkit/WebTextView.java
parent4e47e716d681b56f6ed2a262ddfd40e0c7a296f5 (diff)
parent6e9b327d08f48f0ae4f8b9eba49ad2f67fcb636c (diff)
Merge "Use drawLines to draw the outline of the WebTextView."
Diffstat (limited to 'core/java/android/webkit/WebTextView.java')
-rw-r--r--core/java/android/webkit/WebTextView.java51
1 files changed, 43 insertions, 8 deletions
diff --git a/core/java/android/webkit/WebTextView.java b/core/java/android/webkit/WebTextView.java
index e1a5c2df0872..18a0bda6c7f3 100644
--- a/core/java/android/webkit/WebTextView.java
+++ b/core/java/android/webkit/WebTextView.java
@@ -921,24 +921,59 @@ import junit.framework.Assert;
* Private class used for the background of a password textfield.
*/
private static class OutlineDrawable extends Drawable {
+ private Paint mBackgroundPaint;
+ private Paint mOutlinePaint;
+ private float[] mLines;
+ public OutlineDrawable() {
+ mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mBackgroundPaint.setColor(Color.WHITE);
+
+ mOutlinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
+ mOutlinePaint.setColor(Color.BLACK);
+ mOutlinePaint.setStyle(Paint.Style.STROKE);
+
+ mLines = new float[16];
+ }
+ @Override
+ public void setBounds(int left, int top, int right, int bottom) {
+ super.setBounds(left, top, right, bottom);
+ // Top line
+ mLines[0] = left;
+ mLines[1] = top + 1;
+ mLines[2] = right;
+ mLines[3] = top + 1;
+ // Right line
+ mLines[4] = right;
+ mLines[5] = top;
+ mLines[6] = right;
+ mLines[7] = bottom;
+ // Bottom line
+ mLines[8] = left;
+ mLines[9] = bottom;
+ mLines[10] = right;
+ mLines[11] = bottom;
+ // Left line
+ mLines[12] = left + 1;
+ mLines[13] = top;
+ mLines[14] = left + 1;
+ mLines[15] = bottom;
+ }
+ @Override
public void draw(Canvas canvas) {
- Rect bounds = getBounds();
- Paint paint = new Paint();
- paint.setAntiAlias(true);
// Draw the background.
- paint.setColor(Color.WHITE);
- canvas.drawRect(bounds, paint);
+ canvas.drawRect(getBounds(), mBackgroundPaint);
// Draw the outline.
- paint.setStyle(Paint.Style.STROKE);
- paint.setColor(Color.BLACK);
- canvas.drawRect(bounds, paint);
+ canvas.drawLines(mLines, mOutlinePaint);
}
// Always want it to be opaque.
+ @Override
public int getOpacity() {
return PixelFormat.OPAQUE;
}
// These are needed because they are abstract in Drawable.
+ @Override
public void setAlpha(int alpha) { }
+ @Override
public void setColorFilter(ColorFilter cf) { }
}