Change the Hybrid App Package list view to a gallery view.
The comment tag associated with creating categorized views is ANDROID_CUSTOMIZATION_POINT_HYBRIDAPPLIST.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Gallery xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/gallery" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
package com.sybase.hwc; import java.util.ArrayList; import java.util.Vector; import java.util.Arrays; import com.sybase.hybridApp.*; import com.sybase.hybridApp.amp.Consts; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.AdapterView.OnItemClickListener; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.ImageView; public class HybridAppGalleryActivity extends Activity { ImageAdapter m_adapter; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hybridappgallery); Gallery oGallery = (Gallery) findViewById(R.id.gallery); m_adapter = new ImageAdapter(this); oGallery.setAdapter(m_adapter); oGallery.setOnItemClickListener(new OnItemClickListener () { public void onItemClick(AdapterView parent, View v, int position, long id) { startHybridApp(parent, v, position, id); } }); } public void startHybridApp(AdapterView oParent, View v, int iPos, long id ) { Intent oIntentHybridAppContainer = new Intent( this, UiHybridAppContainer.class ); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_START_MODE, Consts.START_MODE_HYBRIDAPP ); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_ID, m_adapter.getItem( iPos ).getHybridAppId() ); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_PROGRESS_TEXT, m_adapter.getItem( iPos ).getDisplayName() ); startActivityForResult( oIntentHybridAppContainer, Consts.INTENT_ID_HYBRIDAPP_CONTAINER ); } @Override public void onActivityResult( int iRequestCode, int iResultCode, Intent relaunchData ) { super.onActivityResult( iRequestCode, iResultCode, relaunchData ); if ( iRequestCode == Consts.INTENT_ID_HYBRIDAPP_CONTAINER && iResultCode == Consts.RESULT_RELAUNCH ) { Intent oIntentHybridAppContainer = new Intent( this, UiHybridAppContainer.class ); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_START_MODE, Consts.START_MODE_HYBRIDAPP ); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_ID, relaunchData.getIntExtra( Consts.INTENT_PARAM_HYBRIDAPP_ID, 0 )); oIntentHybridAppContainer.putExtra( Consts.INTENT_PARAM_HYBRIDAPP_PROGRESS_TEXT, relaunchData.getStringExtra( Consts.INTENT_PARAM_HYBRIDAPP_PROGRESS_TEXT )); startActivityForResult( oIntentHybridAppContainer, Consts.INTENT_ID_HYBRIDAPP_CONTAINER ); } } public class ImageAdapter extends BaseAdapter { //int mGalleryItemBackground; private Context mContext; private Vector<HybridApp> mHybridApps; private ArrayList<Integer> mImageIds; public ImageAdapter(Context c) { mContext = c; mImageIds = new ArrayList<Integer>(); //have to get a list of all installed HybridAppss mHybridApps = new Vector<HybridApp>( Arrays.asList(HybridAppDb.getInvocableHybridApps(false)) ); for(int iHybridAppIndex = 0; iHybridAppIndex < mHybridApps.size(); iHybridAppIndex++) { HybridAppDb oHybridApp = (HybridAppDb) mHybridApps.get(iHybridAppIndex); int iconIndex = oHybridApp.getIconIndex(); if(iconIndex >= 30 && iconIndex <= 116) { //luckily the icon resources are consecutive int iResource = 0; if(iconIndex < 100) { iResource = 0x7f020022; iResource += (iconIndex - 30)*2; } else { iResource = 0x7f020000; iResource += (iconIndex - 100)*2; } mImageIds.add(new Integer(iResource)); } } } public int getHybridAppId(int position) { return ((HybridAppDb)mHybridApps.get(position)).getHybridAppId(); } public String getDisplayName(int position) { return ((HybridAppDb)mHybridApps.get(position)).getDisplayName(); } public int getCount() { return mImageIds.size(); } public HybridAppDb getItem(int position) { return (HybridAppDb)mHybridApps.get(position); } public long getItemId(int position) { return position; } public View getView(int position, View convertView, ViewGroup parent) { ImageView imageView = new ImageView(mContext); imageView.setImageResource(mImageIds.get(position).intValue()); imageView.setLayoutParams(new Gallery.LayoutParams(150,100)); imageView.setScaleType(ImageView.ScaleType.FIT_XY); return imageView; } } }