// Path: app/src/main/java/com/example/massa/luxvilla/utils/mailcheck.java
// public class mailcheck {
// 
//     public static boolean isEmailValid(CharSequence email) {
//         return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
//     }
// }


import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.AppCompatButton;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.massa.luxvilla.R;
import com.example.massa.luxvilla.utils.mailcheck;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;

    FirebaseAuth firebaseAuth;
    FirebaseUser user;

    private GoogleApiClient mGoogleApiClient;
    private static final int RC_SIGN_IN = 9001;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.login);
        sharedPreferencesapp= PreferenceManager.getDefaultSharedPreferences(Loginactivity.this);
        boolean nightmode=sharedPreferencesapp.getBoolean(getResources().getString(R.string.night_mode),false);
        if (nightmode){
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        }else{
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        super.onCreate(savedInstanceState);

        user=FirebaseAuth.getInstance().getCurrentUser();
        if (user !=null){
            startActivity(new Intent(Loginactivity.this,MainActivity.class));
            finish();
            return;
        }
        setContentView(R.layout.activity_loginactivity);

        firebaseAuth=FirebaseAuth.getInstance();

        linearLayout= findViewById(R.id.linearLayoutsignin);
// Path: app/src/main/java/com/example/massa/luxvilla/utils/mailcheck.java
// public class mailcheck {
// 
//     public static boolean isEmailValid(CharSequence email) {
//         return android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches();
//     }
// }


// Path: app/src/main/java/com/example/massa/luxvilla/Actividades/Loginactivity.java
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.Snackbar;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.AppCompatButton;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.example.massa.luxvilla.R;
import com.example.massa.luxvilla.utils.mailcheck;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.OnFailureListener;
import com.google.android.gms.tasks.OnSuccessListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseAuthException;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GoogleAuthProvider;


    FirebaseAuth firebaseAuth;
    FirebaseUser user;

    private GoogleApiClient mGoogleApiClient;
    private static final int RC_SIGN_IN = 9001;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.login);
        sharedPreferencesapp= PreferenceManager.getDefaultSharedPreferences(Loginactivity.this);
        boolean nightmode=sharedPreferencesapp.getBoolean(getResources().getString(R.string.night_mode),false);
        if (nightmode){
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
        }else{
            AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
        }
        super.onCreate(savedInstanceState);

        user=FirebaseAuth.getInstance().getCurrentUser();
        if (user !=null){
            startActivity(new Intent(Loginactivity.this,MainActivity.class));
            finish();
            return;
        }
        setContentView(R.layout.activity_loginactivity);

        firebaseAuth=FirebaseAuth.getInstance();

        linearLayout= findViewById(R.id.linearLayoutsignin);
        textInputLayoutmail= findViewById(R.id.text_input_mail);