/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.explicitintent;

import android.content.Context;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    /* Fields that will store our EditText and Button */
    private EditText mNameEntry;
    private Button mDoSomethingCoolButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        /*
         * Using findViewById, we get a reference to our Button from xml. This allows us to
         * do things like set the onClickListener which determines what happens when the button
         * is clicked.
         */
        mDoSomethingCoolButton = (Button) findViewById(R.id.b_do_something_cool);
        mNameEntry = (EditText) findViewById(R.id.et_text_entry);

        /* Setting an OnClickListener allows us to do something when this button is clicked. */
        mDoSomethingCoolButton.setOnClickListener(new OnClickListener() {

            /**
             * The onClick method is triggered when this button (mDoSomethingCoolButton) is clicked.
             *
             * @param v The view that is clicked. In this case, it's mDoSomethingCoolButton.
             */
            @Override
            public void onClick(View v) {
                /*
                 * Storing the Context in a variable in this case is redundant since we could have
                 * just used "this" or "MainActivity.this" in the method call below. However, we
                 * wanted to demonstrate what parameter we were using "MainActivity.this" for as
                 * clear as possible.
                 */
                Context context = MainActivity.this;

                // TODO (1) Store ChildActivity.class in a Class object called destinationActivity

                // TODO (2) Create an Intent to start ChildActivity

                // TODO (3) Replace the Toast with code to start ChildActivity
                String message = "Button clicked!\nTODO: Start a new Activity and pass some data.";
                Toast.makeText(context, message, Toast.LENGTH_LONG).show();

            }
        });
    }
}


@@ -686,24 +686,55 @@
 nt.Context;%0A
+import android.content.Intent;%0A
 import andro
@@ -2611,20 +2611,25 @@
      // 
-TODO
+completed
  (1) Sto
@@ -2687,32 +2687,97 @@
 tinationActivity
+%0A                Class destinationActivity = ChildActivity.class;
 %0A%0A              
@@ -2781,20 +2781,25 @@
      // 
-TODO
+completed
  (2) Cre
@@ -2834,16 +2834,181 @@
 Activity
+%0A                //Intent intent = new Intent(this, DisplayMessageActivity.class);%0A                Intent intent = new Intent(getBaseContext(), destinationActivity);
 %0A%0A      
@@ -3020,20 +3020,25 @@
      // 
-TODO
+completed
  (3) Rep
@@ -3201,16 +3201,18 @@
         
+//
 Toast.ma
@@ -3263,16 +3263,56 @@
 show();%0A
+                startActivity(intent);%0A%0A
 %0A       

complete TODO 1-3