|
@@ -135,6 +135,7 @@ import java.util.List;
|
|
|
import javax.inject.Inject;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
|
+import androidx.annotation.VisibleForTesting;
|
|
|
import androidx.appcompat.app.AlertDialog;
|
|
|
import androidx.appcompat.widget.SearchView;
|
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
@@ -514,7 +515,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
|
|
|
transaction.commit();
|
|
|
|
|
|
- if (fragment instanceof UnifiedSearchFragment) {
|
|
|
+ if (fragment instanceof UnifiedSearchFragment || fragment instanceof PreviewMediaFragment) {
|
|
|
showSortListGroup(false);
|
|
|
} else {
|
|
|
showSortListGroup(true);
|
|
@@ -542,8 +543,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
|
|
|
protected void resetTitleBarAndScrolling() {
|
|
|
updateActionBarTitleAndHomeButton(null);
|
|
|
- CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
|
|
|
- params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
|
|
+ resetScrolling();
|
|
|
}
|
|
|
|
|
|
public void updateListOfFilesFragment(boolean fromSearch) {
|
|
@@ -1019,8 +1019,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
createMinFragments(null);
|
|
|
} else {
|
|
|
// pop back
|
|
|
- ((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams())
|
|
|
- .setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
|
|
+ resetScrolling();
|
|
|
hideSearchView(getCurrentDir());
|
|
|
showSortListGroup(true);
|
|
|
super.onBackPressed();
|
|
@@ -1264,9 +1263,19 @@ public class FileDisplayActivity extends FileActivity
|
|
|
DataHolderUtil.getInstance().delete(intent.getStringExtra(FileSyncAdapter.EXTRA_RESULT));
|
|
|
|
|
|
Log_OC.d(TAG, "Setting progress visibility to " + mSyncInProgress);
|
|
|
+
|
|
|
+
|
|
|
OCFileListFragment ocFileListFragment = getListOfFilesFragment();
|
|
|
if (ocFileListFragment != null) {
|
|
|
ocFileListFragment.setLoading(mSyncInProgress);
|
|
|
+ if (!mSyncInProgress && !ocFileListFragment.isLoading()) {
|
|
|
+ // update scrolling when load finishes
|
|
|
+ if (ocFileListFragment.isEmpty()) {
|
|
|
+ lockScrolling();
|
|
|
+ } else {
|
|
|
+ resetScrolling();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
setBackgroundText();
|
|
|
}
|
|
@@ -1505,7 +1514,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
public void showDetails(OCFile file, int activeTab) {
|
|
|
User currentUser = getUser().orElseThrow(RuntimeException::new);
|
|
|
|
|
|
- resetHeaderScrollingState();
|
|
|
+ resetScrolling();
|
|
|
|
|
|
setFile(file);
|
|
|
Fragment detailFragment = FileDetailFragment.newInstance(file, currentUser, activeTab);
|
|
@@ -1515,14 +1524,33 @@ public class FileDisplayActivity extends FileActivity
|
|
|
mDrawerToggle.setDrawerIndicatorEnabled(false);
|
|
|
}
|
|
|
|
|
|
- private void resetHeaderScrollingState() {
|
|
|
- CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) findViewById(R.id.root_layout).getLayoutParams();
|
|
|
- params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
|
|
- AppBarLayout appBarLayout = findViewById(R.id.appbar);
|
|
|
+ /**
|
|
|
+ * Prevents content scrolling and toolbar collapse
|
|
|
+ */
|
|
|
+ @VisibleForTesting
|
|
|
+ public void lockScrolling() {
|
|
|
+ final CoordinatorLayout.LayoutParams coordinatorParams = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
|
|
|
+ coordinatorParams.setBehavior(null);
|
|
|
+ binding.rootLayout.setLayoutParams(coordinatorParams);
|
|
|
+ binding.rootLayout.setNestedScrollingEnabled(false);
|
|
|
+ final AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
|
|
|
+ appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL);
|
|
|
+ binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
|
|
|
+ binding.appbar.appbar.setExpanded(true, false);
|
|
|
+ }
|
|
|
|
|
|
- if (appBarLayout != null) {
|
|
|
- appBarLayout.setExpanded(true);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * Resets content scrolling and toolbar collapse
|
|
|
+ */
|
|
|
+ @VisibleForTesting
|
|
|
+ public void resetScrolling() {
|
|
|
+ final CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams();
|
|
|
+ params.setBehavior(new AppBarLayout.ScrollingViewBehavior());
|
|
|
+ binding.rootLayout.setLayoutParams(params);
|
|
|
+ AppBarLayout.LayoutParams appbarParams = (AppBarLayout.LayoutParams) binding.appbar.toolbarFrame.getLayoutParams();
|
|
|
+ appbarParams.setScrollFlags(AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL | AppBarLayout.LayoutParams.SCROLL_FLAG_ENTER_ALWAYS);
|
|
|
+ binding.appbar.toolbarFrame.setLayoutParams(appbarParams);
|
|
|
+ binding.appbar.appbar.setExpanded(true, false);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -2077,10 +2105,9 @@ public class FileDisplayActivity extends FileActivity
|
|
|
return; // not reachable under normal conditions
|
|
|
}
|
|
|
if (showPreview && file.isDown() && !file.isDownloading() || streamMedia) {
|
|
|
- showSortListGroup(false);
|
|
|
+ configureToolbarForMediaPreview(file);
|
|
|
Fragment mediaFragment = PreviewMediaFragment.newInstance(file, user.get(), startPlaybackPosition, autoplay);
|
|
|
setLeftFragment(mediaFragment);
|
|
|
- configureToolbarForMediaPreview(file);
|
|
|
} else {
|
|
|
Intent previewIntent = new Intent();
|
|
|
previewIntent.putExtra(EXTRA_FILE, file);
|
|
@@ -2095,7 +2122,7 @@ public class FileDisplayActivity extends FileActivity
|
|
|
|
|
|
public void configureToolbarForMediaPreview(OCFile file) {
|
|
|
showSortListGroup(false);
|
|
|
- ((CoordinatorLayout.LayoutParams) binding.rootLayout.getLayoutParams()).setBehavior(null);
|
|
|
+ lockScrolling();
|
|
|
super.updateActionBarTitleAndHomeButton(file);
|
|
|
}
|
|
|
|