Android Multiple File Selector/Chooser Dialog - android

I have been scouring the internet for a simple easy to implement Android file chooser dialog that also has the option of selecting multiple files and returning a uri or string array with all the files selected.
Currently I use aFileChooser on github and it is according to me better than android-file-dialog. But neither address the issue of passing multiple files.
I am only an intermediate android developer but I think this would be something not so hard to implement by a pro.
I have looked at the code of aFileChooser and I think adding a check box to the file item would be the way to go but as far as code is concerned i am clueless and the developer seems he's not really gonna work on it in the foreseeable future
So in short im requesting for help to either add the select multiple files option to aFileChooser via the github or here, or maybe suggest to me a better dialog that does what i want.

I don't know any file chooser you could use, but I can show you how I made my own long time ago. It's actually pretty ugly, but it does what you ask for. You can select multiple files and an ArrayList<File> is returned via Intent.
So you could use it as an example of how to do it, and implement it yourself, if you really need it to (I wouldn't recommend you to use mine as it is now).
Here are the links to GitHub:
FileSelectionActivity.
Used layout file for the FileSelectionActivity.
MainActivity, on line 225 the FileSelectionActivity is started.
Below there's a screenshot of FileSelectionActivity, as I said, ugly.
"Go Up" goes to a higher level of the file hierarchy, there are two ListViews, one for directories and one for files. The files have checkboxes. When the share button is pressed, each item in the second ListView is checked to see if the checkbox is active or not. That's line 71 of the FileSelectionActivity file.
Anyways, I hope this helps you make your own file selector, or something.

Thank's to the answer above, I've made a simple library that addresses the concern. It not only passes an array of file paths but you can also use to select a folder.
It has thumbnails for image files
auto scrolls to last scroll position
will soon have language support for several locales
Here it is: https://github.com/tapaulo/Android-Multiple-file-Selector-Dialog

Related

Rename file in bulk - Android Studio

I would like to rename all of my java classes and layouts that starts with the prefix tranp_ to event_. I can do that one by one using the combination Shift+F6 but it is taking too much time (there are more than 20 files). Is there a quicker way to do that in bulk?
Although is an old question, I feel it's worth answering as there is a valid solution.
Open the project with AndroidStudio, then right click on the main project's folder, select "replace in path" and enjoy it. I just replaced 400 occurrences in less than 40 seconds, just make sure you really need to replace all statements!
There seems to be no feature implemented to rename multiple files at once through refactoring provided within the Android Studio.
I also feel the need to have such feature as I keep changing my decision to name elements of certain category to some specific manner and thus have to tediously do it one by one. Which in many cases causes the bug.
I hope the future version will have it but till then what I am doing best at the moment is use the 'ctrl+r' feature to search all the occurrences of the item and replace it with what I want to rename to. And then do it again on all places where the element has been referenced. And then at last to make sure that there are no errors caused by the recent renaming I just run it. If any errors like "resources not found" then the Android Studio does point me to the location of the error, which generally is the place I left to rename.
Although this is not a sure way but it has helped me quite a lot when you have to rename lots of elements instead of 'shift+f6'.
So since I have tried the reply before me and it didn't help, I actually did find useful to open the direct path of the files I want to change, selected all of them and just pressed on rename(On MAC). It gave me the option to replace specific letters in all of the files. Made my life much easier after changing about 30 files, and noticing I have another 250 to change at least.

How to extend app with downloadable APKs (plugin sort of)

I'm just wondering how the following scenario can be solved:
I want to write a very simple app for my daughter. The app displays 4 colored fields on the activity and through speech output says something like "tap green". She should then tap the green field to get positive feedback. So far, so easy.
I then thought it might be nice if the app would also "grow" as she grows older. Maybe later I want to have a game mode where I display animals, numbers, vehicles, etc., so it would be nice if I could have something like "Shape sets" - basically a set of images along with a description of what the app should say for each image. Also easy enough - all you need is a set of images and an XML file describing the images.
BUT
I'd like to be able to install these "Shape sets" as additional APKs later on, so that I don't have to modify the app every time. I'd like to install the APKs, so that the contents are added to a specific sub folder on the SD card, into which my app looks to enumerate available "Shape sets".
If I ever published the app to the Play Store, other people should also be able to download the "Shape sets" I create (no need for user contributions, though).
Is that possible? If so, what would I have to do to have the Android OS "copy" the contents of an APK to a specific folder (lets say "/TapGame/Shape Sets/Animals") on the SD card? Or is there even another way of achieving what I want that I didn't think of?
The term "plugin architecture" just came to my mind as I wrote the question. Searching using that term I found this question: Extend my android app in different APK
It seems to provide a solution to my problem - I'll investigate this further, but please feel free to suggest other possible solutions!
Is that possible?
Um, sure.
If so, what would I have to do to have the Android OS "copy" the contents of an APK to a specific folder (lets say "/TapGame/Shape Sets/Animals") on the SD card?
Android won't do any of that. You have to do that. You would have to detect that a "shape set" APK was installed (either watching for package-installed broadcasts, scanning all installed apps for ones that seem to be a "shape set", etc.). Then you would have to arrange to copy whatever you wanted to wherever you wanted it, either by:
Asking the "shape set" app to do it (e.g., send a command to some IntentService), or
Using createPackageContext() and trying to do the copying from your main app
Or is there even another way of achieving what I want that I didn't think of?
Um, just use ZIP files that your app downloads itself from a well-known location. That corresponds to Dave Smith's final paragraph of his answer on the question you just linked to in your edit.
Or, just update the main app. I'm not quite certain what effort you think that you are saving otherwise.
Or, just keep the content online, using a Web service to indicate the available "shape sets" and downloading them as needed (with optional caching).
Fascinating question. If you really want to go for plug-ins then OSGi would probably be the way to go, but it's a lot of work to get to know and to use and seems like overkill in this case.
I don't know how your shapes are defined, but they are probably each defined in a separate file-set, providing the shape (maybe a png or jpg?) as well as the audio-file that will be used as a command for this shape. If the folder in which these file-sets are stored is fixed (TapGame/Shape Sets/...) the app could scan the folder each startup and the views could be generated accordingly (in this case, the activity cannot be build entirely in the XML-File, but must be partially done programmatically).
The Plugin-Aps would be rather easy. They are an apk which includes the file sets (jpg and mp3 or whatever). Started once they deposit all these files into the specified folder (they probably check before if these files exist) and then the apk can shut down again and be uninstalled.
on the next startup the Tap Game App would find the new symbols and include them into the game.
This seems rather straight forward to me. Another way would be to actually store the shapes and audio files on the internet and with each start of the App check if the number of shapes and audio-files has changed and create local copies of new ones. This would mean no downloads of apks... probably a more usual approach to the issue.
I am very interested to hear what you make of it, seems like a different approach then the norm, which is always cool to see.

Android DDMS Loaded GPX file Pausing Itself

I am loading a GPX file into my emulator.
THE PROBLEM
The file has 7226 points (it says so in the Point Count column) so the file is being loaded in correctly. However, the problem happens when I press the play button it only reads in about 4 points before it then pauses itself. This is not the functionality I want.
THE QUESTION
How do I make it run through the entire file without it pausing itself?
Thanks in advance
Just for the sake of answering the question from my research and for those of you looking for a solution yourself.
I couldn't manage to get the entire GPX file loaded in via the DDMS even when using different types of converters that you can find online.
The solution in the end was to have a set of classes which decode a GPX file into a set of locations and then do whatever you want with those.
I hope this helps even it is just confirming your thoughts that it wont work (well i couldn't work it out!) :)

Updating XML file on Android

I am fairly new at developing for Android and was hoping to get some help with something.
First, just a brief idea of what I am trying to achieve.
Within the app I am developing, the user can create a project profile for each new project he starts. I have already created the code to create a new XML file for each new project which is stored on the SD Card.
Now I want to create a list of the various projects on the main screen for the user to select from, but I'm not 100% sure how to go about this. My first thought was to have an XML file called Projects List which lists all the projects that have been created. But I just can't seem to figure out a way to update an XML file every time a new project is created, and this is where I was looking for some help.
Can someone please help me to understand how to update an XML file?
Thanks in advance for any replies.
My first thought was to have an XML file called Projects List which
lists all the projects that have been created.
Instead of doing this, why not simply see how many xml files there were created(corresponding to projects created)? I assume that, now, you're saving those project in a folder created by you on the SD Card so when it's time to show that information to the user simple check your projects folder, see how many there are(get the names, get a reference to those xml files so you could open them on a user action etc) and present them to the user.
This would be a lot simpler then implementing the logic to update a xml each time the user does some changes to the projects, not to mention the case when the user might delete those xml files when your app is not running.
I would do the following.
The user create some projects - and for each project you have an xml file.
You check for all xml files - grab a bit of info from each, and build a ListView :
Android listview example
From here you can create a custom adapter which would do the hard work of working out what information you need from each XML file and then when the user clicks the 'browse projects button' they can see all projects in a listview?

PreferenceScreen themed with honeycomb theme

i want to make to make an PreferenceActivity with the same style that can be found on the image below.
Image of Preference Screen Android 3.2 http://img600.imageshack.us/img600/5120/device20120320173903.png
http://imageshack.us/photo/my-images/600/device20120320173903.png
There any way to make a close match of it or do i need to program the behaviour?
I can think of two ways you can do. One is to download the source code, but I think that layout is custom for galaxy tablets.
The other option would be to use the Hierarchy View Perspective in Eclipse to determine the structure and details of the interface and from there replicate the interface.
Good luck!
Udapte:
Ok, if what you want is the drawables you can actually get them from the tablet. With a file manager in the tablet copy the file /System/app/System.apk to the SD card and from there to your computer. There change the extension to .zip and extract the contents. This way you can access only the drawables. The xml files are compiled so you can't see their content.
I think you can use this if you want more data out (like the xml layouts): http://code.google.com/p/android-apktool/
Although as I said in the comments I am not sure about the legality of this given this is Samsung's own IP.

Categories

Resources