From 00de6c0cc6161065d397ef758e3cb7a4e6310cd0 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 13 Feb 2014 18:42:34 +0000 Subject: [PATCH] Bug 968573 - Use ViewConfig's item handler to define url opener flags (r=margaret) --- mobile/android/base/home/PanelGridView.java | 10 +++++++++- mobile/android/base/home/PanelListView.java | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mobile/android/base/home/PanelGridView.java b/mobile/android/base/home/PanelGridView.java index ef356399e10b..d63a9e70931a 100644 --- a/mobile/android/base/home/PanelGridView.java +++ b/mobile/android/base/home/PanelGridView.java @@ -7,6 +7,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; import org.mozilla.gecko.db.BrowserContract.HomeItems; +import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; @@ -27,11 +28,13 @@ public class PanelGridView extends GridView implements DatasetBacked, PanelView { private static final String LOGTAG = "GeckoPanelGridView"; + private final ViewConfig mViewConfig; private final PanelGridViewAdapter mAdapter; protected OnUrlOpenListener mUrlOpenListener; public PanelGridView(Context context, ViewConfig viewConfig) { super(context, null, R.attr.panelGridViewStyle); + mViewConfig = viewConfig; mAdapter = new PanelGridViewAdapter(context); setAdapter(mAdapter); setOnItemClickListener(new PanelGridItemClickListener()); @@ -82,7 +85,12 @@ public class PanelGridView extends GridView int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL); final String url = cursor.getString(urlIndex); - mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.OPEN_WITH_INTENT)); + EnumSet flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class); + if (mViewConfig.getItemHandler() == ItemHandler.INTENT) { + flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT); + } + + mUrlOpenListener.onUrlOpen(url, flags); } } } diff --git a/mobile/android/base/home/PanelListView.java b/mobile/android/base/home/PanelListView.java index e8ae046af6cb..f88504171afa 100644 --- a/mobile/android/base/home/PanelListView.java +++ b/mobile/android/base/home/PanelListView.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.home; import org.mozilla.gecko.R; +import org.mozilla.gecko.home.HomeConfig.ItemHandler; import org.mozilla.gecko.home.HomeConfig.ViewConfig; import org.mozilla.gecko.home.HomePager.OnUrlOpenListener; import org.mozilla.gecko.home.PanelLayout.DatasetBacked; @@ -73,7 +74,12 @@ public class PanelListView extends HomeListView int urlIndex = cursor.getColumnIndexOrThrow(HomeItems.URL); final String url = cursor.getString(urlIndex); - mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.OPEN_WITH_INTENT)); + EnumSet flags = EnumSet.noneOf(OnUrlOpenListener.Flags.class); + if (mViewConfig.getItemHandler() == ItemHandler.INTENT) { + flags.add(OnUrlOpenListener.Flags.OPEN_WITH_INTENT); + } + + mUrlOpenListener.onUrlOpen(url, flags); } } }