Эх сурвалжийг харах

move menu to file name, hide tags (to be implemented later)

AndyScherzinger 7 жил өмнө
parent
commit
46f226ba3a

+ 27 - 22
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -29,7 +29,6 @@ import android.support.design.widget.TabLayout;
 import android.support.v4.view.ViewPager;
 import android.view.LayoutInflater;
 import android.view.Menu;
-import android.view.MenuInflater;
 import android.view.MenuItem;
 import android.view.View;
 import android.view.View.OnClickListener;
@@ -37,6 +36,7 @@ import android.view.ViewGroup;
 import android.widget.ImageView;
 import android.widget.ListAdapter;
 import android.widget.ListView;
+import android.widget.PopupMenu;
 import android.widget.ProgressBar;
 import android.widget.TextView;
 
@@ -153,20 +153,29 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         mView = inflater.inflate(mLayout, null);
         
         if (mLayout == R.layout.file_details_fragment) {
-            int accentColor = ThemeUtils.primaryAccentColor(getContext());
             ProgressBar progressBar = mView.findViewById(R.id.fdProgressBar);
             ThemeUtils.colorHorizontalProgressBar(progressBar, ThemeUtils.primaryAccentColor(getContext()));
             mProgressListener = new ProgressListener(progressBar);
             mView.findViewById(R.id.fdCancelBtn).setOnClickListener(this);
             mView.findViewById(R.id.fdFavorite).setOnClickListener(this);
-            ((TextView)mView.findViewById(R.id.fdShareTitle)).setTextColor(accentColor);
-            ((TextView)mView.findViewById(R.id.fdShareWithUsersTitle)).setTextColor(accentColor);
+            mView.findViewById(R.id.overflow_menu).setOnClickListener(this);
         }
 
         updateFileDetails(false, false);
         return mView;
     }
 
+    public void onOverflowIconClicked(View view) {
+        PopupMenu popup = new PopupMenu(getActivity(), view);
+        popup.inflate(R.menu.file_actions_menu);
+        prepareOptionsMenu(popup.getMenu());
+
+        popup.setOnMenuItemClickListener(item -> {
+            return optionsItemSelected(item);
+        });
+        popup.show();
+    }
+
     private void setupViewPager(View view) {
         TabLayout tabLayout = view.findViewById(R.id.tab_layout);
         tabLayout.removeAllTabs();
@@ -224,22 +233,19 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         return super.getView() == null ? mView : super.getView();
     }
 
-
-    /**
-     * {@inheritDoc}
-     */
     @Override
-    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-        super.onCreateOptionsMenu(menu, inflater);
-        inflater.inflate(R.menu.file_actions_menu, menu);
-    }
+    public void onPrepareOptionsMenu(Menu menu) {
+        super.onPrepareOptionsMenu(menu);
 
+        MenuItem item;
+        for (int i = 0; i < menu.size(); i++) {
+            item = menu.getItem(i);
+            item.setVisible(false);
+            item.setEnabled(false);
+        }
+    }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void onPrepareOptionsMenu(Menu menu) {
+    private void prepareOptionsMenu(Menu menu) {
         super.onPrepareOptionsMenu(menu);
 
         if (mContainerActivity.getStorageManager() != null) {
@@ -336,11 +342,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean onOptionsItemSelected(MenuItem item) {
+    public boolean optionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
             case R.id.action_send_share_file: {
                 if(getFile().isSharedWithMe() && !getFile().canReshare()){
@@ -403,6 +405,9 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                         .toggleOfflineFile(getFile(), !getFile().isAvailableOffline());
                 break;
             }
+            case R.id.overflow_menu: {
+                onOverflowIconClicked(v);
+            }
             default:
                 Log_OC.e(TAG, "Incorrect view clicked!");
                 break;

+ 116 - 163
src/main/res/layout/file_details_fragment.xml

@@ -19,6 +19,7 @@
 -->
 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     android:id="@+id/fdScrollView"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
@@ -45,121 +46,143 @@
         <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:layout_margin="@dimen/standard_margin"
-            android:orientation="vertical">
-
-            <TextView
-                android:id="@+id/fdFilename"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:text="@string/placeholder_filename"
-                android:textSize="16sp"
-                android:textColor="@color/black"/>
+            android:paddingTop="@dimen/standard_padding"
+            android:paddingLeft="@dimen/standard_padding"
+            android:paddingRight="@dimen/standard_padding"
+            android:paddingBottom="@dimen/standard_half_padding"
+            android:orientation="horizontal">
 
             <LinearLayout
-                android:id="@+id/fdFiledetails"
-                android:layout_width="wrap_content"
+                android:layout_width="0dp"
                 android:layout_height="wrap_content"
-                android:gravity="center"
-                android:orientation="horizontal">
-
-                <ImageView
-                    android:id="@+id/fdFavorite"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginEnd="@dimen/standard_eighth_margin"
-                    android:layout_marginLeft="@dimen/zero"
-                    android:layout_marginRight="@dimen/standard_eighth_margin"
-                    android:layout_marginStart="@dimen/zero"
-                    android:contentDescription="@null"
-                    android:src="@drawable/ic_star_outline" />
+                android:layout_weight="1"
+                android:orientation="vertical">
 
                 <TextView
-                    android:id="@+id/fdSize"
+                    android:id="@+id/fdFilename"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:text="@string/placeholder_fileSize"
+                    android:ellipsize="middle"
+                    android:text="@string/placeholder_filename"
+                    android:textColor="@color/black"
                     android:textSize="16sp" />
 
-                <TextView
-                    android:id="@+id/file_separator"
+                <LinearLayout
+                    android:id="@+id/fdFiledetails"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:gravity="end"
-                    android:paddingEnd="@dimen/standard_quarter_padding"
-                    android:paddingLeft="@dimen/zero"
-                    android:paddingRight="@dimen/standard_quarter_padding"
-                    android:paddingStart="@dimen/zero"
-                    android:text="@string/info_separator"
-                    android:textColor="@color/list_item_lastmod_and_filesize_text"
-                    android:textSize="@dimen/two_line_secondary_text_size" />
+                    android:gravity="center"
+                    android:orientation="horizontal">
 
-                <TextView
-                    android:id="@+id/fdModified"
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:gravity="end"
-                    android:text="@string/placeholder_media_time"
-                    android:textSize="16sp" />
+                    <ImageView
+                        android:id="@+id/fdFavorite"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginEnd="@dimen/standard_eighth_margin"
+                        android:layout_marginLeft="@dimen/zero"
+                        android:layout_marginRight="@dimen/standard_eighth_margin"
+                        android:layout_marginStart="@dimen/zero"
+                        android:contentDescription="@null"
+                        android:src="@drawable/ic_star_outline" />
+
+                    <TextView
+                        android:id="@+id/fdSize"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/placeholder_fileSize"
+                        android:textSize="16sp" />
 
-                <ImageView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:layout_marginEnd="@dimen/standard_eighth_margin"
-                    android:layout_marginLeft="@dimen/standard_margin"
-                    android:layout_marginRight="@dimen/standard_eighth_margin"
-                    android:layout_marginStart="@dimen/standard_margin"
-                    android:contentDescription="@null"
-                    android:src="@drawable/ic_tag" />
+                    <TextView
+                        android:id="@+id/file_separator"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:gravity="end"
+                        android:paddingEnd="@dimen/standard_quarter_padding"
+                        android:paddingLeft="@dimen/zero"
+                        android:paddingRight="@dimen/standard_quarter_padding"
+                        android:paddingStart="@dimen/zero"
+                        android:text="@string/info_separator"
+                        android:textColor="@color/list_item_lastmod_and_filesize_text"
+                        android:textSize="@dimen/two_line_secondary_text_size" />
+
+                    <TextView
+                        android:id="@+id/fdModified"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:gravity="end"
+                        android:text="@string/placeholder_media_time"
+                        android:textSize="16sp" />
 
-                <TextView
-                    android:layout_width="wrap_content"
-                    android:layout_height="wrap_content"
-                    android:text="@string/tags" />
+                    <ImageView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_marginEnd="@dimen/standard_eighth_margin"
+                        android:layout_marginLeft="@dimen/standard_margin"
+                        android:layout_marginRight="@dimen/standard_eighth_margin"
+                        android:layout_marginStart="@dimen/standard_margin"
+                        android:contentDescription="@null"
+                        android:src="@drawable/ic_tag"
+                        android:visibility="gone" />
+
+                    <TextView
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:text="@string/tags"
+                        android:visibility="gone" />
+
+                </LinearLayout>
 
             </LinearLayout>
 
+            <ImageView
+                android:id="@+id/overflow_menu"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:background="@color/white"
+                android:src="@drawable/ic_dots_vertical"
+                android:contentDescription="@string/overflow_menu"/>
+        </LinearLayout>
+
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:paddingLeft="@dimen/standard_padding"
+            android:paddingRight="@dimen/standard_padding"
+            android:paddingBottom="@dimen/standard_half_padding"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/fdProgressText"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:text="@string/downloader_download_in_progress_ticker" />
+
             <LinearLayout
+                android:id="@+id/fdProgressBlock"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:orientation="vertical">
+                android:layout_marginBottom="@dimen/standard_quarter_margin"
+                android:gravity="center"
+                android:orientation="horizontal">
 
-                <TextView
-                    android:id="@+id/fdProgressText"
-                    android:layout_width="match_parent"
+                <ProgressBar
+                    android:id="@+id/fdProgressBar"
+                    style="?android:attr/progressBarStyleHorizontal"
+                    android:layout_width="0dp"
                     android:layout_height="wrap_content"
-                    android:layout_marginTop="@dimen/standard_half_margin"
-                    android:text="@string/downloader_download_in_progress_ticker" />
+                    android:layout_weight="1"
+                    android:indeterminate="false"
+                    android:indeterminateOnly="false" />
 
-                <LinearLayout
-                    android:id="@+id/fdProgressBlock"
-                    android:layout_width="match_parent"
+                <ImageButton
+                    android:id="@+id/fdCancelBtn"
+                    android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
-                    android:layout_marginBottom="@dimen/standard_quarter_margin"
-                    android:layout_marginTop="@dimen/standard_half_margin"
-                    android:gravity="center"
-                    android:orientation="horizontal">
-
-                    <ProgressBar
-                        android:id="@+id/fdProgressBar"
-                        style="?android:attr/progressBarStyleHorizontal"
-                        android:layout_width="0dp"
-                        android:layout_height="wrap_content"
-                        android:layout_weight="1"
-                        android:indeterminate="false"
-                        android:indeterminateOnly="false" />
-
-                    <ImageButton
-                        android:id="@+id/fdCancelBtn"
-                        android:layout_width="wrap_content"
-                        android:layout_height="wrap_content"
-                        android:layout_marginLeft="@dimen/standard_half_margin"
-                        android:layout_marginStart="@dimen/standard_half_margin"
-                        android:background="@android:color/transparent"
-                        android:contentDescription="@string/common_cancel"
-                        android:src="@drawable/ic_cancel" />
-
-                </LinearLayout>
+                    android:layout_marginLeft="@dimen/standard_half_margin"
+                    android:layout_marginStart="@dimen/standard_half_margin"
+                    android:background="@android:color/transparent"
+                    android:contentDescription="@string/common_cancel"
+                    android:src="@drawable/ic_cancel" />
 
             </LinearLayout>
 
@@ -174,6 +197,8 @@
             android:id="@+id/tab_layout"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
+            app:tabGravity="center"
+            app:tabMode="scrollable"
             android:background="@color/white" />
 
         <android.support.v4.view.ViewPager
@@ -181,78 +206,6 @@
             android:layout_width="match_parent"
             android:layout_height="fill_parent"/>
 
-        <LinearLayout
-            android:id="@+id/fdShareContainer"
-            android:layout_width="match_parent"
-            android:layout_height="match_parent"
-            android:layout_marginBottom="@dimen/standard_half_margin"
-            android:layout_marginLeft="@dimen/standard_margin"
-            android:layout_marginRight="@dimen/standard_margin"
-            android:layout_marginTop="@dimen/standard_half_margin"
-            android:orientation="vertical"
-            android:visibility="gone">
-
-            <TextView
-                android:id="@+id/fdShareTitle"
-                style="@style/TextAppearance.AppCompat.Body2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_marginBottom="@dimen/standard_half_margin"
-                android:text="@string/action_send_share"
-                android:textColor="@color/color_accent" />
-
-            <LinearLayout
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:orientation="horizontal"
-                tools:ignore="UseCompoundDrawables">
-
-                <ImageView
-                    android:id="@+id/fdShareLinkIcon"
-                    android:layout_width="@dimen/shared_list_icon_width"
-                    android:layout_height="@dimen/shared_list_icon_height"
-                    android:layout_gravity="center_vertical"
-                    android:layout_marginEnd="@dimen/standard_half_margin"
-                    android:layout_marginRight="@dimen/standard_half_margin"
-                    android:contentDescription="@string/shared_icon"
-                    android:src="@drawable/shared_via_link"
-                    android:visibility="gone" />
-
-                <TextView
-                    android:id="@+id/fdSharebyLink"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:layout_gravity="start"
-                    android:text="@string/filedetails_share_link_disable" />
-            </LinearLayout>
-
-            <TextView
-                android:id="@+id/fdShareWithUsersTitle"
-                style="@style/TextAppearance.AppCompat.Body2"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_gravity="start"
-                android:layout_marginBottom="@dimen/standard_half_margin"
-                android:layout_marginTop="@dimen/standard_half_margin"
-                android:text="@string/filedetails_share_users_with_access"
-                android:textColor="@color/color_accent" />
-
-            <ListView
-                android:id="@+id/fdshareUsersList"
-                android:layout_width="match_parent"
-                android:layout_height="0dip"
-                android:layout_weight="1"
-                android:visibility="gone" />
-
-            <TextView
-                android:id="@+id/fdShareNoUsers"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:text="@string/share_no_users"
-                android:textSize="@dimen/share_no_users_text_size" />
-
-        </LinearLayout>
-
     </LinearLayout>
 
 </ScrollView>