New version for Linode Android Beta v0.6.0

I’m very happy with this version, many bug fixed and layout improvements.
Enjoy!!

Beta Version 0.6.0 – May 20,2010
– Fix Layout Landscape View
– Add Kernel Info
– Add Ram Limit Info
– Add ReadOnly Disk Info
– Add Backup Info
– Add Transfer/Mo Info
– Major bug fixes.

Linode Manager for Android
Release History

Linode Android – Beta Release

Start of public beta testing period.
Now Linode Android is Beta, please report bug or suggest features
Enjoy!!

Beta Version 0.5.0 – May 12,2010
– Linode Graphs
– Linode Resize.
– Linode Rename.
– Linode Alert.
– Layout improvements
– Major bug fixes.

Linode Manager for Android
Release History

Android – Tab Layout Scroll

I created an extension of Tab Layout to allow add many elements in TabHost.

1. First Create TabScrollHost Object

Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost1 = getTabHost(); // The activity TabHost
TabHost.TabSpec spec;  // Resusable TabSpec for each tab
Intent intent;  // Reusable Intent for each tab

ImageView tab_next = (ImageView) findViewById(R.id.tab_next); //Next Image
ImageView tab_previous = (ImageView) findViewById(R.id.tab_previous); //Previous Image
TabScrollHost tabHost = new TabScrollHost(tabHost1,tab_next,tab_previous); //my Class

2. Now just add all elements on TabScrollHost

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab1”).setIndicator(“Tab1”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab2”).setIndicator(“Tab2”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

….

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab10”).setIndicator(“Tab10”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

3. Done. TabScrollHost will controller, to change the number of elements:

private static final int TAB_MAX = 4;

Enjoy!!!

main.xml

<?xml version=”1.0″ encoding=”utf-8″?>
<TabHost xmlns:android=”http://schemas.android.com/apk/res/android&#8221;
android:id=”@android:id/tabhost”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”>
<LinearLayout
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:padding=”5dp”>

<TabWidget
android:id=”@android:id/tabs”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_marginRight=”2pt”
android:layout_marginLeft=”2pt” />

<ImageView
android:id=”@+id/tab_previous”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_gravity=”left|top”
android:src=”@drawable/previous”
android:layout_marginTop=”-18px”
android:layout_marginLeft=”-2px”/>

<ImageView
android:id=”@+id/tab_next”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_gravity=”right|top”
android:src=”@drawable/next”
android:layout_marginTop=”-22px”
android:layout_marginRight=”-2px”/>

<FrameLayout
android:id=”@android:id/tabcontent”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”/>
android:padding=”5dp” />
</LinearLayout>
</TabHost>

Java Code:

public class TabScrollHost {
private TabHost tabHost;

private static final int TAB_MAX = 4;
private List<TabHost.TabSpec> listTab;
private int currentPage = 0;

private ImageView tab_next;
private ImageView tab_previous;

public TabScrollHost(TabHost tabHost,ImageView tab_next,ImageView tab_previous) {
this.listTab = new ArrayList<TabHost.TabSpec>();
this.currentPage = 0;
this.tabHost = tabHost;
this.tab_previous = tab_previous;
this.tab_next = tab_next;

this.tab_previous.setVisibility(View.INVISIBLE);
this.tab_next.setVisibility(View.INVISIBLE);

this.tab_next.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onClickNext();
}
});

this.tab_previous.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
onClickPrevious();
}
});
}

public void onClickNext() {
currentPage++;
this.tabHost.setCurrentTab(0);
this.tabHost.clearAllTabs();
int start = currentPage * TAB_MAX;
int end = start + TAB_MAX;
if(end >= listTab.size()){
end = listTab.size();
this.tab_next.setVisibility(View.INVISIBLE);
}
Log.v(“TabScrollHost”, “start:”+start+” end:”+end);
Log.v(“TabScrollHost”, “listTab:”+listTab);

List<TabHost.TabSpec> subList = listTab.subList(start, end);
for (TabHost.TabSpec spec : subList) {
this.tabHost.addTab(spec);
}

//this.tabHost.setCurrentTab(0);
this.tab_previous.setVisibility(View.VISIBLE);
}

public void onClickPrevious() {
currentPage–;
this.tabHost.setCurrentTab(0);
this.tabHost.clearAllTabs();

int start = currentPage * TAB_MAX;
int end = start + TAB_MAX;

Log.v(“TabScrollHost”, “start:”+start+” end:”+end);
Log.v(“TabScrollHost”, “listTab:”+listTab);

List<TabHost.TabSpec> subList = listTab.subList(start, end);
for (TabHost.TabSpec spec : subList) {
this.tabHost.addTab(spec);
}

//this.tabHost.setCurrentTab(0);
if(currentPage <=0)
this.tab_previous.setVisibility(View.INVISIBLE);

this.tab_next.setVisibility(View.VISIBLE);
}

public void addTab(TabHost.TabSpec tabSpec) {
Log.v(“TabScrollHost”, “addTab”);
listTab.add(tabSpec);

if (listTab.size() <= TAB_MAX) {
this.tabHost.addTab(tabSpec);
}else{
this.tab_next.setVisibility(View.VISIBLE);
}
}

public void setCurrentTab(int index){
this.tabHost.setCurrentTab(index);
}

}

public class MainActivity extends TabActivity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost1 = getTabHost(); // The activity TabHost
TabHost.TabSpec spec;  // Resusable TabSpec for each tab
Intent intent;  // Reusable Intent for each tab

ImageView tab_next = (ImageView) findViewById(R.id.tab_next);
ImageView tab_previous = (ImageView) findViewById(R.id.tab_previous);
TabScrollHost tabHost = new TabScrollHost(tabHost1,tab_next,tab_previous);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab1”).setIndicator(“Tab1”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab2”).setIndicator(“Tab2”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab3”).setIndicator(“Tab3”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab4”).setIndicator(“Tab4”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab5”).setIndicator(“Tab5”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab6”).setIndicator(“Tab6”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab7”).setIndicator(“Tab7”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab8”).setIndicator(“Tab8”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab9”).setIndicator(“Tab9”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

intent = new Intent().setClass(this,Tab1Activity.class);
spec = tabHost1.newTabSpec(“tab10”).setIndicator(“Tab10”,
res.getDrawable(R.drawable.icon)).setContent(intent);
tabHost.addTab(spec);

tabHost.setCurrentTab(0);
}
}

public class Tab1Activity extends Activity {

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

TextView textview = new TextView(this);
textview.setText(“This is the Artists tab”);
setContentView(textview);
}

}

Android Https Connection

I got this error on Android SDK 1.1 on HTTPS connections.

java.io.IOException: Hostname <www.verisign.com> was not verified

To Fix it, just include this code bellow:

URL aURL = new URL(url);

HttpsURLConnection conn = (HttpsURLConnection) aURL.openConnection();
conn.setHostnameVerifier( new HostnameVerifier() {
public boolean verify( String hostname, SSLSession session ) {
return true;
}
});

conn.connect();

Enjoy!!