forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce ChromeBulletSpan and use on incognito NTP, sad tab
Move the existing SadTabBulletSpan to a new ui/widget/../ChromeBulletSpan.java and re-use for the material design incognito NTP. This fixes a text wrapping issues caused by the bullet previously being included in the text string. BUG=740619,740619 Change-Id: I172ee3e388962efc90d0defe01525828491883cf Reviewed-on: https://chromium-review.googlesource.com/c/1277376 Reviewed-by: Ted Choc <tedchoc@chromium.org> Commit-Queue: Theresa <twellington@chromium.org> Cr-Commit-Position: refs/heads/master@{#598870}
- Loading branch information
Theresa
authored and
Commit Bot
committed
Oct 11, 2018
1 parent
8bc49ae
commit 91645e3
Showing
6 changed files
with
53 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ui/android/java/src/org/chromium/ui/widget/ChromeBulletSpan.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2018 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package org.chromium.ui.widget; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.text.Layout; | ||
import android.text.style.BulletSpan; | ||
|
||
import org.chromium.ui.R; | ||
|
||
/** | ||
* A wrapper around Android's BulletSpan that provides default styling and adjusts the bullet | ||
* positioning to prevent it from being cut off. | ||
*/ | ||
public class ChromeBulletSpan extends BulletSpan { | ||
private int mXOffset; | ||
|
||
/** | ||
* Construts a new ChromeBuletSpan. | ||
* @param context The context of the containing view, used to retrieve dimensions. | ||
*/ | ||
public ChromeBulletSpan(Context context) { | ||
super(context.getResources().getDimensionPixelSize(R.dimen.chrome_bullet_gap)); | ||
mXOffset = | ||
context.getResources().getDimensionPixelSize(R.dimen.chrome_bullet_leading_offset); | ||
} | ||
|
||
@Override | ||
public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, | ||
int bottom, CharSequence text, int start, int end, boolean first, Layout l) { | ||
// Android cuts off the bullet points. Adjust the x-position so that the bullets aren't | ||
// cut off. | ||
super.drawLeadingMargin( | ||
c, p, x + mXOffset, dir, top, baseline, bottom, text, start, end, first, l); | ||
} | ||
} |