// Path: app/src/main/java/wseemann/media/romote/fragment/ConnectivityDialog.java
// public class ConnectivityDialog extends DialogFragment {
// 
//     private static ConnectivityFragmentListener mListener;
// 
//     public static ConnectivityDialog getInstance(Activity activity) {
//         /*try {
//             // Instantiate the ConnectivityFragmentListener so we can send events with it
//             mListener = (ConnectivityFragmentListener) activity;
//         } catch (ClassCastException e) {
//             // The activity doesn't implement the interface, throw exception
//             throw new ClassCastException(activity.toString()
//                     + " must implement ConnectivityFragmentListener");
//         }*/
// 
//         return new ConnectivityDialog();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setCancelable(false);
//     }
// 
//     @Override
//     public Dialog onCreateDialog(Bundle savedInstanceState) {
//         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//         builder.setTitle(getString(R.string.connectivity_dialog_title));
//         builder.setMessage(getString(R.string.connectivity_dialog_message));
//         builder.setNeutralButton(R.string.connectivity_dialog_button, new DialogInterface.OnClickListener() {
//             public void onClick(DialogInterface dialog, int id) {
//                 try {
//                     // In some cases, a matching Activity may not exist,so ensure you safeguard against this.
//                     startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
//                 } catch (ActivityNotFoundException ex) {
//                     startActivity(new Intent(Settings.ACTION_SETTINGS));
//                 }
//             }
//         });
// 
//         return builder.create();
//     }
// 
//     public interface ConnectivityFragmentListener {
//         public void onDialogCancelled();
//     }
// }
// 
// Path: app/src/main/java/wseemann/media/romote/utils/NetworkMonitor.java
// public class NetworkMonitor {
// 
//     private ConnectivityManager mCm;
//     private WifiApManager mWifiApManager;
// 
//     public NetworkMonitor(Activity activity, int requestCode) {
//         // Here, thisActivity is the current activity
//         if (ContextCompat.checkSelfPermission(activity,
//                 Manifest.permission.ACCESS_NETWORK_STATE)
//                 != PackageManager.PERMISSION_GRANTED) {
//             requestPermission(activity, requestCode);
//         } else {
//             mCm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
//             mWifiApManager = new WifiApManager(activity);
//         }
//     }
// 
//     public boolean isConnectedToiWiFi() {
//         if (mCm == null) {
//             return false;
//         }
// 
//         NetworkInfo activeNetwork = mCm.getActiveNetworkInfo();
// 
//         boolean isConnected = activeNetwork != null &&
//                 activeNetwork.isConnectedOrConnecting();
// 
//         if (isConnected) {
//             return activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
//         }
// 
//         return false;
//     }
// 
//     public boolean isMobileAccessPointOn() {
//         if (mWifiApManager == null) {
//             return false;
//         }
// 
//         return mWifiApManager.isWifiApEnabled();
//     }
// 
//     private void requestPermission(Activity activity, int requestCode) {
//         // Here, thisActivity is the current activity
//         if (ContextCompat.checkSelfPermission(activity,
//                 Manifest.permission.ACCESS_NETWORK_STATE)
//                 != PackageManager.PERMISSION_GRANTED) {
// 
//             // Should we show an explanation?
//             if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
//                     Manifest.permission.ACCESS_NETWORK_STATE)) {
// 
//                 // Show an expanation to the user *asynchronously* -- don't block
//                 // this thread waiting for the user's response! After the user
//                 // sees the explanation, try again to request the permission.
// 
//             } else {
// 
//                 // No explanation needed, we can request the permission.
// 
//                 ActivityCompat.requestPermissions(activity,
//                         new String[]{Manifest.permission.ACCESS_NETWORK_STATE},
//                         requestCode);
// 
//                 // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
//                 // app-defined int constant. The callback method gets the
//                 // result of the request.
//             }
//         }
//     }
// }


import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import wseemann.media.romote.fragment.ConnectivityDialog;
import wseemann.media.romote.utils.NetworkMonitor;
package wseemann.media.romote.activity;



/**
 * Created by wseemann on 6/19/16.
 */
public class ConnectivityActivity extends ShakeActivity {

    private static final int MY_PERMISSIONS_ACCESS_NETWORK_STATE = 100;

// Path: app/src/main/java/wseemann/media/romote/fragment/ConnectivityDialog.java
// public class ConnectivityDialog extends DialogFragment {
// 
//     private static ConnectivityFragmentListener mListener;
// 
//     public static ConnectivityDialog getInstance(Activity activity) {
//         /*try {
//             // Instantiate the ConnectivityFragmentListener so we can send events with it
//             mListener = (ConnectivityFragmentListener) activity;
//         } catch (ClassCastException e) {
//             // The activity doesn't implement the interface, throw exception
//             throw new ClassCastException(activity.toString()
//                     + " must implement ConnectivityFragmentListener");
//         }*/
// 
//         return new ConnectivityDialog();
//     }
// 
//     @Override
//     public void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
// 
//         setCancelable(false);
//     }
// 
//     @Override
//     public Dialog onCreateDialog(Bundle savedInstanceState) {
//         AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
//         builder.setTitle(getString(R.string.connectivity_dialog_title));
//         builder.setMessage(getString(R.string.connectivity_dialog_message));
//         builder.setNeutralButton(R.string.connectivity_dialog_button, new DialogInterface.OnClickListener() {
//             public void onClick(DialogInterface dialog, int id) {
//                 try {
//                     // In some cases, a matching Activity may not exist,so ensure you safeguard against this.
//                     startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS));
//                 } catch (ActivityNotFoundException ex) {
//                     startActivity(new Intent(Settings.ACTION_SETTINGS));
//                 }
//             }
//         });
// 
//         return builder.create();
//     }
// 
//     public interface ConnectivityFragmentListener {
//         public void onDialogCancelled();
//     }
// }
// 
// Path: app/src/main/java/wseemann/media/romote/utils/NetworkMonitor.java
// public class NetworkMonitor {
// 
//     private ConnectivityManager mCm;
//     private WifiApManager mWifiApManager;
// 
//     public NetworkMonitor(Activity activity, int requestCode) {
//         // Here, thisActivity is the current activity
//         if (ContextCompat.checkSelfPermission(activity,
//                 Manifest.permission.ACCESS_NETWORK_STATE)
//                 != PackageManager.PERMISSION_GRANTED) {
//             requestPermission(activity, requestCode);
//         } else {
//             mCm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
//             mWifiApManager = new WifiApManager(activity);
//         }
//     }
// 
//     public boolean isConnectedToiWiFi() {
//         if (mCm == null) {
//             return false;
//         }
// 
//         NetworkInfo activeNetwork = mCm.getActiveNetworkInfo();
// 
//         boolean isConnected = activeNetwork != null &&
//                 activeNetwork.isConnectedOrConnecting();
// 
//         if (isConnected) {
//             return activeNetwork.getType() == ConnectivityManager.TYPE_WIFI;
//         }
// 
//         return false;
//     }
// 
//     public boolean isMobileAccessPointOn() {
//         if (mWifiApManager == null) {
//             return false;
//         }
// 
//         return mWifiApManager.isWifiApEnabled();
//     }
// 
//     private void requestPermission(Activity activity, int requestCode) {
//         // Here, thisActivity is the current activity
//         if (ContextCompat.checkSelfPermission(activity,
//                 Manifest.permission.ACCESS_NETWORK_STATE)
//                 != PackageManager.PERMISSION_GRANTED) {
// 
//             // Should we show an explanation?
//             if (ActivityCompat.shouldShowRequestPermissionRationale(activity,
//                     Manifest.permission.ACCESS_NETWORK_STATE)) {
// 
//                 // Show an expanation to the user *asynchronously* -- don't block
//                 // this thread waiting for the user's response! After the user
//                 // sees the explanation, try again to request the permission.
// 
//             } else {
// 
//                 // No explanation needed, we can request the permission.
// 
//                 ActivityCompat.requestPermissions(activity,
//                         new String[]{Manifest.permission.ACCESS_NETWORK_STATE},
//                         requestCode);
// 
//                 // MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
//                 // app-defined int constant. The callback method gets the
//                 // result of the request.
//             }
//         }
//     }
// }


// Path: app/src/main/java/wseemann/media/romote/activity/ConnectivityActivity.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import wseemann.media.romote.fragment.ConnectivityDialog;
import wseemann.media.romote.utils.NetworkMonitor;

package wseemann.media.romote.activity;



/**
 * Created by wseemann on 6/19/16.
 */
public class ConnectivityActivity extends ShakeActivity {

    private static final int MY_PERMISSIONS_ACCESS_NETWORK_STATE = 100;

    private ConnectivityDialog mDialog;