mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2025-12-15 18:28:47 +00:00
Can now view the Sharee page
This commit is contained in:
parent
96bac9b5bb
commit
19c925700a
@ -40,6 +40,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>
|
||||
@ -41,14 +41,12 @@ 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;
|
||||
|
||||
ArrayList<String> lShareeEmails = new ArrayList<>();
|
||||
|
||||
DecimalFormat df = new DecimalFormat("0.00");
|
||||
|
||||
// TODO: Display a message if their list is empty
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -65,8 +63,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 +73,46 @@ 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));
|
||||
}
|
||||
|
||||
return listproduct;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ public class ShareeSwipeableAdapter extends BaseAdapter {
|
||||
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
||||
//holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.textView = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
|
||||
convertView.setTag(holder);
|
||||
|
||||
@ -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;
|
||||
@ -79,7 +80,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
holder.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
||||
//holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.shareList = convertView.findViewById(R.id.share_list);
|
||||
holder.listName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||
holder.itemCount = (TextView) convertView.findViewById(R.id.shopping_list_item_count);
|
||||
|
||||
@ -120,41 +121,18 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
}
|
||||
});
|
||||
|
||||
/*holder.shareList.setOnClickListener(new View.OnClickListener() {
|
||||
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();
|
||||
Intent listSharees = new Intent(activity, ListSharees.class);
|
||||
|
||||
Toast.makeText(activity, String.format("Share %s", curList.getName()), Toast.LENGTH_SHORT).show();
|
||||
// Send the list ID and list name
|
||||
listSharees.putExtra("listID", curList.getListID());
|
||||
//listPage.putExtra("listName", curList.getName());
|
||||
|
||||
// Close the layout
|
||||
binderHelper.closeLayout(Integer.toString(curList.getListID()));
|
||||
activity.startActivity(listSharees);
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
@ -176,7 +154,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
||||
SwipeRevealLayout swipeLayout;
|
||||
View frontView;
|
||||
View deleteList;
|
||||
//View shareList;
|
||||
View shareList;
|
||||
TextView listName;
|
||||
TextView itemCount;
|
||||
}
|
||||
|
||||
@ -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>
|
||||
@ -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>
|
||||
@ -17,12 +17,12 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<!--<ImageView
|
||||
<ImageView
|
||||
android:id="@+id/share_list"
|
||||
android:src="@drawable/ic_baseline_share_24"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"
|
||||
android:background="@color/colorAccent"/>-->
|
||||
android:background="@color/colorAccent"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/delete_list"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user