mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-16 10:48:46 +00:00
Merge branch 'master' into async-loading
This commit is contained in:
commit
e21913882c
@ -33,9 +33,9 @@
|
|||||||
android:name=".SearchResults"
|
android:name=".SearchResults"
|
||||||
android:label=""
|
android:label=""
|
||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<activity android:name="com.example.listify.SplashActivity" />
|
||||||
<activity android:name="com.example.listify.ui.SignupPage" />
|
<activity android:name="com.example.listify.ui.SignupPage" />
|
||||||
<activity android:name="com.example.listify.ui.LoginPage" />
|
<activity android:name="com.example.listify.ui.LoginPage" />
|
||||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||||
|
|||||||
@ -28,7 +28,6 @@ public class AuthManager {
|
|||||||
String password = null;
|
String password = null;
|
||||||
volatile boolean waiting = false;
|
volatile boolean waiting = false;
|
||||||
|
|
||||||
|
|
||||||
void fetchAuthSession() throws AuthException {
|
void fetchAuthSession() throws AuthException {
|
||||||
waiting = true;
|
waiting = true;
|
||||||
Amplify.Auth.fetchAuthSession(
|
Amplify.Auth.fetchAuthSession(
|
||||||
@ -61,6 +60,13 @@ public class AuthManager {
|
|||||||
return authSession.getUserPoolTokens().getValue().getIdToken();
|
return authSession.getUserPoolTokens().getValue().getIdToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getEmail() {
|
||||||
|
return email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
public void setAuthSession(AuthSession toSet) {
|
public void setAuthSession(AuthSession toSet) {
|
||||||
authSession = (AWSCognitoAuthSession) toSet;
|
authSession = (AWSCognitoAuthSession) toSet;
|
||||||
@ -117,7 +123,6 @@ public class AuthManager {
|
|||||||
error -> setAuthError(error)
|
error -> setAuthError(error)
|
||||||
);
|
);
|
||||||
throwIfAuthError();
|
throwIfAuthError();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void confirmSignUp(String confirmationCode) throws AuthException {
|
public void confirmSignUp(String confirmationCode) throws AuthException {
|
||||||
@ -151,13 +156,15 @@ public class AuthManager {
|
|||||||
|
|
||||||
public void signOutUser() throws AuthException {
|
public void signOutUser() throws AuthException {
|
||||||
authSession = null;
|
authSession = null;
|
||||||
|
email = null;
|
||||||
|
password = null;
|
||||||
waiting = true;
|
waiting = true;
|
||||||
Amplify.Auth.signOut(this::signOutSuccess, error -> setAuthError(error));
|
Amplify.Auth.signOut(this::signOutSuccess, error -> setAuthError(error));
|
||||||
throwIfAuthError();
|
throwIfAuthError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changePassword(String email) throws AuthException {
|
public void changePassword(String email) throws AuthException {
|
||||||
this.email = email;
|
//this.email = email;
|
||||||
//waiting = true;
|
//waiting = true;
|
||||||
Amplify.Auth.resetPassword(email, result -> setAuthResetPasswordResult(result), error -> setAuthError(error));
|
Amplify.Auth.resetPassword(email, result -> setAuthResetPasswordResult(result), error -> setAuthError(error));
|
||||||
throwIfAuthError();
|
throwIfAuthError();
|
||||||
|
|||||||
@ -131,7 +131,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
ArrayList<Integer> pImages;
|
ArrayList<Integer> pImages;
|
||||||
|
|
||||||
MyAdapter (Context c, ArrayList<String> names, ArrayList<String> stores, ArrayList<String> prices, ArrayList<String> quantity, ArrayList<Integer> images) {
|
MyAdapter (Context c, ArrayList<String> names, ArrayList<String> stores, ArrayList<String> prices, ArrayList<String> quantity, ArrayList<Integer> images) {
|
||||||
super(c, R.layout.listproduct, R.id.productView, names);
|
super(c, R.layout.activity_listproductentry, R.id.productView, names);
|
||||||
context = c;
|
context = c;
|
||||||
pNames = names;
|
pNames = names;
|
||||||
pStores = stores;
|
pStores = stores;
|
||||||
@ -144,7 +144,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver {
|
|||||||
@Override
|
@Override
|
||||||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
|
||||||
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||||
View listproduct = layoutInflater.inflate(R.layout.listproduct, parent,false);
|
View listproduct = layoutInflater.inflate(R.layout.activity_listproductentry, parent,false);
|
||||||
|
|
||||||
decrQuan = (Button) listproduct.findViewById(R.id.buttonDecr);
|
decrQuan = (Button) listproduct.findViewById(R.id.buttonDecr);
|
||||||
incrQuan = (Button) listproduct.findViewById(R.id.buttonIncr);
|
incrQuan = (Button) listproduct.findViewById(R.id.buttonIncr);
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.example.listify;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -14,12 +15,16 @@ import androidx.navigation.NavController;
|
|||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
import androidx.navigation.ui.AppBarConfiguration;
|
import androidx.navigation.ui.AppBarConfiguration;
|
||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
import com.amplifyframework.auth.AuthException;
|
import com.amplifyframework.auth.AuthException;
|
||||||
import com.example.listify.data.Item;
|
import com.example.listify.data.Item;
|
||||||
import com.example.listify.data.ItemSearch;
|
import com.example.listify.data.ItemSearch;
|
||||||
import com.example.listify.data.List;
|
import com.example.listify.data.List;
|
||||||
import com.example.listify.data.ListEntry;
|
import com.example.listify.data.ListEntry;
|
||||||
|
import com.example.listify.ui.LoginPage;
|
||||||
import com.google.android.material.navigation.NavigationView;
|
import com.google.android.material.navigation.NavigationView;
|
||||||
|
import static com.example.listify.SplashActivity.showSplash;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -29,13 +34,30 @@ import java.util.Random;
|
|||||||
|
|
||||||
public class MainActivity extends AppCompatActivity implements CreateListDialogFragment.OnNewListListener {
|
public class MainActivity extends AppCompatActivity implements CreateListDialogFragment.OnNewListListener {
|
||||||
private AppBarConfiguration mAppBarConfiguration;
|
private AppBarConfiguration mAppBarConfiguration;
|
||||||
|
|
||||||
public static AuthManager am = new AuthManager();
|
public static AuthManager am = new AuthManager();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
if(showSplash) {
|
||||||
|
showSplash = false;
|
||||||
|
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Intent intent = new Intent(MainActivity.this, SplashActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(am.getEmail() == null) {
|
||||||
|
Intent intent = new Intent(MainActivity.this, LoginPage.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------Auth Testing---------------------------------------------//
|
//------------------------------Auth Testing---------------------------------------------//
|
||||||
|
|
||||||
@ -180,6 +202,24 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onClickSignout(MenuItem m) {
|
||||||
|
m.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemClick(MenuItem item) {
|
||||||
|
try {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendNewListName(String name) {
|
public void sendNewListName(String name) {
|
||||||
Properties configs = new Properties();
|
Properties configs = new Properties();
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.example.listify;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
public static boolean showSplash = true;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_splashscreen);
|
||||||
|
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
showSplash = false;
|
||||||
|
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
package com.example.listify.ui;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -8,31 +10,46 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.example.listify.MainActivity;
|
||||||
import com.example.listify.R;
|
import com.example.listify.R;
|
||||||
import static com.example.listify.MainActivity.am;
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
public class ForgotPasswordPage extends AppCompatActivity implements CodePage.CodeDialogListener {
|
public class ForgotPasswordPage extends AppCompatActivity {
|
||||||
private Button button1; //Code page button
|
private Button button1; //Code page button
|
||||||
|
|
||||||
String email;
|
String email;
|
||||||
String newPassword;
|
String newPassword;
|
||||||
|
String confirmNewPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_forgotpswd);
|
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 = (Button) findViewById(R.id.button1);
|
||||||
button1.setOnClickListener(new View.OnClickListener() {
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress2);
|
EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress);
|
||||||
EditText newPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
EditText newPasswordText = (EditText) findViewById(R.id.editTextTextPassword);
|
||||||
|
EditText confirmNewPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
||||||
|
|
||||||
email = emailText.getText().toString();
|
email = emailText.getText().toString();
|
||||||
newPassword = newPasswordText.getText().toString();
|
newPassword = newPasswordText.getText().toString();
|
||||||
|
confirmNewPassword = confirmNewPasswordText.getText().toString();
|
||||||
|
|
||||||
|
if(!newPassword.equals(confirmNewPassword)) {
|
||||||
|
TextView invalidCred = findViewById(R.id.textView6);
|
||||||
|
invalidCred.setText("\"Confirm New Password\" does not match \"New Password\".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
am.changePassword(email);
|
am.changePassword(email);
|
||||||
@ -41,29 +58,39 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
|
|||||||
Log.i("Authentication", e.toString());
|
Log.i("Authentication", e.toString());
|
||||||
TextView invalidCred = findViewById(R.id.textView6);
|
TextView invalidCred = findViewById(R.id.textView6);
|
||||||
invalidCred.setText("Password criteria not met. Please try again.");
|
invalidCred.setText("Password criteria not met. Please try again.");
|
||||||
|
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);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Log.i("Authentication", e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -25,6 +25,11 @@ public class LoginPage extends AppCompatActivity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_login);
|
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 = (Button) findViewById(R.id.button1);
|
||||||
button1.setOnClickListener(new View.OnClickListener() {
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -57,6 +62,7 @@ public class LoginPage extends AppCompatActivity {
|
|||||||
am.signIn(email, password);
|
am.signIn(email, password);
|
||||||
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
Intent intent = new Intent(LoginPage.this, MainActivity.class);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
catch(Exception e) {
|
||||||
Log.i("Authentication", e.toString());
|
Log.i("Authentication", e.toString());
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package com.example.listify.ui;
|
package com.example.listify.ui;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -11,19 +13,35 @@ import android.widget.TextView;
|
|||||||
import com.example.listify.R;
|
import com.example.listify.R;
|
||||||
import com.example.listify.AuthManager;
|
import com.example.listify.AuthManager;
|
||||||
import com.example.listify.MainActivity;
|
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 static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
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 button1; //Log in page button
|
||||||
private Button button2; //Sign up button
|
private Button button2; //Sign up button
|
||||||
|
|
||||||
|
String email;
|
||||||
|
String password;
|
||||||
|
String confirmPassword;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_signup);
|
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 = (Button) findViewById(R.id.button1);
|
||||||
button1.setOnClickListener(new View.OnClickListener() {
|
button1.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -41,9 +59,9 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
|||||||
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
EditText passwordText = (EditText) findViewById(R.id.editTextTextPassword);
|
||||||
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
EditText confirmPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
|
||||||
|
|
||||||
String email = emailText.getText().toString();
|
email = emailText.getText().toString();
|
||||||
String password = passwordText.getText().toString();
|
password = passwordText.getText().toString();
|
||||||
String confirmPassword = confirmPasswordText.getText().toString();
|
confirmPassword = confirmPasswordText.getText().toString();
|
||||||
|
|
||||||
if(!password.equals(confirmPassword)) {
|
if(!password.equals(confirmPassword)) {
|
||||||
TextView invalidCred = findViewById(R.id.textView3);
|
TextView invalidCred = findViewById(R.id.textView3);
|
||||||
@ -61,27 +79,37 @@ public class SignupPage extends AppCompatActivity implements CodePage.CodeDialog
|
|||||||
return;
|
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);
|
|
||||||
Intent intent = new Intent(SignupPage.this, MainActivity.class);
|
|
||||||
startActivity(intent);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
Log.i("Authentication", e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -1,5 +1,7 @@
|
|||||||
package com.example.listify.ui.home;
|
package com.example.listify.ui.home;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
@ -8,6 +10,8 @@ import android.widget.Button;
|
|||||||
|
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
|
||||||
@ -25,41 +29,53 @@ import java.io.IOException;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
public class HomeFragment extends Fragment {
|
public class HomeFragment extends Fragment {
|
||||||
private Button toLoginPage;
|
private Button toDeleteAccountPage;
|
||||||
private Button toListPage;
|
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
View root = inflater.inflate(R.layout.fragment_home, container, false);
|
||||||
|
|
||||||
toLoginPage = (Button) root.findViewById(R.id.button1);
|
toDeleteAccountPage = (Button) root.findViewById(R.id.button);
|
||||||
toLoginPage.setOnClickListener(new View.OnClickListener() {
|
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
View passwordView = getLayoutInflater().inflate(R.layout.activity_code, null);
|
||||||
startActivity(intent);
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
}
|
builder.setView(passwordView);
|
||||||
});
|
builder.setTitle("Account deletion verification");
|
||||||
|
builder.setMessage("Are you sure you want to delete your account? If so, enter your password below and hit \"Yes\".");
|
||||||
toListPage = (Button) root.findViewById(R.id.button2);
|
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
|
||||||
toListPage.setOnClickListener(new View.OnClickListener() {
|
@Override
|
||||||
@Override
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
public void onClick(View v) {
|
EditText passwordText = (EditText) passwordView.findViewById(R.id.editTextCode);
|
||||||
//Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ListPage.class);
|
String password = passwordText.getText().toString();
|
||||||
//startActivity(intent);
|
if(password.equals(am.getPassword())) {
|
||||||
|
try {
|
||||||
try {
|
Properties configs = new Properties();
|
||||||
Properties configs = new Properties();
|
try {
|
||||||
try {
|
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
||||||
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
|
} catch (IOException | JSONException e) {
|
||||||
} catch (IOException | JSONException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
}
|
||||||
|
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
|
am.deleteUser(requestor);
|
||||||
|
Intent intent = new Intent(getActivity(), com.example.listify.ui.LoginPage.class);
|
||||||
|
startActivity(intent);
|
||||||
|
getActivity().finish();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
Log.i("Authentication", e.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
|
});
|
||||||
am.deleteUser(requestor);
|
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
|
||||||
}
|
@Override
|
||||||
catch (Exception e) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Log.i("Authentication", e.toString());
|
return;
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
dialog.show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -11,8 +11,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="16dp"
|
android:layout_marginTop="16dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="Code"
|
android:hint=""
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPassword"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|||||||
@ -9,51 +9,64 @@
|
|||||||
android:id="@+id/button1"
|
android:id="@+id/button1"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="52dp"
|
android:layout_marginTop="51dp"
|
||||||
android:text="Submit"
|
android:text="Submit"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
||||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/editTextTextEmailAddress2"
|
android:id="@+id/editTextTextEmailAddress"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="295dp"
|
android:layout_marginTop="263dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="Email"
|
android:hint="Email"
|
||||||
android:inputType="textEmailAddress"
|
android:inputType="textEmailAddress"
|
||||||
app:layout_constraintStart_toStartOf="@+id/editTextTextPassword2"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/editTextTextPassword"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="35dp"
|
||||||
|
android:ems="10"
|
||||||
|
android:hint="New Password"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||||
|
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/editTextTextPassword2"
|
android:id="@+id/editTextTextPassword2"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="31dp"
|
android:layout_marginTop="35dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="New Password"
|
android:hint="Confirm New Password"
|
||||||
android:inputType="textPassword"
|
android:inputType="textPassword"
|
||||||
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
app:layout_constraintEnd_toStartOf="@+id/textView6"
|
||||||
app:layout_constraintStart_toStartOf="@+id/textView6"
|
app:layout_constraintStart_toStartOf="@+id/textView6"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress2" />
|
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="34dp"
|
|
||||||
android:layout_marginEnd="2dp"
|
|
||||||
android:text="Please enter your email address."
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress2"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress2" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/textView6"
|
android:id="@+id/textView6"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="2dp"
|
||||||
android:text=""
|
android:text=""
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
app:layout_constraintBottom_toTopOf="@+id/button1"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="46dp"
|
||||||
|
android:layout_marginEnd="2dp"
|
||||||
|
android:text="Please enter your email address."
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/editTextTextEmailAddress"
|
||||||
|
app:layout_constraintEnd_toEndOf="@+id/editTextTextEmailAddress" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
android:layout_marginTop="23dp"
|
android:layout_marginTop="23dp"
|
||||||
android:ems="10"
|
android:ems="10"
|
||||||
android:hint="Password"
|
android:hint="Password"
|
||||||
android:inputType="textPersonName"
|
android:inputType="textPassword"
|
||||||
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
app:layout_constraintStart_toStartOf="@+id/editTextTextEmailAddress"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress" />
|
||||||
|
|
||||||
|
|||||||
@ -7,42 +7,13 @@
|
|||||||
tools:context=".ui.home.HomeFragment">
|
tools:context=".ui.home.HomeFragment">
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/button1"
|
android:id="@+id/button"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="25dp"
|
|
||||||
android:layout_marginEnd="25dp"
|
|
||||||
android:text="Log in"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button2"
|
|
||||||
app:layout_constraintEnd_toEndOf="@+id/button2" />
|
|
||||||
|
|
||||||
<Button
|
|
||||||
android:id="@+id/button2"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="148dp"
|
|
||||||
android:text="Delete Account"
|
android:text="Delete Account"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
<Switch
|
|
||||||
android:id="@+id/switch1"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="29dp"
|
|
||||||
android:text="Kroger"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/button1"
|
|
||||||
app:layout_constraintStart_toStartOf="@+id/button1" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/textView4"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginBottom="31dp"
|
|
||||||
android:text="Search these stores:"
|
|
||||||
app:layout_constraintBottom_toTopOf="@+id/switch1"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@ -8,22 +8,26 @@
|
|||||||
android:id="@+id/nav_home"
|
android:id="@+id/nav_home"
|
||||||
android:icon="@drawable/ic_menu_camera"
|
android:icon="@drawable/ic_menu_camera"
|
||||||
android:title="@string/menu_home" />
|
android:title="@string/menu_home" />
|
||||||
<!-- <item-->
|
<!-- <item-->
|
||||||
<!-- android:id="@+id/nav_gallery"-->
|
<!-- android:id="@+id/nav_gallery"-->
|
||||||
<!-- android:icon="@drawable/ic_menu_gallery"-->
|
<!-- android:icon="@drawable/ic_menu_gallery"-->
|
||||||
<!-- android:title="@string/menu_gallery" />-->
|
<!-- android:title="@string/menu_gallery" />-->
|
||||||
<!-- <item-->
|
<!-- <item-->
|
||||||
<!-- android:id="@+id/nav_slideshow"-->
|
<!-- android:id="@+id/nav_slideshow"-->
|
||||||
<!-- android:icon="@drawable/ic_menu_slideshow"-->
|
<!-- android:icon="@drawable/ic_menu_slideshow"-->
|
||||||
<!-- android:title="@string/menu_slideshow" />-->
|
<!-- android:title="@string/menu_slideshow" />-->
|
||||||
<item
|
<item
|
||||||
android:id="@+id/nav_lists"
|
android:id="@+id/nav_lists"
|
||||||
android:icon="@drawable/ic_baseline_list_alt_28"
|
android:icon="@drawable/ic_baseline_list_alt_28"
|
||||||
android:title="@string/menu_lists" />
|
android:title="@string/menu_lists" />
|
||||||
<!-- <item-->
|
<!-- <item-->
|
||||||
<!-- android:id="@+id/nav_create_list"-->
|
<!-- android:id="@+id/nav_create_list"-->
|
||||||
<!-- android:icon="@drawable/ic_baseline_add_28"-->
|
<!-- android:icon="@drawable/ic_baseline_add_28"-->
|
||||||
<!-- android:title="Create New List"-->
|
<!-- android:title="Create New List"-->
|
||||||
<!-- android:onClick="onClickCreateList"/>-->
|
<!-- android:onClick="onClickCreateList" />-->
|
||||||
|
<item
|
||||||
|
android:id="@+id/nav_logout"
|
||||||
|
android:title="Sign out"
|
||||||
|
android:onClick="onClickSignout" />
|
||||||
</group>
|
</group>
|
||||||
</menu>
|
</menu>
|
||||||
@ -7,7 +7,7 @@
|
|||||||
<string name="nav_header_desc">Navigation header</string>
|
<string name="nav_header_desc">Navigation header</string>
|
||||||
<string name="action_settings">Settings</string>
|
<string name="action_settings">Settings</string>
|
||||||
|
|
||||||
<string name="menu_home">Home</string>
|
<string name="menu_home">Profile</string>
|
||||||
<string name="menu_gallery">Gallery</string>
|
<string name="menu_gallery">Gallery</string>
|
||||||
<string name="menu_slideshow">Slideshow</string>
|
<string name="menu_slideshow">Slideshow</string>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user