From 3d605d5bbef35e3b8aded44c5ef7fe3948f8f7d5 Mon Sep 17 00:00:00 2001 From: Patrick Dubroy Date: Thu, 29 Jul 2010 13:59:29 -0700 Subject: Make tabs in all apps actually filter the list of apps. --- src/com/android/launcher2/AllAppsTabbed.java | 45 ++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) (limited to 'src/com/android/launcher2/AllAppsTabbed.java') diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java index 7f6f63f97..20027032c 100644 --- a/src/com/android/launcher2/AllAppsTabbed.java +++ b/src/com/android/launcher2/AllAppsTabbed.java @@ -34,16 +34,23 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { private static final String TAG = "Launcher.AllAppsTabbed"; - private AllAppsView mAllApps2D; + private static final String TAG_ALL = "ALL"; + private static final String TAG_APPS = "APPS"; + private static final String TAG_GAMES = "GAMES"; + private static final String TAG_DOWNLOADED = "DOWNLOADED"; + + private AllApps2D mAllApps2D; + private Context mContext; public AllAppsTabbed(Context context, AttributeSet attrs) { super(context, attrs); + mContext = context; } @Override protected void onFinishInflate() { try { - mAllApps2D = (AllAppsView)findViewById(R.id.all_apps_2d); + mAllApps2D = (AllApps2D)findViewById(R.id.all_apps_2d); if (mAllApps2D == null) throw new Resources.NotFoundException(); } catch (Resources.NotFoundException e) { Log.e(TAG, "Can't find necessary layout elements for AllAppsTabbed"); @@ -53,15 +60,36 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { // This lets us share the same view between all tabs TabContentFactory contentFactory = new TabContentFactory() { public View createTabContent(String tag) { - return (View)mAllApps2D; + return mAllApps2D; } }; - // TODO: Make these tabs show the appropriate content (they're no-ops for now) - addTab(newTabSpec("apps").setIndicator("All").setContent(contentFactory)); - addTab(newTabSpec("apps").setIndicator("Apps").setContent(contentFactory)); - addTab(newTabSpec("apps").setIndicator("Games").setContent(contentFactory)); - addTab(newTabSpec("apps").setIndicator("Downloaded").setContent(contentFactory)); + String label = mContext.getString(R.string.all_apps_tab_all); + addTab(newTabSpec(TAG_ALL).setIndicator(label).setContent(contentFactory)); + + label = mContext.getString(R.string.all_apps_tab_apps); + addTab(newTabSpec(TAG_APPS).setIndicator(label).setContent(contentFactory)); + + label = mContext.getString(R.string.all_apps_tab_games); + addTab(newTabSpec(TAG_GAMES).setIndicator(label).setContent(contentFactory)); + + label = mContext.getString(R.string.all_apps_tab_downloaded); + addTab(newTabSpec(TAG_DOWNLOADED).setIndicator(label).setContent(contentFactory)); + + setOnTabChangedListener(new OnTabChangeListener() { + public void onTabChanged(String tabId) { + String tag = getCurrentTabTag(); + if (tag == TAG_ALL) { + mAllApps2D.filterApps(AllApps2D.AppType.ALL); + } else if (tag == TAG_APPS) { + mAllApps2D.filterApps(AllApps2D.AppType.APP); + } else if (tag == TAG_GAMES) { + mAllApps2D.filterApps(AllApps2D.AppType.GAME); + } else if (tag == TAG_DOWNLOADED) { + mAllApps2D.filterApps(AllApps2D.AppType.DOWNLOADED); + } + } + }); setCurrentTab(0); setVisibility(GONE); @@ -125,5 +153,4 @@ public class AllAppsTabbed extends TabHost implements AllAppsView { public void surrender() { mAllApps2D.surrender(); } - } -- cgit v1.2.3