This repository has been archived by the owner on Sep 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 517
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #189 from sunny52525/blockquote-style
added blockquote styling feature
- Loading branch information
Showing
9 changed files
with
129 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,4 +22,5 @@ publish { | |
|
||
dependencies { | ||
implementation 'androidx.annotation:annotation:1.1.0' | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
HtmlTextView/src/main/java/org/sufficientlysecure/htmltextview/DesignQuoteSpan.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,73 @@ | ||
package org.sufficientlysecure.htmltextview; | ||
|
||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.text.Layout; | ||
import android.text.style.LeadingMarginSpan; | ||
import android.text.style.LineBackgroundSpan; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
public class DesignQuoteSpan implements LeadingMarginSpan, LineBackgroundSpan { | ||
|
||
private int backgroundColor,stripColor; | ||
private float stripeWidth,gap; | ||
DesignQuoteSpan(int backgroundColor, | ||
int stripColor, | ||
float stripWidth, | ||
float gap){ | ||
|
||
this.backgroundColor=backgroundColor; | ||
this.stripColor=stripColor; | ||
this.stripeWidth=stripWidth; | ||
this.gap=gap; | ||
|
||
} | ||
|
||
@Override | ||
public int getLeadingMargin(boolean first) { | ||
return (int)(stripeWidth + gap); | ||
} | ||
|
||
@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 layout) { | ||
|
||
Paint.Style style=p.getStyle(); | ||
int paintColor=p.getColor(); | ||
p.setStyle(Paint.Style.FILL); | ||
p.setColor(stripColor); | ||
c.drawRect((float)x,(float)top,x+dir * stripeWidth,(float)bottom,p); | ||
p.setStyle(style); | ||
p.setColor(paintColor); | ||
|
||
} | ||
|
||
@Override | ||
public void drawBackground(@NonNull Canvas canvas, | ||
@NonNull Paint paint, | ||
int left, | ||
int right, | ||
int top, | ||
int baseline, | ||
int bottom, | ||
@NonNull CharSequence text, | ||
int start, | ||
int end, | ||
int lineNumber) { | ||
int paintColor=paint.getColor(); | ||
paint.setColor(backgroundColor); | ||
canvas.drawRect((float)left,(float)top,(float)right,(float)bottom,paint); | ||
paint.setColor(paintColor); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="black">#000000</color> | ||
<color name="White">#ffff</color> | ||
</resources> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="blue">#03DAC5</color> | ||
<color name="whitish">#ccc</color> | ||
</resources> |