<commit_before>package im.actor.messenger.app.fragment.auth;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.MenuItem;

import im.actor.messenger.R;
import im.actor.messenger.app.activity.MainActivity;
import im.actor.messenger.app.activity.BaseFragmentActivity;
import im.actor.model.AuthState;
import im.actor.model.concurrency.Command;
import im.actor.model.concurrency.CommandCallback;
import im.actor.model.network.RpcException;
import im.actor.model.network.RpcInternalException;
import im.actor.model.network.RpcTimeoutException;

import static im.actor.messenger.app.core.Core.messenger;

public class AuthActivity extends BaseFragmentActivity {

    private static final int OAUTH_DIALOG = 1;
    private ProgressDialog progressDialog;
    private AlertDialog alertDialog;
    private AuthState state;
    public static final String AUTH_TYPE_KEY = "auth_type";
    public static final String SIGN_TYPE_KEY = "sign_type";
    public static final int AUTH_TYPE_PHONE = 1;
    public static final int AUTH_TYPE_EMAIL = 2;
    public static final int SIGN_TYPE_IN = 3;
    public static final int SIGN_TYPE_UP = 4;
    private int authType = AUTH_TYPE_PHONE;
    private int signType;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        signType = getIntent().getIntExtra(SIGN_TYPE_KEY, SIGN_TYPE_IN);
        if (savedInstanceState == null) {
            updateState();
        }
    }

    @Override
    public void onBackPressed() {
        messenger().trackBackPressed();
        super.onBackPressed();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            messenger().trackUpPressed();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (messenger().getAuthState() == AuthState.LOGGED_IN) {
            finish();
        }
    }

    public void updateState() {
        updateState(messenger().getAuthState());
    }

    private void updateState(AuthState state) {
        if (this.state != null && this.state == state) {
            return;
        }
        this.state = state;

        switch (state) {
            case AUTH_START:
                Fragment chooseAuthFr = new ChooseAuthTypeFragment();
                Bundle b = new Bundle();
                b.putInt(SIGN_TYPE_KEY, signType);
                chooseAuthFr.setArguments(b);
                showFragment(chooseAuthFr, false, false);
                break;
            case AUTH_EMAIL:
                showFragment(new SignEmailFragment(), false, false);
                authType = AUTH_TYPE_EMAIL;
                break;
            case AUTH_PHONE:
                showFragment(new SignPhoneFragment(), false, false);
                authType = AUTH_TYPE_PHONE;
                break;
            case CODE_VALIDATION_PHONE:
            case CODE_VALIDATION_EMAIL:
                if ((state == AuthState.CODE_VALIDATION_EMAIL && authType == AUTH_TYPE_PHONE) || (state == AuthState.CODE_VALIDATION_PHONE && authType == AUTH_TYPE_EMAIL)) {
                    updateState(AuthState.AUTH_START);
                    break;
                }
                Fragment signInFragment = new SignInFragment();
                Bundle args = new Bundle();
                args.putString("authType", state == AuthState.CODE_VALIDATION_EMAIL ? SignInFragment.AUTH_TYPE_EMAIL : SignInFragment.AUTH_TYPE_PHONE);
                signInFragment.setArguments(args);
                showFragment(signInFragment, false, false);
                break;<commit_msg>fix(android): Disabling email auth<commit_after>package im.actor.messenger.app.fragment.auth;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.MenuItem;

import im.actor.messenger.R;
import im.actor.messenger.app.activity.MainActivity;
import im.actor.messenger.app.activity.BaseFragmentActivity;
import im.actor.model.AuthState;
import im.actor.model.concurrency.Command;
import im.actor.model.concurrency.CommandCallback;
import im.actor.model.network.RpcException;
import im.actor.model.network.RpcInternalException;
import im.actor.model.network.RpcTimeoutException;

import static im.actor.messenger.app.core.Core.messenger;

public class AuthActivity extends BaseFragmentActivity {

    private static final int OAUTH_DIALOG = 1;
    private ProgressDialog progressDialog;
    private AlertDialog alertDialog;
    private AuthState state;
    public static final String AUTH_TYPE_KEY = "auth_type";
    public static final String SIGN_TYPE_KEY = "sign_type";
    public static final int AUTH_TYPE_PHONE = 1;
    public static final int AUTH_TYPE_EMAIL = 2;
    public static final int SIGN_TYPE_IN = 3;
    public static final int SIGN_TYPE_UP = 4;
    private int authType = AUTH_TYPE_PHONE;
    private int signType;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        signType = getIntent().getIntExtra(SIGN_TYPE_KEY, SIGN_TYPE_IN);
        if (savedInstanceState == null) {
            updateState();
        }
    }

    @Override
    public void onBackPressed() {
        messenger().trackBackPressed();
        super.onBackPressed();
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            messenger().trackUpPressed();
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if (messenger().getAuthState() == AuthState.LOGGED_IN) {
            finish();
        }
    }

    public void updateState() {
        updateState(messenger().getAuthState());
    }

    private void updateState(AuthState state) {
        if (this.state != null && this.state == state) {
            return;
        }
        this.state = state;

        switch (state) {
            case AUTH_START:
//                Fragment chooseAuthFr = new ChooseAuthTypeFragment();
//                Bundle b = new Bundle();
//                b.putInt(SIGN_TYPE_KEY, signType);
//                chooseAuthFr.setArguments(b);
//                showFragment(chooseAuthFr, false, false);
//                break;
//            case AUTH_EMAIL:
//                showFragment(new SignEmailFragment(), false, false);
//                authType = AUTH_TYPE_EMAIL;
//                break;
//            case AUTH_PHONE:
                showFragment(new SignPhoneFragment(), false, false);
                authType = AUTH_TYPE_PHONE;
                break;
            case CODE_VALIDATION_PHONE:
            case CODE_VALIDATION_EMAIL:
                if ((state == AuthState.CODE_VALIDATION_EMAIL && authType == AUTH_TYPE_PHONE) || (state == AuthState.CODE_VALIDATION_PHONE && authType == AUTH_TYPE_EMAIL)) {
                    updateState(AuthState.AUTH_START);
                    break;
                }
                Fragment signInFragment = new SignInFragment();
                Bundle args = new Bundle();
                args.putString("authType", state == AuthState.CODE_VALIDATION_EMAIL ? SignInFragment.AUTH_TYPE_EMAIL : SignInFragment.AUTH_TYPE_PHONE);
                signInFragment.setArguments(args);
                showFragment(signInFragment, false, false);
                break;
{'fraction_non_alphanumeric': 0.09175138334834641, 'fraction_numerical': 0.001544202805301763, 'mean_word_length': 2.5103884372177054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2409720', 'n_tokens_mistral': 2197, 'n_tokens_neox': 2087, 'n_words': 452}