Skip to content

Commit

Permalink
empty menu implementation per sharee
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyScherzinger committed May 11, 2018
1 parent fa2bd80 commit cec0eb8
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 0 deletions.
39 changes: 39 additions & 0 deletions src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
}
12 changes: 12 additions & 0 deletions src/main/res/layout/file_details_share_user_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:textSize="@dimen/file_details_username_text_size"
android:text="@string/username"
android:id="@+id/userOrGroupName"
Expand All @@ -51,4 +52,15 @@
android:ellipsize="middle"
android:gravity="center_vertical"
android:textColor="@color/black"/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editShareButton"
android:src="@drawable/ic_dots_vertical"
android:padding="@dimen/standard_half_padding"
android:layout_marginEnd="@dimen/standard_half_margin"
android:layout_marginRight="@dimen/standard_half_margin"
android:layout_gravity="center_vertical"
android:contentDescription="@string/overflow_menu"/>
</LinearLayout>
44 changes: 44 additions & 0 deletions src/main/res/menu/file_detail_sharing_menu.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Nesxtcloud Android client application
Copyright (C) 2018 Andy Scherzinger
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
License as published by the Free Software Foundation; either
version 3 of the License, or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU AFFERO GENERAL PUBLIC LICENSE for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="AppCompatResource">

<item
android:id="@+id/action_can_edit"
android:checkable="true"
android:icon="@drawable/ic_share"
android:showAsAction="never"
android:title="@string/share_privilege_can_edit"
app:showAsAction="never" />
<item
android:id="@+id/action_can_reshare"
android:checkable="true"
android:showAsAction="never"
android:title="@string/share_privilege_can_share"
app:showAsAction="never" />
<item
android:id="@+id/action_unshare"
android:showAsAction="never"
android:title="@string/share_privilege_unshare"
app:showAsAction="never" />

</menu>
1 change: 1 addition & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@
<string name="filedetails_share_link_enable">Share by link enabled</string>
<string name="filedetails_share_link_disable">Not shared by link</string>
<string name="filedetails_share_users_with_access">Users and groups with access</string>
<string name="share_privilege_unshare">Unshare</string>
<string name="share_privilege_can_share">can share</string>
<string name="share_privilege_can_edit">can edit</string>
<string name="share_privilege_can_edit_create">create</string>
Expand Down

0 comments on commit cec0eb8

Please sign in to comment.