diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 45bb91e..e8eabfb 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -23,6 +23,15 @@
-
+
+
+
+
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/ActiveListDetailsActivity.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/ActiveListDetailsActivity.java
new file mode 100755
index 0000000..9f15b96
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/ActiveListDetailsActivity.java
@@ -0,0 +1,198 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.DialogFragment;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.AdapterView;
+import android.widget.ListView;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+import com.udacity.firebase.shoppinglistplusplus.ui.BaseActivity;
+
+/**
+ * Represents the details screen for the selected shopping list
+ */
+public class ActiveListDetailsActivity extends BaseActivity {
+ private static final String LOG_TAG = ActiveListDetailsActivity.class.getSimpleName();
+ private ListView mListView;
+ private ShoppingList mShoppingList;
+
+ @Override
+ protected void onCreate(final Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_active_list_details);
+
+ /**
+ * Link layout elements from XML and setup the toolbar
+ */
+ initializeScreen();
+
+ /* Calling invalidateOptionsMenu causes onCreateOptionsMenu to be called */
+ invalidateOptionsMenu();
+
+ /**
+ * Set up click listeners for interaction.
+ */
+
+ /* Show edit list item name dialog on listView item long click event */
+ mListView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
+
+ @Override
+ public boolean onItemLongClick(AdapterView> parent, View view, int position, long id) {
+ /* Check that the view is not the empty footer item */
+ if(view.getId() != R.id.list_view_footer_empty) {
+ showEditListItemNameDialog();
+ }
+ return true;
+ }
+ });
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ /* Inflate the menu; this adds items to the action bar if it is present. */
+ getMenuInflater().inflate(R.menu.menu_list_details, menu);
+
+ /**
+ * Get menu items
+ */
+ MenuItem remove = menu.findItem(R.id.action_remove_list);
+ MenuItem edit = menu.findItem(R.id.action_edit_list_name);
+ MenuItem share = menu.findItem(R.id.action_share_list);
+ MenuItem archive = menu.findItem(R.id.action_archive);
+
+ /* Only the edit and remove options are implemented */
+ remove.setVisible(true);
+ edit.setVisible(true);
+ share.setVisible(false);
+ archive.setVisible(false);
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ int id = item.getItemId();
+
+ /**
+ * Show edit list dialog when the edit action is selected
+ */
+ if (id == R.id.action_edit_list_name) {
+ showEditListNameDialog();
+ return true;
+ }
+
+ /**
+ * removeList() when the remove action is selected
+ */
+ if (id == R.id.action_remove_list) {
+ removeList();
+ return true;
+ }
+
+ /**
+ * Eventually we'll add this
+ */
+ if (id == R.id.action_share_list) {
+ return true;
+ }
+
+ /**
+ * archiveList() when the archive action is selected
+ */
+ if (id == R.id.action_archive) {
+ archiveList();
+ return true;
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+
+ /**
+ * Cleanup when the activity is destroyed.
+ */
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ }
+
+ /**
+ * Link layout elements from XML and setup the toolbar
+ */
+ private void initializeScreen() {
+ mListView = (ListView) findViewById(R.id.list_view_shopping_list_items);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.app_bar);
+ /* Common toolbar setup */
+ setSupportActionBar(toolbar);
+ /* Add back button to the action bar */
+ if (getSupportActionBar() != null) {
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ }
+ /* Inflate the footer, set root layout to null*/
+ View footer = getLayoutInflater().inflate(R.layout.footer_empty, null);
+ mListView.addFooterView(footer);
+ }
+
+
+ /**
+ * Archive current list when user selects "Archive" menu item
+ */
+ public void archiveList() {
+ }
+
+
+ /**
+ * Start AddItemsFromMealActivity to add meal ingredients into the shopping list
+ * when the user taps on "add meal" fab
+ */
+ public void addMeal(View view) {
+ }
+
+ /**
+ * Remove current shopping list and its items from all nodes
+ */
+ public void removeList() {
+ /* Create an instance of the dialog fragment and show it */
+ DialogFragment dialog = RemoveListDialogFragment.newInstance(mShoppingList);
+ dialog.show(getFragmentManager(), "RemoveListDialogFragment");
+ }
+
+ /**
+ * Show the add list item dialog when user taps "Add list item" fab
+ */
+ public void showAddListItemDialog(View view) {
+ /* Create an instance of the dialog fragment and show it */
+ DialogFragment dialog = AddListItemDialogFragment.newInstance(mShoppingList);
+ dialog.show(getFragmentManager(), "AddListItemDialogFragment");
+ }
+
+ /**
+ * Show edit list name dialog when user selects "Edit list name" menu item
+ */
+ public void showEditListNameDialog() {
+ /* Create an instance of the dialog fragment and show it */
+ DialogFragment dialog = EditListNameDialogFragment.newInstance(mShoppingList);
+ dialog.show(this.getFragmentManager(), "EditListNameDialogFragment");
+ }
+
+ /**
+ * Show the edit list item name dialog after longClick on the particular item
+ */
+ public void showEditListItemNameDialog() {
+ /* Create an instance of the dialog fragment and show it */
+ DialogFragment dialog = EditListItemNameDialogFragment.newInstance(mShoppingList);
+ dialog.show(this.getFragmentManager(), "EditListItemNameDialogFragment");
+ }
+
+ /**
+ * This method is called when user taps "Start/Stop shopping" button
+ */
+ public void toggleShopping(View view) {
+
+ }
+}
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/AddListItemDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/AddListItemDialogFragment.java
new file mode 100644
index 0000000..8f0bc9a
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/AddListItemDialogFragment.java
@@ -0,0 +1,49 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.Dialog;
+import android.os.Bundle;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+
+/**
+ * Lets user add new list item.
+ */
+public class AddListItemDialogFragment extends EditListDialogFragment {
+
+ /**
+ * Public static constructor that creates fragment and passes a bundle with data into it when adapter is created
+ */
+ public static AddListItemDialogFragment newInstance(ShoppingList shoppingList) {
+ AddListItemDialogFragment addListItemDialogFragment = new AddListItemDialogFragment();
+
+ Bundle bundle = newInstanceHelper(shoppingList, R.layout.dialog_add_item);
+ addListItemDialogFragment.setArguments(bundle);
+
+ return addListItemDialogFragment;
+ }
+
+ /**
+ * Initialize instance variables with data from bundle
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ /** {@link EditListDialogFragment#createDialogHelper(int)} is a
+ * superclass method that creates the dialog
+ **/
+ return super.createDialogHelper(R.string.positive_button_add_list_item);
+ }
+
+ /**
+ * Adds new item to the current shopping list
+ */
+ @Override
+ protected void doListEdit() {
+
+ }
+}
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListDialogFragment.java
new file mode 100644
index 0000000..c68b105
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListDialogFragment.java
@@ -0,0 +1,129 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
+import android.view.KeyEvent;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.WindowManager;
+import android.view.inputmethod.EditorInfo;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+import com.udacity.firebase.shoppinglistplusplus.utils.Constants;
+
+/**
+ * Base class for {@link DialogFragment}s involved with editing a shopping list.
+ */
+public abstract class EditListDialogFragment extends DialogFragment {
+ EditText mEditTextForList;
+ int mResource;
+
+ /**
+ * Helper method that creates a basic bundle of all of the information needed to change
+ * values in a shopping list.
+ *
+ * @param shoppingList
+ * @param resource
+ * @return
+ */
+ protected static Bundle newInstanceHelper(ShoppingList shoppingList, int resource) {
+ Bundle bundle = new Bundle();
+ bundle.putInt(Constants.KEY_LAYOUT_RESOURCE, resource);
+ return bundle;
+ }
+
+ /**
+ * Initialize instance variables with data from bundle
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mResource = getArguments().getInt(Constants.KEY_LAYOUT_RESOURCE);
+ }
+
+ /**
+ * Open the keyboard automatically when the dialog fragment is opened
+ */
+ @Override
+ public void onActivityCreated(Bundle savedInstanceState) {
+ super.onActivityCreated(savedInstanceState);
+ getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
+ }
+
+ protected Dialog createDialogHelper(int stringResourceForPositiveButton) {
+ /* Use the Builder class for convenient dialog construction */
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.CustomTheme_Dialog);
+ /* Get the layout inflater */
+ LayoutInflater inflater = getActivity().getLayoutInflater();
+ /* Inflate the layout, set root ViewGroup to null*/
+ View rootView = inflater.inflate(mResource, null);
+ mEditTextForList = (EditText) rootView.findViewById(R.id.edit_text_list_dialog);
+
+ /**
+ * Call doListEdit() when user taps "Done" keyboard action
+ */
+ mEditTextForList.setOnEditorActionListener(new TextView.OnEditorActionListener() {
+ @Override
+ public boolean onEditorAction(TextView textView, int actionId, KeyEvent keyEvent) {
+ if (actionId == EditorInfo.IME_ACTION_DONE || keyEvent.getAction() == KeyEvent.ACTION_DOWN) {
+ doListEdit();
+
+ /**
+ * Close the dialog fragment when done
+ */
+ EditListDialogFragment.this.getDialog().cancel();
+ }
+ return true;
+ }
+ });
+ /* Inflate and set the layout for the dialog */
+ /* Pass null as the parent view because its going in the dialog layout */
+ builder.setView(rootView)
+ /* Add action buttons */
+ .setPositiveButton(stringResourceForPositiveButton, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ doListEdit();
+
+ /**
+ * Close the dialog fragment
+ */
+ EditListDialogFragment.this.getDialog().cancel();
+ }
+ })
+ .setNegativeButton(R.string.negative_button_cancel, new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+
+ /**
+ * Close the dialog fragment
+ */
+ EditListDialogFragment.this.getDialog().cancel();
+ }
+ });
+
+ return builder.create();
+ }
+
+ /**
+ * Set the EditText text to be the inputted text
+ * and put the pointer at the end of the input
+ *
+ * @param defaultText
+ */
+ protected void helpSetDefaultValueEditText(String defaultText) {
+ mEditTextForList.setText(defaultText);
+ mEditTextForList.setSelection(defaultText.length());
+ }
+
+ /**
+ * Method to be overriden with whatever edit is supposed to happen to the list
+ */
+ protected abstract void doListEdit();
+}
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListItemNameDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListItemNameDialogFragment.java
new file mode 100644
index 0000000..150a7db
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListItemNameDialogFragment.java
@@ -0,0 +1,50 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.Dialog;
+import android.os.Bundle;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+
+/**
+ * Lets user edit list item name for all copies of the current list
+ */
+public class EditListItemNameDialogFragment extends EditListDialogFragment {
+
+ /**
+ * Public static constructor that creates fragment and passes a bundle with data into it when adapter is created
+ */
+ public static EditListItemNameDialogFragment newInstance(ShoppingList shoppingList) {
+ EditListItemNameDialogFragment editListItemNameDialogFragment = new EditListItemNameDialogFragment();
+
+ Bundle bundle = EditListDialogFragment.newInstanceHelper(shoppingList, R.layout.dialog_edit_item);
+ editListItemNameDialogFragment.setArguments(bundle);
+
+ return editListItemNameDialogFragment;
+ }
+
+ /**
+ * Initialize instance variables with data from bundle
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+
+ @Override
+
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ /** {@link EditListDialogFragment#createDialogHelper(int)} is a
+ * superclass method that creates the dialog
+ */
+ Dialog dialog = super.createDialogHelper(R.string.positive_button_edit_item);
+ return dialog;
+ }
+
+ /**
+ * Change selected list item name to the editText input if it is not empty
+ */
+ protected void doListEdit() {
+ }
+}
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListNameDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListNameDialogFragment.java
new file mode 100644
index 0000000..ef40c52
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/EditListNameDialogFragment.java
@@ -0,0 +1,52 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.Dialog;
+import android.os.Bundle;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+
+/**
+ * Lets user edit the list name for all copies of the current list
+ */
+public class EditListNameDialogFragment extends EditListDialogFragment {
+ private static final String LOG_TAG = ActiveListDetailsActivity.class.getSimpleName();
+
+ /**
+ * Public static constructor that creates fragment and passes a bundle with data into it when adapter is created
+ */
+ public static EditListNameDialogFragment newInstance(ShoppingList shoppingList) {
+ EditListNameDialogFragment editListNameDialogFragment = new EditListNameDialogFragment();
+ Bundle bundle = EditListDialogFragment.newInstanceHelper(shoppingList, R.layout.dialog_edit_list);
+ editListNameDialogFragment.setArguments(bundle);
+ return editListNameDialogFragment;
+ }
+
+ /**
+ * Initialize instance variables with data from bundle
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+ /** {@link EditListDialogFragment#createDialogHelper(int)} is a
+ * superclass method that creates the dialog
+ **/
+ Dialog dialog = super.createDialogHelper(R.string.positive_button_edit_item);
+
+ return dialog;
+ }
+
+ /**
+ * Changes the list name in all copies of the current list
+ */
+ protected void doListEdit() {
+
+ }
+}
+
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/RemoveListDialogFragment.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/RemoveListDialogFragment.java
new file mode 100644
index 0000000..2d42e29
--- /dev/null
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/ui/activeListDetails/RemoveListDialogFragment.java
@@ -0,0 +1,63 @@
+package com.udacity.firebase.shoppinglistplusplus.ui.activeListDetails;
+
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.DialogInterface;
+import android.os.Bundle;
+import android.support.v7.app.AlertDialog;
+
+import com.udacity.firebase.shoppinglistplusplus.R;
+import com.udacity.firebase.shoppinglistplusplus.model.ShoppingList;
+
+/**
+ * Lets the user remove active shopping list
+ */
+public class RemoveListDialogFragment extends DialogFragment {
+ final static String LOG_TAG = RemoveListDialogFragment.class.getSimpleName();
+
+ /**
+ * Public static constructor that creates fragment and passes a bundle with data into it when adapter is created
+ */
+ public static RemoveListDialogFragment newInstance(ShoppingList shoppingList) {
+ RemoveListDialogFragment removeListDialogFragment = new RemoveListDialogFragment();
+ Bundle bundle = new Bundle();
+ removeListDialogFragment.setArguments(bundle);
+ return removeListDialogFragment;
+ }
+
+ /**
+ * Initialize instance variables with data from bundle
+ */
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.CustomTheme_Dialog)
+ .setTitle(getActivity().getResources().getString(R.string.action_remove_list))
+ .setMessage(getString(R.string.dialog_message_are_you_sure_remove_list))
+ .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ removeList();
+ /* Dismiss the dialog */
+ dialog.dismiss();
+ }
+ })
+ .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ /* Dismiss the dialog */
+ dialog.dismiss();
+ }
+ })
+ .setIcon(android.R.drawable.ic_dialog_alert);
+
+ return builder.create();
+ }
+
+ private void removeList() {
+
+ }
+
+}
diff --git a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/utils/Constants.java b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/utils/Constants.java
index 332ecbd..da2a3d5 100755
--- a/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/utils/Constants.java
+++ b/app/src/main/java/com/udacity/firebase/shoppinglistplusplus/utils/Constants.java
@@ -28,6 +28,6 @@ public final class Constants {
/**
* Constants for bundles, extras and shared preferences keys
*/
-
+ public static final String KEY_LAYOUT_RESOURCE = "LAYOUT_RESOURCE";
}
diff --git a/app/src/main/res/layout/activity_active_list_details.xml b/app/src/main/res/layout/activity_active_list_details.xml
new file mode 100755
index 0000000..15f38da
--- /dev/null
+++ b/app/src/main/res/layout/activity_active_list_details.xml
@@ -0,0 +1,81 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/dialog_add_item.xml b/app/src/main/res/layout/dialog_add_item.xml
new file mode 100755
index 0000000..5d38e0c
--- /dev/null
+++ b/app/src/main/res/layout/dialog_add_item.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/dialog_edit_item.xml b/app/src/main/res/layout/dialog_edit_item.xml
new file mode 100755
index 0000000..c6119be
--- /dev/null
+++ b/app/src/main/res/layout/dialog_edit_item.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/app/src/main/res/layout/dialog_edit_list.xml b/app/src/main/res/layout/dialog_edit_list.xml
new file mode 100755
index 0000000..34ee8be
--- /dev/null
+++ b/app/src/main/res/layout/dialog_edit_list.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/app/src/main/res/layout/single_active_list_item.xml b/app/src/main/res/layout/single_active_list_item.xml
new file mode 100755
index 0000000..8ba1e6a
--- /dev/null
+++ b/app/src/main/res/layout/single_active_list_item.xml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/menu/menu_list_details.xml b/app/src/main/res/menu/menu_list_details.xml
new file mode 100755
index 0000000..f15e074
--- /dev/null
+++ b/app/src/main/res/menu/menu_list_details.xml
@@ -0,0 +1,30 @@
+