Posts tagged button

VirtualBox Manager – An Android IT Solution

Published late last night to the Android Marketplace, VirtualBox Manage is making nice progress. Yesterday I put substantial time and effort into the user interface. Particular the onscreen keyboards, and password entry screen. When the main dialogs appear, prompting for user input, the keyboard views are automatically expanded. In the port dialog a telephone keyboard/numerical keyboard is shown. For the host dialog I will update the keyboard to be web based, with a .com button. The password dialog asterisks out user input, and only shows the last four of the currently set value. Ohh, also the port dialog has a format check presenting a dialog if the data entered is not a number.

The header and background images have been updated. They are dynamic in that on different Android devices both with fit the screen. Each host button begins immediately after the header image, and are dynamically create in the main methods onCreate. Actually the only view in each if the three layouts is the header imageView. Other than that table rows and button views are dynamically populated, collapsed and expanded. I’ve tested different screen sizes in the emulator and the header/background image, and the buttons are dynamically fit to the size of the device screen. The very first thing the application does, on first run, is measure the screen. It happens to work very nicely overall.

Currently the application supports seven hosts. In the onCreate each button for the seven hosts is create and collapsed. When a new host is created the table row is inflated making the view visible. Essentially the default state of all buttons and table rows is invalidated, and then when they are added by the user they are validated.

The delete host activity uses the validation state of the host buttons to populate the layout with views. Like the main activity 7 table rows and buttons are created, and subsequently invalidated. Then the oncreate validates views based on the validation state of buttons in the main activity. The delete host activity is actually a callActivityForResult. In the delete host activity the users can click the host button, as well as the delete button. If the user click the host button finish() is called and upon return that host’s preferences menu is inflated. I though it logical to do. The delete button calls finish(), passing back the array index of the host to be deleted. Deleting the bottom most host is easy, but deleting a host right smack in the middle of the list was a bit tricky because of the dynamic nature of the host buttons. Because all the buttons are built in the onCreate when a user deletes a host in the middle of the list the hosts below the selection need to be shifted up to accommodate new hosts being at the bottom of the list. The code to delete a button in the middle of the list is easily twice as long as the code to delete the bottom most host.

Then of course is Jsch; the meat and potatoes. Jsch is a java based implementation of ssh. After several weeks if getting used to their code, implementation became rather straight forward. There is no documentation by the writer; examples and the source code itself are your only references. Ultimately the examples are useful, and when it came to come more complicated method calls the source code was also nice and neat. Overall I rate Jsch very high when it comes to the functionality of an API. Jsch is used by VirtualBox Manager to connect to the host. Upon connection it executes “VBoxManager list vms”. I then pipe the InputStream through a variety of methods, using traditional stdout manipulation binaries to format the data. Once formatted the data populates strings. These strings serve as the title for the buttons in the Machines class as well has a means of identifying a particular virtual machine to control. VirtualBox Manager reads all the virtual machines in the users home directory. The way Linux runs, VirtualBox must be part of a particular user group to run. Typically all virtual machines are run as a particular user on a host therefore logging in with ssh conveniently gives access, in all but unique/custom circumstances, to all the virtual machines on the host. While VirtualBox Manager will read all of the machines, it will only populate views with the first 7. I will be expanding the limit of hosts, and machines in upcoming releases; this will be a straight forward code expansion. I will recode the main and machine activity to display a different index of various arrays created holding button views.

When a machine button is pressed a dialog opens with various options. These options are those of VBoxManage controlvm and VBoxManage start. It runs very quickly on Verizon, and all my hardware testing was done on a Droid Incredible.

As of now I know of one or two little bugs that I want to address. I will probably fix them tonight. I will make some upgrades here and there to version 1, but I will be enhancing the ui, and cleaning up the code when I release version 2, which will be a paid app; most likely 99 cents or so. I have many ideas for ui upgrades!

Ultimately before releasing version 1 I was working heavily on RSA encrypted login. There is a lot of code in version 1 pertaining to this. 90% of the code is done, with a couple of bugs holding back release. If I can get the RSA login portion of the code working it will be release in an Enterprise level package that will be priced accordingly. As of now I see three versions of the app; the free version, an enhanced non commercial version, and a commercial version.

Android – Java Avoid Deleting Then Recreating

If an application has an object that has been created, and displayed to the screen then it is deleted, it cannot be immediately recreated. Recent experience tells me that either the variable has to be re-initialized or use another technique to remove it from the screen. Lets say there are 10 buttons on the screen. Only 2 of them are to be displayed. Each button can have a settings variable that referrs to the buttons active state that can in turn set the objects visibility. For example:

By default all buttons will be off. Then to display a new button toggle the on/off setting and update the view with show/hide methods of the respective class (ie. TableLayout, TableRow). All you really have to do is hide the TableRow and not the object in it. Just remeber when you hide the row reset the settings of the respective option to default.

Android Onclicklistener and Onclick

When onclick is called consuming the onclicklistener you will not be able to press the button again without throwing an exception. If you are using the button to transition to a new activity onclick is clearly the function of choice, but if the button is calling a dialog box, to input or display information, you most likely want the listener to not be consumed. For this you will be using onkey or onlongclick. Onkey will return a boolean, so if you want the onclicklistener to remain after the onkey is finished return a false and the the button can be pressed again.

http://developer.android.com/guide/topics/ui/ui-events.html

VirtualBox Windows Vista – Host Network Bridge and Tap

This entire post is no longer applicable to the most recent version of VirtualBox. Here is a more recent post.

VirtualBox is well equipped for a Windows environment. Most of its features have a mechanism for automatic installation and setup. To get your guest OS, in Windows Vista, to have a real IP address from your router you first need a network bridge and tap. Open the VirtualBox manager:

VirtualBox manager screenshot

Then select a guest OS and open its settings. Then click the network tab:
VirtualBox manager network tab

Then click the add network tap button:
Add network tap button

It doesn’t matter what the name is :) Then adjust your guest OS networking adapter accordingly.

Enable host network

Now open your Windows Vista network configurations manager:

Microsoft Vista network configuration

This screenshot is what your network configurations should be after everything is done. To achieve this simply select both the VirtualBox tap, that was previously created, and bridge it to your LAN connection. Select both by click on each adapter while pressing the shift key. Then right click on either of the two highlighted icons and select “bridge”. This will automatically create a bridge between the tap and your real host networking adapter. Wham bam, now you can select a real static IP in your VirtualBox guest OS on a Windows Vista system :)

Update (12/4/2009); At the top of this post I say that the information here is outdated. You can view the post listed above if you want, but here are the pertinent screenshots also:

Here is a screen from Windows Vista. Go to the network tab of the virtual machine settings:

Network settings

Then select the attach to drop down menu:

Attach

Then change the attach to, drop down menu, to bridged adapter:

Bridged adapter