diff --git a/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java index 6d7d120fbede..a9ba45921f79 100644 --- a/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java +++ b/src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java @@ -23,10 +23,13 @@ import android.content.Context; import android.support.annotation.NonNull; import android.view.LayoutInflater; +import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ImageView; +import android.widget.PopupMenu; import android.widget.TextView; import com.owncloud.android.R; @@ -82,6 +85,7 @@ public long getItemId(int position) { OCShare share = mShares.get(position); TextView userName = view.findViewById(R.id.userOrGroupName); + final ImageView editShareButton = view.findViewById(R.id.editShareButton); ImageView icon = view.findViewById(R.id.userIcon); String name = share.getSharedWithDisplayName(); if (share.getShareType() == ShareType.GROUP) { @@ -107,7 +111,42 @@ public long getItemId(int position) { } userName.setText(name); + /// bind listener to edit privileges + editShareButton.setOnClickListener(v -> onOverflowIconClicked(v,mShares.get(position))); } return view; } + + private void onOverflowIconClicked(View view, OCShare share) { + PopupMenu popup = new PopupMenu(mContext, view); + popup.inflate(R.menu.file_detail_sharing_menu); + + prepareOptionsMenu(popup.getMenu(), share); + + popup.setOnMenuItemClickListener(this::optionsItemSelected); + popup.show(); + } + + private void prepareOptionsMenu(Menu menu, OCShare share) { + // TODO implement menu filtering based on OCShare type + } + + private boolean optionsItemSelected(MenuItem item) { + switch (item.getItemId()) { + case R.id.action_can_edit: { + // TODO implement de/-selecting can edit + return true; + } + case R.id.action_can_reshare: { + // TODO implement de/-selecting can share + return true; + } + case R.id.action_unshare: { + // TODO implement unshare + return true; + } + default: + return true; + } + } } \ No newline at end of file diff --git a/src/main/res/layout/file_details_share_user_item.xml b/src/main/res/layout/file_details_share_user_item.xml index 616c432dba60..e30ecd06bc6a 100644 --- a/src/main/res/layout/file_details_share_user_item.xml +++ b/src/main/res/layout/file_details_share_user_item.xml @@ -42,6 +42,7 @@ + + diff --git a/src/main/res/menu/file_detail_sharing_menu.xml b/src/main/res/menu/file_detail_sharing_menu.xml new file mode 100644 index 000000000000..d812daa5a3b2 --- /dev/null +++ b/src/main/res/menu/file_detail_sharing_menu.xml @@ -0,0 +1,44 @@ + + + + + + + + + diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index 7fc009dd1b5e..cd2325ee6d18 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -500,6 +500,7 @@ Share by link enabled Not shared by link Users and groups with access + Unshare can share can edit create