package passel.w21789.com.passel;

import android.content.Intent;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;


public class ChangePasswordActivity extends ActionBarActivity {

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

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_change_password, menu);
        return true;


    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.

        switch (item.getItemId()) {
//            case R.id.action_settings:
////                openSearch();
//                Intent settingsIntent = new Intent(ChangePasswordActivity.this, SettingsActivity.class);
//                ChangePasswordActivity.this.startActivity(settingsIntent);
//                return true;
            case R.id.change_password_check:
                // Go back to the settings page
                //TODO: Insert password changing logic here
                //TODO: Make it display that little text at the bottom if the pw was changed
                Intent myIntent = new Intent(ChangePasswordActivity.this, SettingsActivity.class);
//        myIntent.putExtra("key", value); //Optional parameters
                ChangePasswordActivity.this.startActivity(myIntent);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}

@@ -28,16 +28,48 @@
 assel;%0A%0A
+import android.content.Context;%0A
 import a
@@ -278,16 +278,77 @@
 Button;%0A
+import android.widget.EditText;%0Aimport android.widget.Toast;%0A
 %0A%0Apublic
@@ -825,17 +825,370 @@
 n true;%0A
-%0A
+    %7D%0A%0A    private boolean checkPasswordAndConfirmPassword(String password,String confirmPassword)%0A    %7B%0A        boolean confirmed = false;%0A        if (confirmPassword != null && password != null)%0A        %7B%0A            if (password.equals(confirmPassword))%0A            %7B%0A                confirmed = true;%0A            %7D%0A        %7D%0A        return confirmed;
 %0A    %7D%0A%0A
@@ -2057,253 +2057,800 @@
     
-Intent myIntent = new Intent(ChangePasswordActivity.this, SettingsActivity.class);%0A//        myIntent.putExtra(%22key%22, value); //Optional parameters%0A                ChangePasswordActivity.this.startActivity(myIntent);%0A                return true;
+//Take inputs from the password fields%0A                String password = ((EditText)findViewById(R.id.passwordNew)).getText().toString();%0A                String passwordConfirm = ((EditText)findViewById(R.id.passwordConfirm)).getText().toString();%0A                boolean confirmed = checkPasswordAndConfirmPassword(password, passwordConfirm);%0A                if (confirmed) %7B%0A                    finish();%0A                    return true;%0A                %7D else %7B%0A                    Context context = getApplicationContext();%0A                    String text = %22Passwords do not match%22;%0A                    int duration = Toast.LENGTH_SHORT;%0A%0A                    Toast toast = Toast.makeText(context, text, duration);%0A                    toast.show();%0A                    %0A                %7D%0A
 %0A   

Add small validator for password changer