Class PWAManifest

java.lang.Object
com.iizix.pwa.PWAManifest

public final class PWAManifest extends Object
The web app manifest of an installable application, one per language (PWA-DESIGN.md 3.2, order CC-PWA-V5B-MANIFEST), served as /app/<appID>/manifest-<lang>.webmanifest (or manifest.webmanifest for an application without languages, ruling PW-3) by the application directory (order V5-E, which calls this class).

Every text and colour comes from the App (ModuleApp): name, description, colours (ruling AU-9 = T1-130: the former name, $descr and localized of .iiziPWA duplicated the App and already disagreed with it in apps\icu; the App wins). The .iiziPWA file (PWAProps) is the switch - absent, there is no manifest - and since CC-PUSH-PWA-PAGES Set I the owner of what the App does not have: the icons (PWAIcons, ruling PX-1), the categories (ruling PM-4: the iiziRun page's list, written as the W3C names of CATEGORIES) and the orientation (ORIENTATIONS). lang is the page's language and dir is rtl for a right-to-left language (ruling PM-1); screenshots lists the designer's files of the PWA folder (PWAScreenshots, ruling PM-2).

id and scope are /app/<appID>/ in every language, so switching the language never makes a second installation. start_url comes from getStartURL(String,String) alone, the one method ruling AU-1's fallback C would change.

A member without a value is omitted, never written empty. Members are written in a fixed order, so the same App gives the same bytes (the directory stamp hashes them).

Author:
Christopher Mindus
  • Field Details

    • APP_PATH_PREFIX

      public static final String APP_PATH_PREFIX
      The path of the application directory before the application ID.
      See Also:
    • MEDIA_TYPE

      public static final String MEDIA_TYPE
      The media type of the manifest.
      See Also:
    • DISPLAY

      public static final String DISPLAY
      The display mode. standalone is what P4-01 measured Push with on iPadOS; the display member of .iiziPWA is v5.1 (PR-3).
      See Also:
    • DEFAULT_THEME_COLOR

      public static final String DEFAULT_THEME_COLOR
      The theme_color when the App has no opaque themeColor: --iz-bg2 of the default family (IIZI), light, in iz/css/iiziThemes.css.
      See Also:
    • DEFAULT_BACKGROUND_COLOR

      public static final String DEFAULT_BACKGROUND_COLOR
      The background_color when the App has neither an opaque iconBG nor an opaque themeColor: --iz-bg of the default family (IIZI), light.
      See Also:
    • ORIENTATIONS

      public static final String[] ORIENTATIONS
      The orientation values by the index .iiziPWA stores (PWAProps.ORIENTATION_PROPNAME): 0 writes no member.
    • CATEGORY_NAMES

      public static final String[] CATEGORY_NAMES
      The category names of the iiziRun page (com.iizigo.run EditableProps0.properties, app_category), by the index .iiziPWA stores (PWAProps.CATEGORY_PROPNAME); the PWA page offers the same list (ruling PM-4). Index 0 is none.
    • CATEGORIES

      public static final String[][] CATEGORIES
      The W3C manifest categories written for each entry of CATEGORY_NAMES (the W3C "Manifest App Categories" list: books, business, education, entertainment, finance, fitness, food, games, government, health, kids, lifestyle, magazines, medical, music, navigation, news, personalization, photo, politics, productivity, security, shopping, social, sports, travel, utilities, weather). Three iiziRun categories have no W3C name of their own and take the nearest: Developer Tools = utilities, Graphics invalid input: '&' Design = productivity, Video = entertainment.
    • FILE_NAME_NO_LANGUAGE

      public static final String FILE_NAME_NO_LANGUAGE
      The file name of the one manifest of an application without languages: "manifest.webmanifest".
      See Also:
  • Method Details

    • getScope

      public static String getScope(String appID)
      Gets the scope of an application, which is also its manifest id.
      Parameters:
      appID - The application ID, already validated by the caller.
      Returns:
      /app/<appID>/.
    • getStartURL

      public static String getStartURL(String appID, String lang)
      Gets the start URL of an application for a language. This is the ONE place the entry URL of an installed application is formed: ruling AU-1's fallback C (?0:0&app=<appID>&lang=) would change this method and nothing else.
      Parameters:
      appID - The application ID, already validated by the caller.
      lang - The language code, or null or empty for none.
      Returns:
      /app/<appID>/?lang=<lang>, or /app/<appID>/ without a language.
    • getFileName

      public static String getFileName(String lang)
      Gets the file name of the manifest for a language, relative to the application directory: manifest-<lang>.webmanifest, and FILE_NAME_NO_LANGUAGE for an application without languages (ruling PW-3: never manifest-.webmanifest). The page's link (PWAHeadTags) and the route (AppDirectoryHandler) both use this name.
      Parameters:
      lang - The language code, null or empty for none.
      Returns:
      The file name.
    • isInstallable

      public static boolean isInstallable(PWAProps pwa)
      Checks whether an application is installable: its .iiziPWA is present. Presence is the whole test (AU-9).
      Parameters:
      pwa - The application's PWA properties, or null when it has no .iiziPWA.
      Returns:
      true when installable.
    • generate

      public static String generate(ModuleApp app, PWAProps pwa, String appID, String lang, PWAIcons icons)
      Generates the manifest of an application for a language.
      Parameters:
      app - The App.
      pwa - The application's PWA properties, null when it has no .iiziPWA; only its presence is used.
      appID - The application ID, already validated by the caller.
      lang - The language code of this manifest.
      icons - The icons, or null when the application has none (then the manifest has no icons member).
      Returns:
      The manifest as JSON text, or null when the application is not installable.
    • generate

      public static String generate(ModuleApp app, PWAProps pwa, String appID, String lang, PWAIcons icons, List<PWAScreenshots.Shot> screenshots)
      Generates the manifest of an application for a language, with its screenshots.
      Parameters:
      app - The App.
      pwa - The application's PWA properties, null when it has no .iiziPWA; its category and orientation are written.
      appID - The application ID, already validated by the caller.
      lang - The language code of this manifest, null or empty for none: then lang and dir are omitted.
      icons - The icons, or null when the application has none: every file the icons hold is listed with its purpose.
      screenshots - The screenshots, empty for none.
      Returns:
      The manifest as JSON text, or null when the application is not installable.
    • isRightToLeft

      public static boolean isRightToLeft(String lang)
      Tests whether a language is written right to left (ruling PM-1: the manifest's dir and the page's <html dir>): Arabic, Persian, Hebrew, Urdu, Yiddish and their aliases, as ComponentOrientation.getOrientation(Locale) knows them.
      Parameters:
      lang - The language code, a BCP 47 tag such as ar or he-IL.
      Returns:
      true for a right-to-left language.
    • getThemeColor

      public static String getThemeColor(ModuleApp app)
      Gets the theme_color: the App's opaque themeColor (a referenced colour resolved for the light scheme, PWAIcons.opaque(ModuleApp,GColor,String)), else DEFAULT_THEME_COLOR.
      Parameters:
      app - The App.
      Returns:
      The CSS colour.
    • getBackgroundColor

      public static String getBackgroundColor(ModuleApp app)
      Gets the background_color, the splash background on Android: the App's opaque iconBG, else its opaque themeColor (a referenced colour resolved for the light scheme), else DEFAULT_BACKGROUND_COLOR.
      Parameters:
      app - The App.
      Returns:
      The CSS colour.