浏览代码

implement set available offline via menu

AndyScherzinger 7 年之前
父节点
当前提交
941f621fcc

+ 11 - 5
src/main/java/com/owncloud/android/ui/fragment/FileDetailFragment.java

@@ -325,8 +325,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
     }
 
     private void prepareOptionsMenu(Menu menu) {
-        super.onPrepareOptionsMenu(menu);
-
         if (mContainerActivity.getStorageManager() != null) {
             FileMenuFilter mf = new FileMenuFilter(
                 getFile(),
@@ -401,6 +399,14 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                 mContainerActivity.getFileOperationsHelper().syncFile(getFile());
                 return true;
             }
+            case R.id.action_keep_files_offline: {
+                mContainerActivity.getFileOperationsHelper().toggleOfflineFile(getFile(), true);
+                return true;
+            }
+            case R.id.action_unset_keep_files_offline: {
+                mContainerActivity.getFileOperationsHelper().toggleOfflineFile(getFile(), false);
+                return true;
+            }
             default:
                 return super.onOptionsItemSelected(item);
         }
@@ -418,18 +424,18 @@ public class FileDetailFragment extends FileFragment implements OnClickListener
                     ((ImageView)getView().findViewById(R.id.fdFavorite)).
                             setImageDrawable(getResources()
                                     .getDrawable(R.drawable.ic_star_outline));
+                    mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), false);
                 } else {
                     ((ImageView)getView().findViewById(R.id.fdFavorite))
                             .setImageDrawable(getResources()
                                     .getDrawable(R.drawable.ic_star));
+                    mContainerActivity.getFileOperationsHelper().toggleFavoriteFile(getFile(), true);
                 }
-
-                mContainerActivity.getFileOperationsHelper()
-                        .toggleOfflineFile(getFile(), !getFile().isAvailableOffline());
                 break;
             }
             case R.id.overflow_menu: {
                 onOverflowIconClicked(v);
+                break;
             }
             default:
                 Log_OC.e(TAG, "Incorrect view clicked!");

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

@@ -728,7 +728,7 @@ public class FileOperationsHelper {
         }
     }
 
-    private void toggleFavoriteFile(OCFile file, boolean shouldBeFavorite) {
+    public void toggleFavoriteFile(OCFile file, boolean shouldBeFavorite) {
         if (file.getIsFavorite() != shouldBeFavorite) {
             EventBus.getDefault().post(new FavoriteEvent(file.getRemotePath(), shouldBeFavorite, file.getRemoteId()));
         }