mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Merge pull request #100 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
222dbda627
@ -68,6 +68,11 @@ public class AuthManager {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void nullify() {
|
||||
email = null;
|
||||
password = null;
|
||||
}
|
||||
|
||||
public void setAuthSession(AuthSession toSet) {
|
||||
authSession = (AWSCognitoAuthSession) toSet;
|
||||
waiting = false;
|
||||
|
||||
@ -42,7 +42,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
Button decrQuan;
|
||||
Button removeItem;
|
||||
Button clearAll;
|
||||
//Button shareList;
|
||||
Button shareList;
|
||||
|
||||
TextView tvTotalPrice;
|
||||
ProgressBar loadingListItems;
|
||||
@ -109,7 +109,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
}
|
||||
});
|
||||
|
||||
/*shareList = (Button) findViewById(R.id.buttonShare);
|
||||
shareList = (Button) findViewById(R.id.buttonShare);
|
||||
shareList.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@ -139,7 +139,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});*/
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -36,6 +36,15 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
private AppBarConfiguration mAppBarConfiguration;
|
||||
public static AuthManager am = new AuthManager();
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev == null) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -48,7 +57,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
public void run() {
|
||||
Intent intent = new Intent(MainActivity.this, SplashActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
@ -198,7 +206,6 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
||||
am.signOutUser();
|
||||
Intent intent = new Intent(MainActivity.this, com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -10,6 +10,9 @@ import androidx.appcompat.app.AppCompatActivity;
|
||||
public class SplashActivity extends AppCompatActivity {
|
||||
public static boolean showSplash = true;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {}
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -20,8 +23,8 @@ public class SplashActivity extends AppCompatActivity {
|
||||
public void run() {
|
||||
showSplash = false;
|
||||
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Splash");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
@ -23,16 +23,20 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
String newPassword;
|
||||
String confirmNewPassword;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Sign up") || prev.equals("Log in"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_forgotpswd);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -55,6 +59,7 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
am.changePassword(email);
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView6);
|
||||
invalidCred.setText("Password criteria not met. Please try again.");
|
||||
@ -74,10 +79,11 @@ public class ForgotPasswordPage extends AppCompatActivity {
|
||||
try {
|
||||
am.confirmPasswordReset(newPassword, code);
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
||||
intent.putExtra("prev", "Forgot password");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,21 +20,26 @@ public class LoginPage extends AppCompatActivity {
|
||||
private Button button2; //Forgot password button
|
||||
private Button button3; //Log in button
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Sign up") || prev.equals("Forgot password"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_login);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, SignupPage.class);
|
||||
intent.putExtra("prev", "Log in");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -44,6 +49,7 @@ public class LoginPage extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(LoginPage.this, ForgotPasswordPage.class);
|
||||
intent.putExtra("prev", "Log in");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -61,10 +67,11 @@ public class LoginPage extends AppCompatActivity {
|
||||
try {
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Login");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch(Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView5);
|
||||
invalidCred.setText("Incorrect email or password. Please try again.");
|
||||
|
||||
@ -32,21 +32,26 @@ public class SignupPage extends AppCompatActivity {
|
||||
String password;
|
||||
String confirmPassword;
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
String prev = getIntent().getStringExtra("prev");
|
||||
|
||||
if (prev != null && (prev.equals("Log in") || prev.equals("Forgot password"))) {
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_signup);
|
||||
|
||||
if(am.getEmail() != null) {
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
button1 = (Button) findViewById(R.id.button1);
|
||||
button1.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(SignupPage.this, LoginPage.class);
|
||||
intent.putExtra("prev", "Sign up");
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
@ -73,6 +78,7 @@ public class SignupPage extends AppCompatActivity {
|
||||
am.startSignUp(email, password);
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
TextView invalidCred = findViewById(R.id.textView3);
|
||||
invalidCred.setText("Invalid credentials. Please try again.");
|
||||
@ -93,10 +99,11 @@ public class SignupPage extends AppCompatActivity {
|
||||
am.confirmSignUp(code);
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
intent.putExtra("prev", "Sign up");
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
am.nullify();
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package com.example.listify.ui.home;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
@ -11,6 +12,7 @@ import android.widget.Button;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
@ -21,6 +23,7 @@ import com.example.listify.AuthManager;
|
||||
import com.example.listify.MainActivity;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.Requestor;
|
||||
import com.example.listify.ui.ForgotPasswordPage;
|
||||
import com.example.listify.ui.LoginPage;
|
||||
|
||||
import org.json.JSONException;
|
||||
@ -57,10 +60,35 @@ public class HomeFragment extends Fragment {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||
|
||||
try {
|
||||
am.changePassword(am.getEmail());
|
||||
}
|
||||
catch (Exception e) {}
|
||||
/*try {
|
||||
am.confirmPasswordReset("", "");
|
||||
}
|
||||
|
||||
String[] TO = {am.getEmail()};
|
||||
Intent emailIntent = new Intent(Intent.ACTION_SEND);
|
||||
emailIntent.setData(Uri.parse("mailto:"));
|
||||
emailIntent.setType("text/plain");
|
||||
emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
|
||||
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Listify account deleted");
|
||||
emailIntent.putExtra(Intent.EXTRA_TEXT, "Hello, this email is to confirm that you have deleted your Listify account.");
|
||||
try {
|
||||
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
|
||||
Log.i("Finished sending email...", "");
|
||||
System.out.println("A");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.out.println("B");
|
||||
}*/
|
||||
|
||||
am.deleteUser(requestor);
|
||||
am.nullify();
|
||||
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
||||
startActivity(intent);
|
||||
getActivity().finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
|
||||
@ -26,14 +26,14 @@
|
||||
android:text="Clear All"
|
||||
android:textSize="10sp"/>
|
||||
|
||||
<!--<Button
|
||||
<Button
|
||||
android:id="@+id/buttonShare"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="26dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginStart="1dp"
|
||||
android:layout_marginTop="1dp"
|
||||
android:text="Share"
|
||||
android:textSize="10sp"/>-->
|
||||
android:textSize="10sp"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user