Class EmailBrand

java.lang.Object
io.meeds.portal.mail.model.EmailBrand

public final class EmailBrand extends Object
The brand an email is dressed in: the company name and the primary color of the site, with the text color that stays readable on it
  • Field Details

    • DEFAULT_COLOR

      public static final String DEFAULT_COLOR
      Used when the site has no valid primary color: the default primary color of the platform theme
      See Also:
    • DEFAULT_RADIUS

      public static final String DEFAULT_RADIUS
      Used when the site has no valid border radius, as the platform does
      See Also:
    • DEFAULT_FONT_FAMILY

      public static final String DEFAULT_FONT_FAMILY
      Used when the site has no valid font, the default font of the platform
      See Also:
  • Constructor Details

    • EmailBrand

      public EmailBrand(String companyName, String primaryColor)
      Parameters:
      companyName - the name shown in the header of the email
      primaryColor - a #rgb, #rrggbb or #rrggbbaa color (the alpha is dropped); anything else, a css injection attempt included, is replaced by DEFAULT_COLOR
    • EmailBrand

      public EmailBrand(String companyName, String primaryColor, String fontFamily, String borderRadius)
      Parameters:
      companyName - the name shown in the header of the email
      primaryColor - the main color of the site, as #rgb, #rrggbb or #rrggbbaa
      fontFamily - the font of the platform branding; the default font of the platform when it is not a font name
      borderRadius - the rounding of its buttons, from 0px to 29px; DEFAULT_RADIUS otherwise
  • Method Details

    • current

      public static EmailBrand current()
      The brand of the site, for a template that has no branding service at hand; the default brand when the site cannot be reached. The brand is kept a few seconds, so that the many helper calls of one rendering (and of the emails sent in a row) read the theme once. A branding saved in the meantime shows in the emails after at most CACHE_MILLIS milliseconds (five seconds).
    • clearCache

      public static void clearCache()
      Forgets the brand kept by current(), so that the next call reads the theme again
    • from

      public static EmailBrand from(org.exoplatform.portal.branding.BrandingService brandingService)
    • getCompanyName

      public String getCompanyName()
    • getColor

      public String getColor()
      Returns:
      the primary color as #rrggbb
    • getFillColor

      public String getFillColor()
      Returns:
      the primary color as it is painted behind text (the header and the buttons): the color itself, or the nearest one that white text can be read on
    • getFontFamily

      public String getFontFamily()
      Returns:
      the font of the platform branding, for the stack of fonts of the email: its name, as the administrator chose it in the branding
    • getFontStack

      public String getFontStack()
      Returns:
      the font of the platform branding first, then the fonts that every mail client has: the email asks for the platform font and takes Arial when the client does not have it; nothing is loaded from a third party, so a client that has not the font shows Arial
    • getOutlineColor

      public String getOutlineColor()
      Returns:
      the primary color, darkened as much as needed (and not more) to be seen as the outline of an outlined button on white: at least 3:1
    • getLinkColor

      public String getLinkColor()
      Returns:
      the primary color, darkened as much as needed (and not more) to be read as the text of a link on white: at least 4.5:1
    • getRadius

      public String getRadius()
      Returns:
      the rounding of the buttons, such as 8px
    • getTextColor

      public String getTextColor()
      Returns:
      the color of the text on the primary color (the company name and the title of the header, the label of a button): always white, in light and in dark mode. It is the fill that moves, so that white reads on it (getFillColor())