package io.smartlogic.smartchat.activities;

import android.app.Activity;
import android.app.ActionBar;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.os.Build;

import io.smartlogic.smartchat.R;
import io.smartlogic.smartchat.fragments.InitialLoginFragment;
import io.smartlogic.smartchat.fragments.LoginFragment;
import io.smartlogic.smartchat.fragments.SignUpFragment;

public class LoginActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_login);

        if (savedInstanceState == null) {
            getFragmentManager().beginTransaction()
                    .add(R.id.container, new InitialLoginFragment())
                    .commit();
        }
    }

    public void switchToLogin() {
        getFragmentManager().beginTransaction()
                .replace(R.id.container, new LoginFragment())
                .commit();
    }

    public void switchToSignUp() {
        getFragmentManager().beginTransaction()
                .replace(R.id.container, new SignUpFragment())
                .commit();
    }
}

@@ -86,250 +86,17 @@
 oid.
-app.ActionBar;%0Aimport android.app.Fragment;%0Aimport android.os.Bundle;%0Aimport android.view.LayoutInflater;%0Aimport android.view.Menu;%0Aimport android.view.MenuItem;%0Aimport android.view.View;%0Aimport android.view.ViewGroup;%0Aimport android.os.Build
+os.Bundle
 ;%0A%0Ai
@@ -351,16 +351,66 @@
 ivity %7B%0A
+    private boolean initialLoginFragment = true;%0A%0A
     @Ove
@@ -785,37 +785,414 @@
     
-public void switchToLogin() %7B
+@Override%0A    public void onBackPressed() %7B%0A        if (initialLoginFragment) %7B%0A            finish();%0A        %7D else %7B%0A            initialLoginFragment = true;%0A%0A            getFragmentManager().beginTransaction()%0A                    .replace(R.id.container, new InitialLoginFragment())%0A                    .commit();%0A        %7D%0A    %7D%0A%0A    public void switchToLogin() %7B%0A        initialLoginFragment = false;%0A
 %0A   
@@ -1363,24 +1363,63 @@
 oSignUp() %7B%0A
+        initialLoginFragment = false;%0A%0A
         getF

Handle back button in the LoginActivity with fragments