Skip to content

Commit 20ac5a0

Browse files
authored
Merge pull request #20 from optimizely/javadoc
Javadoc
2 parents 217c35b + 64b5427 commit 20ac5a0

File tree

33 files changed

+665
-152
lines changed

33 files changed

+665
-152
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android-sdk/build.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2016, Optimizely
3+
* <p/>
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
* <p/>
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
* <p/>
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
apply plugin: 'com.android.library'
218
apply plugin: 'maven'
319
apply plugin: 'maven-publish'
@@ -53,6 +69,7 @@ dependencies {
5369
}
5470

5571
uploadArchives {
72+
dependsOn = [':android-sdk:clean', ':android-sdk:releaseJavadoc']
5673
shouldRunAfter = [':event-handler:uploadArchives', ':user-experiment-record:uploadArchives']
5774
repositories {
5875
mavenDeployer {
@@ -63,3 +80,34 @@ uploadArchives {
6380
}
6481
}
6582
}
83+
84+
android.libraryVariants.all { variant ->
85+
task("${variant.name}Javadoc", type: Javadoc, dependsOn: "assemble${variant.name.capitalize()}") {
86+
source = variant.javaCompile.source
87+
88+
title = "Optimizely X Android SDK"
89+
90+
options.links("http://docs.oracle.com/javase/7/docs/api/");
91+
options.linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference");
92+
93+
// First add all of your dependencies to the classpath, then add the android jars
94+
classpath += files(variant.javaCompile.classpath.files)
95+
classpath += files(android.getBootClasspath())
96+
97+
// We're excluding these generated files
98+
exclude '**/BuildConfig.java'
99+
exclude '**/R.java'
100+
101+
options.tags = ["hide"]
102+
}
103+
}
104+
105+
android.libraryVariants.all { variant ->
106+
task("${variant.name}JavadocJar", type: Jar, dependsOn: "${variant.name}Javadoc") {
107+
classifier = 'javadoc'
108+
from tasks["${variant.name}Javadoc"].destinationDir
109+
}
110+
111+
// Add the Javadoc jar to the project's artifacts. This will allow us to upload it easily later
112+
project.artifacts.add("archives", tasks["${variant.name}JavadocJar"]);
113+
}

android-sdk/src/main/java/com/optimizely/ab/android/sdk/AndroidOptimizely.java

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.app.Activity;
@@ -21,13 +22,10 @@
2122

2223
import com.optimizely.ab.Optimizely;
2324
import com.optimizely.ab.UnknownEventTypeException;
24-
import com.optimizely.ab.UnknownExperimentException;
2525
import com.optimizely.ab.config.Experiment;
26-
import com.optimizely.ab.config.ProjectConfig;
2726
import com.optimizely.ab.config.Variation;
2827

2928
import org.slf4j.Logger;
30-
import org.slf4j.LoggerFactory;
3129

3230
import java.util.Map;
3331

@@ -52,10 +50,14 @@ public class AndroidOptimizely {
5250
}
5351

5452
/**
53+
* Activate an experiment for a user
5554
* @see Optimizely#activate(String, String)
55+
* @param experimentKey the experiment key
56+
* @param userId the user id
57+
* @return the {@link Variation} the user bucketed into
5658
*/
5759
public @Nullable Variation activate(@NonNull String experimentKey,
58-
@NonNull String userId) throws UnknownExperimentException {
60+
@NonNull String userId) {
5961
if (optimizely != null) {
6062
return optimizely.activate(experimentKey, userId);
6163
} else {
@@ -66,11 +68,17 @@ public class AndroidOptimizely {
6668
}
6769

6870
/**
69-
* @see Optimizely#activate(String, String, Map)
71+
* Activate an experiment for a user
72+
* @see Optimizely#activate(String, String)
73+
* @param experimentKey the experiment key
74+
* @param userId the user id
75+
* @param attributes a map of attributes about the user
76+
* @return the {@link Variation} the user bucketed into
7077
*/
78+
@SuppressWarnings("WeakerAccess")
7179
public @Nullable Variation activate(@NonNull String experimentKey,
7280
@NonNull String userId,
73-
@NonNull Map<String, String> attributes) throws UnknownExperimentException {
81+
@NonNull Map<String, String> attributes) {
7482
if (optimizely != null) {
7583
return optimizely.activate(experimentKey, userId, attributes);
7684
} else {
@@ -81,37 +89,12 @@ public class AndroidOptimizely {
8189
}
8290

8391
/**
84-
* @see Optimizely#activate(Experiment, String)
85-
*/
86-
public @Nullable Variation activate(@NonNull Experiment experiment,
87-
@NonNull String userId) {
88-
if (optimizely != null) {
89-
return optimizely.activate(experiment, userId);
90-
} else {
91-
logger.warn("Optimizely is not initialized, can't activate experiment {} for user {}",
92-
experiment.getKey(), userId);
93-
return null;
94-
}
95-
}
96-
97-
public @Nullable Variation activate(@NonNull Experiment experiment,
98-
@NonNull String userId,
99-
@NonNull Map<String, String> attributes) {
100-
if (optimizely != null) {
101-
return optimizely.activate(experiment, userId, attributes);
102-
} else {
103-
logger.warn("Optimizely is not initialized, can't activate experiment {} for user {} " +
104-
"with attributes", experiment.getKey(), userId);
105-
return null;
106-
}
107-
}
108-
109-
110-
/**
111-
* @see Optimizely#track(String, String)
92+
* Track an event for a user
93+
* @param eventName the name of the event
94+
* @param userId the user id
11295
*/
11396
public void track(@NonNull String eventName,
114-
@NonNull String userId) throws UnknownEventTypeException {
97+
@NonNull String userId) {
11598
if (optimizely != null) {
11699
optimizely.track(eventName, userId);
117100
} else {
@@ -120,7 +103,10 @@ public void track(@NonNull String eventName,
120103
}
121104

122105
/**
123-
* @see Optimizely#track(String, String, Map)
106+
* Track an event for a user
107+
* @param eventName the name of the event
108+
* @param userId the user id
109+
* @param attributes a map of attributes about the user
124110
*/
125111
public void track(@NonNull String eventName,
126112
@NonNull String userId,
@@ -134,7 +120,10 @@ public void track(@NonNull String eventName,
134120
}
135121

136122
/**
137-
* @see Optimizely#track(String, String, long)
123+
* Track an event for a user
124+
* @param eventName the name of the event
125+
* @param userId the user id
126+
* @param eventValue a value to tie to the event
138127
*/
139128
public void track(@NonNull String eventName,
140129
@NonNull String userId,
@@ -148,12 +137,17 @@ public void track(@NonNull String eventName,
148137
}
149138

150139
/**
151-
* @see Optimizely#track(String, String, Map, long)
140+
* Track an event for a user with attributes and a value
141+
* @see Optimizely#track(String, String, Map, Long)
142+
* @param eventName the String name of the event
143+
* @param userId the String user id
144+
* @param attributes the attributes of the event
145+
* @param eventValue the value of the event
152146
*/
153147
public void track(@NonNull String eventName,
154148
@NonNull String userId,
155149
@NonNull Map<String, String> attributes,
156-
long eventValue) throws UnknownEventTypeException {
150+
long eventValue) {
157151
if (optimizely != null) {
158152
optimizely.track(eventName, userId, attributes, eventValue);
159153
} else {
@@ -162,26 +156,16 @@ public void track(@NonNull String eventName,
162156
}
163157
}
164158

165-
166159
/**
160+
* Get the variation the user is bucketed into
167161
* @see Optimizely#getVariation(Experiment, String)
162+
* @param experimentKey a String experiment key
163+
* @param userId a String user id
164+
* @return a variation for the provided experiment key and user id
168165
*/
169-
public @Nullable Variation getVariation(@NonNull Experiment experiment,
170-
@NonNull String userId) throws UnknownExperimentException {
171-
if (optimizely != null) {
172-
return optimizely.getVariation(experiment, userId);
173-
} else {
174-
logger.warn("Optimizely is not initialized, could not get variation for experiment {} " +
175-
"for user {}", experiment.getKey(), userId);
176-
return null;
177-
}
178-
}
179-
180-
/**
181-
* @see Optimizely#getVariation(String, String)
182-
*/
166+
@SuppressWarnings("WeakerAccess")
183167
public @Nullable Variation getVariation(@NonNull String experimentKey,
184-
@NonNull String userId) throws UnknownExperimentException{
168+
@NonNull String userId) {
185169
if (optimizely != null) {
186170
return optimizely.getVariation(experimentKey, userId);
187171
} else {
@@ -192,8 +176,14 @@ public void track(@NonNull String eventName,
192176
}
193177

194178
/**
195-
* @see Optimizely#getVariation(String, String, Map)
179+
* Get the variation the user is bucketed into
180+
* @see Optimizely#getVariation(Experiment, String)
181+
* @param experimentKey a String experiment key
182+
* @param userId a String userId
183+
* @param attributes a map of attributes
184+
* @return the variation for the provided experiment key, user id, and attributes
196185
*/
186+
@SuppressWarnings("WeakerAccess")
197187
public @Nullable Variation getVariation(@NonNull String experimentKey,
198188
@NonNull String userId,
199189
@NonNull Map<String, String> attributes) {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/BackgroundWatchersCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.support.annotation.NonNull;
@@ -30,7 +31,7 @@
3031
import java.util.Iterator;
3132
import java.util.List;
3233

33-
/**
34+
/*
3435
* Caches a json dict that saves state about which project IDs have background watching enabled.
3536
*/
3637
class BackgroundWatchersCache {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.support.annotation.NonNull;
@@ -27,7 +28,7 @@
2728
import java.io.FileNotFoundException;
2829
import java.io.IOException;
2930

30-
/**
31+
/*
3132
* Abstracts the actual data "file" {@link java.io.File}
3233
*/
3334
class DataFileCache {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.support.annotation.NonNull;
@@ -25,7 +26,7 @@
2526
import java.net.HttpURLConnection;
2627
import java.net.URL;
2728

28-
/**
29+
/*
2930
* Makes requests to the Optly CDN to get the data file
3031
*/
3132
class DataFileClient {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileLoadedListener.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,21 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

19+
/**
20+
* Listens for new Optimizely datafiles
21+
*
22+
* @hide
23+
*/
1824
interface DataFileLoadedListener {
1925

26+
/**
27+
* Called with new datafile
28+
*
29+
* @param dataFile the datafile json
30+
* @hide
31+
*/
2032
void onDataFileLoaded(String dataFile);
2133
}

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileLoader.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.os.AsyncTask;
@@ -30,7 +31,7 @@
3031
import java.util.concurrent.Executor;
3132
import java.util.concurrent.Executors;
3233

33-
/**
34+
/*
3435
* Handles intents and bindings in {@link DataFileService}
3536
*/
3637
class DataFileLoader {

android-sdk/src/main/java/com/optimizely/ab/android/sdk/DataFileRescheduler.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16+
1617
package com.optimizely.ab.android.sdk;
1718

1819
import android.content.BroadcastReceiver;
@@ -27,6 +28,12 @@
2728

2829
import java.util.List;
2930

31+
/**
32+
* Broadcast Receiver that handles app upgrade and phone restart broadcasts in order
33+
* to reschedule {@link DataFileService}
34+
*
35+
* @hide
36+
*/
3037
public class DataFileRescheduler extends BroadcastReceiver {
3138
Logger logger = LoggerFactory.getLogger(DataFileRescheduler.class);
3239

@@ -49,7 +56,7 @@ public void onReceive(Context context, Intent intent) {
4956
}
5057
}
5158

52-
/**
59+
/*
5360
* Handles building sending Intents to {@link DataFileService}
5461
*
5562
* This abstraction mostly makes unit testing easier

0 commit comments

Comments
 (0)