Compare commits

...
Author SHA1 Message Date
Álvaro Brey Vilas e9e670e75a Fix detekt on OCFileListFragmentIT
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 10:10:22 +01:00
Álvaro Brey Vilas 5b2cdc42b5 Update recently modified screenshots
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 10:07:45 +01:00
tobiasKaminsky e23d45e56c Add tests
Signed-off-by: tobiasKaminsky <[email protected]>
2022-01-24 09:21:54 +01:00
Álvaro Brey Vilas 93e86dd088 Fix default visibility of recently modified
Should be visible unless setup.xml disables is (which it does by default)

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 09:12:05 +01:00
Álvaro Brey Vilas fb87f46161 Remove recently added search
Was never fully implemented. Discarding in favor of recently modified.

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 09:12:05 +01:00
Álvaro Brey Vilas 8328dd381b OCFileListFragment: restore search event on view restored
Partially reverts https://github.com/nextcloud/android/pull/9427, which deleted too much stuff

Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 09:12:05 +01:00
Álvaro Brey Vilas 73cb94f538 OCFileListFragment: add recently modified to the list of valid search events
Signed-off-by: Álvaro Brey Vilas <[email protected]>
2022-01-24 09:11:59 +01:00
10 changed files with 67 additions and 29 deletions

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

@@ -32,7 +32,11 @@ import com.nextcloud.client.network.Connectivity
import com.nextcloud.client.network.ConnectivityService
import com.owncloud.android.AbstractOnServerIT
import com.owncloud.android.datamodel.OCFile
import com.owncloud.android.lib.resources.files.UploadFileRemoteOperation
import com.owncloud.android.ui.activity.DrawerActivity
import com.owncloud.android.ui.activity.FileDisplayActivity
import com.owncloud.android.utils.ScreenshotTest
import org.junit.Assert
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Rule
@@ -184,4 +188,42 @@ class OCFileListFragmentIT : AbstractOnServerIT() {
ocFile.fileLength = 100
assertTrue(sut.checkIfEnoughSpace(200L, ocFile))
}
@Test
@ScreenshotTest
@SuppressWarnings("MagicNumber", "FunctionNaming")
fun testRecentlyModified_NoResults() {
val activity = activityRule.launchActivity(null)
val ocFileListFragment = activity.listOfFilesFragment
Assert.assertNotNull(ocFileListFragment)
shortSleep()
val searchEvent = DrawerActivity.createRecentlyModifiedSearchEvent()
ocFileListFragment?.handleSearchEvent(searchEvent)
shortSleep()
screenshot(activity)
}
@Test
@ScreenshotTest
@SuppressWarnings("MagicNumber", "FunctionNaming")
fun testRecentlyModified_Results() {
val imageFile = getFile("imageFile.png")
assertTrue(
UploadFileRemoteOperation(
imageFile.absolutePath,
"/imageFile.png",
"image/png",
(System.currentTimeMillis() / 1000).toString()
)
.execute(client).isSuccess
)
testRecentlyModified_NoResults()
}
}
@@ -130,6 +130,7 @@ import java.util.List;
import javax.inject.Inject;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
@@ -476,7 +477,7 @@ public abstract class DrawerActivity extends ToolbarActivity
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.SHARED_FILTER),
menuItem.getItemId());
} else if (itemId == R.id.nav_recently_modified) {
handleSearchEvents(new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH),
handleSearchEvents(createRecentlyModifiedSearchEvent(),
menuItem.getItemId());
} else {
if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK &&
@@ -489,6 +490,11 @@ public abstract class DrawerActivity extends ToolbarActivity
}
}
@VisibleForTesting
public static SearchEvent createRecentlyModifiedSearchEvent() {
return new SearchEvent("", SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH);
}
private void startActivity(Class<? extends Activity> activity) {
startActivity(new Intent(getApplicationContext(), activity));
}
@@ -153,7 +153,6 @@ public class ExtendedListFragment extends Fragment implements
FAVORITE_SEARCH,
GALLERY_SEARCH,
RECENTLY_MODIFIED_SEARCH,
RECENTLY_ADDED_SEARCH,
// not a real filter, but nevertheless
SHARED_FILTER
}
@@ -673,10 +672,6 @@ public class ExtendedListFragment extends Fragment implements
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty_recently_modified,
R.drawable.ic_list_empty_recent);
} else if (searchType == SearchType.RECENTLY_ADDED_SEARCH) {
setMessageForEmptyList(R.string.file_list_empty_headline_server_search,
R.string.file_list_empty_recently_added,
R.drawable.ic_list_empty_recent);
} else if (searchType == SearchType.REGULAR_FILTER) {
setMessageForEmptyList(R.string.file_list_empty_headline_search,
R.string.file_list_empty_search,
@@ -54,6 +54,7 @@ import com.nextcloud.client.device.DeviceInfo;
import com.nextcloud.client.di.Injectable;
import com.nextcloud.client.network.ClientFactory;
import com.nextcloud.client.preferences.AppPreferences;
import com.nextcloud.client.utils.Throttler;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.ArbitraryDataProvider;
@@ -101,7 +102,6 @@ import com.owncloud.android.utils.EncryptionUtils;
import com.owncloud.android.utils.FileSortOrder;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.utils.MimeTypeUtil;
import com.nextcloud.client.utils.Throttler;
import com.owncloud.android.utils.theme.ThemeColorUtils;
import com.owncloud.android.utils.theme.ThemeFabUtils;
import com.owncloud.android.utils.theme.ThemeToolbarUtils;
@@ -240,6 +240,9 @@ public class OCFileListFragment extends ExtendedListFragment implements
if (intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT) != null) {
searchEvent = Parcels.unwrap(intent.getParcelableExtra(OCFileListFragment.SEARCH_EVENT));
}
if (isSearchEventSet(searchEvent)) {
handleSearchEvent(searchEvent);
}
@@ -1376,9 +1379,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
case GALLERY_SEARCH:
setTitle(R.string.drawer_item_gallery);
break;
case RECENTLY_ADDED_SEARCH:
setTitle(R.string.drawer_item_recently_added);
break;
case RECENTLY_MODIFIED_SEARCH:
setTitle(R.string.drawer_item_recently_modified);
break;
@@ -1397,9 +1397,6 @@ public class OCFileListFragment extends ExtendedListFragment implements
if (event != null) {
switch (event.getSearchType()) {
case FAVORITE_SEARCH:
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
break;
case RECENTLY_MODIFIED_SEARCH:
menuItemAddRemoveValue = MenuItemAddRemove.REMOVE_SORT;
break;
@@ -1479,12 +1476,22 @@ public class OCFileListFragment extends ExtendedListFragment implements
}
}
@Override
public void onViewStateRestored(@Nullable Bundle savedInstanceState) {
super.onViewStateRestored(savedInstanceState);
if (savedInstanceState != null) {
searchEvent = Parcels.unwrap(savedInstanceState.getParcelable(SEARCH_EVENT));
}
}
@Subscribe(threadMode = ThreadMode.BACKGROUND)
public void onMessageEvent(final SearchEvent event) {
handleSearchEvent(event);
}
private void handleSearchEvent(SearchEvent event) {
@VisibleForTesting
public void handleSearchEvent(SearchEvent event) {
if (SearchRemoteOperation.SearchType.PHOTO_SEARCH == event.searchType) {
return;
}
@@ -1717,7 +1724,8 @@ public class OCFileListFragment extends ExtendedListFragment implements
(!TextUtils.isEmpty(event.getSearchQuery()) ||
event.searchType == SearchRemoteOperation.SearchType.SHARED_SEARCH ||
event.searchType == SearchRemoteOperation.SearchType.SHARED_FILTER ||
event.searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH);
event.searchType == SearchRemoteOperation.SearchType.FAVORITE_SEARCH ||
event.searchType == SearchRemoteOperation.SearchType.RECENTLY_MODIFIED_SEARCH);
}
private void syncAndCheckFiles(Collection<OCFile> files) {
@@ -46,10 +46,6 @@ public final class DrawerMenuUtil {
filterMenuItems(menu, R.id.nav_gallery, R.id.nav_favorites);
}
if (!resources.getBoolean(R.bool.recently_added_enabled)) {
menu.removeItem(R.id.nav_recently_added);
}
if (!resources.getBoolean(R.bool.recently_modified_enabled)) {
menu.removeItem(R.id.nav_recently_modified);
}
+1 -7
View File
@@ -53,18 +53,12 @@
android:icon="@drawable/nav_on_device"
android:orderInCategory="0"
android:title="@string/drawer_item_on_device"/>
<item
android:id="@+id/nav_recently_added"
android:icon="@drawable/nav_recently"
android:orderInCategory="0"
android:title="@string/drawer_item_recently_added"
android:visible="false"/>
<item
android:id="@+id/nav_recently_modified"
android:icon="@drawable/nav_recently"
android:orderInCategory="0"
android:title="@string/drawer_item_recently_modified"
android:visible="false"/>
android:visible="true"/>
<item
android:orderInCategory="0"
android:id="@+id/nav_notifications"
-1
View File
@@ -53,7 +53,6 @@
<bool name="multiaccount_support">true</bool>
<!-- Drawer options -->
<bool name="recently_added_enabled">false</bool>
<bool name="recently_modified_enabled">false</bool>
<bool name="shared_enabled">true</bool>
<bool name="show_drawer_logout">false</bool>
-2
View File
@@ -22,7 +22,6 @@
<string name="drawer_item_home">Home</string>
<string name="drawer_item_favorites">Favorites</string>
<string name="drawer_item_on_device">On device</string>
<string name="drawer_item_recently_added">Recently added</string>
<string name="drawer_item_recently_modified">Recently modified</string>
<string name="drawer_item_shared">Shared</string>
<string name="drawer_item_uploads_list">Uploads</string>
@@ -100,7 +99,6 @@
<string name="file_list_empty_shared">Files and folders you share will show up here.</string>
<string name="file_list_empty_search">Maybe it is in a different folder?</string>
<string name="file_list_empty_recently_modified">Found no files modified within the last 7 days</string>
<string name="file_list_empty_recently_added">Found no recently added files</string>
<string name="trashbin_empty_headline">No deleted files</string>
<string name="trashbin_empty_message">You will be able to recover deleted files from here.</string>
<string name="upload_list_empty_headline">No uploads available</string>