package io.github.lewismcgeary.androidgameoflife;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.ActivityOptionsCompat;
import android.support.v4.util.Pair;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.CardView;
import android.view.MotionEvent;
import android.view.View;

public class IntroActivity extends AppCompatActivity {
    FloatingActionButton introDoneButton;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intro);
        introDoneButton = (FloatingActionButton)findViewById(R.id.intro_done_button);
        introDoneButton.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                startTransition();
                return false;
            }
        });
    }
    private void startTransition(){
        CardView introCardView = (CardView)findViewById(R.id.intro_card_view);
        Intent intent = new Intent(this, LifeGameActivity.class);
        Pair<View, String> pair1 = Pair.create((View)introCardView, getString(R.string.card_view_transition_name));
        Pair<View, String> pair2 = Pair.create((View)introDoneButton, getString(R.string.fab_transition_name));
        ActivityOptionsCompat options =
                ActivityOptionsCompat.makeSceneTransitionAnimation(this, pair1, pair2);
        ActivityCompat.startActivity(this, intent, options.toBundle());

    }
}

@@ -71,24 +71,64 @@
 ent.Intent;%0A
+import android.content.pm.ActivityInfo;%0A
 import andro
@@ -141,16 +141,16 @@
 Bundle;%0A
-
 import a
@@ -457,24 +457,53 @@
 otionEvent;%0A
+import android.view.Surface;%0A
 import andro
@@ -614,16 +614,17 @@
 Button;%0A
+%0A
     @Ove
@@ -1019,24 +1019,69 @@
 nt event) %7B%0A
+                setFixedScreenOrientation();%0A
             
@@ -1161,24 +1161,300 @@
   %7D);%0A    %7D%0A
+%0A    @Override%0A    protected void onResume() %7B%0A        //allows screen to rotate again. Screen orientation is fixed while transitioning between%0A        //activities%0A        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);%0A        super.onResume();%0A    %7D%0A%0A
     private 
@@ -2050,16 +2050,980 @@
 dle());%0A
+    %7D%0A%0A    private void setFixedScreenOrientation()%7B%0A        //setting fixed orientation before switching to the next activity avoids an error if device%0A        //is in a different orientation when back button is pressed to return to this activity%0A        int orientation = getWindowManager().getDefaultDisplay().getRotation();%0A%0A        switch(orientation) %7B%0A            case Surface.ROTATION_180:%0A                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);%0A                break;%0A            case Surface.ROTATION_270:%0A                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);%0A                break;%0A            case  Surface.ROTATION_0:%0A                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);%0A                break;%0A            case Surface.ROTATION_90:%0A                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);%0A                break;%0A        %7D
 %0A    %7D%0A%7D

disable then resume screen rotation when leaving and returning to intro screen