Search in sources :

Example 1 with CustomZoomFocusChange

use of com.amaze.filemanager.ui.views.CustomZoomFocusChange in project AmazeFileManager by TeamAmaze.

the class MainActivity method initializeFabActionViews.

public void initializeFabActionViews() {
    // NOTE: SpeedDial inverts insert index than FABsmenu
    FabWithLabelView cloudFab = initFabTitle(R.id.menu_new_cloud, R.string.cloud_connection, R.drawable.ic_cloud_white_24dp);
    FabWithLabelView newFileFab = initFabTitle(R.id.menu_new_file, R.string.file, R.drawable.ic_insert_drive_file_white_48dp);
    FabWithLabelView newFolderFab = initFabTitle(R.id.menu_new_folder, R.string.folder, R.drawable.folder_fab);
    floatingActionButton.setOnActionSelectedListener(new FabActionListener(this));
    floatingActionButton.setOnClickListener(view -> {
        fabButtonClick(cloudFab);
    });
    floatingActionButton.setOnFocusChangeListener(new CustomZoomFocusChange());
    floatingActionButton.getMainFab().setOnFocusChangeListener(new CustomZoomFocusChange());
    floatingActionButton.setNextFocusUpId(cloudFab.getId());
    floatingActionButton.getMainFab().setNextFocusUpId(cloudFab.getId());
    floatingActionButton.setOnKeyListener((v, keyCode, event) -> {
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
                if (getCurrentTab() == 0 && getFAB().isFocused()) {
                    getTabFragment().mViewPager.setCurrentItem(1);
                }
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
                findViewById(R.id.content_frame).requestFocus();
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) {
                if (pasteHelper != null && pasteHelper.getSnackbar() != null && pasteHelper.getSnackbar().isShown())
                    ((Snackbar.SnackbarLayout) pasteHelper.getSnackbar().getView()).findViewById(R.id.snackBarActionButton).requestFocus();
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_CENTER) {
                fabButtonClick(cloudFab);
            } else if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
                onBackPressed();
            } else {
                return false;
            }
        }
        return true;
    });
    cloudFab.setNextFocusDownId(floatingActionButton.getMainFab().getId());
    cloudFab.setNextFocusUpId(newFileFab.getId());
    cloudFab.setOnFocusChangeListener(new CustomZoomFocusChange());
    newFileFab.setNextFocusDownId(cloudFab.getId());
    newFileFab.setNextFocusUpId(newFolderFab.getId());
    newFileFab.setOnFocusChangeListener(new CustomZoomFocusChange());
    newFolderFab.setNextFocusDownId(newFileFab.getId());
    newFolderFab.setOnFocusChangeListener(new CustomZoomFocusChange());
}
Also used : CustomZoomFocusChange(com.amaze.filemanager.ui.views.CustomZoomFocusChange) FabWithLabelView(com.leinardi.android.speeddial.FabWithLabelView)

Aggregations

CustomZoomFocusChange (com.amaze.filemanager.ui.views.CustomZoomFocusChange)1 FabWithLabelView (com.leinardi.android.speeddial.FabWithLabelView)1