Example #1
0
  /** Load the parameters to be used, starting the trackerThread if necessary. */
  private void loadParameters() {
    gaAccountId = parameterFetcher.getString("ga_api_key");

    if (gaAccountId != null) {
      if (gaDebug == null) gaDebug = parameterFetcher.getBoolean("ga_debug");

      if (gaDryRun == null) gaDryRun = parameterFetcher.getBoolean("ga_dryRun");

      if (gaSampleRate == null) gaSampleRate = parameterFetcher.getInt("ga_sampleRate", 100);

      if (gaDispatchPeriod == null) {
        int dispatchPeriod = parameterFetcher.getInt("ga_dispatchPeriod", 20);
        if (gaDispatchPeriod == null || dispatchPeriod != gaDispatchPeriod) {
          gaDispatchPeriod = dispatchPeriod;
          restartSchedulerIfRunning();
        }
      }

      if (autoActivityTracking == null)
        autoActivityTracking = parameterFetcher.getBoolean("ga_auto_activity_tracking");

      if (gaAnonymizeIp == null) gaAnonymizeIp = parameterFetcher.getBoolean("ga_anonymizeIp");
    } else {
      gaEnabled = false;
    }
  }
Example #2
0
  /**
   * Look up the Activity's display name (as defined in a String resource named for the Activity's
   * canonicalName).
   *
   * @param activity the Activity Class to look up
   * @return the defined display name or the canonicalName if the display name is not found
   */
  private String getActivityName(Activity activity) {
    String canonicalName = activity.getClass().getCanonicalName();

    if (activityNameMap.containsKey(canonicalName)) {
      return activityNameMap.get(canonicalName);
    } else {
      String name = parameterFetcher.getString(canonicalName);
      if (name == null) {
        name = canonicalName;
      }
      activityNameMap.put(canonicalName, name);
      return name;
    }
  }
  /**
   * Private constructor.
   *
   * @param context
   */
  private CurioClientSettings(Context context) {
    ParameterLoader paramLoader = new ParameterLoader(context);

    loggingEnabled = paramLoader.getBoolean(Constants.CONFIG_PARAM_LOGGING_ENABLED, true);
    apiKey = paramLoader.getString(Constants.CONFIG_PARAM_API_KEY, null);
    gcmSenderId = paramLoader.getString(Constants.CONFIG_PARAM_GCM_SENDER_ID, null);
    trackingCode = paramLoader.getString(Constants.CONFIG_PARAM_TRACKING_CODE, null);
    serverUrl = paramLoader.getString(Constants.CONFIG_PARAM_SERVER_URL, null);
    autoPushRegistration =
        paramLoader.getBoolean(Constants.CONFIG_PARAM_AUTO_PUSH_REGISTRATION, false);

    //		if(apiKey == null || trackingCode == null || serverUrl == null){
    //			throw new IllegalStateException("api_key, tracking_code and server_url are required
    // parameters, they can NOT be null. Please be sure that you defined those parameters in
    // curio.xml config file.");
    //		}

    sessionTimeout =
        paramLoader.getInteger(
            Constants.CONFIG_PARAM_SESSION_TIMEOUT,
            Constants.CONFIG_PARAM_DEFAULT_VALUE_SESSION_TIMEOUT_IN_MINUTES);
    isPeriodicDispatchEnabled =
        paramLoader.getBoolean(Constants.CONFIG_PARAM_PERIODIC_DISPATCH, false);
    dispatchPeriod =
        paramLoader.getInteger(
            Constants.CONFIG_PARAM_DISPATCH_PERIOD,
            Constants.CONFIG_PARAM_DEFAULT_VALUE_DISPATCH_PERIOD_IN_MINUTES);
    maxCachedActivityCount =
        paramLoader.getInteger(
            Constants.CONFIG_PARAM_MAX_CACHED_ACTIVITY_COUNT,
            Constants.CONFIG_PARAM_DEFAULT_VALUE_MAX_CACHED_ACTIVITY_COUNT);

    /** User defined max. cached activity count cannot be greater than defined max. */
    if (maxCachedActivityCount > Constants.CONFIG_PARAM_MAX_VALUE_MAX_CACHED_ACTIVITY_COUNT) {
      CurioLogger.w(
          TAG,
          "Max number of cached activity cannot be greater then "
              + Constants.CONFIG_PARAM_MAX_VALUE_MAX_CACHED_ACTIVITY_COUNT
              + ". Will be set to max value.");
      maxCachedActivityCount = Constants.CONFIG_PARAM_MAX_VALUE_MAX_CACHED_ACTIVITY_COUNT;
    }
  }