package com.example.ar;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.RatingBar;
import android.widget.TextView;

public class AccountRegistrationActivity3 extends Activity {
    private static String TAG = "AccountRegistration";

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

        final DatePicker birthdate =
                (DatePicker) findViewById(R.id.birthdate);
        birthdate.init(birthdate.getYear() - 18, 0, 1,
                new DatePicker.OnDateChangedListener() {
                    public void onDateChanged(DatePicker view,
                            int year, int month, int day) {

                        String birthdateString =
                                getResources().getString(
                                        R.string.birthday);
                        TextView text = (TextView) 
                                findViewById(R.id.labelBirthdate);
                        text.setText(birthdateString + ": "
                                + (birthdate.getMonth() + 1) + "/"
                                + birthdate.getDayOfMonth() + "/"
                                + birthdate.getYear());
                    }
                });

        Button done = (Button) findViewById(R.id.done);
        done.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                RatingBar rating =
                        (RatingBar) findViewById(R.id.rating);

                Log.v(TAG, "Birthdate: " + birthdate.getMonth() + " "
                        + birthdate.getDayOfMonth() + ", "
                        + birthdate.getYear());
                Log.v(TAG, "Rating: " + rating.getRating());

                Intent i = new Intent();
                i.setClass(AccountRegistrationActivity3.this,
                        ThankYouActivity.class);
                startActivity(i);
            }
        });

        Button back = (Button) findViewById(R.id.back);
        back.setOnClickListener(new OnClickListener() {
            public void onClick(View view) {
                finish();
            }
        });
    }
}