{ "id": "62474", "key": "TIMOB-1842", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11225", "name": "Release 1.5.0", "archived": true, "released": true, "releaseDate": "2010-12-14" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2011-04-17T01:57:19.000+0000", "created": "2011-04-15T03:03:42.000+0000", "priority": { "name": "Trivial", "id": "5" }, "labels": [ "android", "feature", "file", "spaceavailable" ], "versions": [], "issuelinks": [], "assignee": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2011-04-17T01:57:19.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

right now we just have a place holder of 9999999L

{html}", "attachment": [], "flagged": false, "summary": "Android: Implement spaceAvailable() for File", "creator": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "126803", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [bdee2871d8f32838edd9840e39ce4035088e3a43])\nimplement spaceAvailable() for android TiFile [#1842\nstate:fixed-in-qa] \nhttp://github.com/appcelerator/titanium_mobile/commit/bdee2871d8f32...

{html}", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:42.000+0000", "updated": "2011-04-15T03:03:42.000+0000" }, { "id": "126804", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

using the code below I get binary return, I believe I should be\nseeing a value returning the available space?

\n

var win = Titanium.UI.currentWindow;
\nTitanium.UI.setBackgroundColor('white');

\n

var dir =\nTitanium.Filesystem.getFile(Titanium.Filesystem.resourcesDirectory);
\nvar l = Titanium.UI.createLabel({text:'value should be updated',\nwidth:300, height:'auto', textAlign:'center'});
\nl.text='spaceAvailable = ' + dir.spaceAvailable();
\nwin.add(l);

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:42.000+0000", "updated": "2011-04-15T03:03:42.000+0000" }, { "id": "126805", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Commit bdee2871d8f32838edd9840e39ce4035088e3a43 implemented this\nmethod using file.getFreeSpace() instead of returning a hardcoded\nnumber, but it doesn't appear to actually work in my testing.

\n

java.io.File.getFreeSpace() is new in JDK 1.6, and although I\ncan compile the runtime just fine, since it isn't actually present\nin Android, my app fails when attempting to call it.

\n

\nhttp://download.oracle.com/javase/6/docs/api/java/io/File.html#getF...

\n

http://developer.android.com/reference/java/io/File.html

\n
\nE/AndroidRuntime(  792): FATAL EXCEPTION: kroll$1\nE/AndroidRuntime(  792): java.lang.NoSuchMethodError: java.io.File.getFreeSpace\nE/AndroidRuntime(  792):    at org.appcelerator.titanium.io.TiFile.spaceAvailable(TiFile.java:195)\nE/AndroidRuntime(  792):    at ti.modules.titanium.filesystem.FileProxy.spaceAvailable(FileProxy.java:231)\nE/AndroidRuntime(  792):    at ti.modules.titanium.filesystem.FileProxyBindingGen$15.invoke(FileProxyBindingGen.java:498)\nE/AndroidRuntime(  792):    at org.appcelerator.kroll.KrollMethod.call(KrollMethod.java:46)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1711)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:854)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:426)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3161)\nE/AndroidRuntime(  792):    at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162)\nE/AndroidRuntime(  792):    at org.appcelerator.titanium.kroll.KrollCallback$1.run(KrollCallback.java:97)\nE/AndroidRuntime(  792):    at android.os.Handler.handleCallback(Handler.java:587)\nE/AndroidRuntime(  792):    at android.os.Handler.dispatchMessage(Handler.java:92)\nE/AndroidRuntime(  792):    at android.os.Looper.loop(Looper.java:123)\nE/AndroidRuntime(  792):    at org.appcelerator.titanium.kroll.KrollHandlerThread.run(KrollHandlerThread.java:73)\n
{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:43.000+0000", "updated": "2011-04-15T03:03:43.000+0000" }, { "id": "126806", "author": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [dac0b4dec18678c1f5e9701fe2bdae7f5bb24895])\nclean up singleton modules and event managers in context onDestroy,\nthis lets event listeners work when the app has been relaunched.\nremoved impl of File.spaceAvailable() (it was Java6 only, we'll\nneed to find another way) [#1238] [#1842]\n\nhttp://github.com/appcelerator/titanium_mobile/commit/dac0b4dec1867...

{html}", "updateAuthor": { "name": "mculpepper", "key": "mculpepper", "displayName": "Marshall Culpepper", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:43.000+0000", "updated": "2011-04-15T03:03:43.000+0000" }, { "id": "126807", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Looks like this can be done with android.os.StatFs:

\n

http://developer.android.com/reference/android/os/StatFs.html

\n

I'll throw a quick patch together.

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:43.000+0000", "updated": "2011-04-15T03:03:43.000+0000" }, { "id": "126808", "author": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Branch:
\nhttp://github.com/brion/titanium_mobile/tree/spaceAvailable

\n

Commit:
\n\nhttp://github.com/brion/titanium_mobile/commit/ab4deb35f057165dd5a9...

\n

Pull request:
\nhttp://github.com/appcelerator/titanium_mobile/pull/10

\n

Quick note on something I noticed while testing --\nTi.File.spaceAvailable() is actually documented as returning a\nboolean rather than returning a numeric byte count. On iOS I'm\nindeed getting just true/false out of it... Zero/non-zero should\nact correctly in boolean context, but is there a reason we're\nreturning a number on Android and a boolean on iOS and in the\ndocumentation?

{html}", "updateAuthor": { "name": "brionvibber", "key": "brionvibber", "displayName": "Brion Vibber", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:43.000+0000", "updated": "2011-04-15T03:03:43.000+0000" }, { "id": "126809", "author": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "body": "{html}

(from [e9b35665142d28eddc2f73f1aacd6dc37f357732])\n[#1842 state:fixed-in-qa] Android implementation\nof TiFile.spaceAvailable using android.os.StatFs, as\njava.io.File.getFreeSpace isn't available in current Android.

\n

Signed-off-by: marshall mculpepper@appcelerator.com
\n\nhttp://github.com/appcelerator/titanium_mobile/commit/e9b35665142d2...

{html}", "updateAuthor": { "name": "jhaynie", "key": "jhaynie", "displayName": "Jeff Haynie", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:43.000+0000", "updated": "2011-04-15T03:03:43.000+0000" }, { "id": "126810", "author": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

implemented, logging a new bug about the values being reported\nand platform/doc inconsistencies.

{html}", "updateAuthor": { "name": "thomashuelbert", "key": "thomashuelbert", "displayName": "Thomas Huelbert", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:03:44.000+0000", "updated": "2011-04-15T03:03:44.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }