瀏覽代碼

Merge pull request #5393 from nextcloud/removeUnsetType

Remove UnsetType as we do not have bottom bar anymore…
Andy Scherzinger 5 年之前
父節點
當前提交
c7669fe9db
共有 18 個文件被更改,包括 227 次插入48 次删除
  1. 二進制
      screenshots/com.nextcloud.client.ActivitiesActivityIT_openDrawer.png
  2. 二進制
      screenshots/com.nextcloud.client.FileDisplayActivityIT_drawer.png
  3. 二進制
      screenshots/com.nextcloud.client.FileDisplayActivityIT_open.png
  4. 二進制
      screenshots/com.nextcloud.client.FileDisplayActivityIT_showAccounts.png
  5. 二進制
      screenshots/com.nextcloud.client.NotificationsActivityIT_openDrawer.png
  6. 二進制
      screenshots/com.nextcloud.client.SyncedFoldersActivityIT_openDrawer.png
  7. 二進制
      screenshots/com.nextcloud.client.UploadListActivityActivityIT_openDrawer.png
  8. 二進制
      screenshots/com.owncloud.android.ui.preview.PreviewTextFileFragmentTest_displayJavaSnippetFile.png
  9. 50 0
      src/androidTest/java/com/nextcloud/client/ActivitiesActivityIT.java
  10. 50 0
      src/androidTest/java/com/nextcloud/client/NotificationsActivityIT.java
  11. 50 0
      src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java
  12. 50 0
      src/androidTest/java/com/nextcloud/client/UploadListActivityActivityIT.java
  13. 18 0
      src/androidTest/java/com/owncloud/android/AbstractIT.java
  14. 4 12
      src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java
  15. 0 7
      src/main/java/com/owncloud/android/ui/events/SearchEvent.java
  16. 1 2
      src/main/java/com/owncloud/android/ui/fragment/ExtendedListFragment.java
  17. 3 24
      src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java
  18. 1 3
      src/main/java/com/owncloud/android/ui/fragment/PhotoFragment.java

二進制
screenshots/com.nextcloud.client.ActivitiesActivityIT_openDrawer.png


二進制
screenshots/com.nextcloud.client.FileDisplayActivityIT_drawer.png


二進制
screenshots/com.nextcloud.client.FileDisplayActivityIT_open.png


二進制
screenshots/com.nextcloud.client.FileDisplayActivityIT_showAccounts.png


二進制
screenshots/com.nextcloud.client.NotificationsActivityIT_openDrawer.png


二進制
screenshots/com.nextcloud.client.SyncedFoldersActivityIT_openDrawer.png


二進制
screenshots/com.nextcloud.client.UploadListActivityActivityIT_openDrawer.png


二進制
screenshots/com.owncloud.android.ui.preview.PreviewTextFileFragmentTest_displayJavaSnippetFile.png


+ 50 - 0
src/androidTest/java/com/nextcloud/client/ActivitiesActivityIT.java

@@ -0,0 +1,50 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2020 Tobias Kaminsky
+ * Copyright (C) 2020 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.client;
+
+import android.Manifest;
+
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.ui.activities.ActivitiesActivity;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import androidx.test.espresso.intent.rule.IntentsTestRule;
+import androidx.test.rule.GrantPermissionRule;
+
+
+public class ActivitiesActivityIT extends AbstractIT {
+    @Rule public IntentsTestRule<ActivitiesActivity> activityRule = new IntentsTestRule<>(ActivitiesActivity.class,
+                                                                                          true,
+                                                                                          false);
+
+    @Rule
+    public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
+        Manifest.permission.WRITE_EXTERNAL_STORAGE);
+
+    @Test
+    public void openDrawer() throws InterruptedException {
+        super.openDrawer(activityRule);
+    }
+}

+ 50 - 0
src/androidTest/java/com/nextcloud/client/NotificationsActivityIT.java

@@ -0,0 +1,50 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2020 Tobias Kaminsky
+ * Copyright (C) 2020 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.client;
+
+import android.Manifest;
+
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.ui.activity.NotificationsActivity;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import androidx.test.espresso.intent.rule.IntentsTestRule;
+import androidx.test.rule.GrantPermissionRule;
+
+
+public class NotificationsActivityIT extends AbstractIT {
+    @Rule public IntentsTestRule<NotificationsActivity> activityRule = new IntentsTestRule<>(NotificationsActivity.class,
+                                                                                             true,
+                                                                                             false);
+
+    @Rule
+    public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
+        Manifest.permission.WRITE_EXTERNAL_STORAGE);
+
+    @Test
+    public void openDrawer() throws InterruptedException {
+        super.openDrawer(activityRule);
+    }
+}

+ 50 - 0
src/androidTest/java/com/nextcloud/client/SyncedFoldersActivityIT.java

@@ -0,0 +1,50 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2020 Tobias Kaminsky
+ * Copyright (C) 2020 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.client;
+
+import android.Manifest;
+
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.ui.activity.SyncedFoldersActivity;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import androidx.test.espresso.intent.rule.IntentsTestRule;
+import androidx.test.rule.GrantPermissionRule;
+
+
+public class SyncedFoldersActivityIT extends AbstractIT {
+    @Rule public IntentsTestRule<SyncedFoldersActivity> activityRule = new IntentsTestRule<>(SyncedFoldersActivity.class,
+                                                                                             true,
+                                                                                             false);
+
+    @Rule
+    public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
+        Manifest.permission.WRITE_EXTERNAL_STORAGE);
+
+    @Test
+    public void openDrawer() throws InterruptedException {
+        super.openDrawer(activityRule);
+    }
+}

+ 50 - 0
src/androidTest/java/com/nextcloud/client/UploadListActivityActivityIT.java

@@ -0,0 +1,50 @@
+/*
+ *
+ * Nextcloud Android client application
+ *
+ * @author Tobias Kaminsky
+ * Copyright (C) 2020 Tobias Kaminsky
+ * Copyright (C) 2020 Nextcloud GmbH
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+package com.nextcloud.client;
+
+import android.Manifest;
+
+import com.owncloud.android.AbstractIT;
+import com.owncloud.android.ui.activity.UploadListActivity;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import androidx.test.espresso.intent.rule.IntentsTestRule;
+import androidx.test.rule.GrantPermissionRule;
+
+
+public class UploadListActivityActivityIT extends AbstractIT {
+    @Rule public IntentsTestRule<UploadListActivity> activityRule = new IntentsTestRule<>(UploadListActivity.class,
+                                                                                          true,
+                                                                                          false);
+
+    @Rule
+    public final GrantPermissionRule permissionRule = GrantPermissionRule.grant(
+        Manifest.permission.WRITE_EXTERNAL_STORAGE);
+
+    @Test
+    public void openDrawer() throws InterruptedException {
+        super.openDrawer(activityRule);
+    }
+}

+ 18 - 0
src/androidTest/java/com/owncloud/android/AbstractIT.java

@@ -4,11 +4,13 @@ import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.accounts.AuthenticatorException;
 import android.accounts.OperationCanceledException;
+import android.app.Activity;
 import android.content.ActivityNotFoundException;
 import android.content.Context;
 import android.net.Uri;
 import android.os.Bundle;
 
+import com.facebook.testing.screenshot.Screenshot;
 import com.nextcloud.client.account.UserAccountManager;
 import com.nextcloud.client.account.UserAccountManagerImpl;
 import com.owncloud.android.datamodel.FileDataStorageManager;
@@ -29,10 +31,14 @@ import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 
+import androidx.test.espresso.contrib.DrawerActions;
+import androidx.test.espresso.intent.rule.IntentsTestRule;
 import androidx.test.ext.junit.runners.AndroidJUnit4;
 import androidx.test.platform.app.InstrumentationRegistry;
 
 import static androidx.test.InstrumentationRegistry.getInstrumentation;
+import static androidx.test.espresso.Espresso.onView;
+import static androidx.test.espresso.matcher.ViewMatchers.withId;
 
 
 /**
@@ -149,4 +155,16 @@ public abstract class AbstractIT {
     protected void waitForIdleSync() {
         InstrumentationRegistry.getInstrumentation().waitForIdleSync();
     }
+
+    protected void openDrawer(IntentsTestRule activityRule) throws InterruptedException {
+        Activity sut = activityRule.launchActivity(null);
+
+        Thread.sleep(3000);
+
+        onView(withId(R.id.drawer_layout)).perform(DrawerActions.open());
+
+        waitForIdleSync();
+
+        Screenshot.snapActivity(sut).record();
+    }
 }

+ 4 - 12
src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java

@@ -430,9 +430,7 @@ public abstract class DrawerActivity extends ToolbarActivity
 
                 break;
             case R.id.nav_favorites:
-                handleSearchEvents(new SearchEvent("",
-                                                   SearchRemoteOperation.SearchType.FAVORITE_SEARCH,
-                                                   SearchEvent.UnsetType.NO_UNSET),
+                handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.FAVORITE_SEARCH),
                                    menuItem.getItemId());
                 break;
             case R.id.nav_photos:
@@ -472,15 +470,11 @@ public abstract class DrawerActivity extends ToolbarActivity
                 UserInfoActivity.openAccountRemovalConfirmationDialog(getAccount(), getSupportFragmentManager());
                 break;
             case R.id.nav_shared:
-                handleSearchEvents(new SearchEvent("",
-                                                   SearchRemoteOperation.SearchType.SHARED_SEARCH,
-                                                   SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR),
+                handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_SEARCH),
                                    menuItem.getItemId());
                 break;
             case R.id.nav_recently_modified:
-                handleSearchEvents(new SearchEvent("",
-                                                   SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH,
-                                                   SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR),
+                handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
                                    menuItem.getItemId());
                 break;
             default:
@@ -532,9 +526,7 @@ public abstract class DrawerActivity extends ToolbarActivity
     }
 
     private void startPhotoSearch(MenuItem menuItem) {
-        SearchEvent searchEvent = new SearchEvent("image/%",
-                                                  SearchRemoteOperation.SearchType.PHOTO_SEARCH,
-                                                  SearchEvent.UnsetType.NO_UNSET);
+        SearchEvent searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
 
         Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class);
         intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

+ 0 - 7
src/main/java/com/owncloud/android/ui/events/SearchEvent.java

@@ -39,11 +39,4 @@ import lombok.Setter;
 public class SearchEvent {
     public String searchQuery;
     public SearchRemoteOperation.SearchType searchType;
-    public UnsetType unsetType;
-
-    public enum UnsetType {
-        NO_UNSET,
-        UNSET_DRAWER,
-        UNSET_BOTTOM_NAV_BAR
-    }
 }

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

@@ -320,8 +320,7 @@ public class ExtendedListFragment extends Fragment implements
                     handler.post(() -> {
                         if (adapter instanceof OCFileListAdapter) {
                             EventBus.getDefault().post(new SearchEvent(query,
-                                                                       SearchRemoteOperation.SearchType.FILE_SEARCH,
-                                                                       SearchEvent.UnsetType.NO_UNSET));
+                                                                       SearchRemoteOperation.SearchType.FILE_SEARCH));
                         } else if (adapter instanceof LocalFileListAdapter) {
                             LocalFileListAdapter localFileListAdapter = (LocalFileListAdapter) adapter;
                             localFileListAdapter.filter(query);

+ 3 - 24
src/main/java/com/owncloud/android/ui/fragment/OCFileListFragment.java

@@ -86,7 +86,6 @@ import com.owncloud.android.ui.dialog.SetupEncryptionDialogFragment;
 import com.owncloud.android.ui.dialog.SyncFileNotEnoughSpaceDialogFragment;
 import com.owncloud.android.ui.events.ChangeMenuEvent;
 import com.owncloud.android.ui.events.CommentsEvent;
-import com.owncloud.android.ui.events.DummyDrawerEvent;
 import com.owncloud.android.ui.events.EncryptionEvent;
 import com.owncloud.android.ui.events.FavoriteEvent;
 import com.owncloud.android.ui.events.SearchEvent;
@@ -1384,20 +1383,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
         }
     }
 
-    private void unsetAllMenuItems(final boolean unsetDrawer) {
-        new Handler(Looper.getMainLooper()).post(() -> {
-            if (unsetDrawer) {
-                EventBus.getDefault().post(new DummyDrawerEvent());
-            }
-        });
-
-    }
-
-    public void setTitleFromSearchEvent(SearchEvent event) {
-        prepareCurrentSearch(event);
-        setTitle();
-    }
-
     private void setTitle() {
         // set title
 
@@ -1524,12 +1509,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
 
         setFabVisible(false);
 
-        if (event.getUnsetType() == SearchEvent.UnsetType.UNSET_BOTTOM_NAV_BAR) {
-            unsetAllMenuItems(false);
-        } else if (event.getUnsetType() == SearchEvent.UnsetType.UNSET_DRAWER) {
-            unsetAllMenuItems(true);
-        }
-
         Runnable switchViewsRunnable = () -> {
             if (isGridViewPreferred(mFile) && !isGridEnabled()) {
                 switchToGridView();
@@ -1718,10 +1697,10 @@ public class OCFileListFragment extends ExtendedListFragment implements
     }
 
     private boolean isSearchEventSet(SearchEvent event) {
-        return event != null && event.getSearchType() != null &&
+        return event != null &&
+            event.getSearchType() != null &&
             (!TextUtils.isEmpty(event.getSearchQuery()) ||
-                event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH)
-            && event.getUnsetType() != null;
+                event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH);
     }
 
     private void syncAndCheckFiles(Collection<OCFile> files) {

+ 1 - 3
src/main/java/com/owncloud/android/ui/fragment/PhotoFragment.java

@@ -65,9 +65,7 @@ public class PhotoFragment extends OCFileListFragment {
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
-        searchEvent = new SearchEvent("image/%",
-                                      SearchRemoteOperation.SearchType.PHOTO_SEARCH,
-                                      SearchEvent.UnsetType.NO_UNSET);
+        searchEvent = new SearchEvent("image/%", SearchRemoteOperation.SearchType.PHOTO_SEARCH);
 
         searchRemoteOperation = new SearchRemoteOperation(searchEvent.getSearchQuery(),
                                                           searchEvent.getSearchType(),