Browse Source

use own, distinct menu definition, fix strings, use relative date

AndyScherzinger 7 years ago
parent
commit
11edb451b0

+ 13 - 71
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -238,57 +238,10 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             emptyProgressBar.setVisibility(View.GONE);
         }
     }
-    // TODO use whenever we switch to use glide for preview images
-    /*
-    private void setHeaderImage() {
-        if (mContainerActivity.getStorageManager().getCapability(account.name)
-                .getServerBackground() != null && previewImage != null) {
-
-            String background = mContainerActivity.getStorageManager().getCapability(account.name).getServerBackground();
-
-            int primaryColor = ThemeUtils.primaryColor(account, getContext());
-
-            if (URLUtil.isValidUrl(background)) {
-                // background image
-                SimpleTarget target = new SimpleTarget<Drawable>() {
-                    @Override
-                    public void onResourceReady(Drawable resource, GlideAnimation glideAnimation) {
-                        Drawable[] drawables = {new ColorDrawable(primaryColor), resource};
-                        LayerDrawable layerDrawable = new LayerDrawable(drawables);
-                        previewImage.setImageDrawable(layerDrawable);
-                        previewImage.setVisibility(View.VISIBLE);
-                        ((ToolbarActivity) getActivity()).getSupportActionBar().setTitle(null);
-                        ((ToolbarActivity) getActivity()).getSupportActionBar().setBackgroundDrawable(null);
-                        toolbarProgressBar.setVisibility(View.GONE);
-                        previewLoaded = true;
-                    }
-
-                    @Override
-                    public void onLoadFailed(Exception e, Drawable errorDrawable) {
-                        previewImage.setVisibility(View.GONE);
-                        toolbarProgressBar.setVisibility(View.VISIBLE);
-                    }
-                };
-
-                Glide.with(this)
-                        .load(background)
-                        .centerCrop()
-                        .placeholder(R.drawable.background)
-                        .error(R.drawable.background)
-                        .crossFade()
-                        .into(target);
-            } else {
-                // hide image
-                previewImage.setVisibility(View.GONE);
-                toolbarProgressBar.setVisibility(View.VISIBLE);
-            }
-        }
-    }
-    */
 
     public void onOverflowIconClicked(View view) {
         PopupMenu popup = new PopupMenu(getActivity(), view);
-        popup.inflate(R.menu.file_actions_menu);
+        popup.inflate(R.menu.file_details_actions_menu);
         prepareOptionsMenu(popup.getMenu());
 
         popup.setOnMenuItemClickListener(this::optionsItemSelected);
@@ -392,41 +345,22 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
             mf.filter(menu, true);
         }
 
-        // restriction for this fragment
-        FileMenuFilter.hideMenuItems(
-                menu.findItem(R.id.action_see_details),
-                menu.findItem(R.id.action_select_all),
-                menu.findItem(R.id.action_move),
-                menu.findItem(R.id.action_copy),
-                menu.findItem(R.id.action_favorite),
-                menu.findItem(R.id.action_unset_favorite),
-                menu.findItem(R.id.action_search)
-        );
-
         // dual pane restrictions
         if (!getResources().getBoolean(R.bool.large_land_layout)){
             FileMenuFilter.hideMenuItems(
-                    menu.findItem(R.id.action_switch_view),
-                    menu.findItem(R.id.action_sync_account),
-                    menu.findItem(R.id.action_sort)
+                    menu.findItem(R.id.action_sync_account)
             );
         }
-
-        // share restrictions
-        if (getFile().isSharedWithMe() && !getFile().canReshare()) {
-            FileMenuFilter.hideMenuItems(menu.findItem(R.id.action_send_share_file));
-        }
     }
 
     public boolean optionsItemSelected(MenuItem item) {
         switch (item.getItemId()) {
-            case R.id.action_send_share_file: {
+            case R.id.action_send_file: {
                 if(getFile().isSharedWithMe() && !getFile().canReshare()){
                     Snackbar.make(getView(),
                             R.string.resharing_is_not_allowed,
                             Snackbar.LENGTH_LONG
-                    )
-                            .show();
+                    ).show();
                 } else {
                     mContainerActivity.getFileOperationsHelper().sendShareFile(getFile());
                 }
@@ -463,6 +397,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 mContainerActivity.getFileOperationsHelper().toggleOfflineFile(getFile(), false);
                 return true;
             }
+            case R.id.action_encrypted: {
+                // TODO implement or remove
+                return true;
+            }
+            case R.id.action_unset_encrypted: {
+                // TODO implement or remove
+                return true;
+            }
             default:
                 return super.onOptionsItemSelected(item);
         }
@@ -544,7 +486,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 fileName.setVisibility(View.GONE);
             }
             fileSize.setText(DisplayUtils.bytesToHumanReadable(file.getFileLength()));
-            fileModifiedTimestamp.setText(DisplayUtils.unixTimeToHumanReadable(file.getModificationTimestamp()));
+            fileModifiedTimestamp.setText(DisplayUtils.getRelativeTimestamp(getContext(), file.getModificationTimestamp()));
             setFilePreview(file);
             setFavoriteIconStatus(file.getIsFavorite());
 

+ 1 - 1
src/main/res/layout/file_details_sharing_fragment.xml

@@ -38,7 +38,7 @@
             android:layout_marginBottom="@dimen/standard_half_margin"
             android:paddingLeft="@dimen/standard_padding"
             android:paddingRight="@dimen/standard_padding"
-            android:text="@string/action_send_share"
+            android:text="@string/common_share"
             android:textColor="@color/color_accent" />
 
         <LinearLayout

+ 99 - 0
src/main/res/menu/file_details_actions_menu.xml

@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ownCloud Android client application
+
+  Copyright (C) 2012  Bartek Przybylski
+  Copyright (C) 2015 ownCloud Inc.
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License version 2,
+  as published by the Free Software Foundation.
+
+  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 General Public License for more details.
+
+  You should have received a copy of the GNU 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_send_file"
+        android:title="@string/common_send"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:icon="@drawable/ic_share"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_open_file_with"
+        android:title="@string/actionbar_open_with"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_download_file"
+        android:title="@string/filedetails_download"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_sync_file"
+        android:title="@string/filedetails_sync_file"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_cancel_sync"
+        android:title="@string/common_cancel_sync"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_rename_file"
+        android:title="@string/common_rename"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_keep_files_offline"
+        android:title="@string/favorite"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_unset_keep_files_offline"
+        android:title="@string/unfavorite"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_encrypted"
+        android:title="@string/encrypted"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1"/>
+    <item
+        android:id="@+id/action_unset_encrypted"
+        android:title="@string/unset_encrypted"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1"/>
+    <item
+        android:id="@+id/action_set_as_wallpaper"
+        android:title="@string/set_picture_as"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_remove_file"
+        android:title="@string/common_remove"
+        app:showAsAction="never"
+        android:showAsAction="never"
+        android:orderInCategory="1" />
+
+</menu>

+ 2 - 0
src/main/res/values/strings.xml

@@ -132,6 +132,8 @@
     <string name="common_error_unknown">Unknown error</string>
     <string name="common_pending">Pending</string>
     <string name="common_delete">Delete</string>
+    <string name="common_share">Share</string>
+    <string name="common_send">Send</string>
     <string name="about_title">About</string>
     <string name="delete_account">Remove account</string>
     <string name="delete_account_warning">Remove account %s and delete all local files?\n\nDeletion cannot be undone.</string>