Răsfoiți Sursa

empty menu implementation per sharee

AndyScherzinger 7 ani în urmă
părinte
comite
cd200b2e9f

+ 39 - 0
src/main/java/com/owncloud/android/ui/adapter/UserListAdapter.java

@@ -23,10 +23,13 @@ package com.owncloud.android.ui.adapter;
 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 class UserListAdapter extends ArrayAdapter {
             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 class UserListAdapter extends ArrayAdapter {
             }
             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 - 0
src/main/res/layout/file_details_share_user_item.xml

@@ -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"
@@ -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 - 0
src/main/res/menu/file_detail_sharing_menu.xml

@@ -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 - 0
src/main/res/values/strings.xml

@@ -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>