mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 02:38:47 +00:00
Merge pull request #67 from ClaytonWWilson/aaron-branch-2
Aaron branch 2
This commit is contained in:
commit
c6b5e28755
@ -164,7 +164,7 @@ public class AuthManager {
|
||||
}
|
||||
|
||||
public void changePassword(String email) throws AuthException {
|
||||
this.email = email;
|
||||
//this.email = email;
|
||||
//waiting = true;
|
||||
Amplify.Auth.resetPassword(email, result -> setAuthResetPasswordResult(result), error -> setAuthError(error));
|
||||
throwIfAuthError();
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
|
||||
import com.example.listify.AuthManager;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.MainActivity;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.app.AppCompatDialog;
|
||||
import androidx.appcompat.app.AppCompatDialogFragment;
|
||||
|
||||
public class CodePage extends AppCompatDialogFragment {
|
||||
private EditText ediTextCode;
|
||||
|
||||
private CodeDialogListener listener;
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||
LayoutInflater inflater = getActivity().getLayoutInflater();
|
||||
View view = inflater.inflate(R.layout.activity_code, null);
|
||||
|
||||
builder.setView(view)
|
||||
.setTitle("Verification code")
|
||||
.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String code = ediTextCode.getText().toString();
|
||||
listener.sendCode("" + code + "", false);
|
||||
}
|
||||
})
|
||||
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
String code = ediTextCode.getText().toString();
|
||||
listener.sendCode("" + code + "", true);
|
||||
}
|
||||
});
|
||||
|
||||
ediTextCode = view.findViewById(R.id.editTextCode);
|
||||
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
try {
|
||||
listener = (CodeDialogListener) context;
|
||||
} catch (ClassCastException e) {
|
||||
throw new ClassCastException("CodeDialogListener not implemented.");
|
||||
}
|
||||
}
|
||||
|
||||
public interface CodeDialogListener {
|
||||
void sendCode(String code, boolean cancel);
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -14,7 +16,7 @@ import static com.example.listify.MainActivity.am;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class ForgotPasswordPage extends AppCompatActivity implements CodePage.CodeDialogListener {
|
||||
public class ForgotPasswordPage extends AppCompatActivity {
|
||||
private Button button1; //Code page button
|
||||
|
||||
String email;
|
||||
@ -59,28 +61,36 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
|
||||
return;
|
||||
}
|
||||
|
||||
openDialog();
|
||||
View codeView = getLayoutInflater().inflate(R.layout.activity_code, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(ForgotPasswordPage.this);
|
||||
builder.setView(codeView);
|
||||
builder.setTitle("Verification code");
|
||||
builder.setMessage("Please enter the 6-digit verification code sent to your email.");
|
||||
builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EditText codeText = (EditText) codeView.findViewById(R.id.editTextCode);
|
||||
String code = codeText.getText().toString();
|
||||
try {
|
||||
am.confirmPasswordReset(newPassword, code);
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void openDialog() {
|
||||
CodePage codePage = new CodePage();
|
||||
codePage.show(getSupportFragmentManager(), "Verification code");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCode(String code, boolean cancel) {
|
||||
if(!cancel) {
|
||||
try {
|
||||
am.confirmPasswordReset(newPassword, code);
|
||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,7 @@
|
||||
package com.example.listify.ui;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -11,11 +13,18 @@ import android.widget.TextView;
|
||||
import com.example.listify.R;
|
||||
import com.example.listify.AuthManager;
|
||||
import com.example.listify.MainActivity;
|
||||
import com.example.listify.Requestor;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import static com.example.listify.MainActivity.am;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class SignupPage extends AppCompatActivity implements CodePage.CodeDialogListener {
|
||||
public class SignupPage extends AppCompatActivity {
|
||||
private Button button1; //Log in page button
|
||||
private Button button2; //Sign up button
|
||||
|
||||
@ -70,29 +79,37 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
||||
return;
|
||||
}
|
||||
|
||||
openDialog();
|
||||
View codeView = getLayoutInflater().inflate(R.layout.activity_code, null);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(SignupPage.this);
|
||||
builder.setView(codeView);
|
||||
builder.setTitle("Verification code");
|
||||
builder.setMessage("Please enter the 6-digit verification code sent to your email.");
|
||||
builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
EditText codeText = (EditText) codeView.findViewById(R.id.editTextCode);
|
||||
String code = codeText.getText().toString();
|
||||
try {
|
||||
am.confirmSignUp(code);
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void openDialog() {
|
||||
CodePage codePage = new CodePage();
|
||||
codePage.show(getSupportFragmentManager(), "Verification code");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendCode(String code, boolean cancel) {
|
||||
if(!cancel) {
|
||||
try {
|
||||
am.confirmSignUp(code);
|
||||
am.signIn(email, password);
|
||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
catch (Exception e) {
|
||||
Log.i("Authentication", e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -74,7 +74,6 @@ public class HomeFragment extends Fragment {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
AlertDialog dialog = builder.create();
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user