001package de.econda.droid; 002 003/** 004 * SettingsBuilder used to create a Settings-Object. Settings-Object is needed for creating a new session. 005 * 006 * The Settings-Object can be constructed comfortable by using the SettingsBuilder 007 */ 008public class SettingsBuilder { 009 private PrivacySettings defaultPrivacySettingsNewUser = PrivacySettings.FULL; 010 private final String clientKey; 011 private boolean secureTransmit=true; 012 private String customHostName=null; 013 private int batchAutoTransmitTimeout=-1; 014 private int samplingRate=1; 015 016 017 /** 018 * @param clientKey the account identification id. This id is given you by econda support. 019 */ 020 public SettingsBuilder(String clientKey) { 021 this.clientKey = clientKey; 022 } 023 024 /** 025 * 026 * @param defaultPrivacySettingsNewUser the privacy settings the new session will start with 027 * @return the builder itself 028 */ 029 public SettingsBuilder setDefaultPrivacySettingsNewUser(PrivacySettings defaultPrivacySettingsNewUser) { 030 this.defaultPrivacySettingsNewUser = defaultPrivacySettingsNewUser; 031 return this; 032 } 033 034 /** 035 * 036 * @param secureTransmit use https only, defaults to true 037 * @return 038 */ 039 public SettingsBuilder setSecureTransmit(boolean secureTransmit) { 040 this.secureTransmit = secureTransmit; 041 return this; 042 } 043 044 /** 045 * 046 * @param customHostName you can set a customized hostname. if null, a hostname will be constructed using Android/ and the packagename of the app 047 * @return 048 */ 049 public SettingsBuilder setCustomHostName(String customHostName) { 050 this.customHostName = customHostName; 051 return this; 052 } 053 054 /** 055 * 056 * @param batchAutoTransmitTimeout timeout in seconds. after this time all collected data will be submitted. 057 * @return 058 */ 059 public SettingsBuilder setBatchAutoTransmitTimeout(int batchAutoTransmitTimeout) { 060 this.batchAutoTransmitTimeout = batchAutoTransmitTimeout; 061 return this; 062 } 063 064 /** 065 * 066 * @param samplingRate The sampling rate. If samplingRate=5 each 5th Visitor will be analyzed. 067 * @return 068 */ 069 public SettingsBuilder setSamplingRate(int samplingRate) { 070 this.samplingRate = samplingRate; 071 return this; 072 } 073 074 /** 075 * 076 * @return The settings Object 077 */ 078 public Settings build() { 079 return new Settings(defaultPrivacySettingsNewUser, clientKey, secureTransmit, customHostName, batchAutoTransmitTimeout, samplingRate); 080 } 081}