Merge pull request #60 from ClaytonWWilson/layout-improvements

Layout improvements
This commit is contained in:
Clayton Wilson 2020-10-09 01:36:45 -04:00 committed by GitHub
commit 43bd0a7fb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 114 additions and 87 deletions

View File

@ -46,7 +46,7 @@ public class UserDeleter implements CallHandler {
awsCognitoIdentityProvider.adminDeleteUser(adminDeleteUserRequest); awsCognitoIdentityProvider.adminDeleteUser(adminDeleteUserRequest);
try {
PreparedStatement statement = connection.prepareStatement(GET_LISTS); PreparedStatement statement = connection.prepareStatement(GET_LISTS);
statement.setString(1, cognitoID); statement.setString(1, cognitoID);
System.out.println(statement); System.out.println(statement);
@ -65,9 +65,7 @@ public class UserDeleter implements CallHandler {
System.out.println(statement); System.out.println(statement);
statement.executeQuery(); statement.executeQuery();
connection.commit(); connection.commit();
} finally {
connection.close();
}
return null; return null;
} }
} }

View File

@ -0,0 +1,30 @@
import org.junit.Test;
import java.sql.SQLException;
public class TestUserDeleter {
@Test
public void TestUserDelete(){
try {
testUserDeleter(false);
assert(false);
} catch (Exception e) {}
}
public void testUserDeleter(boolean shouldThrow) {
StatementInjector si = null;
try {
si = new StatementInjector(null, null, shouldThrow);
} catch (SQLException e) {
e.printStackTrace();
}
String cognitoID = "adbe8b88-9df4-4900-90e1-58dc48b82612";
UserDeleter userDeleter = new UserDeleter(si, cognitoID);
try {
userDeleter.conductAction(null, null, cognitoID);
} catch (SQLException e) {
e.printStackTrace();
}
}
}

View File

@ -29,6 +29,7 @@ public class CreateListDialogFragment extends DialogFragment {
@Override @Override
public Dialog onCreateDialog(final Bundle savedInstanceState) { public Dialog onCreateDialog(final Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
// Get the layout inflater // Get the layout inflater
LayoutInflater inflater = requireActivity().getLayoutInflater(); LayoutInflater inflater = requireActivity().getLayoutInflater();
@ -59,7 +60,7 @@ public class CreateListDialogFragment extends DialogFragment {
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
try { try {
onNewListListener = (OnNewListListener) getActivity(); onNewListListener = (OnNewListListener) getTargetFragment();
} catch (ClassCastException e) { } catch (ClassCastException e) {
Log.e("CreateListDialogFragment", "onAttach: ClassCastException: " + e.getMessage()); Log.e("CreateListDialogFragment", "onAttach: ClassCastException: " + e.getMessage());
} }

View File

@ -52,7 +52,6 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
// Load Product object from search results activity // Load Product object from search results activity
curProduct = (Product) getIntent().getSerializableExtra("SelectedProduct"); curProduct = (Product) getIntent().getSerializableExtra("SelectedProduct");
// Set up floating action buttons // Set up floating action buttons
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
linAddItem = (LinearLayout) findViewById(R.id.lin_add_item); linAddItem = (LinearLayout) findViewById(R.id.lin_add_item);
@ -123,8 +122,8 @@ public class ItemDetails extends AppCompatActivity implements ListPickerDialogFr
tvItemPrice = (TextView) findViewById(R.id.item_price); tvItemPrice = (TextView) findViewById(R.id.item_price);
tvItemPrice.setText(String.format("$%.2f", curProduct.getPrice())); tvItemPrice.setText(String.format("$%.2f", curProduct.getPrice()));
tvItemDesc = (TextView) findViewById(R.id.item_desc); // tvItemDesc = (TextView) findViewById(R.id.item_desc);
tvItemDesc.setText(curProduct.getDescription()); // tvItemDesc.setText(curProduct.getDescription());
tvCreateNew = (TextView) findViewById(R.id.create_new_list); tvCreateNew = (TextView) findViewById(R.id.create_new_list);
tvCreateNew.setVisibility(View.INVISIBLE); tvCreateNew.setVisibility(View.INVISIBLE);

View File

@ -74,11 +74,11 @@ public class ListPickerDialogFragment extends DialogFragment {
userListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { userListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
for (int i = 0; i < parent.getChildCount(); i++) { // for (int i = 0; i < parent.getChildCount(); i++) {
parent.getChildAt(i).setBackgroundColor(Color.TRANSPARENT); // parent.getChildAt(i).setBackgroundColor(Color.TRANSPARENT);
} // }
parent.getChildAt(position).setBackgroundColor(Color.GREEN); // parent.getChildAt(position).setBackgroundColor(Color.GREEN);
// view.setBackgroundColor(Color.GREEN); // view.setBackgroundColor(Color.GREEN);
selectedListIndex = position; selectedListIndex = position;
} }

View File

@ -134,7 +134,7 @@ public class MainActivity extends AppCompatActivity implements CreateListDialogF
NavigationView navigationView = findViewById(R.id.nav_view); NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each menu should be considered as top level destinations. // Passing each menu ID as a set of Ids because each menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder( mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow, R.id.nav_lists) R.id.nav_home, R.id.nav_lists)
.setDrawerLayout(drawer) .setDrawerLayout(drawer)
.build(); .build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment); NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);

View File

@ -57,8 +57,8 @@ public class SearchResultsListAdapter extends BaseAdapter {
Product product = productList.get(position); Product product = productList.get(position);
// TODO: If image url is broken, display @drawable/ic_baseline_broken_image_600.xml // TODO: If image url is broken, display @drawable/ic_baseline_broken_image_600.xml
Glide.with(activity).load(product.getImageUrl()).into(productImage); Glide.with(activity).load(product.getImageUrl()).into(productImage);
if (product.getItemName().length() >= 35) { if (product.getItemName().length() >= 60) {
itemName.setText(product.getItemName().substring(0, 35) + "..."); itemName.setText(product.getItemName().substring(0, 60) + "...");
} else { } else {
itemName.setText(product.getItemName()); itemName.setText(product.getItemName());
} }

View File

@ -36,6 +36,7 @@ import static com.example.listify.MainActivity.am;
public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener { public class ListsFragment extends Fragment implements CreateListDialogFragment.OnNewListListener {
ArrayList<List> shoppingLists = new ArrayList<>(); ArrayList<List> shoppingLists = new ArrayList<>();
DisplayShoppingListsAdapter displayShoppingListsAdapter;
ListView shoppingListsView; ListView shoppingListsView;
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
@ -67,7 +68,7 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
// Set adapter and display this users lists // Set adapter and display this users lists
DisplayShoppingListsAdapter displayShoppingListsAdapter = new DisplayShoppingListsAdapter(getActivity(), shoppingLists); displayShoppingListsAdapter = new DisplayShoppingListsAdapter(getActivity(), shoppingLists);
shoppingListsView.setAdapter(displayShoppingListsAdapter); shoppingListsView.setAdapter(displayShoppingListsAdapter);
shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() { shoppingListsView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override @Override
@ -81,11 +82,13 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
}); });
FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.new_list_fab); FloatingActionButton fab = (FloatingActionButton) root.findViewById(R.id.new_list_fab);
Fragment thisFragment = this;
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CreateListDialogFragment createListDialogFragment = new CreateListDialogFragment(); CreateListDialogFragment createListDialogFragment = new CreateListDialogFragment();
createListDialogFragment.show(getActivity().getSupportFragmentManager(), "Create New List"); createListDialogFragment.show(getFragmentManager(), "Create New List");
createListDialogFragment.setTargetFragment(thisFragment, 0);
} }
}); });
@ -108,7 +111,9 @@ public class ListsFragment extends Fragment implements CreateListDialogFragment.
try { try {
requestor.postObject(newList, idReceiver, idReceiver); requestor.postObject(newList, idReceiver, idReceiver);
System.out.println(idReceiver.await()); newList.setItemID(idReceiver.await());
shoppingLists.add(newList);
displayShoppingListsAdapter.notifyDataSetChanged();
Toast.makeText(getContext(), String.format("%s created", name), Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), String.format("%s created", name), Toast.LENGTH_LONG).show();
} catch (Exception e) { } catch (Exception e) {
Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show(); Toast.makeText(getContext(), "An error occurred", Toast.LENGTH_LONG).show();

View File

@ -8,15 +8,13 @@
<TextView <TextView
android:id="@+id/item_name" android:id="@+id/item_name"
android:layout_width="307dp" android:layout_width="fill_parent"
android:layout_height="56dp" android:layout_height="56dp"
android:layout_marginStart="50dp" android:layout_marginHorizontal="50dp"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
android:layout_marginEnd="50dp"
android:text="@string/default_product_name" android:text="@string/default_product_name"
android:textSize="16sp" android:textSize="16sp"
android:textStyle="bold" android:textStyle="bold"
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" />
@ -24,26 +22,23 @@
android:id="@+id/store_name" android:id="@+id/store_name"
android:layout_width="126dp" android:layout_width="126dp"
android:layout_height="28dp" android:layout_height="28dp"
android:layout_marginStart="52dp" android:layout_marginStart="50dp"
android:layout_marginTop="50dp" android:layout_marginTop="90dp"
android:text="@string/default_store" android:text="@string/default_store"
app:layout_constraintBottom_toTopOf="@+id/item_image"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" /> app:layout_constraintVertical_bias="1.0" />
<ImageView <ImageView
android:id="@+id/item_image" android:id="@+id/item_image"
android:layout_width="307dp" android:layout_width="match_parent"
android:layout_height="224dp" android:layout_height="224dp"
android:layout_marginStart="50dp"
android:layout_marginTop="120dp" android:layout_marginTop="120dp"
android:layout_marginEnd="50dp" android:layout_marginHorizontal="50dp"
android:foregroundGravity="center"
android:background="@color/light_gray" android:background="@color/light_gray"
android:textAlignment="center" android:textAlignment="center"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHorizontal_bias="0.75"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:contentDescription="@string/product_image_description" /> android:contentDescription="@string/product_image_description" />
@ -56,22 +51,18 @@
android:layout_marginBottom="25dp" android:layout_marginBottom="25dp"
android:text="@string/default__00_00" android:text="@string/default__00_00"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintBottom_toTopOf="@+id/item_desc" app:layout_constraintTop_toBottomOf="@id/item_image"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/item_image" />
<TextView
android:id="@+id/item_desc"
android:layout_width="309dp"
android:layout_height="290dp"
android:layout_marginHorizontal="50dp"
android:layout_marginStart="50dp"
android:layout_marginEnd="50dp"
android:layout_marginBottom="7dp"
android:text="@string/default_description"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<!-- <TextView-->
<!-- android:id="@+id/item_desc"-->
<!-- android:layout_width="309dp"-->
<!-- android:layout_height="290dp"-->
<!-- android:layout_marginHorizontal="50dp"-->
<!-- android:layout_marginBottom="7dp"-->
<!-- android:text="@string/default_description"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintStart_toStartOf="parent" />-->
<!-- app:srcCompat="@drawable/ic_baseline_arrow_downward_50"--> <!-- app:srcCompat="@drawable/ic_baseline_arrow_downward_50"-->
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -18,7 +18,9 @@
android:layout_height="300dp" android:layout_height="300dp"
android:divider="@color/list_divider" android:divider="@color/list_divider"
android:dividerHeight="1dp" android:dividerHeight="1dp"
android:choiceMode="multipleChoiceModal"/> android:layout_marginHorizontal="50dp"
android:choiceMode="singleChoice"
android:listSelector="@color/colorAccent"/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"

View File

@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height" android:layout_height="10dp"
android:background="@drawable/side_nav_bar" android:background="@drawable/side_nav_bar"
android:gravity="bottom" android:gravity="bottom"
android:orientation="vertical" android:orientation="vertical"
@ -12,24 +12,24 @@
android:paddingBottom="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark"> android:theme="@style/ThemeOverlay.AppCompat.Dark">
<ImageView <!-- <ImageView-->
android:id="@+id/imageView" <!-- android:id="@+id/imageView"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:contentDescription="@string/nav_header_desc" <!-- android:contentDescription="@string/nav_header_desc"-->
android:paddingTop="@dimen/nav_header_vertical_spacing" <!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
app:srcCompat="@mipmap/ic_launcher_round" /> <!-- app:srcCompat="@mipmap/ic_launcher_round" />-->
<TextView <!-- <TextView-->
android:layout_width="match_parent" <!-- android:layout_width="match_parent"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:paddingTop="@dimen/nav_header_vertical_spacing" <!-- android:paddingTop="@dimen/nav_header_vertical_spacing"-->
android:text="@string/nav_header_title" <!-- android:text="@string/nav_header_title"-->
android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> <!-- android:textAppearance="@style/TextAppearance.AppCompat.Body1" />-->
<TextView <!-- <TextView-->
android:id="@+id/textView" <!-- android:id="@+id/textView"-->
android:layout_width="wrap_content" <!-- android:layout_width="wrap_content"-->
android:layout_height="wrap_content" <!-- android:layout_height="wrap_content"-->
android:text="@string/nav_header_subtitle" /> <!-- android:text="@string/nav_header_subtitle" />-->
</LinearLayout> </LinearLayout>

View File

@ -44,6 +44,7 @@
android:paddingTop="20dp" android:paddingTop="20dp"
android:textSize="12sp" android:textSize="12sp"
android:layout_toEndOf="@+id/item_image" android:layout_toEndOf="@+id/item_image"
android:layout_alignParentBottom="true"
android:text=""/> android:text=""/>
<!-- Only displays if the item is cheaper at another store --> <!-- Only displays if the item is cheaper at another store -->

View File

@ -8,14 +8,14 @@
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"