Search in sources :

Example 21 with FileDisplayActivity

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);
    }
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Intent(android.content.Intent)

Example 22 with FileDisplayActivity

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());
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Test(org.junit.Test)

Example 23 with FileDisplayActivity

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);
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) RemoveFilesDialogFragment(com.owncloud.android.ui.dialog.RemoveFilesDialogFragment) RenameFileDialogFragment(com.owncloud.android.ui.dialog.RenameFileDialogFragment)

Example 24 with FileDisplayActivity

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();
    }
}
Also used : FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity)

Example 25 with FileDisplayActivity

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());
}
Also used : Handler(android.os.Handler) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) Activity(android.app.Activity) MenuItem(android.view.MenuItem) InputMethodManager(android.view.inputmethod.InputMethodManager) LayoutTransition(android.animation.LayoutTransition) DisplayMetrics(android.util.DisplayMetrics) Fragment(androidx.fragment.app.Fragment) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(androidx.recyclerview.widget.RecyclerView) SearchView(androidx.appcompat.widget.SearchView) TextView(android.widget.TextView) EmptyRecyclerView(com.owncloud.android.ui.EmptyRecyclerView) FileDisplayActivity(com.owncloud.android.ui.activity.FileDisplayActivity) FolderPickerActivity(com.owncloud.android.ui.activity.FolderPickerActivity) SearchView(androidx.appcompat.widget.SearchView) UploadFilesActivity(com.owncloud.android.ui.activity.UploadFilesActivity) ViewTreeObserver(android.view.ViewTreeObserver) LinearLayout(android.widget.LinearLayout)

Aggregations

FileDisplayActivity (com.owncloud.android.ui.activity.FileDisplayActivity)26 OCFile (com.owncloud.android.datamodel.OCFile)11 Test (org.junit.Test)9 Intent (android.content.Intent)8 FolderPickerActivity (com.owncloud.android.ui.activity.FolderPickerActivity)7 Activity (android.app.Activity)4 FileDataStorageManager (com.owncloud.android.datamodel.FileDataStorageManager)4 OCCapability (com.owncloud.android.lib.resources.status.OCCapability)4 UploadFilesActivity (com.owncloud.android.ui.activity.UploadFilesActivity)4 ScreenshotTest (com.owncloud.android.utils.ScreenshotTest)4 View (android.view.View)3 FragmentActivity (androidx.fragment.app.FragmentActivity)3 User (com.nextcloud.client.account.User)3 ArrayList (java.util.ArrayList)3 Account (android.accounts.Account)2 AccountManager (android.accounts.AccountManager)2 Bundle (android.os.Bundle)2 Handler (android.os.Handler)2 MenuItem (android.view.MenuItem)2 AdapterView (android.widget.AdapterView)2