Merge pull request #136 from ClaytonWWilson/aaron-branch-2

Aaron branch 2
This commit is contained in:
Aaron Sun 2020-11-29 13:00:49 -08:00 committed by GitHub
commit dc3d233711
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 121 additions and 71 deletions

View File

@ -55,6 +55,7 @@
<activity android:name="com.example.listify.ui.LoginPage" />
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
<activity android:name="com.example.listify.ListPage" />
<activity android:name="com.example.listify.ListSharees" />
</application>
</manifest>

View File

@ -41,14 +41,14 @@ import androidx.appcompat.app.AppCompatActivity;
import static com.example.listify.MainActivity.am;
public class ListSharees extends AppCompatActivity implements Requestor.Receiver {
ShareeSwipeableAdapter myAdapter;
ListView listView;
MyAdapter myAdapter;
Requestor requestor;
ProgressBar loadingListItems;
Button removeSharee;
DecimalFormat df = new DecimalFormat("0.00");
ArrayList<String> lShareeEmails = new ArrayList<>();
// TODO: Display a message if their list is empty
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -65,8 +65,9 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
requestor = new Requestor(am, configs.getProperty("apiKey"));
requestor.getObject(Integer.toString(listID), ListShare.class, this);
loadingListItems = findViewById(R.id.progress_loading_list_items);
loadingListItems.setVisibility(View.VISIBLE);
listView = findViewById(R.id.listOfSharees);
myAdapter = new MyAdapter(this, lShareeEmails);
listView.setAdapter(myAdapter);
}
@Override
@ -74,29 +75,54 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
ListShare sharee = (ListShare) delivered;
if(sharee != null) {
SynchronousReceiver<ListShare> listShareReceiver = new SynchronousReceiver<>();
requestor.getObject(Integer.toString(sharee.getListID()), ListShare.class, listShareReceiver, listShareReceiver);
lShareeEmails.add("sharee.getShareWithEmail()");
ArrayList<ListShare> resultList = new ArrayList<>();
ListShare result;
try {
result = listShareReceiver.await();
}
catch (Exception e) {
e.printStackTrace();
result = null;
}
if(result != null) {
resultList.add(result);
for(ListShare r : result.getEntries()) {
resultList.add(r);
if(sharee.getEntries() != null) {
for(ListShare ls : sharee.getEntries()) {
lShareeEmails.add(ls.getShareWithEmail());
}
myAdapter = new ShareeSwipeableAdapter(this, resultList);
}
runOnUiThread(new Runnable() {
@Override
public void run() {
myAdapter.notifyDataSetChanged();
}
});
}
}
class MyAdapter extends ArrayAdapter<String> {
Context context;
ArrayList<String> lShareeEmails;
MyAdapter (Context c, ArrayList<String> shareeEmails) {
super(c, R.layout.shopping_list_sharee_entry, R.id.textView14, shareeEmails);
context = c;
lShareeEmails = shareeEmails;
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View listproduct = layoutInflater.inflate(R.layout.shopping_list_sharee_entry, parent,false);
TextView shareeEmail = listproduct.findViewById(R.id.textView14);
if(!lShareeEmails.isEmpty()) {
shareeEmail.setText(lShareeEmails.get(position));
}
removeSharee = (Button) listproduct.findViewById(R.id.button4);
removeSharee.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
lShareeEmails.remove(position);
myAdapter.notifyDataSetChanged();
}
});
return listproduct;
}
}
}

View File

@ -49,7 +49,7 @@ public class ShoppingListsAdapter extends BaseAdapter {
TextView tvListName = (TextView) convertView.findViewById(R.id.shopping_list_name);
if(curList.isShared()) {
tvListName.setText(curList.getName() + " (shared)");
tvListName.setText(curList.getName() + " (shared by " + curList.getOwner() + ")");
}
else {
tvListName.setText(curList.getName());

View File

@ -17,6 +17,7 @@ import com.chauthai.swipereveallayout.SwipeRevealLayout;
import com.chauthai.swipereveallayout.ViewBinderHelper;
import com.example.listify.AuthManager;
import com.example.listify.ListPage;
import com.example.listify.ListSharees;
import com.example.listify.R;
import com.example.listify.Requestor;
import com.example.listify.data.List;
@ -94,7 +95,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
binderHelper.bind(holder.swipeLayout, Integer.toString(curList.getListID()));
if(curList.isShared()) {
holder.listName.setText(curList.getName() + " (shared)");
holder.listName.setText(curList.getName() + " (shared by " + curList.getOwner() + ")");
}
else {
holder.listName.setText(curList.getName());
@ -124,41 +125,18 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
}
});
// holder.shareList.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// View codeView = inflater.inflate(R.layout.activity_sharedemail, null);
// AlertDialog.Builder builder = new AlertDialog.Builder(activity);
// builder.setView(codeView);
// builder.setTitle("Share list");
// builder.setMessage("Please enter the email of the user who you want to share the list with.");
// builder.setPositiveButton("Submit", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {
// EditText sharedEmailText = (EditText) codeView.findViewById(R.id.editTextTextSharedEmail);
// String sharedEmail = sharedEmailText.getText().toString();
// ListShare listShare = new ListShare(curList.getListID(), sharedEmail, "Read, Write, Delete, Share", null);
// try {
// requestor.putObject(listShare);
// }
// catch(Exception e) {
// e.printStackTrace();
// }
// }
// });
// builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
// @Override
// public void onClick(DialogInterface dialog, int which) {}
// });
// AlertDialog dialog = builder.create();
// dialog.show();
//
// Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
//
// // Close the layout
// binderHelper.closeLayout(Integer.toString(curList.getListID()));
// }
// });
holder.shareList.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent listSharees = new Intent(activity, ListSharees.class);
// Send the list ID and list name
listSharees.putExtra("listID", curList.getListID());
//listPage.putExtra("listName", curList.getName());
activity.startActivity(listSharees);
}
});
holder.frontView.setOnClickListener(new View.OnClickListener() {
@Override

View File

@ -3,20 +3,36 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="@+id/progress_loading_list_items"
style="?android:attr/progressBarStyleLarge"
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:visibility="gone"/>
android:text="Enter the email of the user you want to share the list with."
android:layout_marginTop="10dp"
android:layout_marginLeft="13dp"/>
<EditText
android:id="@+id/editTextShareeEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="17"
android:inputType="textPersonName"
android:hint="Sharee's email"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"/>
<Button
android:id="@+id/buttonShare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Share"
android:layout_marginTop="100dp"
android:layout_marginLeft="10dp"/>
<ListView
android:id="@+id/listOfSharees"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="0dp" />
android:layout_marginTop="175dp"/>
</RelativeLayout>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginTop="16dp"
android:text="Stop sharing"
android:textSize="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="30dp"
android:text="Sharee's email"
android:textSize="15dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>