Class DynamicCodeUtils
java.lang.Object
com.pranavpandey.android.dynamic.theme.util.DynamicCodeUtils
Helper class to perform theme code operations.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Format data to suitable for the code.static Bitmap
generateCode
(CodeTheme<?> theme, Drawable overlay) Generates a QR Code from the dynamic theme.static Bitmap
generateCode
(CodeTheme<?> theme, String data, Drawable overlay) Generates a QR Code from the dynamic theme.static Bitmap
generateThemeCode
(AppTheme<?> theme, Drawable overlay) Generates a QR Code for the dynamic theme data.static Drawable
getCornerDrawable
(float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawable
(int width, int height, float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawableWithStroke
(float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawableWithStroke
(float cornerRadius, int color, boolean topOnly, float strokeSize, int strokeColor) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawableWithStroke
(int width, int height, float cornerRadius, int color, boolean topOnly) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawableWithStroke
(int width, int height, float cornerRadius, int color, boolean topOnly, float strokeSize, int strokeColor) Returns a corner drawable according to the supplied parameters.static Drawable
getCornerDrawableWithStroke
(int width, int height, float cornerRadius, int color, boolean topOnly, int strokeColor) Returns a corner drawable according to the supplied parameters.static ErrorCorrectionLevel
getErrorCorrectionLevel
(String content) Returns the error correction level according to the supplied content.static Paint
getPaint
(int style) Returns the paint according to the supplied code style.static String
Scans the dynamic theme QR Code.static Result
Scans 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
-true
to 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
-true
to 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
-true
to round the top corners only.strokeSize
- The sizegreater than 0
in 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
-true
to 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
-true
to 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
-true
to round the top corners only.strokeSize
- The sizegreater than 0
in 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
-true
to 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.
-