Merge pull request #110 from ClaytonWWilson/master

Merge from master
This commit is contained in:
Aaron Sun 2020-11-06 11:29:08 -08:00 committed by GitHub
commit 530d23de3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 15 deletions

View File

@ -8,10 +8,6 @@ import java.util.Map;
public class TestListDelete {
@Test
public void testListDeleterValid() {
testListDeleterCore(false, true);
}
@Test
public void testListDeleterWOAccess() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -90,7 +90,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Descending"
android:text="Ascending"
android:textSize="16sp"
android:textColor="@android:color/black"
android:paddingStart="16dp"/>