Share My Creation VoiceGPS and some suggestions

I created an app using Basic4Android called VoiceGPS and its available for free on android market. I would just like to thank all here for their valuable help with this good software including Schimanski who gave me the basic idea. I just wanted something that could be practical to use in a car. Since I don't think everybody wants to scroll in and out of maps all the time I just wanted something that could tell you the address in big type on the screen (and in reverse type on the car windscreen, which works quite well at night) particularly the townlands in Ireland.

Anyway I don't think people would like the spagetti junction of If.. Then loops that I tend to write but I thought I'd share these few bits that people might like to copy.

This is what I went for as regards saving and using settings for the app that will be preserved the next time it is opened up. Its just a simple way of doing it I think, each of the text files listed ends up with only one word of text. I don't think it slows down the app at all to do it this way.

Sub Process_Globals
Dim voicesetting As String
Dim geocodename As String
Dim fonttype As String
Dim yahoostreetnamesetting As String
End Sub

Sub Activity_Create
If FirstTime Then
If File.Exists(File.DirInternal,"settings.txt") Then
geocodename=File.GetText(File.DirInternal,"settings.txt")
Else
File.WriteString(File.DirInternal,"settings.txt","yahoo")
geocodename="yahoo"
End If
If File.Exists(File.DirInternal,"fonttype.txt") Then
fonttype=File.GetText(File.DirInternal,"fonttype.txt")
Else
File.WriteString(File.DirInternal,"fonttype.txt","forwards")
fonttype="forwards"
End If
If File.Exists(File.DirInternal,"voice.txt") Then
voicesetting=File.GetText(File.DirInternal,"voice.txt")
Else
File.WriteString(File.DirInternal,"voice.txt","on")
voicesetting="on"
End If
If File.Exists(File.DirInternal,"yahoostreet.txt") Then
yahoostreetnamesetting=File.GetText(File.DirInternal,"yahoostreet.txt")
Else
File.WriteString(File.DirInternal,"yahoostreet.txt","neighborhood")
yahoostreetnamesetting="neighborhood"
End If
End If
End Sub

This is how I use the latter variable then, it kicks in if the label - which is the whole screen - is long clicked. I obviously just see what is there and swap it around to the other variable, like a toggle switch:

Sub label1_LongClick
If yahoostreetnamesetting="neighborhood" Then
File.WriteString(File.DirInternal,"yahoostreet.txt","street")
End If
If yahoostreetnamesetting="street" Then
File.WriteString(File.DirInternal,"yahoostreet.txt","neighborhood")
End If
yahoostreetnamesetting=File.GetText(File.DirInternal,"yahoostreet.txt")
ToastMessageShow("Yahoo geocode setting set to " & yahoostreetnamesetting,False)
Activity.Invalidate 'I want it to refresh the screen as well.
End Sub

This one activates when a short click is felt on the screen:

Sub Label1_Click
If geocodename="yahoo" Then
File.WriteString(File.DirInternal,"settings.txt","google")
End If
If geocodename="google" Then
File.WriteString(File.DirInternal,"settings.txt","yahoo")
End If
geocodename=File.GetText(File.DirInternal,"settings.txt")
ToastMessageShow("Geocode server set to " & geocodename,False)
Activity.Invalidate
End Sub

It is also activated under one of the menu buttons, I list three of the menu options here:

Sub settings_Click
If geocodename="yahoo" Then
File.WriteString(File.DirInternal,"settings.txt","google")
End If
If geocodename="google" Then
File.WriteString(File.DirInternal,"settings.txt","yahoo")
End If
geocodename=File.GetText(File.DirInternal,"settings.txt")
ToastMessageShow("Geocode server set to " & geocodename,False)
End Sub

Sub settings2_Click
If fonttype="backwards" Then
File.WriteString(File.DirInternal,"fonttype.txt","forwards")
End If
If fonttype="forwards" Then
File.WriteString(File.DirInternal,"fonttype.txt","backwards")
End If
fonttype=File.GetText(File.DirInternal,"fonttype.txt")
ToastMessageShow("Text set to " & fonttype,False)
End Sub

Sub settings3_Click
If voicesetting="on" Then
File.WriteString(File.DirInternal,"voice.txt","off")
End If
If voicesetting="off" Then
File.WriteString(File.DirInternal,"voice.txt","on")
End If
voicesetting=File.GetText(File.DirInternal,"voice.txt")
ToastMessageShow("Text to speech set to " & voicesetting,False)
End Sub

Incidentally this is the code to create the menu options and the label that I write to, in Sub Activity_Create:

Activity.AddMenuItem2("yahoo/google","settings",LoadBitmap(File.DirAssets, "advancedsettings48X48.png"))
Activity.AddMenuItem2("mirrored/not","settings2",LoadBitmap(File.DirAssets, "mirror48X48.png"))
Activity.AddMenuItem2("voice on/off","settings3",LoadBitmap(File.DirAssets, "kmix48X48.png"))
Activity.AddMenuItem2("Full Info","gpsinfo",LoadBitmap(File.DirAssets, "info48X48.png"))
Activity.AddMenuItem2("Help","help",LoadBitmap(File.DirAssets, "khelpcenter48X48.png"))
Activity.AddMenuItem2("Quit","Quit",LoadBitmap(File.DirAssets, "exit48x48.png"))
Activity.AddView(label1,1,1,100%x,100%y)

Anyhow I think this is excellent software and I would like to compliment all involved if I may, but at the same time I thought I would throw in a few, hopefully constructive, suggestions to Erel et al:

1. I actually think that more emphasis should be placed on doing the whole app through code and discourage people from using the designer? I know that sounds mad and I do think that the designer is well put together and easy to use but I just think that android devices come in so many shapes and sizes that its almost impossible to get it right if you are placing buttons and labels on a screen like that. I think you have to use menu choices, tabs, message boxes - and the similiar type of input screens - etc rather than load a layout because you are bound to have it turn out bad in some type of android device otherwise, no matter how much checking you do? I guess thats pessimistic but the point is anyway that maybe you should gear the tutorials towards that? Encourage code only app making?

2. Anyway its not that anybody is discouraging the use of code only but I thought that maybe a few steps could help out here. I think you should consider some step like the 'generate members' part of the designer to automate some code only app making. It seems to me that a lot of people are aiming to do much the same thing in their code and if they could easily get access to some standard code it might make things go quicker. So my idea is that you would have a section in the IDE called something like 'Quickcode', and in that menu option you will have 'Quicksettings, Quickmenu, Quickbuttons ...etc.

Then what happens is that when a new comer hits 'quickmenu', say, he gets a screen where you have the usual options for a menu listed on a normal windows form screen. So you could have a tick box beside an option for an icon for your new menu item and then a browse button where you are asked to select a 48X48 icon image etc. You get another box to fill in for the menu text and another one for the menu name (with a tick box, defaulted to on, which asks if you want those two options to be the same) etc. Then when you have everything arranged to your satisfaction, and click ok, a screen wil come up which will list exactly what extra code the program will now add into your code screen (which will obviously be the Activity. addmenu thing, a menu-click sub with some remarked text added pointing out that the user should add here what happens when the menu item is clicked, and a note where it says it will add the icon image to the files tab) and asking you if you would like to add this code to your program. Also the resulting code will have the first letter of each line in red, to indicate clearly what it added in automatically. The point is that this makes it very easy for a newcomer to see exactly what code is needed to add a menu item, and of course since this is just normal code added to the program it is totally customisable after its added.

All of the variables added with this option would have 'Quick' in front of them, so you get 'QuickLabel1', 'Quickbutton1' etc so of course it wouldn't interfere with the code already there. Another option might be a 'QuickLayout' option (again this is a menu item added into the 'Quickcode' menu in the IDE). This wouldn't add a layout at all as such, but would add in by code certain commonly used options. So for example it might throw up an option to add a screen with two buttons and a label say (and in the resulting code you would select the best way of doing this, by using % 's in the button and label settings for example, so it should work ok on most devices) and you get to fill in on a windows form the text you want on each button and on the label etc and again then the program will - after asking first - add in the necessary code to get you a simple screen with those buttons and a label. (The screen, created by the new code, will come up at the point in the code where the cursor is, and will dissapear with a click on an OK or Cancel button, which you might add automatically.) I know most people will probably not go for the default screen anyway but again they will then see what code the program adds and it will be no problem to modify that as they wish.

Just a suggestion in any case, its easy to image how you could get a 'Quicksettings' windows form etc (e.g. you could ask do you want to save two settings and ask the user to name them, then you could set up a process variable for both, and load them in and out of a text file exactly like I do in the code above, again just providing some code that the user might like to add in and use, he will learn a lot from just reading what the programme decides to add in in response to his option ticks on the windows form) ...

3. I think webview is potentially the best way of coding in pictures and text etc, because obviously its a doddle to programme all this in as html and then just load the html page (which you either created dynamically or added in with dir assets). I can think of countless good apps which could be turned out very quickly that way and would look good on most devices, because you can rely on the html to scroll well for each screen size etc.

But, and its a big but!, the options that we get with webview are not very comprehensive. I know this is all that the java code allows but I was thinking that it might be possible to draw up a tutorial where you could combine javascript in the html with the normal basic4android commands to get the full range of power over the html? For example would it be possible to institute a text search of a html page using javascript on the page and then have that interact with menu buttons etc? Can we use different fonts by using fontface and a font loaded with the html, and could it be possible to use javascript to locate where in the text the current reader is at (which is necessary if you have a large html page and you want the reader to return to the spot he was at before the activity refreshed e.g. because the orientation changed).

4. Finally I think a printed manual (with an index!) would be great, as I am sure everybody knows anyways. I publish books myself so i could possibly draw one up maybe.

They are just a few thoughts in any case, and again I don't mean to suggest that you are doing anything other than great work with this software.
 
Top