// Path: app/src/main/java/io/github/krtkush/marsexplorer/About/Credits/CreditsActivity.java
// public class CreditsActivity extends AppCompatActivity {
// 
//     @BindView(R.id.toolbar) Toolbar toolbar;
//     @BindView(R.id.creditsRecyclerView) RecyclerView recyclerView;
// 
//     private CreditsActivityPresenterInteractor presenterInteractor;
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_credits);
// 
//         // Initialise butterknife, timber and the presenter layer
//         ButterKnife.bind(CreditsActivity.this);
//         Timber.tag(CreditsActivity.this.getClass().getSimpleName());
//         presenterInteractor = new CreditsActivityPresenterLayer(this);
// 
//         // Setup the toolbar
//         setSupportActionBar(toolbar);
//         getSupportActionBar().setTitle("Credits");
// 
//         // Show the credit list
//         presenterInteractor.prepareRecyclerViewAndAddData(recyclerView);
//     }
// 
//     @Override
//     protected void attachBaseContext(Context newBase) {
//         super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         presenterInteractor.checkInternetConnectivity();
//     }
// 
//     /**
//      * Method to make toast on this activity
//      * @param toastMessage The message to be displayed
//      * @param toastDuration Duration for the toast to be visible
//      */
//     protected void showToast(String toastMessage, int toastDuration) {
//         Toast.makeText(this, toastMessage, toastDuration).show();
//     }
// }
// 
// Path: app/src/main/java/io/github/krtkush/marsexplorer/UtilityMethods.java
// public class UtilityMethods {
// 
//     /**
//      * Method to detect network connection on the device
//      * @return
//      */
//     public static boolean isNetworkAvailable() {
// 
//         ConnectivityManager connectivityManager =
//                 (ConnectivityManager) MarsExplorerApplication.getApplicationInstance()
//                         .getSystemService(MarsExplorerApplication.getApplicationInstance()
//                                 .CONNECTIVITY_SERVICE);
// 
//         return connectivityManager.getActiveNetworkInfo() != null
//                 && connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting();
//     }
// 
//     /**
//      * It's usually very important for websites to track where their traffic is coming from.
//      * We make sure to let them know that we are sending them users by setting the referrer when
//      * launching our Custom Tab.
//      * @return The value of the Referrer Intent.
//      */
//     public static String customTabReferrerString() {
// 
//         int URI_ANDROID_APP_SCHEME;
// 
//         // Prepare for SDK version compatibility problems.
//         if(Build.VERSION.SDK_INT < 22)
//             URI_ANDROID_APP_SCHEME = 1<<1;
//         else
//             URI_ANDROID_APP_SCHEME = Intent.URI_ANDROID_APP_SCHEME;
// 
//         return URI_ANDROID_APP_SCHEME + "//" + MarsExplorerApplication.getApplicationInstance()
//                 .getPackageName();
//     }
// 
//     /**
//      * @return The Referrer intent key.
//      */
//     public static String customTabReferrerKey() {
// 
//         String EXTRA_REFERRER;
// 
//         // Prepare for SDK version compatibility problems.
//         if(Build.VERSION.SDK_INT < 17)
//             EXTRA_REFERRER = "android.intent.extra.REFERRER";
//         else
//             EXTRA_REFERRER = Intent.EXTRA_REFERRER;
// 
//         return EXTRA_REFERRER;
//     }
// }


import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.customtabs.CustomTabsClient;
import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsServiceConnection;
import android.support.customtabs.CustomTabsSession;
import android.support.v4.app.NavUtils;
import android.support.v4.content.ContextCompat;
import android.view.MenuItem;
import android.widget.Toast;
import io.github.krtkush.marsexplorer.About.Credits.CreditsActivity;
import io.github.krtkush.marsexplorer.R;
import io.github.krtkush.marsexplorer.UtilityMethods;
package io.github.krtkush.marsexplorer.About;



/**
 * Created by kartikeykushwaha on 21/10/16.
 */

public class AboutActivityPresenterLayer implements AboutActivityPresenterInteractor {

    private AboutActivity activity;

    // Variables for CustomTabs.
    private CustomTabsIntent customTabsIntent;
    private CustomTabsClient customTabsClient;
    private CustomTabsSession customTabsSession;
    private String DEVELOPER_PAGE = "https://krtkush.github.io";
    private String GITHUB_PAGE = "https://github.com/krtkush/MarsExplorer";
    // Keep track if the CustomTab is up and running. If not, open the links in the browser.
    private boolean isConnectedToCustomTabService;

    public AboutActivityPresenterLayer(AboutActivity activity) {

        this.activity = activity;
        prepareCustomTabs();
    }

    @Override
    public void checkInternetConnectivity() {
// Path: app/src/main/java/io/github/krtkush/marsexplorer/About/Credits/CreditsActivity.java
// public class CreditsActivity extends AppCompatActivity {
// 
//     @BindView(R.id.toolbar) Toolbar toolbar;
//     @BindView(R.id.creditsRecyclerView) RecyclerView recyclerView;
// 
//     private CreditsActivityPresenterInteractor presenterInteractor;
// 
//     @Override
//     protected void onCreate(Bundle savedInstanceState) {
//         super.onCreate(savedInstanceState);
//         setContentView(R.layout.activity_credits);
// 
//         // Initialise butterknife, timber and the presenter layer
//         ButterKnife.bind(CreditsActivity.this);
//         Timber.tag(CreditsActivity.this.getClass().getSimpleName());
//         presenterInteractor = new CreditsActivityPresenterLayer(this);
// 
//         // Setup the toolbar
//         setSupportActionBar(toolbar);
//         getSupportActionBar().setTitle("Credits");
// 
//         // Show the credit list
//         presenterInteractor.prepareRecyclerViewAndAddData(recyclerView);
//     }
// 
//     @Override
//     protected void attachBaseContext(Context newBase) {
//         super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
//     }
// 
//     @Override
//     protected void onResume() {
//         super.onResume();
//         presenterInteractor.checkInternetConnectivity();
//     }
// 
//     /**
//      * Method to make toast on this activity
//      * @param toastMessage The message to be displayed
//      * @param toastDuration Duration for the toast to be visible
//      */
//     protected void showToast(String toastMessage, int toastDuration) {
//         Toast.makeText(this, toastMessage, toastDuration).show();
//     }
// }
// 
// Path: app/src/main/java/io/github/krtkush/marsexplorer/UtilityMethods.java
// public class UtilityMethods {
// 
//     /**
//      * Method to detect network connection on the device
//      * @return
//      */
//     public static boolean isNetworkAvailable() {
// 
//         ConnectivityManager connectivityManager =
//                 (ConnectivityManager) MarsExplorerApplication.getApplicationInstance()
//                         .getSystemService(MarsExplorerApplication.getApplicationInstance()
//                                 .CONNECTIVITY_SERVICE);
// 
//         return connectivityManager.getActiveNetworkInfo() != null
//                 && connectivityManager.getActiveNetworkInfo().isConnectedOrConnecting();
//     }
// 
//     /**
//      * It's usually very important for websites to track where their traffic is coming from.
//      * We make sure to let them know that we are sending them users by setting the referrer when
//      * launching our Custom Tab.
//      * @return The value of the Referrer Intent.
//      */
//     public static String customTabReferrerString() {
// 
//         int URI_ANDROID_APP_SCHEME;
// 
//         // Prepare for SDK version compatibility problems.
//         if(Build.VERSION.SDK_INT < 22)
//             URI_ANDROID_APP_SCHEME = 1<<1;
//         else
//             URI_ANDROID_APP_SCHEME = Intent.URI_ANDROID_APP_SCHEME;
// 
//         return URI_ANDROID_APP_SCHEME + "//" + MarsExplorerApplication.getApplicationInstance()
//                 .getPackageName();
//     }
// 
//     /**
//      * @return The Referrer intent key.
//      */
//     public static String customTabReferrerKey() {
// 
//         String EXTRA_REFERRER;
// 
//         // Prepare for SDK version compatibility problems.
//         if(Build.VERSION.SDK_INT < 17)
//             EXTRA_REFERRER = "android.intent.extra.REFERRER";
//         else
//             EXTRA_REFERRER = Intent.EXTRA_REFERRER;
// 
//         return EXTRA_REFERRER;
//     }
// }


// Path: app/src/main/java/io/github/krtkush/marsexplorer/About/AboutActivityPresenterLayer.java
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.support.customtabs.CustomTabsClient;
import android.support.customtabs.CustomTabsIntent;
import android.support.customtabs.CustomTabsServiceConnection;
import android.support.customtabs.CustomTabsSession;
import android.support.v4.app.NavUtils;
import android.support.v4.content.ContextCompat;
import android.view.MenuItem;
import android.widget.Toast;
import io.github.krtkush.marsexplorer.About.Credits.CreditsActivity;
import io.github.krtkush.marsexplorer.R;
import io.github.krtkush.marsexplorer.UtilityMethods;

package io.github.krtkush.marsexplorer.About;



/**
 * Created by kartikeykushwaha on 21/10/16.
 */

public class AboutActivityPresenterLayer implements AboutActivityPresenterInteractor {

    private AboutActivity activity;

    // Variables for CustomTabs.
    private CustomTabsIntent customTabsIntent;
    private CustomTabsClient customTabsClient;
    private CustomTabsSession customTabsSession;
    private String DEVELOPER_PAGE = "https://krtkush.github.io";
    private String GITHUB_PAGE = "https://github.com/krtkush/MarsExplorer";
    // Keep track if the CustomTab is up and running. If not, open the links in the browser.
    private boolean isConnectedToCustomTabService;

    public AboutActivityPresenterLayer(AboutActivity activity) {

        this.activity = activity;
        prepareCustomTabs();
    }

    @Override
    public void checkInternetConnectivity() {
        if(!UtilityMethods.isNetworkAvailable())