An open API service indexing awesome lists of open source software.

https://github.com/lemberg/directory-selector-dialog-preference


https://github.com/lemberg/directory-selector-dialog-preference

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

![demo](images/demo.gif)

# Description
The project contains an Android library which provides directory selection functionality using **DialogFragment** and **DialogPreference** and a Demo application.

## How to use
Import the library into your project and use it in the following ways:
### Using **DialogFragment**
1. Implement **DirectoryDialog.Listener** interface in your activity:

```java
public class MainActivity extends Activity implements DirectoryDialog.Listener {

@Override
public void onDirectorySelected(File dir) {
}

@Override
public void onCancelled() {
}

// ...
}
```
2. Open directory selector dialog when needed:

```java
DialogFragment dialog = DirectoryDialog.newInstance(settings.getStorePath());
dialog.show(getFragmentManager(), "directoryDialog");
```

### Using **DialogPreference**
1. Define directory preference entry in your preferences file:

```xml

```
2. Implement your custom **PreferenceActivity** activity which will use our preference file and open it when needed (most likely on menu item click). Refer to **SettingsActivity** in Demo application for example. Note how the preference "summary" is updating there.
3. Clicking on **DirectoryPreference** entry will open a directory selection dialog. Selecting a directory will automatically save it in shared preferences using configured key.

## License
The project is available under MIT license. See the file **license** with the full license text.

## Compatibility
Minimum SDK version is 14.