From 25a67fe4cb60cf5f0c32df7e5e94451d4329bf9f Mon Sep 17 00:00:00 2001 From: tobiasKaminsky Date: Tue, 10 Mar 2020 11:56:34 +0100 Subject: [PATCH] All files shows root again annotated functions with correct NonNull Signed-off-by: tobiasKaminsky --- .../client/FileDisplayActivityIT.java | 35 +++++++++++++++++++ .../ui/activity/ConflictsResolveActivity.java | 3 +- .../android/ui/activity/DrawerActivity.java | 9 +++-- .../android/ui/activity/FileActivity.java | 3 +- .../ui/activity/FileDisplayActivity.java | 2 +- .../ReceiveExternalFilesActivity.java | 2 +- .../ui/activity/UploadFilesActivity.java | 2 +- .../android/ui/activity/UserInfoActivity.java | 2 +- .../ui/preview/PreviewImageActivity.java | 3 +- .../ui/preview/PreviewVideoActivity.java | 3 +- 10 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java b/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java index 1bf97dd178..71ed3b6708 100644 --- a/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java +++ b/src/androidTest/java/com/nextcloud/client/FileDisplayActivityIT.java @@ -28,12 +28,14 @@ import android.app.Activity; import com.facebook.testing.screenshot.Screenshot; import com.owncloud.android.AbstractIT; import com.owncloud.android.R; +import com.owncloud.android.datamodel.OCFile; import com.owncloud.android.lib.resources.files.CreateFolderRemoteOperation; import com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation; import com.owncloud.android.lib.resources.files.SearchRemoteOperation; import com.owncloud.android.lib.resources.shares.CreateShareRemoteOperation; import com.owncloud.android.lib.resources.shares.OCShare; import com.owncloud.android.lib.resources.shares.ShareType; +import com.owncloud.android.operations.CreateFolderOperation; import com.owncloud.android.ui.activity.FileDisplayActivity; import com.owncloud.android.ui.events.SearchEvent; @@ -43,6 +45,7 @@ import org.junit.Rule; import org.junit.Test; import androidx.test.espresso.contrib.DrawerActions; +import androidx.test.espresso.contrib.NavigationViewActions; import androidx.test.espresso.intent.rule.IntentsTestRule; import androidx.test.rule.GrantPermissionRule; @@ -50,6 +53,7 @@ import static androidx.test.espresso.Espresso.onView; import static androidx.test.espresso.action.ViewActions.click; import static androidx.test.espresso.matcher.ViewMatchers.withId; import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation; +import static junit.framework.TestCase.assertEquals; import static junit.framework.TestCase.assertTrue; @@ -136,4 +140,35 @@ public class FileDisplayActivityIT extends AbstractIT { Screenshot.snapActivity(sut).record(); } + + @Test + public void allFiles() throws InterruptedException { + // ActivityScenario sut = ActivityScenario.launch(FileDisplayActivity.class); + FileDisplayActivity sut = activityRule.launchActivity(null); + + // given test folder + assertTrue(new CreateFolderOperation("/test/", true).execute(client, getStorageManager()).isSuccess()); + + // navigate into it + // sut.onActivity(activity -> activity.onBrowsedDownTo(getStorageManager().getFileByPath("/test/"))); + //sut.onBrowsedDownTo(getStorageManager().getFileByPath("/test/")); + OCFile test = getStorageManager().getFileByPath("/test/"); + sut.setFile(test); + sut.startSyncFolderOperation(test, false); + + assertEquals(getStorageManager().getFileByPath("/test/"), sut.getCurrentDir()); + + // open drawer + onView(withId(R.id.drawer_layout)).perform(DrawerActions.open()); + + // click "all files" + onView(withId(R.id.nav_view)) + .perform(NavigationViewActions.navigateTo(R.id.nav_all_files)); + + // then should be in root again + Thread.sleep(2000); + assertEquals(getStorageManager().getFileByPath("/"), sut.getCurrentDir()); + + + } } diff --git a/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java b/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java index d158fa1990..56895810b5 100644 --- a/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ConflictsResolveActivity.java @@ -39,6 +39,7 @@ import com.owncloud.android.ui.dialog.ConflictsResolveDialog.OnConflictDecisionM import javax.inject.Inject; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; @@ -136,7 +137,7 @@ public class ConflictsResolveActivity extends FileActivity implements OnConflict } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(EXTRA_CONFLICT_UPLOAD, conflictUpload); diff --git a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index 9c58c892df..35b7f4e2ab 100644 --- a/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -409,14 +409,13 @@ public abstract class DrawerActivity extends ToolbarActivity case R.id.nav_all_files: if (this instanceof FileDisplayActivity) { if (((FileDisplayActivity) this).getListOfFilesFragment() instanceof PhotoFragment) { - // showFiles(false); Intent intent = new Intent(getApplicationContext(), FileDisplayActivity.class); intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId()); intent.setAction(FileDisplayActivity.ALL_FILES); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } else { - showFiles(false); + ((FileDisplayActivity) this).browseToRoot(); EventBus.getDefault().post(new ChangeMenuEvent()); } } else { @@ -1217,7 +1216,7 @@ public abstract class DrawerActivity extends ToolbarActivity } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, mIsAccountChooserActive); @@ -1225,7 +1224,7 @@ public abstract class DrawerActivity extends ToolbarActivity } @Override - public void onRestoreInstanceState(Bundle savedInstanceState) { + public void onRestoreInstanceState(@NonNull Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); mIsAccountChooserActive = savedInstanceState.getBoolean(KEY_IS_ACCOUNT_CHOOSER_ACTIVE, false); @@ -1257,7 +1256,7 @@ public abstract class DrawerActivity extends ToolbarActivity } @Override - public void onConfigurationChanged(Configuration newConfig) { + public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); if (mDrawerToggle != null) { mDrawerToggle.onConfigurationChanged(newConfig); diff --git a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java index 665e600fcf..6006f319ed 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileActivity.java @@ -86,6 +86,7 @@ import java.lang.ref.WeakReference; import javax.inject.Inject; +import androidx.annotation.NonNull; import androidx.fragment.app.DialogFragment; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -253,7 +254,7 @@ public abstract class FileActivity extends DrawerActivity * {@inheritDoc} */ @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putParcelable(FileActivity.EXTRA_FILE, mFile); outState.putBoolean(FileActivity.EXTRA_FROM_NOTIFICATION, mFromNotification); diff --git a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java index 8899410938..5dfdff58a2 100644 --- a/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -1180,7 +1180,7 @@ public class FileDisplayActivity extends FileActivity } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { // responsibility of restore is preferred in onCreate() before than in // onRestoreInstanceState when there are Fragments involved Log_OC.v(TAG, "onSaveInstanceState() start"); diff --git a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java index 034790ea2c..0fedc9d49e 100755 --- a/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java @@ -243,7 +243,7 @@ public class ReceiveExternalFilesActivity extends FileActivity } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { Log_OC.d(TAG, "onSaveInstanceState() start"); super.onSaveInstanceState(outState); outState.putString(KEY_PARENTS, generatePath(mParents)); diff --git a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java index 4a46e4e5c7..4bf336a1d3 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UploadFilesActivity.java @@ -404,7 +404,7 @@ public class UploadFilesActivity extends FileActivity implements } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { // responsibility of restore is preferred in onCreate() before than in // onRestoreInstanceState when there are Fragments involved Log_OC.d(TAG, "onSaveInstanceState() start"); diff --git a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java index 83a45440a2..4e074ee0a4 100644 --- a/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java +++ b/src/main/java/com/owncloud/android/ui/activity/UserInfoActivity.java @@ -395,7 +395,7 @@ public class UserInfoActivity extends FileActivity implements Injectable { } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); if (userInfo != null) { outState.putParcelable(KEY_USER_DATA, Parcels.wrap(userInfo)); diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java b/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java index 3cf91eb914..4e29a4356e 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewImageActivity.java @@ -64,6 +64,7 @@ import com.owncloud.android.utils.ThemeUtils; import javax.inject.Inject; +import androidx.annotation.NonNull; import androidx.appcompat.app.ActionBar; import androidx.drawerlayout.widget.DrawerLayout; import androidx.viewpager.widget.ViewPager; @@ -203,7 +204,7 @@ public class PreviewImageActivity extends FileActivity implements } @Override - protected void onSaveInstanceState(Bundle outState) { + protected void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putBoolean(KEY_WAITING_FOR_BINDER, mRequestWaitingForBinder); outState.putBoolean(KEY_SYSTEM_VISIBLE, isSystemUIVisible()); diff --git a/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java b/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java index 3bc30e7473..dad19f4f3d 100644 --- a/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java +++ b/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.java @@ -39,6 +39,7 @@ import com.owncloud.android.lib.common.utils.Log_OC; import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.utils.MimeTypeUtil; +import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; /** @@ -114,7 +115,7 @@ public class PreviewVideoActivity extends FileActivity implements OnCompletionLi * {@inheritDoc} */ @Override - public void onSaveInstanceState(Bundle outState) { + public void onSaveInstanceState(@NonNull Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(PreviewVideoActivity.EXTRA_START_POSITION, mVideoPlayer.getCurrentPosition()); outState.putBoolean(PreviewVideoActivity.EXTRA_AUTOPLAY , mVideoPlayer.isPlaying());