// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java
// public class ServiceConstants {
// 
//     // MSA
//     public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>";
//     public static final String ONENOTE_API = "https://www.onenote.com/api";
//     // Org
//     public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com";
//     public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common";
//     public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>";
//     public static final String CLIENT_ID = "<Your CLIENT ID HERE>";
// }
// 
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java
// public class SharedPrefsUtil {
// 
//     public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN";
// 
//     public static SharedPreferences getSharedPreferences() {
//         return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE);
//     }
// 
//     public static void persistAuthToken(AuthenticationResult result) {
//         setAccessToken(result.getAccessToken());
//         User.isOrg(true);
//     }
// 
//     public static void persistAuthToken(LiveConnectSession session) {
//         setAccessToken(session.getAccessToken());
//         User.isMsa(true);
//     }
// 
//     private static void setAccessToken(String accessToken) {
//         getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit();
//     }
// }
// 
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java
// public class User {
// 
//     private static final String PREF_MSA = "PREF_MSA";
//     private static final String PREF_ORG = "PREF_ORG";
// 
//     static void isMsa(boolean msa) {
//         set(PREF_MSA, msa);
//     }
// 
//     static void isOrg(boolean org) {
//         set(PREF_ORG, org);
//     }
// 
//     public static boolean isMsa() {
//         return is(PREF_MSA);
//     }
// 
//     public static boolean isOrg() {
//         return is(PREF_ORG);
//     }
// 
//     private static boolean is(String which) {
//         return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false);
//     }
// 
//     private static void set(String which, boolean state) {
//         SharedPrefsUtil
//                 .getSharedPreferences()
//                 .edit()
//                 .putBoolean(which, state)
//                 .commit();
//     }
// }


import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.live.LiveAuthException;
import com.microsoft.live.LiveAuthListener;
import com.microsoft.live.LiveConnectSession;
import com.microsoft.live.LiveStatus;
import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants;
import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil;
import com.microsoft.o365_android_onenote_rest.util.User;
import java.net.URI;
import java.util.UUID;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;
import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin;
import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin;
    }

    private void start() {
        Intent appLaunch = new Intent(this, SnippetListActivity.class);
        startActivity(appLaunch);
    }

    @Override
    public void onError(Exception e) {
        e.printStackTrace();
        String msg;
        if (null == (msg = e.getLocalizedMessage())) {
            msg = getString(R.string.signin_err);
        }
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onAuthComplete(LiveStatus status,
                               LiveConnectSession session,
                               Object userState) {
        Timber.d("MSA: Auth Complete...");
        if (null != status) {
            Timber.d(status.toString());
        }
        if (null != session) {
            Timber.d(session.toString());
            SharedPrefsUtil.persistAuthToken(session);
        }
        if (null != userState) {
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/conf/ServiceConstants.java
// public class ServiceConstants {
// 
//     // MSA
//     public static final String MSA_CLIENT_ID = "<Your MSA CLIENT ID>";
//     public static final String ONENOTE_API = "https://www.onenote.com/api";
//     // Org
//     public static final String AUTHENTICATION_RESOURCE_ID = "https://onenote.com";
//     public static final String AUTHORITY_URL = "https://login.microsoftonline.com/common";
//     public static final String REDIRECT_URI = "<Your REDIRECT URI HERE>";
//     public static final String CLIENT_ID = "<Your CLIENT ID HERE>";
// }
// 
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/SharedPrefsUtil.java
// public class SharedPrefsUtil {
// 
//     public static final String PREF_AUTH_TOKEN = "PREF_AUTH_TOKEN";
// 
//     public static SharedPreferences getSharedPreferences() {
//         return SnippetApp.getApp().getSharedPreferences(AppModule.PREFS, Context.MODE_PRIVATE);
//     }
// 
//     public static void persistAuthToken(AuthenticationResult result) {
//         setAccessToken(result.getAccessToken());
//         User.isOrg(true);
//     }
// 
//     public static void persistAuthToken(LiveConnectSession session) {
//         setAccessToken(session.getAccessToken());
//         User.isMsa(true);
//     }
// 
//     private static void setAccessToken(String accessToken) {
//         getSharedPreferences().edit().putString(PREF_AUTH_TOKEN, accessToken).commit();
//     }
// }
// 
// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/util/User.java
// public class User {
// 
//     private static final String PREF_MSA = "PREF_MSA";
//     private static final String PREF_ORG = "PREF_ORG";
// 
//     static void isMsa(boolean msa) {
//         set(PREF_MSA, msa);
//     }
// 
//     static void isOrg(boolean org) {
//         set(PREF_ORG, org);
//     }
// 
//     public static boolean isMsa() {
//         return is(PREF_MSA);
//     }
// 
//     public static boolean isOrg() {
//         return is(PREF_ORG);
//     }
// 
//     private static boolean is(String which) {
//         return SharedPrefsUtil.getSharedPreferences().getBoolean(which, false);
//     }
// 
//     private static void set(String which, boolean state) {
//         SharedPrefsUtil
//                 .getSharedPreferences()
//                 .edit()
//                 .putBoolean(which, state)
//                 .commit();
//     }
// }


// Path: app/src/main/java/com/microsoft/o365_android_onenote_rest/SignInActivity.java
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.microsoft.aad.adal.AuthenticationCallback;
import com.microsoft.aad.adal.AuthenticationResult;
import com.microsoft.live.LiveAuthException;
import com.microsoft.live.LiveAuthListener;
import com.microsoft.live.LiveConnectSession;
import com.microsoft.live.LiveStatus;
import com.microsoft.o365_android_onenote_rest.conf.ServiceConstants;
import com.microsoft.o365_android_onenote_rest.util.SharedPrefsUtil;
import com.microsoft.o365_android_onenote_rest.util.User;
import java.net.URI;
import java.util.UUID;
import butterknife.ButterKnife;
import butterknife.OnClick;
import timber.log.Timber;
import static com.microsoft.o365_android_onenote_rest.R.id.msa_signin;
import static com.microsoft.o365_android_onenote_rest.R.id.o365_signin;

    }

    private void start() {
        Intent appLaunch = new Intent(this, SnippetListActivity.class);
        startActivity(appLaunch);
    }

    @Override
    public void onError(Exception e) {
        e.printStackTrace();
        String msg;
        if (null == (msg = e.getLocalizedMessage())) {
            msg = getString(R.string.signin_err);
        }
        Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onAuthComplete(LiveStatus status,
                               LiveConnectSession session,
                               Object userState) {
        Timber.d("MSA: Auth Complete...");
        if (null != status) {
            Timber.d(status.toString());
        }
        if (null != session) {
            Timber.d(session.toString());
            SharedPrefsUtil.persistAuthToken(session);
        }
        if (null != userState) {
            Timber.d(userState.toString());