use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.
the class DisplayUtils method switchToSearchFragment.
private static void switchToSearchFragment(Activity activity, SearchEvent event) {
if (activity instanceof FileDisplayActivity) {
EventBus.getDefault().post(event);
} else {
Intent recentlyAddedIntent = new Intent(activity.getBaseContext(), FileDisplayActivity.class);
recentlyAddedIntent.putExtra(OCFileListFragment.SEARCH_EVENT, event);
recentlyAddedIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
activity.startActivity(recentlyAddedIntent);
}
}
use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.
the class SyncFileNotEnoughSpaceDialogFragmentTest method showNotEnoughSpaceDialogForFolder.
@Test
public void showNotEnoughSpaceDialogForFolder() {
FileDisplayActivity test = activityRule.launchActivity(null);
OCFile ocFile = new OCFile("/Document/");
ocFile.setFileLength(5000000);
SyncFileNotEnoughSpaceDialogFragment dialog = SyncFileNotEnoughSpaceDialogFragment.newInstance(ocFile, 1000);
dialog.show(test.getListOfFilesFragment().getFragmentManager(), "1");
getInstrumentation().waitForIdleSync();
screenshot(Objects.requireNonNull(dialog.requireDialog().getWindow()).getDecorView());
}
use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.
the class FileDetailFragment method optionsItemSelected.
private boolean optionsItemSelected(MenuItem item) {
int itemId = item.getItemId();
if (itemId == R.id.action_send_file) {
containerActivity.getFileOperationsHelper().sendShareFile(getFile(), true);
return true;
} else if (itemId == R.id.action_open_file_with) {
containerActivity.getFileOperationsHelper().openFile(getFile());
return true;
} else if (itemId == R.id.action_remove_file) {
RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), FTAG_CONFIRMATION);
return true;
} else if (itemId == R.id.action_rename_file) {
RenameFileDialogFragment dialog = RenameFileDialogFragment.newInstance(getFile());
dialog.show(getFragmentManager(), FTAG_RENAME_FILE);
return true;
} else if (itemId == R.id.action_cancel_sync) {
((FileDisplayActivity) containerActivity).cancelTransference(getFile());
return true;
} else if (itemId == R.id.action_download_file || itemId == R.id.action_sync_file) {
containerActivity.getFileOperationsHelper().syncFile(getFile());
return true;
} else if (itemId == R.id.action_set_as_wallpaper) {
containerActivity.getFileOperationsHelper().setPictureAs(getFile(), getView());
return true;
} else if (itemId == R.id.action_encrypted) {
// TODO implement or remove
return true;
} else if (itemId == R.id.action_unset_encrypted) {
// TODO implement or remove
return true;
}
return super.onOptionsItemSelected(item);
}
use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.
the class ExtendedListFragment method onRefresh.
@Override
public void onRefresh() {
if (searchView != null) {
searchView.onActionViewCollapsed();
Activity activity;
if ((activity = getActivity()) != null && activity instanceof FileDisplayActivity) {
FileDisplayActivity fileDisplayActivity = (FileDisplayActivity) activity;
fileDisplayActivity.setDrawerIndicatorEnabled(fileDisplayActivity.isDrawerIndicatorAvailable());
fileDisplayActivity.hideSearchView(fileDisplayActivity.getCurrentDir());
}
}
if (mOnRefreshListener != null) {
mOnRefreshListener.onRefresh();
}
}
use of com.owncloud.android.ui.activity.FileDisplayActivity in project android by nextcloud.
the class ExtendedListFragment method onCreateOptionsMenu.
@Override
public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) {
final MenuItem item = menu.findItem(R.id.action_search);
searchView = (SearchView) MenuItemCompat.getActionView(item);
closeButton = searchView.findViewById(androidx.appcompat.R.id.search_close_btn);
searchView.setOnQueryTextListener(this);
searchView.setOnCloseListener(this);
ThemeToolbarUtils.themeSearchView(searchView, requireContext());
SearchView.SearchAutoComplete theTextArea = searchView.findViewById(R.id.search_src_text);
theTextArea.setHighlightColor(ThemeColorUtils.primaryAccentColor(getContext()));
final Handler handler = new Handler();
DisplayMetrics displaymetrics = new DisplayMetrics();
Activity activity;
if ((activity = getActivity()) != null) {
activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
int width = displaymetrics.widthPixels;
if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
searchView.setMaxWidth((int) (width * 0.4));
} else {
if (activity instanceof FolderPickerActivity) {
searchView.setMaxWidth((int) (width * 0.8));
} else {
searchView.setMaxWidth(width);
}
}
}
searchView.setOnQueryTextFocusChangeListener((v, hasFocus) -> handler.post(() -> {
if (getActivity() != null && !(getActivity() instanceof FolderPickerActivity) && !(getActivity() instanceof UploadFilesActivity)) {
if (getActivity() instanceof FileDisplayActivity) {
Fragment fragment = ((FileDisplayActivity) getActivity()).getLeftFragment();
if (fragment instanceof OCFileListFragment) {
((OCFileListFragment) fragment).setFabVisible(!hasFocus);
}
}
if (TextUtils.isEmpty(searchView.getQuery())) {
closeButton.setVisibility(View.INVISIBLE);
}
}
}));
// On close -> empty field, show keyboard and
closeButton.setOnClickListener(view -> {
searchView.setQuery("", true);
searchView.requestFocus();
searchView.onActionViewExpanded();
InputMethodManager inputMethodManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null) {
inputMethodManager.showSoftInput(searchView, InputMethodManager.SHOW_IMPLICIT);
}
});
final View mSearchEditFrame = searchView.findViewById(androidx.appcompat.R.id.search_edit_frame);
ViewTreeObserver vto = mSearchEditFrame.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
int oldVisibility = -1;
@Override
public void onGlobalLayout() {
int currentVisibility = mSearchEditFrame.getVisibility();
if (currentVisibility != oldVisibility) {
if (currentVisibility == View.VISIBLE) {
setEmptyListMessage(SearchType.REGULAR_FILTER);
} else {
if (MainApp.isOnlyOnDevice()) {
setMessageForEmptyList(R.string.file_list_empty_headline, R.string.file_list_empty_on_device, R.drawable.ic_list_empty_folder, true);
} else {
setEmptyListMessage(SearchType.NO_SEARCH);
}
}
oldVisibility = currentVisibility;
}
}
});
LinearLayout searchBar = searchView.findViewById(R.id.search_bar);
searchBar.setLayoutTransition(new LayoutTransition());
}
Aggregations