Class Configuration

java.lang.Object
nz.co.electricbolt.appfiguratelibrary.Configuration

public abstract class Configuration extends Object
  • Method Details

    • sharedConfiguration

      @NonNull public static Configuration sharedConfiguration()
      The singleton instance of the Configuration subclass. The instance is automatically instantiated on application startup. It is permissible to have a multi-level class hierarchy if required. e.g. AppConfiguration ‣ CommonConfiguration ‣ Configuration.
      Returns:
      Singleton instance
    • allowInvalidSignatures

      public abstract boolean allowInvalidSignatures()
      Return true if invalid signatures are allowed to apply configuration (Debug builds), or false if only a correct signature is acceptable (Release builds).

      > Java example

       @Override
       public boolean allowInvalidSignatures() {
         return BuildConfig.DEBUG;
       }
       
      > Kotlin example
       override fun allowInvalidSignatures(): Boolean {
         return BuildConfig.DEBUG
       }
       
      Returns:
      true if invalid signatures are allowed.
    • reset

      public abstract void reset()
      Set default values into your properties. You should ensure that all reset values conform to minimum and maximum values, list entries and regular expressions. Any reset values not conforming will be output to the console.
       public void reset() {
         this.decibelLimit = 5.1f;
         this.foregroundColorHex = "fa3bcc";
       }
       
    • publicKey

      @NonNull public abstract String publicKey()
      Override to return the public key for this application. Use the Appfigurate app (Emulator or Google Play Store) to output the public key.

      > Java example (abbreviated)

       @Override
       public String publicKey() {
         // 41 36 87 71 0D 05
         return "-----BEGIN PUBLIC KEY-----\n"
           + "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4TZnKfGeXttN7Rr3eiAZ\n"
           ...
           + "ywIDAQAB\n"
           + "-----END PUBLIC KEY-----\n";
       }
       
      > Kotlin example (abbreviated)
       override fun publicKey(): String {
         // 41 36 87 71 0D 05
         return """
           -----BEGIN PUBLIC KEY-----
           MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4TZnKfGeXttN7Rr3eiAZ
           ...
           ywIDAQAB
           -----END PUBLIC KEY-----
           """.trimIndent()
       }
       
      Returns:
      public key
    • environmentTags

      @Nullable public String[] environmentTags()
      Optionally override to return a list of environment tags in the order you want them to appear in a segmented control in the Appfigurate Configure app screen.

      AppfigurateLibraryException will be thrown if there are environment tags specified in the values of IntPropertyList, IntPropertyListEdit, FloatPropertyList, FloatPropertyListEdit, DoublePropertyList, DoublePropertyListEdit, StringPropertyList, StringPropertyListEdit, EncryptedStringPropertyListEdit annotations that are not returned in the list from this method.

      > Java example

       @override String[] environmentTags() {
         return {"Dev", "Test", "Prod"}
       }
       
      > Kotlin example
       override fun environmentTags() -> String[] {
         return {"Dev", "Test", "Prod"}
       }
       
      Returns:
      array of environment tags.
    • modifications

      @NonNull public String modifications()
      Returns the textual representation of all properties that have non default values. Property names are shortened to camel case and appended with the non default value, except for String properties which omit the property name. Example: "userInteractionTimeout=60.0" would be returned as "UIT=60.0".
      Returns:
      textual representation of non default values
    • description

      @NonNull public String description()
      Returns the textual representation of all properties. Property names are shortened to camel case and appended with the value, except for String properties which omit the property name. Example: "debugLog=5" would be returned as "DL=5".
      Returns:
      textual representation of all properties
    • automationApply

      public void automationApply()
      Applies configuration properties to the app when automation testing using Espresso. The allowInvalidSignatures() method must return true. The standard "Configuration applied" dialog will be suppressed.
    • automationReset

      public void automationReset()
      Resets configuration properties to factory defaults (the values specified in your reset() method) when automation testing using Espresso. The allowInvalidSignatures() method must return true. The standard "Configuration reset" dialog will be suppressed.
    • automationAction

      public void automationAction(String action)
      Executes the action specified when automation testing using Espresso. The allowInvalidSignatures() method must return true. The standard "Configuration reset" dialog will be suppressed.
      Parameters:
      action - action to execute.
    • remoteDefaults

      public Map<String,Object> remoteDefaults()
      Returns a dictionary of remote property default values as set in the reset() method. Used when integrating with select third party remote configuration providers. See also Appfigurate.fetchRemoteConfiguration(nz.co.electricbolt.appfiguratelibrary.Appfigurate.FetchRemoteConfiguration).

      > Java Firebase Remote Config example

       this.remoteConfig.setDefaultsAsync(Configuration.sharedConfiguration().remoteDefaults());
       
      > Kotlin Firebase Remote Config example
       this.remoteConfig.setDefaultsAsync(Configuration.sharedConfiguration().remoteDefaults())
       
      Returns:
      dictionary of remote property default values.