Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Picker now has more options
Browse files Browse the repository at this point in the history
Removed onlyDirs in favor of a mode variable. Now possible to
select between: Files, Dirs, or Both.

The ability to create directories is now an option as well
which defaults to false.

Fixes #1
Fixes #2
  • Loading branch information
spacecowboy committed Apr 1, 2014
1 parent 898a0cc commit 26b0595
Show file tree
Hide file tree
Showing 11 changed files with 394 additions and 166 deletions.
21 changes: 19 additions & 2 deletions gradle.properties
@@ -1,7 +1,24 @@
#
# Copyright (c) 2014 Jonas Kalderstam
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

# Project-wide Gradle settings.

VERSION_NAME=1.0
VERSION_CODE=1
VERSION_NAME=1.1-SNAPSHOT
VERSION_CODE=2
GROUP=com.nononsenseapps

POM_DESCRIPTION=An extendable Android file/directory-picker you can include in your app
Expand Down
Expand Up @@ -59,17 +59,20 @@
public abstract class AbstractFilePickerActivity<T> extends Activity implements
AbstractFilePickerFragment.OnFilePickedListener {
public static final String EXTRA_START_PATH = "nononsense.intent" +
".extrastart_path";
public static final String EXTRA_ONLY_DIRS = "nononsense.intent.only_dirs";
".START_PATH";
public static final String EXTRA_MODE = "nononsense.intent.MODE";
public static final String EXTRA_ALLOW_CREATE_DIR = "nononsense.intent" +
".ALLOW_CREATE_DIR";
// For compatibility
public static final String EXTRA_ALLOW_MULTIPLE = "android.intent.extra" +
".ALLOW_MULTIPLE";
public static final String EXTRA_PATHS = "nononsense.intent.paths";
public static final String EXTRA_PATHS = "nononsense.intent.PATHS";
private static final String TAG = "filepicker_fragment";


private String startPath = null;
protected boolean onlyDirs = false;
protected int mode = AbstractFilePickerFragment.MODE_FILE;
protected boolean allowCreateDir = false;
protected boolean allowMultiple = false;

@Override
Expand All @@ -84,15 +87,17 @@ protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();
if (intent != null) {
startPath = intent.getStringExtra(EXTRA_START_PATH);
onlyDirs = intent.getBooleanExtra(EXTRA_ONLY_DIRS, onlyDirs);
mode = intent.getIntExtra(EXTRA_MODE, mode);
allowCreateDir = intent.getBooleanExtra(EXTRA_ALLOW_CREATE_DIR,
allowCreateDir);
allowMultiple = intent.getBooleanExtra(EXTRA_ALLOW_MULTIPLE, allowMultiple);
}

FragmentManager fm = getFragmentManager();
AbstractFilePickerFragment<T> fragment = (AbstractFilePickerFragment<T>) fm.findFragmentByTag(TAG);

if (fragment == null) {
fragment = getFragment(startPath, onlyDirs, allowMultiple);
fragment = getFragment(startPath, mode, allowMultiple, allowCreateDir);
fm.beginTransaction().replace(R.id.fragment,
fragment, TAG).commit();
}
Expand Down Expand Up @@ -127,10 +132,11 @@ private void setupActionBar() {

protected abstract String getWindowTitle();

protected abstract AbstractFilePickerFragment<T> getFragment(final String
startPath,
final boolean onlyDirs,
final boolean allowMultiple);
protected abstract AbstractFilePickerFragment<T>
getFragment(final String startPath,
final int mode,
final boolean allowMultiple,
final boolean allowCreateDir);



Expand Down

0 comments on commit 26b0595

Please sign in to comment.