Code Monkey home page Code Monkey logo

Comments (15)

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

All references to sdcard with Basic.filePath which is assigned a value in onCreate() in Basic.java.
filePath = Environment.getExternalStorageDirectory().getPath() + "/" + AppPath;

from basic.

mougino avatar mougino commented on June 30, 2024

Paul, if that is ok with you I would like to reopen this issue. Because the following has been solved:
Android suggests to not hardcode "/sdcard/" but use Environment.getExternalStorageDirectory().getPath() instead

But not this second aspect:
Currently IDE can load programs only from /sdcard it would be an enhancement for the user to choose another place, typically an external sdcard (when /sdcard is used for internal memory)

I have been meeting the issue with a Samsung Galaxy S III, and now with a Sony Xperia Go. BASIC! should propose to load programs from external SD-Card and not only internal memory. Here is a Java code snippet to list all the SD-Cards: http://renzhi.ca/2012/02/03/how-to-list-all-sd-cards-on-android/
I will try to look at how to implement a new preference in BASIC! IDE this week-end

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

Do you only want to be able to change the program LOAD path? Or do you want to change the base path for all storage access commands?

Do you want BASIC! to initialize all of its directories to a different card. If so, how to your propose telling BASIC! to do this?

Maybe can provide some commands that would illustrate what it is you wish to accomplish.

from basic.

mougino avatar mougino commented on June 30, 2024

Yes you are right, I would in fact like to change the base path for all storage access commands. Basically change the Environment.getExternalStorageDirectory().getPath() value to any sd-card chosen by the user.
This would be done by a "base path" or "base drive" or "root drive" preference in the IDE (via menu touch) containing the list of /mnt resources made available by this renzhi.ca snippet

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

The base path is set the first time BASIC! (or a derived APK) is loaded after a new release. Is it your idea that every time BASIC! (or a derived APK) is first loaded, the user is asked where to store thing?

from basic.

mougino avatar mougino commented on June 30, 2024

We could do that, but it wouldn't be so good: ask something at first BASIC! start would go over most users' heads. I was thinking more to start by assuming that baseDrive=Environment.getExternalStorageDirectory().getPath() (same as currently) but offer a preference in the IDE menu for user to change that: present the list of sd-cards and if user selects one different from Environment.getExternalStorageDirectory().getPath() then create the base folders and copy the initial resource, or and it could be acceptable I think, save the preference and simply exit the IDE (after a small warning popup, maybe) then initialize folders and resource at next start (automatic or launched by user, TBC what is doable).

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

Please explain your term IDE in this context.

I think you are saying that Menu->Preferences should contain an entry for selecting available storage devices. The user selects one.

How do you propose BASIC! communicate to itself that it is to initialize/use this new base directory the next time it starts?

Edited: I think I can see how to do that communication using saved preferences. I still need to figure out how to save present/save a value that was not predefined at compile time. I am pretty sure it can be done.

from basic.

mougino avatar mougino commented on June 30, 2024

Yes sorry, IDE = Integrated Environment Development = what I call RFO-BASIC! application (as opposed to a BASIC! program compiled to an APK).
You got it right, this would be a new entry in Menu->Preferences.
I have been digging in the Editor.java code but am a little lost of how to implement this (the initialize part I mean), particularly how the preferences are stored

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

Look at Settings.java.

from basic.

mougino avatar mougino commented on June 30, 2024

On a related note is it normal that in LoadFile.java there is still a hard-coded "/sdcard" ? line 147 sdDir = new File("/sdcard/"); shouldn't we make use of Environment.getExternalStorageDirectory().getPath() ?

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

Apparently I did not get every /sdcard/ in the full IDE. I will so a search and replace of the whole things.

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

This issue needs to be re-opened. I think that the changing of the base drive can be done using preferences.

from basic.

jMarcS avatar jMarcS commented on June 30, 2024

I got an error: In Editor, selected "Load" from menu. "Load File" app header with blank screen, error Toast "System Error. File not directory." issued by LoadFile.Load1().

Debug:
My "git pull" got this. I uninstalled BASIC!, built with this change, and installed from Eclipse (debug run).

Basic.onCreate() calls Settings.getBaseDrive() which returns "0". "0" is the default value if the Settings Activity was never run. Basic.onCreate() compares "0" to "none". "none" is the default value if Settings.setBaseDrive finds no external drive. Compare fails, so Basic.basePath is set to "0" and Basic.filePath is set to "0/rfo-basic".

The rest is obvious: Editor.loadFile() starts LoadFile Activity. LoadFile.Load1() uses Basic.basePath, but there is no path "/0".

I didn't commit a fix because I don't know your intention regarding the initialization of a new preference. My workaround was to patch Settings.getBaseDrive to use "none" as the default string. This may not be appropriate if you're trying to distinguish "never initialized" from "there really isn't an external sd".

Is there a reason to use sdDir.getAbsoluteFile() + "/" + Basic.AppPath instead of Basic.filePath (which is Basic.basePath + "/" + Basic.AppPath)?

from basic.

RFO-BASIC avatar RFO-BASIC commented on June 30, 2024

The first problem is easily fixed by changing line 162 of Setting.java:
from: .getString("base_drive_pref", "0");
to: .getString("base_drive_pref", "none");

When Basic.java is started it will see "none" and use "Environment.getExternalStorageDirectory().getPath();" for the base path.

I will commit this one line change.

No, there is no reason why Load1 is the way it is other than historical. The code you mentioned will work just as well.

from basic.

jMarcS avatar jMarcS commented on June 30, 2024

Released in v01.72

from basic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.