package it.solarma.android.colorcode;

import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.common.api.GoogleApiClient;

public class MainActivity extends AppCompatActivity {

    /**
     * ATTENTION: This was auto-generated to implement the App Indexing API.
     * See https://g.co/AppIndexing/AndroidStudio for more information.
     */
    private GoogleApiClient client;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();

        showSomething("Color Code\nCopyright 2016, Gianpaolo Macario");
    }

//    /**
//     * This method is called when one of the buttons at top is clicked.
//     */
//    public void chooseFunction(View view) {
//        // TODO
//        // Button nameField = (Button) findViewById(R.id.name_field);
//        // Editable nameEditable = nameField.getText();
//        Button button = (Button) view;
//        // String text = button.getText();
//        // showSomething(text);
//    }

    public void chooseFunc1(View view) {
        showSomething("Function 1\nShow Value");
    }

    public void chooseFunc2(View view) {
        showSomething("Function 2\nShow Color");
    }

    public void chooseFunc3(View view) {
        showSomething("Function 3\nNominal Values");
    }

    public void chooseFunc4(View view) {
        showSomething("Function 4\nFind the Wrong Color");
    }

    public void chooseFunc5(View view) {
        showSomething("Function 5\nFind the Missing Color");
    }

    public void chooseFunc6(View view) {
        showSomething("Color Code\nCopyright 2016, Gianpaolo Macario");
    }

    /**
     * Displays the given score for Team A.
     */
    public void showSomething(String text) {
        TextView scoreView = (TextView) findViewById(R.id.textView_func1);
        //scoreView.setText(String.valueOf(score));
        scoreView.setText(text);
    }

    @Override
    public void onStart() {
        super.onStart();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        client.connect();
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app URL is correct.
                Uri.parse("android-app://it.solarma.android.colorcode/http/host/path")
        );
        AppIndex.AppIndexApi.start(client, viewAction);
    }

    @Override
    public void onStop() {
        super.onStop();

        // ATTENTION: This was auto-generated to implement the App Indexing API.
        // See https://g.co/AppIndexing/AndroidStudio for more information.
        Action viewAction = Action.newAction(
                Action.TYPE_VIEW, // TODO: choose an action type.
                "Main Page", // TODO: Define a title for the content shown.
                // TODO: If you have web page content that matches this app activity's content,
                // make sure this auto-generated web page URL is correct.
                // Otherwise, set the URL to null.
                Uri.parse("http://host/path"),
                // TODO: Make sure this auto-generated app URL is correct.
                Uri.parse("android-app://it.solarma.android.colorcode/http/host/path")
        );
        AppIndex.AppIndexApi.end(client, viewAction);
        client.disconnect();
    }
}

@@ -1685,16 +1685,18 @@
 w Value%22
+,1
 );%0A    %7D
@@ -1780,24 +1780,26 @@
 nShow Color%22
+,2
 );%0A    %7D%0A%0A  
@@ -1887,16 +1887,18 @@
  Values%22
+,3
 );%0A    %7D
@@ -1988,32 +1988,34 @@
 the Wrong Color%22
+,4
 );%0A    %7D%0A%0A    pu
@@ -2107,16 +2107,18 @@
 g Color%22
+,5
 );%0A    %7D
@@ -2221,32 +2221,34 @@
 anpaolo Macario%22
+,6
 );%0A    %7D%0A%0A    /*
@@ -2342,16 +2342,27 @@
 ing text
+,int choice
 ) %7B%0A    
@@ -2387,56 +2387,630 @@
 View
- = (TextView) findViewById(R.id.textView_func1);
+;%0A        if(choice == 1 %7C%7C choice == 6)%0A        %7B%0A          scoreView = (TextView) findViewById(R.id.textView_func1);   %0A        %7D%0A        else if(choice == 2)%0A        %7B%0A          scoreView = (TextView) findViewById(R.id.textView_func2);   %0A        %7D  %0A        else if(choice == 3)%0A        %7B%0A          scoreView = (TextView) findViewById(R.id.textView_func3);   %0A        %7D   %0A        else if(choice == 4)%0A        %7B%0A          scoreView = (TextView) findViewById(R.id.textView_func4);   %0A        %7D   %0A        else if(choice == 5)%0A        %7B%0A          scoreView = (TextView) findViewById(R.id.textView_func5);   %0A        %7D   
 %0A   

Update MainActivity.java (#34)