com.github.angads25.filepicker.model.DialogConfigs Java Examples

The following examples show how to use com.github.angads25.filepicker.model.DialogConfigs. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelpActivity.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
private void chooseOutputFolder() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.DIR_SELECT;
    properties.root = new File(Environment.getExternalStorageDirectory().toURI());
    properties.error_dir = new File(Environment.getExternalStorageDirectory().toURI());
    properties.offset = new File(Environment.getExternalStorageDirectory().toURI());
    FilePickerDialog dial = new FilePickerDialog(this, properties);
    dial.setTitle(R.string.backupFolder);
    dial.setDialogSelectionListener(files -> {
        pathToSaveLogs = files[0];
        etLogsPath.setText(pathToSaveLogs);
        br.setPathToSaveLogs(pathToSaveLogs);
    });
    dial.show();
}
 
Example #2
Source File: BackupFragment.java    From InviZible with GNU General Public License v3.0 6 votes vote down vote up
private void selectBackupPath() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.DIR_SELECT;
    properties.root = new File(Environment.getExternalStorageDirectory().toURI());
    properties.error_dir = new File(Environment.getExternalStorageDirectory().toURI());
    properties.offset = new File(Environment.getExternalStorageDirectory().toURI());
    properties.extensions = new String[]{"arch:"};
    FilePickerDialog dial = new FilePickerDialog(getActivity(), properties);
    dial.setTitle(R.string.backupFolder);
    dial.setDialogSelectionListener(files -> {
        pathBackup = files[0];
        etFilePath.setText(pathBackup);

        if (backupHelper != null) {
            backupHelper.setPathBackup(pathBackup);
        }

        if (restoreHelper != null) {
            restoreHelper.setPathBackup(pathBackup);
        }
    });
    dial.show();
}
 
Example #3
Source File: ActivityExportCSV.java    From fingen with Apache License 2.0 6 votes vote down vote up
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
void SelectFile() {
    FileUtils.SelectFileFromStorage(ActivityExportCSV.this, DialogConfigs.FILE_AND_DIR_SELECT, new FileUtils.IOnSelectFile() {
        @Override
        public void OnSelectFile(String path) {
            String dir;
            String fn;
            File file = new File(path);
            if (file.isDirectory()) {
                dir = path;
                fn = "";
            } else {
                dir = file.getParent();
                fn = file.getName();
            }
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(ActivityExportCSV.this);
            preferences.edit().putString("export_dir", dir).putString("export_file", fn).apply();
            mEditTextDirectory.setText(dir);
            mEditTextFileName.setText(fn);
        }
    });
}
 
Example #4
Source File: UriDirectoryPickerDialogFragment.java    From SAI with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void deliverSelectionResult(String tag, int selectedItemIndex) {
    switch (selectedItemIndex) {
        case 0:
            DialogProperties properties = new DialogProperties();
            properties.selection_mode = DialogConfigs.SINGLE_MODE;
            properties.selection_type = DialogConfigs.DIR_SELECT;
            properties.root = Environment.getExternalStorageDirectory();

            openFilePicker(FilePickerDialogFragment.newInstance("backup_dir", getString(R.string.settings_main_pick_dir), properties));
            break;
        case 1:
            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            startActivityForResult(Intent.createChooser(intent, getString(R.string.installer_pick_apks)), REQUEST_CODE_SELECT_BACKUP_DIR);
            break;
    }
}
 
Example #5
Source File: OfflinePickerSample.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
/**
 * step 1, users selects files
 */
private void promptForFiles() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.MULTI_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = new File(DialogConfigs.DEFAULT_DIR);
    properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
    properties.offset = new File(DialogConfigs.DEFAULT_DIR);

    Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions();
    //api check
    if (Build.VERSION.SDK_INT >= 14)
        registeredExtensions.add("gpkg");
    registeredExtensions.add("map");

    String[] ret = new String[registeredExtensions.size()];
    ret = registeredExtensions.toArray(ret);
    properties.extensions = ret;

    FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
    dialog.setTitle("Select a File");
    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
            //files is the array of the paths of files selected by the Application User.
            setProviderConfig(files);
        }

    });
    dialog.show();
}
 
Example #6
Source File: BookmarkSample.java    From osmdroid with Apache License 2.0 5 votes vote down vote up
private void showFilePicker(){
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = new File(DialogConfigs.DEFAULT_DIR);
    properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
    properties.offset = new File(DialogConfigs.DEFAULT_DIR);

    Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions();

    registeredExtensions.add("csv");


    String[] ret = new String[registeredExtensions.size()];
    ret = registeredExtensions.toArray(ret);
    properties.extensions = ret;

    FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
    dialog.setTitle("Select a CSV File");
    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(final String[] files) {
            //files is the array of the paths of files selected by the Application User.
            if (files.length==1)
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        importFromCsv(new File(files[0]));
                    }
                }).start();

        }

    });
    dialog.show();
}
 
Example #7
Source File: EncodingConfigFragment.java    From PLDroidMediaStreaming with Apache License 2.0 5 votes vote down vote up
private void initPicturePanel(final View root) {
    ((ImageView) root.findViewById(R.id.picture_preview)).setImageResource(R.drawable.pause_publish);
    root.findViewById(R.id.picture_preview).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogProperties properties = new DialogProperties();
            properties.selection_mode = DialogConfigs.SINGLE_MODE;
            properties.selection_type = DialogConfigs.FILE_SELECT;
            properties.root = new File(DialogConfigs.STORAGE_DIR);
            properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
            properties.extensions = new String[]{"jpg", "png"};

            FilePickerDialog dialog = new FilePickerDialog(getActivity(), properties);
            dialog.setTitle("Select a File");
            dialog.setDialogSelectionListener(new DialogSelectionListener() {
                @Override
                public void onSelectedFilePaths(String[] files) {
                    ImageView imageView = ((ImageView) getView().findViewById(R.id.picture_preview));
                    if (files != null && files.length > 0){
                        mPictureFilePath = files[0];
                        imageView.setImageBitmap(BitmapFactory.decodeFile(mPictureFilePath));
                    } else {
                        mPictureFilePath = null;
                        imageView.setImageResource(R.drawable.pause_publish);
                    }
                }
            });
            dialog.show();
        }
    });
}
 
Example #8
Source File: FilePickerListener.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean onPreferenceSingleClick(Preference preference) {
    mPreference = preference;

    File offset = null;
    String current = HiSettingsHelper.getInstance().getStringValue(preference.getKey(), "");
    if (!TextUtils.isEmpty(current)) {
        File currentFile = new File(current);
        if (currentFile.exists()) {
            offset = currentFile.getParentFile();
        }
    }

    DialogProperties properties = new DialogProperties();
    properties.root = Environment.getExternalStorageDirectory();
    properties.error_dir = Environment.getExternalStorageDirectory();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    if (offset != null)
        properties.offset = offset;
    if (mType == FONT_FILE) {
        properties.selection_type = DialogConfigs.FILE_SELECT;
        properties.extensions = "ttf:otf".split(":");
        properties.enable_clear_button = true;
    } else if (mType == SAVE_DIR) {
        properties.selection_type = DialogConfigs.DIR_SELECT;
    }

    FilePickerDialog mDialog = new FilePickerDialog(mActivity);
    mDialog.setProperties(properties);
    mDialog.setDialogSelectionListener(this);
    mDialog.setTitle(preference.getTitle());
    mDialog.show();
    return false;
}
 
Example #9
Source File: ActivityImportCSVAdvanced.java    From fingen with Apache License 2.0 5 votes vote down vote up
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
void SelectFile() {
    FileUtils.SelectFileFromStorage(ActivityImportCSVAdvanced.this, DialogConfigs.FILE_SELECT, new FileUtils.IOnSelectFile() {
        @Override
        public void OnSelectFile(String fileName) {
            mPath = fileName;
            initColumns();
        }
    });
}
 
Example #10
Source File: ActivityImportCSV.java    From fingen with Apache License 2.0 5 votes vote down vote up
@NeedsPermission(Manifest.permission.READ_EXTERNAL_STORAGE)
void SelectFile() {
    FileUtils.SelectFileFromStorage(ActivityImportCSV.this, DialogConfigs.FILE_SELECT, new FileUtils.IOnSelectFile() {
        @Override
        public void OnSelectFile(String FileName) {
            editTextFileName.setText(FileName);
        }
    });
}
 
Example #11
Source File: FileUtils.java    From fingen with Apache License 2.0 5 votes vote down vote up
public static void SelectFileFromStorage(Activity activity, int selectionType, final IOnSelectFile onSelectFileListener) {
    final DialogProperties properties=new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = selectionType;
    properties.root = new File(DialogConfigs.DEFAULT_DIR);
    properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
    properties.offset = new File(DialogConfigs.DEFAULT_DIR);
    properties.extensions = new String[] {"csv", "CSV"};

    FilePickerDialog dialog=new FilePickerDialog(activity,properties);
    String title = "";
    title = selectionType == DialogConfigs.FILE_SELECT ? activity.getString(R.string.ttl_select_csv_file) : activity.getString(R.string.ttl_select_export_dir);
    dialog.setTitle(title);
    dialog.setPositiveBtnName("Select");
    dialog.setNegativeBtnName("Cancel");

    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
            if (files.length == 1 && !files[0].isEmpty()) {
                onSelectFileListener.OnSelectFile(files[0]);
            }
        }
    });

    dialog.show();
}
 
Example #12
Source File: InstallerXDialogFragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
private void checkPermissionsAndPickFiles() {
    if (!PermissionsUtils.checkAndRequestStoragePermissions(this))
        return;

    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.MULTI_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = Environment.getExternalStorageDirectory();
    properties.offset = new File(mHelper.getHomeDirectory());
    properties.extensions = new String[]{"zip", "apks", "xapk", "apk"};
    properties.sortBy = mHelper.getFilePickerSortBy();
    properties.sortOrder = mHelper.getFilePickerSortOrder();

    FilePickerDialogFragment.newInstance(null, getString(R.string.installer_pick_apks), properties).show(getChildFragmentManager(), "dialog_files_picker");
}
 
Example #13
Source File: LegacyInstallerFragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
private void checkPermissionsAndPickFiles() {
    if (!PermissionsUtils.checkAndRequestStoragePermissions(this))
        return;

    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.MULTI_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = Environment.getExternalStorageDirectory();
    properties.offset = new File(mHelper.getHomeDirectory());
    properties.extensions = new String[]{"apk", "zip", "apks"};
    properties.sortBy = mHelper.getFilePickerSortBy();
    properties.sortOrder = mHelper.getFilePickerSortOrder();

    FilePickerDialogFragment.newInstance(null, getString(R.string.installer_pick_apks), properties).show(getChildFragmentManager(), "dialog_files_picker");
}
 
Example #14
Source File: Installer2Fragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
private void checkPermissionsAndPickFiles() {
    if (!PermissionsUtils.checkAndRequestStoragePermissions(this))
        return;

    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.MULTI_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = Environment.getExternalStorageDirectory();
    properties.offset = new File(mHelper.getHomeDirectory());
    properties.extensions = new String[]{"apk", "zip", "apks", "xapk"};
    properties.sortBy = mHelper.getFilePickerSortBy();
    properties.sortOrder = mHelper.getFilePickerSortOrder();

    FilePickerDialogFragment.newInstance(null, getString(R.string.installer_pick_apks), properties).show(getChildFragmentManager(), "dialog_files_picker");
}
 
Example #15
Source File: PreferencesFragment.java    From SAI with GNU General Public License v3.0 5 votes vote down vote up
private void selectHomeDir() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.DIR_SELECT;
    properties.root = Environment.getExternalStorageDirectory();

    openFilePicker(FilePickerDialogFragment.newInstance("home", getString(R.string.settings_main_pick_dir), properties));
}
 
Example #16
Source File: PreferencesFragment.java    From SAI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onItemSelected(String dialogTag, int selectedItemIndex) {
    switch (dialogTag) {
        case "sort":
            mHelper.setFilePickerRawSort(selectedItemIndex);
            switch (selectedItemIndex) {
                case 0:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_NAME);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_NORMAL);
                    break;
                case 1:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_NAME);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_REVERSE);
                    break;
                case 2:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_LAST_MODIFIED);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_NORMAL);
                    break;
                case 3:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_LAST_MODIFIED);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_REVERSE);
                    break;
                case 4:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_SIZE);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_REVERSE);
                    break;
                case 5:
                    mHelper.setFilePickerSortBy(DialogConfigs.SORT_BY_SIZE);
                    mHelper.setFilePickerSortOrder(DialogConfigs.SORT_ORDER_NORMAL);
                    break;
            }
            updateFilePickerSortSummary();
            break;
        case "installer":
            boolean installerSet = false;
            switch (selectedItemIndex) {
                case PreferencesValues.INSTALLER_ROOTLESS:
                    installerSet = true;
                    break;
                case PreferencesValues.INSTALLER_ROOTED:
                    if (!SuShell.getInstance().requestRoot()) {
                        AlertsUtils.showAlert(this, R.string.error, R.string.settings_main_use_root_error);
                        return;
                    }
                    installerSet = true;
                    break;
                case PreferencesValues.INSTALLER_SHIZUKU:
                    if (!Utils.apiIsAtLeast(Build.VERSION_CODES.M)) {
                        AlertsUtils.showAlert(this, R.string.error, R.string.settings_main_installer_error_shizuku_pre_m);
                        return;
                    }
                    if (!ShizukuClientHelper.isManagerV3Installed(requireContext())) {
                        AlertsUtils.showAlert(this, R.string.error, R.string.settings_main_installer_error_no_shizuku);
                        return;
                    }

                    installerSet = PermissionsUtils.checkAndRequestShizukuPermissions(this);
                    break;
            }
            if (installerSet) {
                mHelper.setInstaller(selectedItemIndex);
                updateInstallerSummary();
            }
            break;
    }
}
 
Example #17
Source File: PreferencesHelper.java    From SAI with GNU General Public License v3.0 4 votes vote down vote up
public int getFilePickerSortOrder() {
    return mPrefs.getInt(PreferencesKeys.FILE_PICKER_SORT_ORDER, DialogConfigs.SORT_ORDER_NORMAL);
}
 
Example #18
Source File: PreferencesHelper.java    From SAI with GNU General Public License v3.0 4 votes vote down vote up
public int getFilePickerSortBy() {
    return mPrefs.getInt(PreferencesKeys.FILE_PICKER_SORT_BY, DialogConfigs.SORT_BY_NAME);
}
 
Example #19
Source File: SampleShapeFile.java    From osmdroid with Apache License 2.0 4 votes vote down vote up
private void showPicker() {
    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    properties.selection_type = DialogConfigs.FILE_SELECT;
    properties.root = new File(DialogConfigs.DEFAULT_DIR);
    properties.error_dir = new File(DialogConfigs.DEFAULT_DIR);
    properties.offset = new File(DialogConfigs.DEFAULT_DIR);

    Set<String> registeredExtensions = ArchiveFileFactory.getRegisteredExtensions();
    registeredExtensions.add("shp");


    String[] ret = new String[registeredExtensions.size()];
    ret = registeredExtensions.toArray(ret);
    properties.extensions = ret;

    FilePickerDialog dialog = new FilePickerDialog(getContext(), properties);
    dialog.setTitle("Select a File");
    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
            //files is the array of the paths of files selected by the Application User.
            try {
                List<Overlay>  folder = ShapeConverter.convert(mMapView, new File(files[0]));
                for (final Overlay item : folder) {
                    if (item instanceof PolyOverlayWithIW) {
                        final PolyOverlayWithIW poly = (PolyOverlayWithIW)item;
                        poly.setDowngradePixelSizes(50, 25);
                        poly.setDowngradeDisplay(true);
                        final Paint paint = poly.getOutlinePaint();
                        paint.setStyle(Paint.Style.STROKE);
                        paint.setStrokeJoin(Paint.Join.ROUND);
                        paint.setStrokeCap(Paint.Cap.ROUND);
                    }
                }
                mMapView.getOverlayManager().addAll(folder);
                mMapView.invalidate();
            } catch (Exception e) {
                Toast.makeText(getActivity(), "Error importing file: " + e.getMessage(), Toast.LENGTH_LONG).show();
                Log.e(TAG, "error importing file from " + files[0], e);
            }

        }

    });
    dialog.show();

}
 
Example #20
Source File: Utils.java    From VIA-AI with MIT License 4 votes vote down vote up
private static void showFileDialog(final Context context, final Preference preference, String extension, String rootPath, final boolean isSelectFile)
{
    if (preference instanceof EditTextPreference) {
        ((EditTextPreference) preference).getDialog().dismiss();
    }

    DialogProperties properties = new DialogProperties();
    properties.selection_mode = DialogConfigs.SINGLE_MODE;
    if(isSelectFile) {
        properties.selection_type = DialogConfigs.FILE_SELECT;
        properties.extensions = new String[]{extension};
    }
    else {
        properties.selection_type = DialogConfigs.DIR_SELECT;
    }
    properties.root = new File(rootPath);
    properties.error_dir = new File("/storage/emulated/0/");
    properties.offset = new File("/storage");

    FilePickerDialog dialog = new FilePickerDialog(context, properties);
    if(isSelectFile) {
        dialog.setTitle("Select a <" + extension + "> File");
    }
    else {
        dialog.setTitle("Select a Folder");
    }
    dialog.setDialogSelectionListener(new DialogSelectionListener() {
        @Override
        public void onSelectedFilePaths(String[] files) {
            if (preference instanceof EditTextPreference) {
                ((EditTextPreference)preference).setText(files[0]); // Saves the text to the SharedPreferences.
                preference.setSummary("    " + files[0]);
            }
            else if (preference instanceof VideoSelectPreference) {
                ((VideoSelectPreference)preference).setVideoPath(files[0]); // Saves the text to the SharedPreferences.
            }
            else if (preference instanceof FileDialogPreference) {
                ((FileDialogPreference)preference).setPath(files[0]); // Saves the text to the SharedPreferences.
            }
        }
    });
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
    dialog.show();
}