add stack to hold sortGroup view visibility

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parneet-guraya 2023-09-12 18:15:41 +05:30
parent eddbc878c7
commit 09b8f48bcf
No known key found for this signature in database
GPG key ID: 26DB680F1EE174D5
3 changed files with 49 additions and 36 deletions

View file

@ -144,6 +144,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Stack;
import javax.inject.Inject;
@ -233,7 +234,7 @@ public class FileDisplayActivity extends FileActivity
private PlayerServiceConnection mPlayerConnection;
private Optional<User> lastDisplayedUser = Optional.empty();
private int menuItemId = -1;
private Stack<Boolean> previousSortGroupState;
@Inject
AppPreferences preferences;
@ -622,7 +623,7 @@ public class FileDisplayActivity extends FileActivity
//clear the subtitle while navigating to any other screen from Media screen
clearToolbarSubtitle();
showSortListGroup(showSortListGroup);
setSortListGroup(sortListGroupVisibility(), showSortListGroup);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.addToBackStack(null);
transaction.replace(R.id.left_fragment_container, fragment, TAG_LIST_OF_FILES);
@ -1027,9 +1028,9 @@ public class FileDisplayActivity extends FileActivity
}
private void popBack() {
// pop back
// pop back fragment
resetScrolling(true);
showSortListGroup(true);
popSortListGroupVisibility();
super.onBackPressed();
}
@ -1038,7 +1039,6 @@ public class FileDisplayActivity extends FileActivity
setFile(listOfFiles.getCurrentFile());
listOfFiles.setFabVisible(true);
listOfFiles.registerFabListener();
showSortListGroup(true);
resetTitleBarAndScrolling();
setDrawerAllFiles();
}
@ -1058,11 +1058,12 @@ public class FileDisplayActivity extends FileActivity
hideSearchView(getCurrentDir());
setDrawerIndicatorEnabled(isDrawerIndicatorAvailable());
}
}
if (leftFragment instanceof UnifiedSearchFragment) {
popSortListGroupVisibility();
super.onBackPressed();
}
}
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
@ -2611,4 +2612,13 @@ public class FileDisplayActivity extends FileActivity
}
}
private void setSortListGroup(boolean currentListGroupVisibility, boolean show) {
previousSortGroupState.push(currentListGroupVisibility);
showSortListGroup(show);
}
private void popSortListGroupVisibility() {
boolean popped = previousSortGroupState.pop();
showSortListGroup(popped);
}
}

View file

@ -197,7 +197,6 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
/**
* checks if the given file is the root folder.
*
*
* @param file file to be checked if it is the root folder
* @return <code>true</code> if it is <code>null</code> or the root folder, else returns <code>false</code>
*/
@ -243,6 +242,9 @@ public abstract class ToolbarActivity extends BaseActivity implements Injectable
findViewById(R.id.sort_list_button_group).setVisibility(show ? View.VISIBLE : View.GONE);
}
public boolean sortListGroupVisibility(){
return findViewById(R.id.sort_list_button_group).getVisibility() == View.VISIBLE;
}
/**
* Change the bitmap for the toolbar's preview image.
*

View file

@ -144,7 +144,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
/**
* Public factory method to create new FileDetailFragment instances.
*
* <p>
* When 'fileToDetail' or 'ocAccount' are null, creates a dummy layout (to use when a file wasn't tapped before).
*
* @param fileToDetail An {@link OCFile} to show in the fragment
@ -224,7 +224,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
user = savedInstanceState.getParcelable(ARG_USER);
}
binding = FileDetailsFragmentBinding.inflate(inflater,container,false);
binding = FileDetailsFragmentBinding.inflate(inflater, container, false);
view = binding.getRoot();
if (getFile() == null || user == null) {
@ -373,8 +373,6 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
super.onResume();
if (toolbarActivity != null) {
toolbarActivity.showSortListGroup(false);
if (previewLoaded) {
toolbarActivity.setPreviewImageVisibility(true);
}
@ -477,7 +475,8 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
}
/**
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be replaced.
* Check if the fragment was created with an empty layout. An empty fragment can't show file details, must be
* replaced.
*
* @return True when the fragment was created with the empty layout.
*/
@ -498,11 +497,11 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
/**
* Updates the view with all relevant details about that file.
*
* <p>
* TODO Remove parameter when the transferring state of files is kept in database.
*
* @param transferring Flag signaling if the file should be considered as downloading or uploading,
* although {@link FileDownloaderBinder#isDownloading(User, OCFile)} and
* @param transferring Flag signaling if the file should be considered as downloading or uploading, although
* {@link FileDownloaderBinder#isDownloading(User, OCFile)} and
* {@link FileUploaderBinder#isUploading(User, OCFile)} return false.
* @param refresh If 'true', try to refresh the whole file from the database
*/
@ -664,8 +663,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
//if (getFile().isDownloading()) {
if (downloaderBinder != null && downloaderBinder.isDownloading(user, getFile())) {
binding.progressText.setText(R.string.downloader_download_in_progress_ticker);
}
else {
} else {
if (uploaderBinder != null && uploaderBinder.isUploading(user, getFile())) {
binding.progressText.setText(R.string.uploader_upload_in_progress_ticker);
}
@ -733,6 +731,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
/**
* open the sharing process fragment for creating new share
*
* @param shareeName
* @param shareType
*/
@ -749,6 +748,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
/**
* method will handle the views need to be hidden when sharing process fragment shows
*
* @param isFragmentReplaced
*/
public void showHideFragmentView(boolean isFragmentReplaced) {
@ -765,6 +765,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
/**
* open the new sharing screen process to modify the created share
*
* @param share
* @param screenTypePermission
* @param isReshareShown
@ -816,7 +817,7 @@ public class FileDetailFragment extends FileFragment implements OnClickListener,
@Override
public void onTransferProgress(long progressRate, long totalTransferredSoFar,
long totalToTransfer, String filename) {
int percent = (int)(100.0*((double)totalTransferredSoFar)/((double)totalToTransfer));
int percent = (int) (100.0 * ((double) totalTransferredSoFar) / ((double) totalToTransfer));
if (percent != lastPercent) {
ProgressBar pb = progressBarReference.get();
if (pb != null) {