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 @@ - + All Classes (app 1.0.4 API) @@ -16,7 +16,7 @@

All Classes

  • LogUtil
  • SSIDUtil
  • WiseFy
  • -
  • WiseFy.generator
  • +
  • WiseFy.withContext
  • diff --git a/javadoc/allclasses-noframe.html b/javadoc/allclasses-noframe.html index abac2f59..8a4d7ba2 100644 --- a/javadoc/allclasses-noframe.html +++ b/javadoc/allclasses-noframe.html @@ -2,7 +2,7 @@ - + All Classes (app 1.0.4 API) @@ -16,7 +16,7 @@

    All Classes

  • LogUtil
  • SSIDUtil
  • WiseFy
  • -
  • WiseFy.generator
  • +
  • WiseFy.withContext
  • diff --git a/javadoc/com/isupatches/wisefy/WiseFy.html b/javadoc/com/isupatches/wisefy/WiseFy.html index e70b57dc..5018198a 100644 --- a/javadoc/com/isupatches/wisefy/WiseFy.html +++ b/javadoc/com/isupatches/wisefy/WiseFy.html @@ -2,7 +2,7 @@ - + WiseFy (app 1.0.4 API) @@ -49,7 +49,7 @@ @@ -130,8 +133,10 @@

    Nested Class Summary

    static class  -WiseFy.generator -
    Internal static class for builder pattern
    +WiseFy.withContext +
    Static class for builder pattern + + Implements builder interfaces #Logging #GetSmarts
    @@ -777,7 +782,7 @@

    isLoggingEnabled

    diff --git a/javadoc/com/isupatches/wisefy/package-summary.html b/javadoc/com/isupatches/wisefy/package-summary.html index 51262cdb..da9d8465 100644 --- a/javadoc/com/isupatches/wisefy/package-summary.html +++ b/javadoc/com/isupatches/wisefy/package-summary.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy (app 1.0.4 API) @@ -83,12 +83,18 @@

    Package com.isupatches.wisefy

    WiseFy -  + +
    Main class to manipulate and query network settings on an Android device + + Uses the builder pattern for creation - WiseFy.withContext
    + -WiseFy.generator +WiseFy.withContext -
    Internal static class for builder pattern
    +
    Static class for builder pattern + + Implements builder interfaces #Logging #GetSmarts
    diff --git a/javadoc/com/isupatches/wisefy/package-tree.html b/javadoc/com/isupatches/wisefy/package-tree.html index f4b195b7..5a0fd1d7 100644 --- a/javadoc/com/isupatches/wisefy/package-tree.html +++ b/javadoc/com/isupatches/wisefy/package-tree.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy Class Hierarchy (app 1.0.4 API) @@ -81,7 +81,7 @@

    Class Hierarchy

  • java.lang.Object
  • diff --git a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html index 5ee56b2b..f67ebc0f 100644 --- a/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html +++ b/javadoc/com/isupatches/wisefy/util/GetManagerUtil.html @@ -2,7 +2,7 @@ - + GetManagerUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/LogUtil.html b/javadoc/com/isupatches/wisefy/util/LogUtil.html index 4fceabc8..8b545713 100644 --- a/javadoc/com/isupatches/wisefy/util/LogUtil.html +++ b/javadoc/com/isupatches/wisefy/util/LogUtil.html @@ -2,7 +2,7 @@ - + LogUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html index 1f312a55..81007827 100644 --- a/javadoc/com/isupatches/wisefy/util/SSIDUtil.html +++ b/javadoc/com/isupatches/wisefy/util/SSIDUtil.html @@ -2,7 +2,7 @@ - + SSIDUtil (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-frame.html b/javadoc/com/isupatches/wisefy/util/package-frame.html index a282b641..950cdd39 100644 --- a/javadoc/com/isupatches/wisefy/util/package-frame.html +++ b/javadoc/com/isupatches/wisefy/util/package-frame.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-summary.html b/javadoc/com/isupatches/wisefy/util/package-summary.html index f19c4115..c25450e0 100644 --- a/javadoc/com/isupatches/wisefy/util/package-summary.html +++ b/javadoc/com/isupatches/wisefy/util/package-summary.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util (app 1.0.4 API) diff --git a/javadoc/com/isupatches/wisefy/util/package-tree.html b/javadoc/com/isupatches/wisefy/util/package-tree.html index 715df538..6842dd49 100644 --- a/javadoc/com/isupatches/wisefy/util/package-tree.html +++ b/javadoc/com/isupatches/wisefy/util/package-tree.html @@ -2,7 +2,7 @@ - + com.isupatches.wisefy.util Class Hierarchy (app 1.0.4 API) diff --git a/javadoc/constant-values.html b/javadoc/constant-values.html index 86cd2c3e..c7537ad5 100644 --- a/javadoc/constant-values.html +++ b/javadoc/constant-values.html @@ -2,7 +2,7 @@ - + Constant Field Values (app 1.0.4 API) diff --git a/javadoc/deprecated-list.html b/javadoc/deprecated-list.html index b0650931..c3703044 100644 --- a/javadoc/deprecated-list.html +++ b/javadoc/deprecated-list.html @@ -2,7 +2,7 @@ - + Deprecated List (app 1.0.4 API) diff --git a/javadoc/help-doc.html b/javadoc/help-doc.html index d0ad8f37..43240a03 100644 --- a/javadoc/help-doc.html +++ b/javadoc/help-doc.html @@ -2,7 +2,7 @@ - + API Help (app 1.0.4 API) diff --git a/javadoc/index-all.html b/javadoc/index-all.html index a0119ffa..17920809 100644 --- a/javadoc/index-all.html +++ b/javadoc/index-all.html @@ -2,7 +2,7 @@ - + Index (app 1.0.4 API) @@ -145,8 +145,6 @@

    E

    G

    -
    generator() - Constructor for class com.isupatches.wisefy.WiseFy.generator
    -
     
    getConnectivityManager(Context) - Method in class com.isupatches.wisefy.util.GetManagerUtil
    To get a Connectivity manger instance from an activity's context.
    @@ -173,7 +171,7 @@

    G

    To retrieve a list of saved networks on a user's device
    -
    getSmarts() - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    getSmarts() - Method in class com.isupatches.wisefy.WiseFy.withContext
    Mandatory - To build and return a WiseFy instance
    @@ -227,9 +225,9 @@

    I

    L

    -
    logging(boolean) - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    logging(boolean) - Method in class com.isupatches.wisefy.WiseFy.withContext
    -
    Non-mandatory - To enable/disable logging for the WiseFy instance
    +
    Optional - Builder method that enables/disables logging for a WiseWy instance
    LogUtil - Class in com.isupatches.wisefy.util
     
    @@ -278,14 +276,20 @@

    W

    WISE_MANAGER_FAILURE - Static variable in class com.isupatches.wisefy.WiseFy
     
    WiseFy - Class in com.isupatches.wisefy
    -
     
    -
    WiseFy.generator - Class in com.isupatches.wisefy
    -
    Internal static class for builder pattern
    +
    Main class to manipulate and query network settings on an Android device + + Uses the builder pattern for creation - WiseFy.withContext
    +
    +
    WiseFy.withContext - Class in com.isupatches.wisefy
    +
    +
    Static class for builder pattern + + Implements builder interfaces #Logging #GetSmarts
    -
    withContext(Context) - Method in class com.isupatches.wisefy.WiseFy.generator
    +
    withContext(Context) - Constructor for class com.isupatches.wisefy.WiseFy.withContext
    -
    Mandatory - The context to get a WiFi and Connectivity manager
    +
    Mandatory - The public constructor for the builder that requires a context
    A C D E G I L M R S W  diff --git a/javadoc/index.html b/javadoc/index.html index a92a8ded..f8a47f95 100644 --- a/javadoc/index.html +++ b/javadoc/index.html @@ -2,7 +2,7 @@ - + app 1.0.4 API