Class DynamicCodeUtils
java.lang.Object
com.pranavpandey.android.dynamic.theme.util.DynamicCodeUtils
Helper class to perform theme code operations.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFormat data to suitable for the code.static BitmapgenerateCode(CodeTheme<?> theme, Drawable overlay) Generates a QR Code from the dynamic theme.static BitmapgenerateCode(CodeTheme<?> theme, String data, Drawable overlay) Generates a QR Code from the dynamic theme.static BitmapgenerateThemeCode(AppTheme<?> theme, Drawable overlay) Generates a QR Code for the dynamic theme data.static DrawablegetCornerDrawable(float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawable(int width, int height, float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawableWithStroke(float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawableWithStroke(float cornerRadius, int color, boolean topOnly, float strokeSize, int strokeColor) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawableWithStroke(int width, int height, float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawableWithStroke(int width, int height, float cornerRadius, int color, boolean topOnly, float strokeSize, int strokeColor) Returns a corner drawable according to the supplied parameters.static DrawablegetCornerDrawableWithStroke(int width, int height, float cornerRadius, int color, boolean topOnly, int strokeColor) Returns a corner drawable according to the supplied parameters.static ErrorCorrectionLevelgetErrorCorrectionLevel(String content) Returns the error correction level according to the supplied content.static PaintgetPaint(int style) Returns the paint according to the supplied code style.static StringScans the dynamic theme QR Code.static ResultScans the code for the result.
-
Field Details
-
PATTERN_LINE_BREAK
Constant for the line break.- See Also:
-
PATTERN_QUOTES
Pattern to replace extra quotes.- See Also:
-
PATTERN_SPACE
Pattern to replace white space.- See Also:
-
LINE_BREAK
Constant to render line break.- See Also:
-
-
Constructor Details
-
DynamicCodeUtils
public DynamicCodeUtils()
-
-
Method Details
-
format
Format data to suitable for the code.- Parameters:
data- The data to be formatted.- Returns:
- The formatted data suitable for the code.
-
getErrorCorrectionLevel
Returns the error correction level according to the supplied content.- Parameters:
content- The content to be used.- Returns:
- The error correction level according to the supplied content.
-
getPaint
Returns the paint according to the supplied code style.- Parameters:
style- The code style to be used.- Returns:
- The paint according to the supplied code style.
-
getCornerDrawable
@NonNull public static Drawable getCornerDrawable(int width, int height, float cornerRadius, @ColorInt int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawable
@NonNull public static Drawable getCornerDrawable(float cornerRadius, @ColorInt int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.- Parameters:
cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawableWithStroke
@NonNull public static Drawable getCornerDrawableWithStroke(int width, int height, float cornerRadius, @ColorInt int color, boolean topOnly, float strokeSize, @ColorInt int strokeColor) Returns a corner drawable according to the supplied parameters.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.strokeSize- The sizegreater than 0in dip to enable the stroke.strokeColor- The color for the stroke.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawableWithStroke
@NonNull public static Drawable getCornerDrawableWithStroke(int width, int height, float cornerRadius, @ColorInt int color, boolean topOnly, @ColorInt int strokeColor) Returns a corner drawable according to the supplied parameters.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.strokeColor- The color for the stroke.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawableWithStroke
@NonNull public static Drawable getCornerDrawableWithStroke(int width, int height, float cornerRadius, @ColorInt int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.- Parameters:
width- The width in dip for the drawable.height- The height in dip for the drawable.cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawableWithStroke
@NonNull public static Drawable getCornerDrawableWithStroke(float cornerRadius, @ColorInt int color, boolean topOnly, float strokeSize, @ColorInt int strokeColor) Returns a corner drawable according to the supplied parameters.- Parameters:
cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.strokeSize- The sizegreater than 0in dip to enable the stroke.strokeColor- The color for the stroke.- Returns:
- The corner drawable according to the supplied parameters.
-
getCornerDrawableWithStroke
@NonNull public static Drawable getCornerDrawableWithStroke(float cornerRadius, @ColorInt int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.- Parameters:
cornerRadius- The corner size in dip for the drawable.color- The color for the drawable.topOnly-trueto round the top corners only.- Returns:
- The corner drawable according to the supplied parameters.
-
scanCode
Scans the code for the result.- Parameters:
bitmap- The bitmap to be scanned.- Returns:
- The result from the code.
-
getTheme
Scans the dynamic theme QR Code.- Parameters:
bitmap- The bitmap to be scanned.- Returns:
- The dynamic theme string from the QR Code bitmap.
-