mirror of
https://github.com/ClaytonWWilson/Listify.git
synced 2026-03-11 02:55:04 +00:00
Can now view the Sharee page
This commit is contained in:
@@ -40,6 +40,7 @@
|
|||||||
<activity android:name="com.example.listify.ui.LoginPage" />
|
<activity android:name="com.example.listify.ui.LoginPage" />
|
||||||
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
<activity android:name="com.example.listify.ui.ForgotPasswordPage" />
|
||||||
<activity android:name="com.example.listify.ListPage" />
|
<activity android:name="com.example.listify.ListPage" />
|
||||||
|
<activity android:name="com.example.listify.ListSharees" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -41,14 +41,12 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import static com.example.listify.MainActivity.am;
|
import static com.example.listify.MainActivity.am;
|
||||||
|
|
||||||
public class ListSharees extends AppCompatActivity implements Requestor.Receiver {
|
public class ListSharees extends AppCompatActivity implements Requestor.Receiver {
|
||||||
ShareeSwipeableAdapter myAdapter;
|
ListView listView;
|
||||||
|
MyAdapter myAdapter;
|
||||||
Requestor requestor;
|
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
|
@Override
|
||||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -65,8 +63,9 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
|||||||
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
requestor = new Requestor(am, configs.getProperty("apiKey"));
|
||||||
requestor.getObject(Integer.toString(listID), ListShare.class, this);
|
requestor.getObject(Integer.toString(listID), ListShare.class, this);
|
||||||
|
|
||||||
loadingListItems = findViewById(R.id.progress_loading_list_items);
|
listView = findViewById(R.id.listOfSharees);
|
||||||
loadingListItems.setVisibility(View.VISIBLE);
|
myAdapter = new MyAdapter(this, lShareeEmails);
|
||||||
|
listView.setAdapter(myAdapter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -74,29 +73,46 @@ public class ListSharees extends AppCompatActivity implements Requestor.Receiver
|
|||||||
ListShare sharee = (ListShare) delivered;
|
ListShare sharee = (ListShare) delivered;
|
||||||
|
|
||||||
if(sharee != null) {
|
if(sharee != null) {
|
||||||
SynchronousReceiver<ListShare> listShareReceiver = new SynchronousReceiver<>();
|
lShareeEmails.add("sharee.getShareWithEmail()");
|
||||||
requestor.getObject(Integer.toString(sharee.getListID()), ListShare.class, listShareReceiver, listShareReceiver);
|
|
||||||
|
|
||||||
ArrayList<ListShare> resultList = new ArrayList<>();
|
if(sharee.getEntries() != null) {
|
||||||
ListShare result;
|
for(ListShare ls : sharee.getEntries()) {
|
||||||
|
lShareeEmails.add(ls.getShareWithEmail());
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
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);
|
holder.textView = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||||
|
|
||||||
convertView.setTag(holder);
|
convertView.setTag(holder);
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import com.chauthai.swipereveallayout.SwipeRevealLayout;
|
|||||||
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
import com.chauthai.swipereveallayout.ViewBinderHelper;
|
||||||
import com.example.listify.AuthManager;
|
import com.example.listify.AuthManager;
|
||||||
import com.example.listify.ListPage;
|
import com.example.listify.ListPage;
|
||||||
|
import com.example.listify.ListSharees;
|
||||||
import com.example.listify.R;
|
import com.example.listify.R;
|
||||||
import com.example.listify.Requestor;
|
import com.example.listify.Requestor;
|
||||||
import com.example.listify.data.List;
|
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.swipeLayout = (SwipeRevealLayout)convertView.findViewById(R.id.swipe_layout);
|
||||||
holder.frontView = convertView.findViewById(R.id.front_layout);
|
holder.frontView = convertView.findViewById(R.id.front_layout);
|
||||||
holder.deleteList = convertView.findViewById(R.id.delete_list);
|
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.listName = (TextView) convertView.findViewById(R.id.shopping_list_name);
|
||||||
holder.itemCount = (TextView) convertView.findViewById(R.id.shopping_list_item_count);
|
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
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
View codeView = inflater.inflate(R.layout.activity_sharedemail, null);
|
Intent listSharees = new Intent(activity, ListSharees.class);
|
||||||
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();
|
// Send the list ID and list name
|
||||||
|
listSharees.putExtra("listID", curList.getListID());
|
||||||
|
//listPage.putExtra("listName", curList.getName());
|
||||||
|
|
||||||
// Close the layout
|
activity.startActivity(listSharees);
|
||||||
binderHelper.closeLayout(Integer.toString(curList.getListID()));
|
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
|
|
||||||
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
holder.frontView.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -176,7 +154,7 @@ public class ShoppingListsSwipeableAdapter extends BaseAdapter {
|
|||||||
SwipeRevealLayout swipeLayout;
|
SwipeRevealLayout swipeLayout;
|
||||||
View frontView;
|
View frontView;
|
||||||
View deleteList;
|
View deleteList;
|
||||||
//View shareList;
|
View shareList;
|
||||||
TextView listName;
|
TextView listName;
|
||||||
TextView itemCount;
|
TextView itemCount;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,36 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent">
|
||||||
|
|
||||||
<ProgressBar
|
<TextView
|
||||||
android:id="@+id/progress_loading_list_items"
|
android:id="@+id/textView15"
|
||||||
style="?android:attr/progressBarStyleLarge"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_centerHorizontal="true"
|
android:text="Enter the email of the user you want to share the list with."
|
||||||
android:layout_centerVertical="true"
|
android:layout_marginTop="10dp"
|
||||||
android:indeterminate="true"
|
android:layout_marginLeft="13dp"/>
|
||||||
android:visibility="gone"/>
|
|
||||||
|
<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
|
<ListView
|
||||||
android:id="@+id/listOfSharees"
|
android:id="@+id/listOfSharees"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginTop="0dp" />
|
android:layout_marginTop="175dp"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</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_width="wrap_content"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<!--<ImageView
|
<ImageView
|
||||||
android:id="@+id/share_list"
|
android:id="@+id/share_list"
|
||||||
android:src="@drawable/ic_baseline_share_24"
|
android:src="@drawable/ic_baseline_share_24"
|
||||||
android:layout_width="50dp"
|
android:layout_width="50dp"
|
||||||
android:layout_height="50dp"
|
android:layout_height="50dp"
|
||||||
android:background="@color/colorAccent"/>-->
|
android:background="@color/colorAccent"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/delete_list"
|
android:id="@+id/delete_list"
|
||||||
|
|||||||
Reference in New Issue
Block a user