Merge pull request #62 from ClaytonWWilson/aaron-branch-2

This commit is contained in:
DreamCoder23 2020-10-21 10:26:05 -07:00 committed by GitHub
commit dacd469a56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 146 additions and 73 deletions

View File

@ -33,9 +33,9 @@
android:name=".SearchResults"
android:label=""
android:theme="@style/AppTheme.NoActionBar">
</activity>
<activity android:name="com.example.listify.SplashActivity" />
<activity android:name="com.example.listify.ui.SignupPage" />
<activity android:name="com.example.listify.ui.LoginPage" />
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />

View File

@ -28,7 +28,6 @@ public class AuthManager {
String password = null;
volatile boolean waiting = false;
void fetchAuthSession() throws AuthException {
waiting = true;
Amplify.Auth.fetchAuthSession(
@ -61,6 +60,9 @@ public class AuthManager {
return authSession.getUserPoolTokens().getValue().getIdToken();
}
public String getPassword() {
return password;
}
public void setAuthSession(AuthSession toSet) {
authSession = (AWSCognitoAuthSession) toSet;
@ -117,7 +119,6 @@ public class AuthManager {
error -> setAuthError(error)
);
throwIfAuthError();
}
public void confirmSignUp(String confirmationCode) throws AuthException {

View File

@ -123,7 +123,7 @@ public class ListPage extends AppCompatActivity {
ArrayList<Integer> pImages;
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;
pNames = names;
pStores = stores;
@ -136,7 +136,7 @@ public class ListPage extends AppCompatActivity {
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
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);
incrQuan = (Button) listproduct.findViewById(R.id.buttonIncr);

View File

@ -2,6 +2,7 @@ package com.example.listify;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
@ -14,12 +15,15 @@ import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import com.amplifyframework.auth.AuthException;
import com.example.listify.data.Item;
import com.example.listify.data.ItemSearch;
import com.example.listify.data.List;
import com.example.listify.data.ListEntry;
import com.google.android.material.navigation.NavigationView;
import static com.example.listify.SplashActivity.showSplash;
import org.json.JSONException;
import java.io.IOException;
import java.time.Instant;
@ -29,13 +33,25 @@ import java.util.Random;
public class MainActivity extends AppCompatActivity implements CreateListDialogFragment.OnNewListListener {
private AppBarConfiguration mAppBarConfiguration;
public static AuthManager am = new AuthManager();
@Override
protected void onCreate(Bundle 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);
}
//------------------------------Auth Testing---------------------------------------------//

View File

@ -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);
}
}

View File

@ -18,6 +18,7 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
String email;
String newPassword;
String confirmNewPassword;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -28,11 +29,19 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
button1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress2);
EditText newPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
EditText emailText = (EditText) findViewById(R.id.editTextTextEmailAddress);
EditText newPasswordText = (EditText) findViewById(R.id.editTextTextPassword);
EditText confirmNewPasswordText = (EditText) findViewById(R.id.editTextTextPassword2);
email = emailText.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 {
am.changePassword(email);
@ -41,7 +50,9 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
Log.i("Authentication", e.toString());
TextView invalidCred = findViewById(R.id.textView6);
invalidCred.setText("Password criteria not met. Please try again.");
return;
}
openDialog();
}
});
@ -57,13 +68,12 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
if(!cancel) {
try {
am.confirmPasswordReset(newPassword, code);
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
startActivity(intent);
}
catch (Exception e) {
Log.i("Authentication", e.toString());
}
}
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
startActivity(intent);
}
}

View File

@ -1,5 +1,7 @@
package com.example.listify.ui.home;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
@ -8,6 +10,8 @@ import android.widget.Button;
import android.view.ViewGroup;
import android.view.LayoutInflater;
import android.widget.EditText;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
@ -26,7 +30,7 @@ import java.util.Properties;
public class HomeFragment extends Fragment {
private Button toLoginPage;
private Button toListPage;
private Button toDeleteAccountPage;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View root = inflater.inflate(R.layout.fragment_home, container, false);
@ -40,13 +44,21 @@ public class HomeFragment extends Fragment {
}
});
toListPage = (Button) root.findViewById(R.id.button2);
toListPage.setOnClickListener(new View.OnClickListener() {
toDeleteAccountPage = (Button) root.findViewById(R.id.button2);
toDeleteAccountPage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Intent intent = new Intent(HomeFragment.this.getActivity(), com.example.listify.ListPage.class);
//startActivity(intent);
View passwordView = getLayoutInflater().inflate(R.layout.activity_code, null);
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\".");
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
EditText passwordText = (EditText) passwordView.findViewById(R.id.editTextCode);
String password = passwordText.getText().toString();
if(password.equals(am.getPassword())) {
try {
Properties configs = new Properties();
try {
@ -61,6 +73,18 @@ public class HomeFragment extends Fragment {
Log.i("Authentication", e.toString());
}
}
}
});
builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
return;
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
});
return root;

View File

@ -9,51 +9,64 @@
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:layout_marginTop="51dp"
android:text="Submit"
app:layout_constraintEnd_toStartOf="@+id/textView6"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword2" />
<EditText
android:id="@+id/editTextTextEmailAddress2"
android:id="@+id/editTextTextEmailAddress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="295dp"
android:layout_marginTop="263dp"
android:ems="10"
android:hint="Email"
android:inputType="textEmailAddress"
app:layout_constraintStart_toStartOf="@+id/editTextTextPassword2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="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
android:id="@+id/editTextTextPassword2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="31dp"
android:layout_marginTop="35dp"
android:ems="10"
android:hint="New Password"
android:hint="Confirm New Password"
android:inputType="textPassword"
app:layout_constraintEnd_toStartOf="@+id/textView6"
app:layout_constraintStart_toStartOf="@+id/textView6"
app:layout_constraintTop_toBottomOf="@+id/editTextTextEmailAddress2" />
<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" />
app:layout_constraintTop_toBottomOf="@+id/editTextTextPassword" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:text=""
app:layout_constraintBottom_toTopOf="@+id/button1"
app:layout_constraintEnd_toEndOf="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>

View File

@ -10,39 +10,20 @@
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="40dp"
android:text="Log in"
app:layout_constraintBottom_toTopOf="@+id/button2"
app:layout_constraintEnd_toEndOf="@+id/button2" />
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="148dp"
android:text="Delete Account"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="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" />
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -7,7 +7,7 @@
<string name="nav_header_desc">Navigation header</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_slideshow">Slideshow</string>