Package com.iizix.prop.ui.device
Class GThemes
java.lang.Object
com.iizix.prop.ui.device.GThemes
- All Implemented Interfaces:
Cloneable
This is a data holder class for UI themes, specifying UI type (desktop/mobile) and the themes that are selected or possible.
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The type: ANY.static final GThemes
The "ANY_MASK" themes mask, could replace a mask with "null" value (note: not the sameNONE
).static final GThemes
The default theme selection for desktop, i.e.static final GThemes
The default theme selection: allow all, both desktop and mobile.static final GThemes
The default theme selection for mobile, all default desktop theme and all mobile themes.static final GThemes
The default start-up theme for the app: Flat and iOS7+.static final int
The type: DESKTOP.static final GThemes
The default theme selection for any desktop theme and no mobile themes.static final int
The type: MOBILE.static final GThemes
The default theme selection for any mobile theme and no desktop themes.static final GThemes
The "NONE" themes mask when intersection is too narrow.Constructor Summary
ConstructorDescriptionGThemes
(int type, UIThemes.Name[] desktop, UIThemes.Name[] mobile) Creates a new instance of themes.Method Summary
Modifier and TypeMethodDescriptionvoid
append
(SendTransaction trans) Appends the themes to a transaction.computeIntersection
(GThemes mask) Computes the "intersection" of this mask and another one.boolean
contains
(UIThemes.Name name) Checks if the theme name is contained in this theme instances mask.The data string representation.boolean
Checks if two color objects are equal.static GThemes
from
(int type, UIThemes.Name[] desktop, UIThemes.Name[] mobile) Creates a new instance of themes or grabs a cached copy.static GThemes
from
(ReadTransaction trans) Creates a color from a transaction.static GThemes
Creates an instance of the themes from a string.static GThemes
fromDesktop
(UIThemes.Name name) Gets a cached desktop theme from a name using with no mobile themes.static GThemes
fromMobile
(UIThemes.Name name) Gets a cached mobile theme from a name using the default desktop name.Gets the desktop themes.Gets the mobile themes.boolean
Checks if this theme is for desktop.boolean
isMobile()
Checks if this theme is for mobile.boolean
Returns if this mask is a "null" mask, or a NONE mask.Returns the representation of the theme for the client to use.toString()
Returns a string representation of this class instance and its values.Verifies if the current theme is not "masked away" from its initial intents.
Field Details
ANY
public static final int ANYThe type: ANY.- See Also:
DESKTOP
public static final int DESKTOPThe type: DESKTOP.- See Also:
MOBILE
public static final int MOBILEThe type: MOBILE.- See Also:
NONE
The "NONE" themes mask when intersection is too narrow.DEFAULT_DESKTOP
The default theme selection for desktop, i.e. Flat, Bootstrap and Claro.DEFAULT_MOBILE
The default theme selection for mobile, all default desktop theme and all mobile themes.DEFAULT_MASK
The default theme selection: allow all, both desktop and mobile.MOBILE_MASK
The default theme selection for any mobile theme and no desktop themes.DESKTOP_MASK
The default theme selection for any desktop theme and no mobile themes.DEFAULT_STARTUP
The default start-up theme for the app: Flat and iOS7+.ANY_MASK
The "ANY_MASK" themes mask, could replace a mask with "null" value (note: not the sameNONE
).
Constructor Details
GThemes
Creates a new instance of themes.- Parameters:
type
- The theme type: ANY=-1 for any, DESKTOP=0, MOBILE=1.desktop
- The array of themes for desktop, or null for any.mobile
- The array of themes for mobile, or null for any.- Throws:
IllegalArgumentException
- If type is not ANY, DESKTOP or MOBILE, or if the theme names are invalid for the type.NullPointerException
- If any theme instance in the array isnull
.
Method Details
from
Creates a new instance of themes or grabs a cached copy.- Parameters:
type
- The theme type: ANY=-1 for any, DESKTOP=0, MOBILE=1.desktop
- The array of themes for desktop, or null for any.mobile
- The array of themes for mobile, or null for any.- Returns:
- A cached instance of GThemes. The instance might be just newly created.
- Throws:
IllegalArgumentException
- If type is not ANY, DESKTOP or MOBILE, or if the theme names are invalid for the type.NullPointerException
- If any theme instance in the array isnull
.
from
Creates an instance of the themes from a string.The format of the string must be the same as the one returned in
dataToString()
.- Parameters:
string
- The string.- Throws:
IllegalArgumentException
- If the string type or theme name is wrong.NoSuchElementException
- If there are no more tokens in this tokenizer's string.
from
Creates a color from a transaction.- Parameters:
trans
- The transaction.- Throws:
IllegalArgumentException
- If there is a Transaction error.
fromMobile
Gets a cached mobile theme from a name using the default desktop name.- Parameters:
name
- The name.- Returns:
- A cached instance for the theme for the name.
- Throws:
IllegalArgumentException
- If the name is not of mobile type.
fromDesktop
Gets a cached desktop theme from a name using with no mobile themes.- Parameters:
name
- The name.- Returns:
- A cached instance for the theme for the name.
- Throws:
IllegalArgumentException
- If the name is not of desktop type.
append
Appends the themes to a transaction.equals
Checks if two color objects are equal.isDesktop
public boolean isDesktop()Checks if this theme is for desktop. The theme can be mobile also.isMobile
public boolean isMobile()Checks if this theme is for mobile. The theme can be for desktop also.getDesktopThemes
Gets the desktop themes.- Returns:
- An array of desktop themes possible, or null for any. DO NOT MODIFY THE RETURNED ARRAY!
getMobileThemes
Gets the mobile themes.- Returns:
- An array of mobile themes possible, or null for any. DO NOT MODIFY THE RETURNED ARRAY!
dataToString
The data string representation.toString
Returns a string representation of this class instance and its values.computeIntersection
Computes the "intersection" of this mask and another one.- Parameters:
mask
- The mask to "intersect" with.- Returns:
- The "intersection" mask, or the special value
NONE
that is not allowed to be serialized (saved to XML, stored in ThemesProp or sent over a transaction).
isNullMask
public boolean isNullMask()Returns if this mask is a "null" mask, or a NONE mask.- Returns:
- true if no themes are present, i.e. a "null" mask or NONE mask, false if there is a type present.
verify
Verifies if the current theme is not "masked away" from its initial intents. This method is intended to be used on a panel theme and a mask applies from parent folders.- Parameters:
mask
- The mask from parent folders.- Returns:
- null if it is valid, otherwise an error message of the problem.
contains
Checks if the theme name is contained in this theme instances mask.- Parameters:
name
- The themes name to test.- Returns:
- true if it is contained in either mobile or desktop.
toClientThemesString
Returns the representation of the theme for the client to use.- Returns:
- String formatted as "desktop,[mobile]".