diff --git a/README.md b/README.md
index a5829ab8..504764ed 100644
--- a/README.md
+++ b/README.md
@@ -12,13 +12,13 @@ WiseFy now supports the builder pattern so cool functionality can be added later
To grab a default instance:
```java
-WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).getSmarts();
+WiseFy mWiseFy = new WiseFy.withContext(getActivity()).getSmarts();
```
To grab an instance with logging enabled:
```java
-WiseFy mWiseFy = new WiseFy.generator().withContext(getActivity()).logging(true).getSmarts();
+WiseFy mWiseFy = new WiseFy.withContext(getActivity()).logging(true).getSmarts();
```
**IMPORTANT!** Please make sure you call withContext for WiseFy to work properly
diff --git a/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java
index a9774320..e5526ee0 100644
--- a/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java
+++ b/app/src/androidTest/java/com/isupatches/wisefy/WiseFyTest.java
@@ -43,7 +43,7 @@ public void setUp() {
mActivityTestRule.launchActivity(new Intent());
- mWiseFy = new WiseFy.generator().withContext(mActivityTestRule.getActivity()).getSmarts();
+ mWiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).getSmarts();
}
@Test
@@ -146,13 +146,13 @@ public void testAddWPA2NetworkNullWifiManager() {
@Test
public void testBuilderWithLoggingFalse() {
- WiseFy wiseFy = new WiseFy.generator().logging(false).getSmarts();
+ WiseFy wiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).logging(false).getSmarts();
assertEquals(false, wiseFy.isLoggingEnabled());
}
@Test
public void testBuilderWithLoggingTrue() {
- WiseFy wiseFy = new WiseFy.generator().logging(true).getSmarts();
+ WiseFy wiseFy = new WiseFy.withContext(mActivityTestRule.getActivity()).logging(true).getSmarts();
assertEquals(true, wiseFy.isLoggingEnabled());
}
diff --git a/app/src/main/java/com/isupatches/wisefy/WiseFy.java b/app/src/main/java/com/isupatches/wisefy/WiseFy.java
index 35db6856..dd89936e 100644
--- a/app/src/main/java/com/isupatches/wisefy/WiseFy.java
+++ b/app/src/main/java/com/isupatches/wisefy/WiseFy.java
@@ -1,3 +1,19 @@
+/**
+ * Copyright 2016 by Patches Klinefelter
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
package com.isupatches.wisefy;
@@ -16,6 +32,11 @@
import java.util.List;
+/**
+ * Main class to manipulate and query network settings on an Android device
+ *
+ * Uses the builder pattern for creation - {@link withContext}
+ */
public class WiseFy {
private static final String TAG = WiseFy.class.getSimpleName();
@@ -37,64 +58,72 @@ public class WiseFy {
/**
* Private constructor that accepts builder input
*/
- private WiseFy(generator generator) {
- this.mLoggingEnabled = generator.loggingEnabled;
- this.mConnectivityManager = GetManagerUtil.getInstance().getConnectivityManager(generator.context);
- this.mWifiManager = GetManagerUtil.getInstance().getWiFiManager(generator.context);
+ private WiseFy(withContext withContext) {
+ this.mLoggingEnabled = withContext.loggingEnabled;
+ this.mConnectivityManager = GetManagerUtil.getInstance().getConnectivityManager(withContext.context);
+ this.mWifiManager = GetManagerUtil.getInstance().getWiFiManager(withContext.context);
}
/**
- * Internal static class for builder pattern
+ * Static class for builder pattern
+ *
+ * Implements builder interfaces #{@link Logging} #{@link GetSmarts}
*/
- public static class generator implements GetSmarts, WithContext {
+ public static class withContext implements Logging, GetSmarts {
private Context context;
private boolean loggingEnabled;
/**
- * Mandatory - The context to get a WiFi and Connectivity manager
+ * Mandatory - The public constructor for the builder that requires a context
*
- * @param context - The activity or application context
- * {@link WithContext}
+ * @param context - The activity or application context to get a WifiConfiguration and
+ * ConnectivityManager instance
*
- * @return generator - The builder with updated context
+ * {@link #WiseFy(withContext)}
*/
- public GetSmarts withContext(Context context) {
+ public withContext(Context context) {
this.context = context;
- return this;
}
/**
- * Non-mandatory - To enable/disable logging for the WiseFy instance
- *
- * @param loggingEnabled - If logging is enabled or disabled
- * {@link GetSmarts}
+ * Mandatory - To build and return a WiseFy instance
*
- * @return generator - The builder with updated logging setting
+ * @return WiseFy - The instance created by the builder
*/
- public generator logging(boolean loggingEnabled) {
- this.loggingEnabled = loggingEnabled;
- return this;
+ @Override
+ public WiseFy getSmarts() {
+ return new WiseFy(this);
}
/**
- * Mandatory - To build and return a WiseFy instance
+ * Optional - Builder method that enables/disables logging for a WiseWy instance
*
- * @return WiseFy - The instance created by the builder
+ * @param loggingEnabled - If logging is enabled or disabled for an instance
+ * {@link Logging}
+ *
+ * @return withContext - The builder with updated logging setting
*/
- public WiseFy getSmarts() {
- return new WiseFy(this);
+ @Override
+ public withContext logging(boolean loggingEnabled) {
+ this.loggingEnabled = loggingEnabled;
+ return this;
}
}
- interface GetSmarts {
- WiseFy getSmarts();
+ /**
+ * An interface that enables/disables logging for a WiseFy instance
+ */
+ interface Logging {
+ withContext logging(boolean loggingEnabled);
}
- interface WithContext {
- GetSmarts withContext(Context context);
- generator logging(boolean loggingEnabled);
+ /**
+ * An interface that builds a WiseFy instance
+ */
+ interface GetSmarts {
+ WiseFy getSmarts();
}
/**
diff --git a/javadoc/allclasses-frame.html b/javadoc/allclasses-frame.html
index 224afb9a..ae44ff45 100644
--- a/javadoc/allclasses-frame.html
+++ b/javadoc/allclasses-frame.html
@@ -2,7 +2,7 @@