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

- replace Toast with Snackbar
- remove not used code

tobiaskaminsky 7 жил өмнө
parent
commit
297c6024bc

+ 2 - 11
src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -1449,9 +1449,6 @@ public class FileDisplayActivity extends HookActivity
                             case OCFileListFragment.DOWNLOAD_SEND:
                                 sendDownloadedFile();
                                 break;
-                            case OCFileListFragment.DOWNLOAD_SET_AS:
-                                setPictureAs();
-                                break;
                             default:
                                 // do nothing
                                 break;
@@ -1609,7 +1606,7 @@ public class FileDisplayActivity extends HookActivity
                 mUploaderBinder = null;
             }
         }
-    };    
+    }
 
     private MediaServiceConnection newMediaConnection(){
         return new MediaServiceConnection();
@@ -1639,7 +1636,7 @@ public class FileDisplayActivity extends HookActivity
                 mMediaServiceBinder = null;
             }
         }
-    };
+    }
 
     /**
      * Updates the view associated to the activity after the finish of some operation over files
@@ -1986,12 +1983,6 @@ public class FileDisplayActivity extends HookActivity
         mWaitingToSend = null;
     }
 
-    private void setPictureAs() {
-        getFileOperationsHelper().setPictureAs(mWaitingToSend);
-        mWaitingToSend = null;
-    }
-
-
     /**
      * Requests the download of the received {@link OCFile} , updates the UI
      * to monitor the download progress and prepares the activity to send the file

+ 1 - 2
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -129,7 +129,6 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
 
     public static final String DOWNLOAD_BEHAVIOUR = "DOWNLOAD_BEHAVIOUR";
     public static final String DOWNLOAD_SEND = "DOWNLOAD_SEND";
-    public static final String DOWNLOAD_SET_AS = "DOWNLOAD_SET_AS";
 
     public static final String SEARCH_EVENT = "SEARCH_EVENT";
 
@@ -985,7 +984,7 @@ public class OCFileListFragment extends ExtendedListFragment implements OCFileLi
                     }
                 }
                 case R.id.action_set_as_wallpaper: {
-                    mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile);
+                    mContainerActivity.getFileOperationsHelper().setPictureAs(singleFile, getView());
                     return true;
                 }
             }

+ 4 - 3
src/main/java/com/owncloud/android/ui/helpers/FileOperationsHelper.java

@@ -30,9 +30,10 @@ import android.content.pm.ResolveInfo;
 import android.net.Uri;
 import android.os.Build;
 import android.support.annotation.Nullable;
+import android.support.design.widget.Snackbar;
 import android.support.v4.content.FileProvider;
+import android.view.View;
 import android.webkit.MimeTypeMap;
-import android.widget.Toast;
 
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
@@ -581,7 +582,7 @@ public class FileOperationsHelper {
         }
     }
 
-    public void setPictureAs(OCFile file) {
+    public void setPictureAs(OCFile file, View view) {
         if (file != null) {
             Context context = MainApp.getAppContext();
             Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
@@ -610,7 +611,7 @@ public class FileOperationsHelper {
 
                 intent.setDataAndType(uri, file.getMimetype());
             } catch (ActivityNotFoundException exception) {
-                Toast.makeText(context, R.string.picture_set_as_no_app, Toast.LENGTH_LONG).show();
+                Snackbar.make(view, R.string.picture_set_as_no_app, Snackbar.LENGTH_LONG).show();
             }
         } else {
             Log_OC.wtf(TAG, "Trying to send a NULL OCFile");

+ 1 - 1
src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.java

@@ -452,7 +452,7 @@ public class PreviewImageFragment extends FileFragment {
                 return true;
 
             case R.id.action_set_as_wallpaper:
-                mContainerActivity.getFileOperationsHelper().setPictureAs(getFile());
+                mContainerActivity.getFileOperationsHelper().setPictureAs(getFile(), getImageView());
                 return true;
 
             default: