Skip to content

Commit 9546159

Browse files
committed
change how folders are handled on android sdk
1 parent 6a0ce4f commit 9546159

File tree

5 files changed

+187
-126
lines changed

5 files changed

+187
-126
lines changed

app/src/processing/app/Base.java

Lines changed: 66 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,8 @@ static protected File getDefaultSketchbookFolder() {
19281928
} catch (Exception e) { }
19291929

19301930
if (sketchbookFolder == null) {
1931-
sketchbookFolder = promptSketchbookLocation();
1931+
showError("No sketchbook",
1932+
"Problem while trying to get the sketchbook", null);
19321933
}
19331934

19341935
// create the folder if it doesn't exist already
@@ -1947,33 +1948,33 @@ static protected File getDefaultSketchbookFolder() {
19471948
}
19481949

19491950

1950-
/**
1951-
* Check for a new sketchbook location.
1952-
*/
1953-
static protected File promptSketchbookLocation() {
1954-
// Most often this will happen on Linux, so default to their home dir.
1955-
File folder = new File(System.getProperty("user.home"), "sketchbook");
1956-
String prompt = "Select a folder to place sketches...";
1957-
1958-
// FolderSelector fs = new FolderSelector(prompt, folder, new Frame());
1959-
// folder = fs.getFolder();
1960-
folder = Base.selectFolder(prompt, folder, new Frame());
1961-
1962-
// folder = Base.selectFolder(prompt, folder, null);
1963-
// PApplet.selectFolder(prompt,
1964-
// "promptSketchbookCallback", dflt,
1965-
// Preferences.this, dialog);
1966-
1967-
if (folder == null) {
1968-
System.exit(0);
1969-
}
1970-
// Create the folder if it doesn't exist already
1971-
if (!folder.exists()) {
1972-
folder.mkdirs();
1973-
return folder;
1974-
}
1975-
return folder;
1976-
}
1951+
// /**
1952+
// * Check for a new sketchbook location.
1953+
// */
1954+
// static protected File promptSketchbookLocation() {
1955+
// // Most often this will happen on Linux, so default to their home dir.
1956+
// File folder = new File(System.getProperty("user.home"), "sketchbook");
1957+
// String prompt = "Select a folder to place sketches...";
1958+
//
1959+
//// FolderSelector fs = new FolderSelector(prompt, folder, new Frame());
1960+
//// folder = fs.getFolder();
1961+
// folder = Base.selectFolder(prompt, folder, new Frame());
1962+
//
1963+
//// folder = Base.selectFolder(prompt, folder, null);
1964+
//// PApplet.selectFolder(prompt,
1965+
//// "promptSketchbookCallback", dflt,
1966+
//// Preferences.this, dialog);
1967+
//
1968+
// if (folder == null) {
1969+
// System.exit(0);
1970+
// }
1971+
// // Create the folder if it doesn't exist already
1972+
// if (!folder.exists()) {
1973+
// folder.mkdirs();
1974+
// return folder;
1975+
// }
1976+
// return folder;
1977+
// }
19771978

19781979

19791980
// .................................................................
@@ -2066,43 +2067,43 @@ static public void openFolder(File file) {
20662067
// }
20672068

20682069

2069-
static class FolderSelector {
2070-
File folder;
2071-
boolean ready;
2072-
2073-
FolderSelector(String prompt, File defaultFile, Frame parentFrame) {
2074-
PApplet.selectFolder(prompt, "callback", defaultFile, this, parentFrame);
2075-
}
2076-
2077-
public void callback(File folder) {
2078-
this.folder = folder;
2079-
ready = true;
2080-
}
2081-
2082-
boolean isReady() {
2083-
return ready;
2084-
}
2085-
2086-
/** block until the folder is available */
2087-
File getFolder() {
2088-
while (!ready) {
2089-
try {
2090-
Thread.sleep(100);
2091-
} catch (InterruptedException e) { }
2092-
}
2093-
return folder;
2094-
}
2095-
}
2096-
2097-
2098-
/**
2099-
* Blocking version of folder selection. Runs and sleeps until an answer
2100-
* comes back. Avoid using: try to make things work with the async
2101-
* selectFolder inside PApplet instead.
2102-
*/
2103-
static public File selectFolder(String prompt, File folder, Frame frame) {
2104-
return new FolderSelector(prompt, folder, frame).getFolder();
2105-
}
2070+
// static class FolderSelector {
2071+
// File folder;
2072+
// boolean ready;
2073+
//
2074+
// FolderSelector(String prompt, File defaultFile, Frame parentFrame) {
2075+
// PApplet.selectFolder(prompt, "callback", defaultFile, this, parentFrame);
2076+
// }
2077+
//
2078+
// public void callback(File folder) {
2079+
// this.folder = folder;
2080+
// ready = true;
2081+
// }
2082+
//
2083+
// boolean isReady() {
2084+
// return ready;
2085+
// }
2086+
//
2087+
// /** block until the folder is available */
2088+
// File getFolder() {
2089+
// while (!ready) {
2090+
// try {
2091+
// Thread.sleep(100);
2092+
// } catch (InterruptedException e) { }
2093+
// }
2094+
// return folder;
2095+
// }
2096+
// }
2097+
//
2098+
//
2099+
// /**
2100+
// * Blocking version of folder selection. Runs and sleeps until an answer
2101+
// * comes back. Avoid using: try to make things work with the async
2102+
// * selectFolder inside PApplet instead.
2103+
// */
2104+
// static public File selectFolder(String prompt, File folder, Frame frame) {
2105+
// return new FolderSelector(prompt, folder, frame).getFolder();
2106+
// }
21062107

21072108

21082109
// .................................................................

app/src/processing/app/Platform.java

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,44 +33,44 @@
3333
/**
3434
* Used by Base for platform-specific tweaking, for instance finding the
3535
* sketchbook location using the Windows registry, or OS X event handling.
36-
*
37-
* The methods in this implementation are used by default, and can be
38-
* overridden by a subclass, if loaded by Base.main().
39-
*
36+
*
37+
* The methods in this implementation are used by default, and can be
38+
* overridden by a subclass, if loaded by Base.main().
39+
*
4040
* These methods throw vanilla-flavored Exceptions, so that error handling
41-
* occurs inside Base.
42-
*
43-
* There is currently no mechanism for adding new platforms, as the setup is
44-
* not automated. We could use getProperty("os.arch") perhaps, but that's
45-
* debatable (could be upper/lowercase, have spaces, etc.. basically we don't
41+
* occurs inside Base.
42+
*
43+
* There is currently no mechanism for adding new platforms, as the setup is
44+
* not automated. We could use getProperty("os.arch") perhaps, but that's
45+
* debatable (could be upper/lowercase, have spaces, etc.. basically we don't
4646
* know if name is proper Java package syntax.)
4747
*/
4848
public class Platform {
4949
Base base;
50-
51-
50+
51+
5252
/**
5353
* Set the default L & F. While I enjoy the bounty of the sixteen possible
54-
* exception types that this UIManager method might throw, I feel that in
54+
* exception types that this UIManager method might throw, I feel that in
5555
* just this one particular case, I'm being spoiled by those engineers
5656
* at Sun, those Masters of the Abstractionverse. It leaves me feeling sad
5757
* and overweight. So instead, I'll pretend that I'm not offered eleven dozen
5858
* ways to report to the user exactly what went wrong, and I'll bundle them
59-
* all into a single catch-all "Exception". Because in the end, all I really
59+
* all into a single catch-all "Exception". Because in the end, all I really
6060
* care about is whether things worked or not. And even then, I don't care.
61-
*
61+
*
6262
* @throws Exception Just like I said.
6363
*/
6464
public void setLookAndFeel() throws Exception {
6565
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
6666
}
67-
68-
67+
68+
6969
public void init(Base base) {
7070
this.base = base;
7171
}
72-
73-
72+
73+
7474
public File getSettingsFolder() throws Exception {
7575
// otherwise make a .processing directory int the user's home dir
7676
File home = new File(System.getProperty("user.home"));
@@ -92,32 +92,32 @@ public File getSettingsFolder() throws Exception {
9292
}
9393
*/
9494
}
95-
95+
9696

9797
/**
98-
* @return null if not overridden, which will cause a prompt to show instead.
98+
* @return null if not overridden, which will cause a prompt to show instead.
9999
* @throws Exception
100100
*/
101101
public File getDefaultSketchbookFolder() throws Exception {
102-
return null;
102+
return new File(System.getProperty("user.dir"), "sketchbook");
103103
}
104-
105-
104+
105+
106106
public void openURL(String url) throws Exception {
107107
String launcher = Preferences.get("launcher");
108108
if (launcher != null) {
109109
Runtime.getRuntime().exec(new String[] { launcher, url });
110110
} else {
111111
showLauncherWarning();
112-
}
112+
}
113113
}
114114

115115

116116
public boolean openFolderAvailable() {
117117
return Preferences.get("launcher") != null;
118118
}
119-
120-
119+
120+
121121
public void openFolder(File file) throws Exception {
122122
String launcher = Preferences.get("launcher");
123123
if (launcher != null) {
@@ -127,11 +127,11 @@ public void openFolder(File file) throws Exception {
127127
showLauncherWarning();
128128
}
129129
}
130-
131-
132-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133-
134-
130+
131+
132+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133+
134+
135135
public interface CLibrary extends Library {
136136
CLibrary INSTANCE = (CLibrary)Native.loadLibrary("c", CLibrary.class);
137137
int setenv(String name, String value, int overwrite);
@@ -140,13 +140,13 @@ public interface CLibrary extends Library {
140140
int putenv(String string);
141141
}
142142

143-
143+
144144
public void setenv(String variable, String value) {
145145
CLibrary clib = CLibrary.INSTANCE;
146146
clib.setenv(variable, value, 1);
147147
}
148148

149-
149+
150150
public String getenv(String variable) {
151151
CLibrary clib = CLibrary.INSTANCE;
152152
return clib.getenv(variable);
@@ -158,15 +158,15 @@ public int unsetenv(String variable) {
158158
return clib.unsetenv(variable);
159159
}
160160

161-
162-
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
161+
162+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
163163

164164

165165
protected void showLauncherWarning() {
166-
Base.showWarning("No launcher available",
167-
"Unspecified platform, no launcher available.\n" +
166+
Base.showWarning("No launcher available",
167+
"Unspecified platform, no launcher available.\n" +
168168
"To enable opening URLs or folders, add a \n" +
169-
"\"launcher=/path/to/app\" line to preferences.txt",
169+
"\"launcher=/path/to/app\" line to preferences.txt",
170170
null);
171171
}
172172
}

0 commit comments

Comments
 (0)