diff --git a/Lambdas/Lists/List/test/TestListDelete.java b/Lambdas/Lists/List/test/TestListDelete.java index 70ab8e3..162b56a 100644 --- a/Lambdas/Lists/List/test/TestListDelete.java +++ b/Lambdas/Lists/List/test/TestListDelete.java @@ -8,10 +8,6 @@ import java.util.Map; public class TestListDelete { - @Test - public void testListDeleterValid() { - testListDeleterCore(false, true); - } @Test public void testListDeleterWOAccess() { diff --git a/Listify/app/src/main/java/com/example/listify/AuthManager.java b/Listify/app/src/main/java/com/example/listify/AuthManager.java index 399511c..48a2f4a 100644 --- a/Listify/app/src/main/java/com/example/listify/AuthManager.java +++ b/Listify/app/src/main/java/com/example/listify/AuthManager.java @@ -69,6 +69,12 @@ public class AuthManager { } public void nullify() { + authSession = null; + authSignUpResult = null; + authSignInResult = null; + authResetPasswordResult = null; + authError = null; + email = null; email = null; password = null; } diff --git a/Listify/app/src/main/java/com/example/listify/ListPage.java b/Listify/app/src/main/java/com/example/listify/ListPage.java index d5f48c2..49cddfa 100644 --- a/Listify/app/src/main/java/com/example/listify/ListPage.java +++ b/Listify/app/src/main/java/com/example/listify/ListPage.java @@ -346,6 +346,7 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver { totalPriceByStore.put(storeName, totalPriceByStore.get(storeName) - (Double.parseDouble(pPrices.get(position)) * Integer.parseInt(pQuantity.get(position)))); pPrices.set(storeHeaderIndex.get(storeName), df.format(totalPriceByStore.get(storeName))); + totalPrice -= (Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position))); tvTotalPrice.setText(String.format("$%.2f", totalPrice)); @@ -369,7 +370,11 @@ public class ListPage extends AppCompatActivity implements Requestor.Receiver { if(!pNames.isEmpty()) { name.setText(pNames.get(position)); store.setText(pStores.get(position)); - price.setText("$" + pPrices.get(position)); + if (Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position)) <= 0) { + price.setText(String.format("$%s", pPrices.get(position))); + } else { + price.setText(String.format("$%s ($%.2f)", pPrices.get(position), Double.parseDouble(pPrices.get(position)) * Double.parseDouble(pQuantity.get(position)))); + } if(pQuantity.get(position).equals("-1")) { quantity.setVisibility(View.GONE); diff --git a/Listify/app/src/main/java/com/example/listify/MainActivity.java b/Listify/app/src/main/java/com/example/listify/MainActivity.java index 90473f1..b2edf0a 100644 --- a/Listify/app/src/main/java/com/example/listify/MainActivity.java +++ b/Listify/app/src/main/java/com/example/listify/MainActivity.java @@ -15,7 +15,6 @@ 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; @@ -23,15 +22,16 @@ import com.example.listify.data.List; import com.example.listify.data.ListEntry; import com.example.listify.ui.LoginPage; 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; import java.util.Arrays; import java.util.Properties; import java.util.Random; +import static com.example.listify.SplashActivity.showSplash; + public class MainActivity extends AppCompatActivity implements CreateListDialogFragment.OnNewListListener { private AppBarConfiguration mAppBarConfiguration; public static AuthManager am = new AuthManager(); @@ -61,7 +61,8 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF }, 1); } - if(am.getEmail() == null) { + if(am.getUserToken().equals("")) { + am.nullify(); Intent intent = new Intent(MainActivity.this, LoginPage.class); startActivity(intent); } diff --git a/Listify/app/src/main/java/com/example/listify/SearchResults.java b/Listify/app/src/main/java/com/example/listify/SearchResults.java index e673b05..06ff3f3 100644 --- a/Listify/app/src/main/java/com/example/listify/SearchResults.java +++ b/Listify/app/src/main/java/com/example/listify/SearchResults.java @@ -352,6 +352,7 @@ public class SearchResults extends AppCompatActivity implements FilterDialogFrag } // Create a list of all stores in the results so the user can filter by store name + stores.clear(); for (int i = 0; i < resultsProductList.size(); i++) { if (!stores.contains(resultsProductList.get(i).getChainName())) { stores.add(resultsProductList.get(i).getChainName()); @@ -377,6 +378,17 @@ public class SearchResults extends AppCompatActivity implements FilterDialogFrag } }); + // Reset price filter + double max = 0; + for (int i = 0; i < resultsProductListSorted.size(); i++){ + if (resultsProductListSorted.get(i).getPrice().doubleValue() > max) { + max = resultsProductListSorted.get(i).getPrice().doubleValue(); + } + } + + this.minPrice = 0; + this.maxPrice = max; + // Apply selected sorting to the list sortResults(); diff --git a/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java b/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java index 5951d79..df7ea8f 100644 --- a/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java +++ b/Listify/app/src/main/java/com/example/listify/adapter/CheckBoxListViewAdapter.java @@ -55,19 +55,30 @@ public class CheckBoxListViewAdapter extends BaseAdapter { holder = new ViewHolder(); holder.label = (TextView) convertView.findViewById(R.id.store_name); holder.checkBox = (CheckBox)convertView.findViewById(R.id.store_check_box); - - holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { + holder.checkBox.setOnClickListener(new View.OnClickListener() { @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - int getPosition = (Integer) buttonView.getTag(); + public void onClick(View v) { + int getPosition = (Integer) ((CompoundButton)(v)).getTag(); - if (isChecked) { + if (((CompoundButton) v).isChecked()) { checkedList.add(list.get(getPosition)); } else { checkedList.remove(list.get(getPosition)); } } }); +// holder.checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { +// @Override +// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { +// int getPosition = (Integer) buttonView.getTag(); +// +// if (isChecked) { +// checkedList.add(list.get(getPosition)); +// } else { +// checkedList.remove(list.get(getPosition)); +// } +// } +// }); convertView.setOnClickListener(new View.OnClickListener() { @Override diff --git a/Listify/app/src/main/res/layout/dialog_sort.xml b/Listify/app/src/main/res/layout/dialog_sort.xml index af88f7d..d01f288 100644 --- a/Listify/app/src/main/res/layout/dialog_sort.xml +++ b/Listify/app/src/main/res/layout/dialog_sort.xml @@ -90,7 +90,7 @@