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

Commit

Permalink
Update back button example
Browse files Browse the repository at this point in the history
fixes #106
  • Loading branch information
spacecowboy committed Aug 22, 2016
1 parent 9f61fa9 commit d20afa1
Show file tree
Hide file tree
Showing 20 changed files with 602 additions and 455 deletions.
2 changes: 1 addition & 1 deletion docs-src/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PygmentsOptions = ""
logo = ""
favicon = ""

permalink = ":slug"
# permalink = "#"

# Custom assets
custom_css = []
Expand Down
56 changes: 36 additions & 20 deletions docs-src/content/example/override_back_button.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ instantly exiting the activity, this is one approach you might take.
## Create an activity which overrides the back button and loads a custom fragment

```java
package com.nononsenseapps.filepicker.examples.backbutton;

import android.os.Environment;

import com.nononsenseapps.filepicker.AbstractFilePickerFragment;
import com.nononsenseapps.filepicker.FilePickerActivity;

import java.io.File;

public class BackHandlingFilePickerActivity extends FilePickerActivity {
Expand All @@ -41,11 +45,11 @@ public class BackHandlingFilePickerActivity extends FilePickerActivity {
// startPath is allowed to be null.
// In that case, default folder should be SD-card and not "/"
String path = (startPath != null ? startPath
: Environment.getExternalStorageDirectory().getPath());
: Environment.getExternalStorageDirectory().getPath());

currentFragment = new BackHandlingFilePickerFragment();
currentFragment.setArgs(path, mode, allowMultiple, allowDirCreate,
allowExistingFile, singleClick);
allowExistingFile, singleClick);
return currentFragment;
}

Expand All @@ -68,7 +72,10 @@ public class BackHandlingFilePickerActivity extends FilePickerActivity {
## In your custom fragment, implement the goUp and isBackTop methods

```java
package com.nononsenseapps.filepicker.examples.backbutton;

import com.nononsenseapps.filepicker.FilePickerFragment;

import java.io.File;

public class BackHandlingFilePickerFragment extends FilePickerFragment {
Expand All @@ -78,19 +85,15 @@ public class BackHandlingFilePickerFragment extends FilePickerFragment {
* But it will fall back on /.
*/
public File getBackTop() {
if (getArguments().containsKey(KEY_START_PATH)) {
return getPath(getArguments().getString(KEY_START_PATH));
} else {
return new File("/");
}
return getPath(getArguments().getString(KEY_START_PATH, "/"));
}

/**
*
* @return true if the current path is the startpath or /
*/
public boolean isBackTop() {
return 0 == compareFiles(mCurrentPath, getBackTop()) || 0 == compareFiles(mCurrentPath, new File("/"));
return 0 == compareFiles(mCurrentPath, getBackTop()) ||
0 == compareFiles(mCurrentPath, new File("/"));
}

/**
Expand All @@ -105,18 +108,31 @@ public class BackHandlingFilePickerFragment extends FilePickerFragment {
}
```

## And finally, add the following to your manifest
## Example manifest

And make sure `android-theme` points to the correct theme.
Make sure `android-theme` points to the correct theme.

```xml
<activity
android:name=".BackHandlingFilePickerActivity"
android:label="@string/select_file"
android:theme="@style/FilePickerTheme">
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.nononsenseapps.filepicker.examples">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Only needed to create sub directories. -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/FilePickerTheme">

<activity
android:name=".backbutton.BackHandlingFilePickerActivity"
android:label="Override back button"
android:theme="@style/FilePickerTheme">
</activity>
</application>

</manifest>
```
58 changes: 29 additions & 29 deletions docs/changelog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@

<meta name="description" content="An extensible and flexible file-picker for Android.">

<link rel="canonical" href="http://localhost:1313/NoNonsense-FilePicker/changelog/">
<link rel="canonical" href="http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/">

<meta name="author" content="SpaceCowboy">


<meta property="og:url" content="http://localhost:1313/NoNonsense-FilePicker/changelog/">
<meta property="og:url" content="http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/">
<meta property="og:title" content="NoNonsense FilePicker">

<meta name="apple-mobile-web-app-title" content="NoNonsense FilePicker">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

<link rel="shortcut icon" type="image/x-icon" href="http://localhost:1313/NoNonsense-FilePicker/images/favicon.ico">
<link rel="icon" type="image/x-icon" href="http://localhost:1313/NoNonsense-FilePicker/images/favicon.ico">
<link rel="shortcut icon" type="image/x-icon" href="http://spacecowboy.github.io/NoNonsense-FilePicker/images/favicon.ico">
<link rel="icon" type="image/x-icon" href="http://spacecowboy.github.io/NoNonsense-FilePicker/images/favicon.ico">

<style>
@font-face {
font-family: 'Icon';
src: url('http://localhost:1313/NoNonsense-FilePicker/fonts/icon.eot?52m981');
src: url('http://localhost:1313/NoNonsense-FilePicker/fonts/icon.eot?#iefix52m981')
src: url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.eot?52m981');
src: url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.eot?#iefix52m981')
format('embedded-opentype'),
url('http://localhost:1313/NoNonsense-FilePicker/fonts/icon.woff?52m981')
url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.woff?52m981')
format('woff'),
url('http://localhost:1313/NoNonsense-FilePicker/fonts/icon.ttf?52m981')
url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.ttf?52m981')
format('truetype'),
url('http://localhost:1313/NoNonsense-FilePicker/fonts/icon.svg?52m981#icon')
url('http://spacecowboy.github.io/NoNonsense-FilePicker/fonts/icon.svg?52m981#icon')
format('svg');
font-weight: normal;
font-style: normal;
}
</style>

<link rel="stylesheet" href="http://localhost:1313/NoNonsense-FilePicker/stylesheets/application.css">
<link rel="stylesheet" href="http://localhost:1313/NoNonsense-FilePicker/stylesheets/temporary.css">
<link rel="stylesheet" href="http://localhost:1313/NoNonsense-FilePicker/stylesheets/palettes.css">
<link rel="stylesheet" href="http://localhost:1313/NoNonsense-FilePicker/stylesheets/highlight/highlight.css">
<link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/application.css">
<link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/temporary.css">
<link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/palettes.css">
<link rel="stylesheet" href="http://spacecowboy.github.io/NoNonsense-FilePicker/stylesheets/highlight/highlight.css">



Expand All @@ -66,7 +66,7 @@
</style>


<script src="http://localhost:1313/NoNonsense-FilePicker/javascripts/modernizr.js"></script>
<script src="http://spacecowboy.github.io/NoNonsense-FilePicker/javascripts/modernizr.js"></script>



Expand Down Expand Up @@ -176,7 +176,7 @@



<a title="Readme" href="http://localhost:1313/NoNonsense-FilePicker/readme/">
<a title="Readme" href="http://spacecowboy.github.io/NoNonsense-FilePicker/readme/">

Readme
</a>
Expand All @@ -193,7 +193,7 @@



<a class="current" title="Changelog" href="http://localhost:1313/NoNonsense-FilePicker/changelog/">
<a class="current" title="Changelog" href="http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/">

Changelog
</a>
Expand All @@ -213,7 +213,7 @@



<a title="License" href="http://localhost:1313/NoNonsense-FilePicker/license/">
<a title="License" href="http://spacecowboy.github.io/NoNonsense-FilePicker/license/">

License
</a>
Expand All @@ -234,7 +234,7 @@



<a title="Change the sort order" href="http://localhost:1313/NoNonsense-FilePicker/example/sortorder/">
<a title="Change the sort order" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/sortorder/">

Change the sort order
</a>
Expand All @@ -246,7 +246,7 @@



<a title="Filter based on file extension" href="http://localhost:1313/NoNonsense-FilePicker/example/filter_file_extension/">
<a title="Filter based on file extension" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/filter_file_extension/">

Filter based on file extension
</a>
Expand All @@ -258,7 +258,7 @@



<a title="Custom item layout" href="http://localhost:1313/NoNonsense-FilePicker/example/custom_item_layout/">
<a title="Custom item layout" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/custom_item_layout/">

Custom item layout
</a>
Expand All @@ -270,7 +270,7 @@



<a title="Override the back button" href="http://localhost:1313/NoNonsense-FilePicker/example/override_back_button/">
<a title="Override the back button" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/override_back_button/">

Override the back button
</a>
Expand All @@ -282,7 +282,7 @@



<a title="Override selection behavior" href="http://localhost:1313/NoNonsense-FilePicker/example/override_selection_behavior/">
<a title="Override selection behavior" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/override_selection_behavior/">

Override selection behavior
</a>
Expand All @@ -294,7 +294,7 @@



<a title="Standalone fragment" href="http://localhost:1313/NoNonsense-FilePicker/example/standalone_fragment/">
<a title="Standalone fragment" href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/standalone_fragment/">

Standalone fragment
</a>
Expand Down Expand Up @@ -718,7 +718,7 @@ <h2 id="v0-9-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-v0-9-2014-0
<nav class="pagination" aria-label="Footer">
<div class="previous">

<a href="http://localhost:1313/NoNonsense-FilePicker/example/sortorder/" title="Change the sort order">
<a href="http://spacecowboy.github.io/NoNonsense-FilePicker/example/sortorder/" title="Change the sort order">
<span class="direction">
Previous
</span>
Expand All @@ -738,7 +738,7 @@ <h2 id="v0-9-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-v0-9-2014-0

<div class="next">

<a href="http://localhost:1313/NoNonsense-FilePicker/" title="Readme">
<a href="http://spacecowboy.github.io/NoNonsense-FilePicker/" title="Readme">
<span class="direction">
Next
</span>
Expand Down Expand Up @@ -777,12 +777,12 @@ <h2 id="v0-9-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-v0-9-2014-0

<script>

var base_url = 'http:\/\/localhost:1313\/NoNonsense-FilePicker\/';
var base_url = 'http:\/\/spacecowboy.github.io\/NoNonsense-FilePicker\/';
var repo_id = 'spacecowboy\/NoNonsense-FilePicker';

</script>

<script src="http://localhost:1313/NoNonsense-FilePicker/javascripts/application.js"></script>
<script src="http://spacecowboy.github.io/NoNonsense-FilePicker/javascripts/application.js"></script>


<script>
Expand Down Expand Up @@ -817,7 +817,7 @@ <h2 id="v0-9-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-v0-9-2014-0
a.setAttribute("class", "headerlink");
a.setAttribute("href", "#" + headers[i].id);
a.setAttribute("title", "Permanent link")
a.innerHTML = ":slug";
a.innerHTML = "";
headers[i].appendChild(a);
}
}
Expand All @@ -827,5 +827,5 @@ <h2 id="v0-9-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-v0-9-2014-0

<script src="//gohugo.io/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script data-no-instant>document.write('<script src="/livereload.js?mindelay=10"></' + 'script>')</script></body>
</body>
</html>
8 changes: 4 additions & 4 deletions docs/changelog/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Changelogs on NoNonsense FilePicker</title>
<link>http://localhost:1313/NoNonsense-FilePicker/changelog/</link>
<link>http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/</link>
<description>Recent content in Changelogs on NoNonsense FilePicker</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-us</language>
<lastBuildDate>Sat, 16 Jul 2016 17:06:45 +0200</lastBuildDate>
<atom:link href="http://localhost:1313/NoNonsense-FilePicker/changelog/index.xml" rel="self" type="application/rss+xml" />
<atom:link href="http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/index.xml" rel="self" type="application/rss+xml" />

<item>
<title>ChangeLog</title>
<link>http://localhost:1313/NoNonsense-FilePicker/changelog/</link>
<link>http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/</link>
<pubDate>Sat, 16 Jul 2016 17:06:45 +0200</pubDate>

<guid>http://localhost:1313/NoNonsense-FilePicker/changelog/</guid>
<guid>http://spacecowboy.github.io/NoNonsense-FilePicker/changelog/</guid>
<description>

&lt;h2 id=&#34;3-0-0-https-github.aaakk.us.kg-spacecowboy-nononsense-filepicker-tree-3-0-0-2016-07-03&#34;&gt;&lt;a href=&#34;https://github.com/spacecowboy/NoNonsense-FilePicker/tree/3.0.0&#34;&gt;3.0.0&lt;/a&gt; (2016-07-03)&lt;/h2&gt;
Expand Down
Loading

0 comments on commit d20afa1

Please sign in to comment.