I'm using Intellij. On Tuesday, October 17, 2017 at 2:27:55 PM UTC-4, BWC wrote: > > If you are experiencing an issue please mention the full platform your > issue applies to: > IDE: IDEA > Device: iPhone > > Hi, while testing my app on an iPhone, my filechooser shows the name of > the file (in this a case an image) as temp_image.jpg. I emailed this > image from my phone to my desktop email and its name is listed as > XXXXXX.png. > > *How can I get the true filename on my device? * > > I understand that the simulator designates temporary filenames as well and > have seen this post: > https://groups.google.com/forum/#!searchin/codenameone-discussions/filechooser%7Csort:relevance/codenameone-discussions/O3c3CLbKJW8/xTn8KtFeCQAJ > > . Do I need to do something similar? > > Here is my code: > > ActionListener callback = e->{ > if (e != null && e.getSource() != null) { > String filePath = (String)e.getSource(); > //File newFile = new File(filePath); > String dir = FileSystemStorage.getInstance().getAppHomePath() > +"/myApp"; > FileSystemStorage storage = FileSystemStorage.getInstance(); > storage.mkdir(dir); > Log.p("" + new File(dir).exists()); > List<String> filepathParsed = StringUtil.tokenize(filePath, > "[/.]"); > for (int j = 0; j < filepathParsed.size(); j++) > Log.p(j +": " + filepathParsed.get(j)); > Log.p("last: " + filepathParsed.get(filepathParsed.size() -1)); > > > StringBuilder hi = new StringBuilder(filePath); > if (filePath.startsWith("file://")) > hi.delete(0, 7); > int lastIndexPeriod = hi.toString().lastIndexOf("."); > //StringBuilder newFileName = new StringBuilder(filePath); > //hi.replace(lastIndexPeriod - 1, lastIndexPeriod, "/file"); > Log.p(hi.toString()); > String hmore = hi.toString().substring(0, lastIndexPeriod -1); > String ext = hi.toString().substring(lastIndexPeriod); > //String[] last = hi.toString().split("/"); > String hi2 = hmore + "/file" + ext;/*hi;*/ > List<String> last = StringUtil.tokenize(hi.toString(), > "/");/*hi.toString().split("/");*/ > //FIXME! > if (filePath == null) { > Log.p("no file was selected"); > } else { > initializeSpinner(); > > } > > > if (FileChooser.isAvailable()) { > > FileChooser.showOpenDialog(".pdf,application/pdf,.png,image/png,.jpg,image/jpg,.jpeg, > image/jpeg", callback); > } else { > Display.getInstance().openGallery(callback, Display.GALLERY_IMAGE); > } > } > > > *Also: *Is there a way to open a native (at least iOS) dialog to open both > images and PDF files, instead of only > Display.getInstance().*openGallery(callback, Display.**GALLERY_IMAGE); ??* > > > Thanks! > > >
-- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e5950f33-e2c0-48a7-a461-9a8330dea780%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
