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: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" />

View File

@ -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,9 @@ public class AuthManager {
return authSession.getUserPoolTokens().getValue().getIdToken(); return authSession.getUserPoolTokens().getValue().getIdToken();
} }
public String getPassword() {
return password;
}
public void setAuthSession(AuthSession toSet) { public void setAuthSession(AuthSession toSet) {
authSession = (AWSCognitoAuthSession) toSet; authSession = (AWSCognitoAuthSession) toSet;
@ -117,7 +119,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 {

View File

@ -123,7 +123,7 @@ public class ListPage extends AppCompatActivity {
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;
@ -136,7 +136,7 @@ public class ListPage extends AppCompatActivity {
@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);

View File

@ -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,15 @@ 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.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 +33,25 @@ 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);
}
//------------------------------Auth Testing---------------------------------------------// //------------------------------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 email;
String newPassword; String newPassword;
String confirmNewPassword;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -28,11 +29,19 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
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,7 +50,9 @@ 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(); openDialog();
} }
}); });
@ -57,13 +68,12 @@ public class ForgotPasswordPage extends AppCompatActivity implements CodePage.Co
if(!cancel) { if(!cancel) {
try { try {
am.confirmPasswordReset(newPassword, code); am.confirmPasswordReset(newPassword, code);
Intent intent = new Intent(ForgotPasswordPage.this, LoginPage.class);
startActivity(intent);
} }
catch (Exception e) { catch (Exception e) {
Log.i("Authentication", e.toString()); 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; 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;
@ -26,7 +30,7 @@ import java.util.Properties;
public class HomeFragment extends Fragment { public class HomeFragment extends Fragment {
private Button toLoginPage; private Button toLoginPage;
private Button toListPage; private Button toDeleteAccountPage;
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);
@ -40,26 +44,46 @@ public class HomeFragment extends Fragment {
} }
}); });
toListPage = (Button) root.findViewById(R.id.button2); toDeleteAccountPage = (Button) root.findViewById(R.id.button2);
toListPage.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(HomeFragment.this.getActivity(), com.example.listify.ListPage.class); View passwordView = getLayoutInflater().inflate(R.layout.activity_code, null);
//startActivity(intent); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(passwordView);
try { builder.setTitle("Account deletion verification");
Properties configs = new Properties(); builder.setMessage("Are you sure you want to delete your account? If so, enter your password below and hit \"Yes\".");
try { builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json"); @Override
} catch (IOException | JSONException e) { public void onClick(DialogInterface dialog, int which) {
e.printStackTrace(); EditText passwordText = (EditText) passwordView.findViewById(R.id.editTextCode);
String password = passwordText.getText().toString();
if(password.equals(am.getPassword())) {
try {
Properties configs = new Properties();
try {
configs = AuthManager.loadProperties(getContext(), "android.resource://" + getActivity().getPackageName() + "/raw/auths.json");
} catch (IOException | JSONException e) {
e.printStackTrace();
}
Requestor requestor = new Requestor(am, configs.getProperty("apiKey"));
am.deleteUser(requestor);
}
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();
} }
}); });

View File

@ -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>

View File

@ -10,39 +10,20 @@
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_marginBottom="25dp" android:layout_marginBottom="40dp"
android:layout_marginEnd="25dp"
android:text="Log in" android:text="Log in"
app:layout_constraintBottom_toTopOf="@+id/button2" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@+id/button2" /> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button <Button
android:id="@+id/button2" android:id="@+id/button2"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="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>

View File

@ -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>