Friday, 8 July 2011

Austin DWI Attorney | Texas DWI Legislation Update Part 1

As the 82nd Legislature winds down their special summer session, I thought I would take some time to write about various bills relating to Texas DWI that an Austin DWI Attorney and others. There were a number of DWI related bills considered by the legislature, so I will probably break this up into two posts.

House Bill 189 was passed by the House but not by the Senate. Generally, HB 189 would have allowed a form of deferred adjudication community supervision for first time DWI convictions in Texas.

As the law now stands in Texas, the only types of crimes that a person cannot bet deferred adjudication for are DWI, Flying While Intoxicated, and Boating While Intoxicated related crimes; certain sexual crimes where the defendant has previous convictions; and drug offenses in a drug free zone where the defendant has previously been convicted of a similar crime.

Yes, you can be convicted of murder and still be eligible for deferred adjudication, but not if you are convicted of DWI. You can be convicted of certain sexual offenses and still be eligible for deferred adjudication, but not if you are convicted of DWI.

Maybe this will change in the future, but not at least until the legislature meets again in 2014.House Bill 1507 was not passed by either the House or Senate. HB 1507 would have allowed non-lawyer magistrates in counties with populations under 100,000 to issue search warrants.

Austin DWI Lawyer | ALR Hearings and Occupational Licenses Part 4

Welcome back to my series of posts on Texas ALR Hearings and Occupational Licenses. Austin DWI Attorneys and drivers accused of an Austin DWI deal with Administrative License Revocation (ALR) hearings when they contest the driver’s license suspension after a DWI arrest. Here is my post on what an ALR hearing is.

Here is my post on ALR hearing witnesses and discovery. And here is my post on laws pertaining to ALR hearings.ALR HEARING LICENSE SUSPENSIONSNo one wants their driver’s license to be suspended. But sometimes in ALR hearings, Judges rule that the State has proven that the officer had reasonable suspicion to stop or probable cause to arrest the driver for DWI, and that the driver refused to provide a specimen or had an alcohol concentration greater than 0.08.

How long the driver’s license is suspended for depends on whether the case was a refusal or failure, and whether the driver has had alcohol or drug related contact within 10 years before the date of arrest. Contact an Austin DWI Attorney to discuss the possible length of your suspension.

ALR SUSPENSION LENGTHSIf an ALR Judge orders a suspension and the driver has had no alcohol or drug related law enforcement contact during the 10 years immediately preceding the date of arrest for DWI and the driver refused to provide a blood or breath specimen, the license suspension length is 180 days.

If the driver provided a specimen and it showed an alcohol concentration of 0.08 or more, the suspension length is 90 days. If the ALR judge orders a suspension and the driver has had 1 or more alcohol or drug related law enforcement contacts in the 10 years before the arrest date, and the driver refused to provide a blood or breath specimen, the suspension length is 2 years. If the driver did provide a specimen but had an alcohol concentration of 0.08, the suspension length is 1 year.

Austin Texas DWI Attorney

Austin DWI Attorneys and Austin, TX DWI LawyersAustin DWI attorneys at the Dunham Law Firm know Texas DWI laws and handle drunk driving defense cases in Travis County. Call Texas DWI Lawyers in Austin.www.dwi.com/texas/austinDWI Austin Lawyer| DWI San Antonio Attorney| The Law Office of …Austin | San Antonio DWI Attorney: Get DWI help from Austin and San Antonio lawyer Jamie Balagia.dwidude.com/Austin DWI Lawyer: Austin DWI Attorney handling Drunk Driving DefenseAustin DWI Lawyer Firm: Dunham Law Firm. Austin DWI lawyers and criminal defense attorneys handling DWI and drunk driving defense cases in Travis County, …www.austindwilawyer.comAustin Criminal Defense Lawyers / Travis County Divorce AttorneysExperienced and Aggressive Austin, TX Criminal Defense and Family Law Attorneys. If you have been charged with a criminal offense or have a family law issue …www.mbfc.com/Austin DWI Attorney, Jail Release, Texas DWI, DWI Defense LawyerAustin DWI Criminal Defense Attorney Austin, Texas. Jail release 24/7. Criminal defense cases such as DWI, drunk driving, jail release, driving while …www.austindwiattorney.com/Austin Texas DWI AttorneyWant to know the best DWI facts at Austin DWI Attorney?www.austin-tx-dwi-attorney.com/Austin DWI Attorney Blog : Austin DWI Lawyer & Attorney : Law …Austin DWI Lawyer & Attorney, Law Office of Ken Gibson, offering services related to DWI defense, DUI, drunk driving defense and drivers license suspension. …www.austindwiattorneyblog.com/http://www.dwidefenselawaustin.com/about_kyle_lowe_criminal_defense_dwi_attorney.php

Friday, 1 July 2011

GoogleBar Options

The GoogleBar allows you to achieve similar functionality to what you would get by using the Google AJAX Search API to perform a Local Search, but provides a few advantages: 
1. If you just need the basic functionality, all you need is one extra command in your code: map.enableGoogleBar(). 
2. You can use it without having agreed to the Google AJAX Search API Terms of Use, which seem to not allow you to modify the results.

The Maps API GoogleBar options provide facilities which you can use to:
1.Modify or replace the text, images, or other content of the Google Search Results
2.Changing the order in which the Google Search Results appear
3.Intermix Search Results from sources other than Google
4.Intermix other content such that it appears to be part of the Google Search Results
5.Modify, replace or otherwise disable the functioning of links All of which would be prohibited if you were using the Google AJAX Search API.

OptionsThe possible entries in the googleBarOptions are:
property type purposeshowOnLoad bool If true, the Google Bar will be expanded when the map has loaded.linkTarget string Use one of these string variables to control the link target pane G_GOOGLEBAR_LINK_TARGET_BLANK, G_GOOGLEBAR_LINK_TARGET_PARENT, G_GOOGLEBAR_LINK_TARGET_SELF, G_GOOGLEBAR_LINK_TARGET_TOPresultList string Use one of these string variables to control result list suppression G_GOOGLEBAR_RESULT_LIST_INLINE, G_GOOGLEBAR_RESULT_LIST_SUPPRESSsuppressInitialResultSelection bool If true, the info window is not opened on the first result.

suppressZoomToBounds bool If true, the map does not zoom and pan to fit the results.onIdleCallback function Function be be called when the GoogleBar finishes searchingonSearchCompleteCallback function Function to be called when the search is complete, before the reults are plottedonMarkersSetCallback function Function to be called after the markers have been placed on the map.

onGenerateMarkerHtmlCallback function Function to be called when the info window is about to be opened on one of the results. Must return the (modified) html element object to be used for the info window contents.

The first six options are fairly straight forward, but the callback functions need a bit of explanation:onIdleCallbackThis function is called when the GoogleBar is opened for the first time, and called again whenever the previous results are cleared. It is not called if a second search is executed without the user explicitly clearing the previous results.No parameters are passed.onSearchCompleteCallbackThis function is called when the search is complete, before the results are plotted.

There is one parameter, a reference to a GlocalSearch object, see Official Class referenceOf particular interest is the .results[] array, which is an array of GlocalResult() objects, see Official Class referenceYou can read that information, but also, because it's a reference, you can modify the contents of the .result[] array. The .html will have already been calculated, so changing things like the .results[i].city won't affect what gets displayed in the info window.

If you want to change the info window contents at this point, then you need to change the .results[i].html.innerHTML.onMarkersSetCallbackThis function is called when the API has created markers corresponding to the search results.There is one parameter, an array of anonymous Objects.Each Object in the array has two properties, .result is a GlocalResult object and .marker is a GMarker.

onGenerateMarkerHtmlCallbackThis function is called whenever an info window is about to be opened.The parameters are: The GMarker The HTMLElement which is intended to become the info window contents The GlocalResult The function must return a HTMLElement which will become the actual info window contents.

Simple result filtering exampleThis example uses onSearchCompleteCallback to filter the search results, reducing the number of results to no more than two.Simple info window modificationThis example uses onGenerateMarkerHtmlCallback to read information from the GMarker and from the GlocalResult to modify the contents of the info window at the time that the info window is opened.

Advanced example: add ELabelsThis advanced example uses all the GoogleBar Options. It displays an Elabel alongside each marker, and in order to do that it uses the callback functions like this:onIdleCallback uses map.clearOverlays() to remove the old ELabelsonSearchCompleteCallback uses map.clearOverlays() to remove the old ELabelsonMarkersSetCallback reads the location of each GMarker and the titleNoFormatting of each GlocalResult and uses that information to create an ELabel.onGenerateMarkerHtmlCallback hides the ELabel corresponding to the marker on which the info window is opening.

Example of Position in phonegap

Contains Position coordinates that are created by the geolocation API.Properties coords: A set of geographic coordinates. (Coordinates) timestamp: Creation timestamp for coords in milliseconds. (DOMTimeStamp)DescriptionThe Position object is created and populated by PhoneGap, and returned to the user through a callback function.Supported Platforms Android BlackBerry (OS 4.6) BlackBerry WebWorks (OS 5.0 and higher) iPhone

Preview Gmail's New Interface

Gmail found an interesting way to test the new Google+ interface: using themes. If you go to the Themes page and select "Preview" or "Preview (dense)", you'll be able to try the upcoming Gmail interface. "Why two themes? Our new interface will eventually expand dynamically to accommodate different screen sizes and user preferences, but until then you can pick the information density that you prefer," explains Google.

The new interface uses the same color scheme from Google Maps, Google Calendar and Google Search, the same gray header and blue search button. Since Gmail has two search buttons, Google had to use labels to distinguish between the button that lets you search your message and the Google Search button. The interface is cleaner, since it uses a lot of white space to separate the different sections.

Even if you don't enable the new themes, you'll still see some subtle design changes: many links are now buttons (navigation links, "Back to message list"), the "Refresh" button uses a familiar icon, the "More actions" button changed the label to "More" and Gmail's footer is much cleaner. These are just the first UI updates, so we'll see many other changes until "Preview" becomes the default theme.

Gmail is a complex application and it's difficult to simplify the interface and make it more consistent, especially when you consider the numerous Gmail Labs features and themes. "You can expect some updated themes that embody the same design principles but are better suited to working in a dark environment, use a different color palette, or include the illustrations that we know many of you love to see around your inbox," mentions Gmail's blog.

It should be obvious right now that Google+ is more than a social network or a social layer, it's a Google-wide initiative that affects both the form and the functionality of Google's applications. It's actually a new Google, a social Google that tries to offer cutting-edge apps and a cohesive experience.{ Thanks, Maarten, James, Yasar, סמנה, Mushaf, Kai, Anthony, Jason, Kartik, David and Karol. }

Programming with php in a local environment

I have two files, main.php and register.php that I've been editing. I renamed their extensions to .txt so that you can view them here. If I had left them as .php's, they'll try to run when you click on the filenames. You'll see that they are nothing fancy, just an initial draft to get you started. So, now I'd like to show you how to execute those files.

I told you my directory name at the beginning of the post. So, type into your browser:"localhost/eclipseworkspace/projectX/main.php"If I had named it "index.php" instead of main, then you could skip the filename. This code shows how you can validate the fields of the form in PHP, and give the user an error message if something is wrong.

It works fine except for one problem: if there are multiple errors, such as a zero length username AND a zero length password, then only one error message is displayed to the user. In this case it's the password error message, since that check occurs later in the code.

To fix this, we can change the code to keep an array of error messages. Here's how we'll do that:1. Instead of setting $error=false, lets instead create an empty array, and let's make the variable plural $errors instead of $error. Of course, you know that a compiler, or in this case the PHP interpreter, does not really distinguish between singular and plural form.

It just helps make the variable names more meaningful for us:In this case where it's just one line of HTML to be output, that's not a bad way to do it. But when sending long stretches of HTML I think the format where you jump back and forth between PHP and HTML is the way to do. You end up with a file that looks more like HTML code with PHP sprinkled in, rather than an onslaught of PHP echo statements.

That might be hard to visualize with just a small example like this, but if you code up an entire page you'll see what I mean.The idea of echo'ing all output from a PHP program would be similar to writing a C program where you printf all the HTML. Come to think of it, you could actually write all this pure C. You could have an Apache module that links in your C code as a shared library.

It would handle the TCP connection from the browser, doing printf's to send the HTML and other content to the browser. In other words, you'd be generating the HTML from your C program entirely. All the things that we are doing with PHP, you could do it with C instead in which case you would not need to switch between PHP and HTML. However, it'd be more complex. Say you needed to make a change, with PHP you just edit the file and you are done; with C, you have the extra step of compiling which will slow you down. Then you have to restart the web server process.

JavaScript date validation

JavaScriptJavaScript date validation can be done in many ways, like month range testing, then day range testing (depend on month) and so on. I suggest simpler solution. Take day, month and year from string to create a Date object. Compare day, month and year with day, month and year extracted from the Date() object.

If they aren't the same, than the input date is not valid.Please try how date validation works:
Enter date (mm/dd/yyyy): /*Function is checked with JSLint (JavaScript syntax checker and validator).
function isDate(txtDate) {
var objDate, // date object initialized from the txtDate string mSeconds, // txtDate in milliseconds day, // day month, // month year; // year // date length should be 10 characters (no more no less)
if (txtDate.length !== 10) { return false; } // third and sixth character should be '/'
if (txtDate.substring(2, 3) !== '/' || txtDate.substring(5, 6) !== '/')
{ return false; } // extract month, day and year from the txtDate
(expected format is mm/dd/yyyy) // subtraction will cast variables to integer implicitly (needed // for !== comparing)
month = txtDate.substring(0, 2) - 1; // because months in JS start from 0
day = txtDate.substring(3, 5) - 0;
year = txtDate.substring(6, 10) - 0; // test year range
if (year < 1000 || year > 3000) { return false; } // convert txtDate to milliseconds
mSeconds = (new Date(year, month, day)).getTime(); // initialize Date() object from calculated milliseconds objDate = new Date(); objDate.setTime(mSeconds); // compare input date and parts from Date() object // if difference exists then date isn't valid
if (objDate.getFullYear() !== year || objDate.getMonth() !== month || objDate.getDate() !== day)
{ return false; } // otherwise return true return true;}
And finally, see how to use date validation function. checkDate() is called on button click.function checkDate()
{ // define date string to test var txtDate = document.getElementById('txtDate').value; // check date and print message if (isDate(txtDate)) { alert('OK'); }
else {
alert('Invalid date format!'); }}*/This entry was posted on January 23, 2009 and is filed under JavaScript

Thursday, 30 June 2011

Simple Android Developer Mistakes

I would really like to write more tips, tricks, and tutorial posts relating to Android, but I’ve been extremely busy on apps both professionally and personally, and I am also doing technical review on an Android dev book due out later this year. So, while I don’t have time to go in the level of depth I’d like to, I thought I could work on a post with a bunch of short pieces that could be written when I have a few free minutes here and there and save the longer posts that require a greater chunk of continuous focus for later.

This post talks about some challenges that you may run into early in your foray into Android development. There isn’t really any sense of order to these; they’re more-or-less a brain dump of issues I’ve experienced or seen that take seconds to solve if you know what you’re doing or hours if you don’t.OMG! The emulator is slow!There are two things to note here: the default AVDs tend to have limited resources and the devices you’re targeting are likely running with a different chipset than the computer you’re developing on.

The first limitation can be easily overcome; the second is a much bigger issue, particularly with Android 3.x and attempting to develop for Honeycomb tablets without actually having a Xoom, Asus Eee Pad Transformer, etc.

Currently, it’s not very feasible to develop a 3.x app without a tablet.Back to that first limitation: When creating a new AVD, you can specify hardware settings, which can dramatically improve performance. The most important setting is the device RAM size; I tend to want the emulator to be as fast as possible, relying on on-device testing for a sense of “real-world speed,” so I usually give my phone emulators 512MB of RAM. That’s the equivalent of most good smartphones from 2010. The 1.x AVDs seem to run fine on 256MB, so you can potentially drop to that if your machine is limited (the Motorola Droid/Milestone had 256MB of RAM as well).

You can also try upping the cache partition size (128MB is a good start) and the max VM application heap size (48 is plenty) for a minor improvement.LinearLayout mistakesLinearLayout is a very useful and very simple ViewGroup. It essentially puts one View after another either horizontally or vertically, depending on the orientation you have set. Set an orientation!LinearLayout defaults to horizontal, but you should always manually specify an orientation. It’s very easy to throw two Views in there and not see one because the first View is set to match_parent for width.

That said, LinearLayout also processes layouts linearly, which is what you’d expect, but that means that setting a child View to match_parent can leave no room for subsequent Views. If you aren’t seeing one of your Views in a LinearLayout, verify you’ve set the orientation and that none of the Views are taking up all the available space. Within a LinearLayout, you should generally rely on layout_weight to “grow” the View.

Here’s an example: The heights are set to 0, but both child Views have weights. The first has a weight of 2 and the second has a weight of 3. Out of a total of 5, the first is taking 2 (40%) and the second gets 3 (60%), so their heights will actually use that portion of the parent View’s space (if that View has a 100px height, the first child will be 40px tall). The weights are relative, so you can set whatever values make sense for you.

In this example, the second layout could have had a set height and no weight and the first could have had a weight of 1, which would have made the first take up all space that the second didn’t use.Stupid Android! It keeps restarting my Activity!The default behavior when a configuration change happens (e.g., orientation change, sliding out the keyboard, etc.) is to finish the current Activity and restart it with the new configuration.

If you’re not getting any dynamic data, such as loading content from the web, this means you probably don’t have to do any work to support configuration changes; however, if you are loading other data, you need to pass it between configuration changes. Fortunately, there’s already a great post on Faster screen orientation changes. Read it and remember that you should not pass anything via the config change methods that is tied to the Activity or Context.DensityDensity should only be considered in terms of density not size. In other words, don’t decide that MDPI means 320px wide. It doesn’t.

It means that the device has around 160dpi like the G1 (320px wide) and the Xoom (1280px wide). Fortunately, you can combine multiple qualifiers for your folders to give precise control, so you can have a drawable-large-land-hdpi/ containing only drawables that are used on large HDPI devices that are in landscape orientation.One other important thing to note: Support for different screen sizes and densities came in Android 1.6. Android 1.5 devices are all MDPI devices, but they don’t know to look in drawable-mdpi/ because there were no different densities then.

So, if you’re supporting Android 1.5, your MDPI drawables should go in drawables/. If your minSdkVersion is 1.6 or above, put the MDPI drawables in drawable-mdpi/.What the heck is ListView doing?A full explanation of ListView would take quite a while, but here’s a quick summary: A ListView’s associated Adapter’s getView method is called for each child View it needs to construct to fill the ListView.

If you scroll down, the top View that leaves the screen is not garbage collected but is instead passed back to the getView method as the “convertView” (second param). Use this View! If you don’t, not only does it need to be garbage collected, you have to inflate new Views. You should also use the ViewHolder paradigm where you use a simple class to store View references to avoid constant findViewById() calls.

Here’s an example: 

@Override
public View getView(int position, View convertView, ViewGroup parent) 
{ final ViewHolder holder;

if (convertView == null) {
convertView = mInflater.inflate(R.layout.some_layout, null);
holder = new ViewHolder();
holder.thumbnail = (ImageView) convertView.findViewById(R.id.thumbnail);
holder.title = (TextView) convertView.findViewById(R.id.title);
convertView.setTag(holder);
}
else {
holder = (ViewHolder) convertView.getTag();
}
final MyObject obj = (MyObject) getItem(position);
holder.thumbnail.setImageDrawable(obj.getThumbnail());
holder.title.setText(Html.fromHtml(obj.getTitle()));
return convertView;
} /** * Static ViewHolder class for retaining View references*/

private static class ViewHolder {
ImageView thumbnail; TextView title;
}

This method is first checking if the convertView exists (when the ListView is first laid out, convertView will not exist). If it doesn’t exist, a new layout is inflated with the LayoutInflater. A ViewHolder object is instantiated and the View references are set. Then, the holder is assigned to the View with the setTag method (which essentially allows you to associate an arbitrary object with a View).

If the convertView already exists, all that has already been done, so you just have to call getTag() to pull that ViewHolder out. The “bulk” of the method is just grabbing MyObject (whatever object your Adapter is connecting to) and setting the thumbnail ImageView and the title TextView.

You could also make the ViewHolder fields final and set them in the constructor, but I tried to keep this example as simple as possible. This method no longer requires View inflation while scrolling nor does it require looking through the Views for specific IDs each time. This little bit of work can make a huge different on scrolling smoothness.One last thing about ListViews… never set the height of a ListView to wrap_content.

If you have all your data locally available, it might not seem so bad, but it becomes particularly troublesome when you don’t. Consider the above example but instead of the setImageDrawable call, it triggers an image download (though it’s better to have the Adapter handle that).

If you use wrap_content on your ListView, this is what happens: The first getView call is done, convertView is null, and position 0 is loaded. Now, position 1 is loaded, but it is passed the View you just generated for position 0 as its convertView. Then position 2 is loaded with that same View, and so on. This is done to lay out the ListView since it has to figure out how tall it should be and you didn’t explicitly tell it.

Once it has run through all of those positions, that View is passed back to position 0 for yet another getView call, and then position 1 and on are loaded with getView and no convertView. You’re going to end up seeing getView called two or three times as often as you would have expected.

Not only does that suck for performance, but you can get some really confusing issues (e.g., if you had been passing a reference to an ImageView with an image download request, that same ImageView could be tied to all of the download requests, causing it to flicker through the images as they return).

It’s very easy to send email via an Android intent. Here’s an example where we already have the subject and body prepared but want to let the user decide on the recipient:

(It’s important to note that this should be attempted on a real device.)

I ran into some trouble with sending HTML in an email because it was being interpreted as plain text both in the user’s email client and in the recipient’s. Simply changing the MIME type didn’t help, but I eventually came across the solution:

Note that both the MIME type is changed and the EXTRA_TEXT is now set as Html.fromHtml(body) instead of just being passed a string with HTML in it. As long as the mail app that is selected is able to properly handle the Intent (e.g., the Gmail app can, the default mail app cannot), then HTML email can be sent.

Twitter Delicious Facebook Digg Stumbleupon Favorites More