package edu.rpi.cs.yacs.core;

import android.Manifest;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;

import com.github.paolorotolo.appintro.AppIntro2;
import com.github.paolorotolo.appintro.AppIntroFragment;

import edu.rpi.cs.yacs.R;
import edu.rpi.cs.yacs.slides.SelectHomeSlide;

/**
 * Created by Mark Robinson on 9/24/16.
 */

public class IntroActivity extends AppIntro2 {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        addSlide(AppIntroFragment.newInstance("Welcome To YACS!", "Short description \n", R.drawable.indicator_dot_white, Color.parseColor("#ef5350")));
        addSlide(AppIntroFragment.newInstance("YACS", "Description of features\n", R.drawable.indicator_dot_white, Color.parseColor("#ef5350")));
        addSlide(AppIntroFragment.newInstance("Google Calendar", "If you want, Google Calendar can be used to save your schedules.\n", R.drawable.indicator_dot_white, Color.parseColor("#ef5350")));
        addSlide(new SelectHomeSlide());
        addSlide(AppIntroFragment.newInstance("All Set!", "You're awesome, enjoy our app! \n", R.drawable.indicator_dot_white, Color.parseColor("#ef5350")));

        askForPermissions(new String[]{Manifest.permission.READ_CALENDAR, Manifest.permission.WRITE_CALENDAR}, 2);

        setFlowAnimation();
        setSwipeLock(false);
        setNextPageSwipeLock(false);
        setImmersiveMode(true);
    }

    @Override
    public void onSkipPressed(Fragment currentFragment) {
        super.onSkipPressed(currentFragment);

        launchMain();
    }

    @Override
    public void onDonePressed(Fragment currentFragment) {
        super.onDonePressed(currentFragment);

        launchMain();
    }

    public void launchMain() {
        Intent i = new Intent(this, MainActivity.class);
        i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

        startActivity(i);
        finish();
    }
}
@@ -99,48 +99,135 @@
 oid.
-graphics.Color;%0Aimport android.os.Bundle
+content.SharedPreferences;%0Aimport android.graphics.Color;%0Aimport android.os.Bundle;%0Aimport android.preference.PreferenceManager
 ;%0Aim
@@ -544,16 +544,61 @@
 tro2 %7B%0A%0A
+    SelectHomeSlide selectHomeSlide = null;%0A%0A
     @Ove
@@ -701,24 +701,74 @@
 nceState);%0A%0A
+        selectHomeSlide = new SelectHomeSlide();%0A%0A
         addS
@@ -1269,21 +1269,17 @@
 ddSlide(
-new S
+s
 electHom
@@ -1284,18 +1284,16 @@
 omeSlide
-()
 );%0A     
@@ -1442,24 +1442,53 @@
 f5350%22)));%0A%0A
+        setFlowAnimation();%0A%0A
         askF
@@ -1590,38 +1590,9 @@
 R%7D, 
-2);%0A%0A        setFlowAnimation(
+3
 );%0A 
@@ -1759,32 +1759,355 @@
 rentFragment) %7B%0A
+        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());%0A        String houseOfYACS = preferences.getString(getString(R.string.houseOfYACS), %22unkown%22);%0A%0A        if (!currentFragment.getClass().equals(selectHomeSlide.getClass()) && !houseOfYACS.equals(%22unkown%22)) %7B%0A    
         super.on
@@ -2128,33 +2128,36 @@
 rrentFragment);%0A
-%0A
+    
         launchMa
@@ -2154,32 +2154,42 @@
   launchMain();%0A
+        %7D%0A
     %7D%0A%0A    @Over
@@ -2243,32 +2243,355 @@
 rentFragment) %7B%0A
+        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());%0A        String houseOfYACS = preferences.getString(getString(R.string.houseOfYACS), %22unkown%22);%0A%0A        if (!currentFragment.getClass().equals(selectHomeSlide.getClass()) && !houseOfYACS.equals(%22unkown%22)) %7B%0A    
         super.on
@@ -2620,17 +2620,20 @@
 gment);%0A
-%0A
+    
         
@@ -2642,24 +2642,34 @@
 unchMain();%0A
+        %7D%0A
     %7D%0A%0A    p

Disable launchMain() on SelectHomeSlide