Commit 9ea73cdd authored by Tristan's avatar Tristan
Browse files

V2 Tristan

parent 26e00d3b
package com.example.wastedfood;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
public class LoginActivity extends AppCompatActivity {
private EditText edEmail;
private EditText edPassword;
private EditText btnLogin;
private EditText btnSignin;
private final String CREDENTIAL_SHARED_PREF = "our_shared_pref";
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
edEmail = findViewById(R.id.ed_email);
edPassword = findViewById(R.id.ed_password);
btnLogin = findViewById(R.id.btn_login);
btnSignin = findViewById(R.id.btn_signin);
btnSignin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent( LoginActivity.this, SignupActivity.class);
startActivity(intent);
}
});
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SharedPreferences credentials = getSharedPreferences(CREDENTIAL_SHARED_PREF, Context.MODE_PRIVATE);
String strEmail = credentials.getString("Email",null);
String strPassword = credentials.getString("Password",null);
String email_from_ed = edEmail.getText().toString();
String password_from_ed = edPassword.getText().toString();
if (strEmail != null && email_from_ed != null && strEmail.equalsIgnoreCase(email_from_ed)) {
if (strPassword != null && password_from_ed != null && strPassword.equalsIgnoreCase(password_from_ed)) {
Toast.makeText(LoginActivity.this, "Login Successful", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(LoginActivity.this, "Login Failed", Toast.LENGTH_SHORT).show();
}
} else{
Toast.makeText(LoginActivity.this, "Login Failed", Toast.LENGTH_SHORT).show();
}
}
});
}
}
\ No newline at end of file
package com.example.wastedfood;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
public class SignupActivity extends AppCompatActivity {
private EditText edEmail;
private EditText edPassword;
private EditText edConfPassword;
private EditText btnConfirm;
private final String CREDENTIAL_SHARED_PREF = "our_shared_pref";
@SuppressLint("WrongViewCast")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
edEmail = findViewById(R.id.ed_email);
edPassword = findViewById(R.id.ed_password);
edConfPassword = findViewById(R.id.ed_conf_password2);
btnConfirm = findViewById(R.id.btn_confirm);
btnConfirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String strPassword = edPassword.getText().toString();
String strConfPassword = edConfPassword.getText().toString();
String strEmail = edEmail.getText().toString();
if (strPassword != null && strConfPassword != null && strPassword.equalsIgnoreCase(strConfPassword)){
SharedPreferences credentials = getSharedPreferences(CREDENTIAL_SHARED_PREF, Context.MODE_PRIVATE);
SharedPreferences.Editor editor=credentials.edit();
editor.putString("Password", strPassword);
editor.putString("Email", strEmail);
editor.commit();
SignupActivity.this.finish();
}
}
});
}
}
\ No newline at end of file
......@@ -10,74 +10,98 @@
android:id="@+id/imageView2"
android:layout_width="409dp"
android:layout_height="172dp"
app:srcCompat="@drawable/logo"
tools:layout_editor_absoluteX="-2dp"
tools:layout_editor_absoluteY="62dp" />
android:layout_marginTop="62dp"
android:layout_marginEnd="2dp"
android:layout_marginRight="2dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo" />
<Button
android:id="@+id/button"
android:id="@+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="58dp"
android:layout_marginEnd="115dp"
android:layout_marginRight="115dp"
android:background="@drawable/button"
android:text="Log In"
tools:layout_editor_absoluteX="114dp"
tools:layout_editor_absoluteY="515dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView4" />
<Button
android:id="@+id/button2"
android:id="@+id/btn_signin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="21dp"
android:layout_marginEnd="115dp"
android:layout_marginRight="115dp"
android:background="@drawable/button"
android:text="Sig In"
tools:layout_editor_absoluteX="114dp"
tools:layout_editor_absoluteY="620dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView5" />
<EditText
android:id="@+id/editTextTextPassword"
android:id="@+id/ed_password"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="9dp"
android:layout_marginEnd="100dp"
android:layout_marginRight="100dp"
android:ems="10"
android:inputType="textPassword"
android:hint="Password"
tools:layout_editor_absoluteX="100dp"
tools:layout_editor_absoluteY="421dp" />
android:inputType="textPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed_email" />
<EditText
android:id="@+id/editTextTextEmailAddress"
android:id="@+id/ed_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="29dp"
android:layout_marginEnd="100dp"
android:layout_marginRight="100dp"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
tools:layout_editor_absoluteX="100dp"
tools:layout_editor_absoluteY="343dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="136dp"
android:layout_marginRight="136dp"
android:text="LOGIN"
android:textColor="@android:color/holo_green_dark"
android:textSize="48dp"
tools:layout_editor_absoluteX="136dp"
tools:layout_editor_absoluteY="250dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView2" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginEnd="92dp"
android:layout_marginRight="92dp"
android:text="--Forgot Your Password ?--"
android:textColor="@android:color/holo_green_dark"
tools:layout_editor_absoluteX="146dp"
tools:layout_editor_absoluteY="476dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed_password" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginEnd="188dp"
android:layout_marginRight="188dp"
android:text="- Or --"
android:textColor="@android:color/holo_green_dark"
tools:layout_editor_absoluteX="189dp"
tools:layout_editor_absoluteY="586dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/btn_login" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
......@@ -10,56 +10,71 @@
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="48dp"
android:layout_marginEnd="97dp"
android:layout_marginRight="97dp"
android:text="REGISTER"
android:textColor="@android:color/holo_green_dark"
android:textSize="48dp"
tools:layout_editor_absoluteX="97dp"
tools:layout_editor_absoluteY="232dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/imageView3" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/logo"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="50dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/logo" />
<Button
android:id="@+id/button3"
android:id="@+id/btn_confirm"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:layout_marginEnd="115dp"
android:layout_marginRight="115dp"
android:background="@drawable/button"
android:text="Confirm"
tools:layout_editor_absoluteX="114dp"
tools:layout_editor_absoluteY="594dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed_conf_password2" />
<EditText
android:id="@+id/editTextTextEmailAddress2"
android:id="@+id/ed_email2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Email"
android:layout_marginTop="97dp"
android:layout_marginEnd="184dp"
android:layout_marginRight="184dp"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="343dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<EditText
android:id="@+id/editTextTextPassword2"
android:id="@+id/ed_password2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="31dp"
android:layout_marginEnd="184dp"
android:layout_marginRight="184dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="420dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed_email2" />
<EditText
android:id="@+id/editTextTextPassword3"
android:id="@+id/ed_conf_password2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="33dp"
android:layout_marginEnd="184dp"
android:layout_marginRight="184dp"
android:ems="10"
android:hint="Confirm Password"
android:inputType="textPassword"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="497dp" />
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/ed_password2" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources></resources>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment