// Path: src/org/oscim/app/filefilter/ValidFileFilter.java
// public interface ValidFileFilter extends FileFilter {
// 	/**
// 	 * @return the result of the last {@link #accept} call (might be null).
// 	 */
// 	OpenResult getFileOpenResult();
// }


import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;
import java.util.Comparator;
import org.oscim.app.R;
import org.oscim.app.filefilter.ValidFileFilter;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
/*
 * Copyright 2010, 2011, 2012 mapsforge.org
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.oscim.app.filepicker;




/**
 * A FilePicker displays the contents of directories. The user can navigate
 * within the file system and select a single
 * file whose path is then returned to the calling activity. The ordering of
 * directory contents can be specified via
 * {@link #setFileComparator(Comparator)}. By default subfolders and files are
 * grouped and each group is ordered
 * alphabetically.
 * <p>
 * A {@link FileFilter} can be activated via
 * {@link #setFileDisplayFilter(FileFilter)} to restrict the displayed files and
 * folders. By default all files and folders are visible.
 * <p>
 * Another <code>FileFilter</code> can be applied via
 * {@link #setFileSelectFilter(ValidFileFilter)} to check if a selected file is
 * valid before its path is returned. By default all files are considered as
 * valid and can be selected.
 */
public class FilePicker extends Activity implements AdapterView.OnItemClickListener {
	/**
	 * The name of the extra data in the result {@link Intent}.
	 */
	public static final String SELECTED_FILE = "selectedFile";

	private static final String CURRENT_DIRECTORY = "currentDirectory";
	private static final String DEFAULT_DIRECTORY = "/";
	private static final int DIALOG_FILE_INVALID = 0;
	// private static final int DIALOG_FILE_SELECT = 1;
	private static Comparator<File> fileComparator = getDefaultFileComparator();
	private static FileFilter fileDisplayFilter;
// Path: src/org/oscim/app/filefilter/ValidFileFilter.java
// public interface ValidFileFilter extends FileFilter {
// 	/**
// 	 * @return the result of the last {@link #accept} call (might be null).
// 	 */
// 	OpenResult getFileOpenResult();
// }


// Path: src/org/oscim/app/filepicker/FilePicker.java
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import java.io.File;
import java.io.FileFilter;
import java.util.Arrays;
import java.util.Comparator;
import org.oscim.app.R;
import org.oscim.app.filefilter.ValidFileFilter;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;

/*
 * Copyright 2010, 2011, 2012 mapsforge.org
 *
 * This program is free software: you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with
 * this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.oscim.app.filepicker;




/**
 * A FilePicker displays the contents of directories. The user can navigate
 * within the file system and select a single
 * file whose path is then returned to the calling activity. The ordering of
 * directory contents can be specified via
 * {@link #setFileComparator(Comparator)}. By default subfolders and files are
 * grouped and each group is ordered
 * alphabetically.
 * <p>
 * A {@link FileFilter} can be activated via
 * {@link #setFileDisplayFilter(FileFilter)} to restrict the displayed files and
 * folders. By default all files and folders are visible.
 * <p>
 * Another <code>FileFilter</code> can be applied via
 * {@link #setFileSelectFilter(ValidFileFilter)} to check if a selected file is
 * valid before its path is returned. By default all files are considered as
 * valid and can be selected.
 */
public class FilePicker extends Activity implements AdapterView.OnItemClickListener {
	/**
	 * The name of the extra data in the result {@link Intent}.
	 */
	public static final String SELECTED_FILE = "selectedFile";

	private static final String CURRENT_DIRECTORY = "currentDirectory";
	private static final String DEFAULT_DIRECTORY = "/";
	private static final int DIALOG_FILE_INVALID = 0;
	// private static final int DIALOG_FILE_SELECT = 1;
	private static Comparator<File> fileComparator = getDefaultFileComparator();
	private static FileFilter fileDisplayFilter;
	private static ValidFileFilter fileSelectFilter;