Class DynamicCodeUtils

java.lang.Object
com.pranavpandey.android.dynamic.theme.util.DynamicCodeUtils

public class DynamicCodeUtils extends Object
Helper class to perform theme code operations.
  • Field Details

  • Constructor Details

    • DynamicCodeUtils

      public DynamicCodeUtils()
  • Method Details

    • format

      @Nullable public static String format(@Nullable String data)
      Format data to suitable for the code.
      Parameters:
      data - The data to be formatted.
      Returns:
      The formatted data suitable for the code.
    • getErrorCorrectionLevel

      @NonNull public static ErrorCorrectionLevel getErrorCorrectionLevel(@Nullable String content)
      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

      @NonNull public static Paint getPaint(int style)
      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 size greater 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 size greater 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.
    • generateCode

      @Nullable public static Bitmap generateCode(@Nullable CodeTheme<?> theme, @Nullable String data, @Nullable Drawable overlay)
      Generates a QR Code from the dynamic theme.
      Parameters:
      theme - The theme to generate the QR Code.
      data - The data for the QR Code.
      overlay - The optional QR Code overlay.
      Returns:
      The generated QR Code from the dynamic theme.
    • generateCode

      @Nullable public static Bitmap generateCode(@Nullable CodeTheme<?> theme, @Nullable Drawable overlay)
      Generates a QR Code from the dynamic theme.
      Parameters:
      theme - The theme to generate the QR Code.
      overlay - The optional QR Code overlay.
      Returns:
      The generated QR Code from the dynamic theme.
      See Also:
    • generateThemeCode

      @Nullable public static Bitmap generateThemeCode(@Nullable AppTheme<?> theme, @Nullable Drawable overlay)
      Generates a QR Code for the dynamic theme data.
      Parameters:
      theme - The theme to generate the QR Code.
      overlay - The optional QR Code overlay.
      Returns:
      The generated QR Code for the dynamic theme data.
      See Also:
    • scanCode

      @Nullable public static Result scanCode(@Nullable Bitmap bitmap)
      Scans the code for the result.
      Parameters:
      bitmap - The bitmap to be scanned.
      Returns:
      The result from the code.
    • getTheme

      @Nullable public static String getTheme(@Nullable Bitmap bitmap)
      Scans the dynamic theme QR Code.
      Parameters:
      bitmap - The bitmap to be scanned.
      Returns:
      The dynamic theme string from the QR Code bitmap.