tobiasKaminsky 9 年之前
父節點
當前提交
d41f295be2

+ 5 - 0
res/menu/file_actions_menu.xml

@@ -106,6 +106,11 @@
         app:showAsAction="never"
         android:showAsAction="never"
         android:orderInCategory="1" />
+    <item
+        android:id="@+id/action_set_as_wallpaper"
+        android:title="@string/set_picture_as"
+        android:icon="@android:drawable/ic_menu_set_as"
+        android:orderInCategory="1" />
     <item
         android:id="@+id/action_see_details"
         android:title="@string/actionbar_see_details"

+ 2 - 0
res/values/strings.xml

@@ -440,6 +440,8 @@
     <string name="file_list__footer__files">%1$d files</string>
     <string name="file_list__footer__files_and_folder">%1$d files, 1 folder</string>
     <string name="file_list__footer__files_and_folders">%1$d files, %2$d folders</string>
+    <string name="set_picture_as">Set picture as</string>
+
     <string name="prefs_instant_behaviour_dialogTitle">Original file will be&#8230;</string>
     <string name="prefs_instant_behaviour_title">Original file will be&#8230;</string>
     <string name="upload_copy_files">Copy file</string>

+ 18 - 0
src/com/owncloud/android/ui/helpers/FileOperationsHelper.java

@@ -519,6 +519,24 @@ public class FileOperationsHelper {
         }
     }
 
+    public void setPictureAs(OCFile file) {
+        if (file != null) {
+            String storagePath = file.getStoragePath();
+            String encodedStoragePath = WebdavUtils.encodePath(storagePath);
+            Intent sendIntent = new Intent(Intent.ACTION_ATTACH_DATA);
+            // set MimeType
+            sendIntent.setData(Uri.parse(encodedStoragePath));
+//            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + encodedStoragePath));
+//            sendIntent.putExtra("jpg", "image/*");
+
+            mFileActivity.startActivity(Intent.createChooser(sendIntent,
+                    mFileActivity.getString(R.string.set_picture_as)));
+
+        } else {
+            Log_OC.wtf(TAG, "Trying to send a NULL OCFile");
+        }
+    }
+
     /**
      * Request the synchronization of a file or folder with the OC server, including its contents.
      *

+ 4 - 0
src/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -320,6 +320,10 @@ public class PreviewImageFragment extends FileFragment {
                 mContainerActivity.getFileOperationsHelper().toggleFavorite(getFile(), false);
                 return true;
             }
+            case R.id.action_set_as_wallpaper:{
+                mContainerActivity.getFileOperationsHelper().setPictureAs(getFile());
+                return true;
+            }
             default:
                 return super.onOptionsItemSelected(item);
         }