mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 730952 - Update mayHaveTouchListeners correctly on tab changes. r=mleibovic
This commit is contained in:
parent
01c1492892
commit
119c643410
@ -158,12 +158,6 @@ abstract public class GeckoApp
|
||||
private static final String HANDLER_MSG_TYPE = "type";
|
||||
private static final int HANDLER_MSG_TYPE_INITIALIZE = 1;
|
||||
|
||||
public interface OnTabsChangedListener {
|
||||
public void onTabsChanged(Tab tab);
|
||||
}
|
||||
|
||||
private static ArrayList<OnTabsChangedListener> mTabsChangedListeners;
|
||||
|
||||
static class ExtraMenuItem implements MenuItem.OnMenuItemClickListener {
|
||||
String label;
|
||||
String icon;
|
||||
@ -691,7 +685,7 @@ abstract public class GeckoApp
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setFavicon(tab.getFavicon());
|
||||
|
||||
onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.FAVICON);
|
||||
}
|
||||
});
|
||||
|
||||
@ -750,7 +744,6 @@ abstract public class GeckoApp
|
||||
mBrowserToolbar.setSecurityMode("unknown");
|
||||
mDoorHangerPopup.updatePopup();
|
||||
mBrowserToolbar.setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
||||
mLayerController.setWaitForTouchListeners(false);
|
||||
|
||||
if (tab != null)
|
||||
hidePlugins(tab, true);
|
||||
@ -860,30 +853,6 @@ abstract public class GeckoApp
|
||||
overridePendingTransition(R.anim.grow_fade_in, 0);
|
||||
}
|
||||
|
||||
public static void registerOnTabsChangedListener(OnTabsChangedListener listener) {
|
||||
if (mTabsChangedListeners == null)
|
||||
mTabsChangedListeners = new ArrayList<OnTabsChangedListener>();
|
||||
|
||||
mTabsChangedListeners.add(listener);
|
||||
}
|
||||
|
||||
public static void unregisterOnTabsChangedListener(OnTabsChangedListener listener) {
|
||||
if (mTabsChangedListeners == null)
|
||||
return;
|
||||
|
||||
mTabsChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
public void onTabsChanged(Tab tab) {
|
||||
if (mTabsChangedListeners == null)
|
||||
return;
|
||||
|
||||
Iterator<OnTabsChangedListener> items = mTabsChangedListeners.iterator();
|
||||
while (items.hasNext()) {
|
||||
items.next().onTabsChanged(tab);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleMessage(String event, JSONObject message) {
|
||||
Log.i(LOGTAG, "Got message: " + event);
|
||||
try {
|
||||
@ -1276,7 +1245,7 @@ abstract public class GeckoApp
|
||||
if (showProgress)
|
||||
mBrowserToolbar.setProgressVisibility(true);
|
||||
}
|
||||
onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.START);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1292,7 +1261,7 @@ abstract public class GeckoApp
|
||||
public void run() {
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setProgressVisibility(false);
|
||||
onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.STOP);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1331,7 +1300,7 @@ abstract public class GeckoApp
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
|
||||
onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.LOADED);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -1347,7 +1316,7 @@ abstract public class GeckoApp
|
||||
public void run() {
|
||||
if (Tabs.getInstance().isSelectedTab(tab))
|
||||
mBrowserToolbar.setTitle(tab.getDisplayTitle());
|
||||
onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.TITLE);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ public final class Tab {
|
||||
}
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
GeckoApp.mAppContext.onTabsChanged(tab);
|
||||
Tabs.getInstance().notifyListeners(tab, Tabs.TabEvents.THUMBNAIL);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -332,7 +332,7 @@ public final class Tab {
|
||||
mHasTouchListeners = aValue;
|
||||
}
|
||||
|
||||
public boolean hasTouchListeners() {
|
||||
public boolean getHasTouchListeners() {
|
||||
return mHasTouchListeners;
|
||||
}
|
||||
|
||||
|
@ -137,6 +137,7 @@ public class Tabs implements GeckoEventListener {
|
||||
GeckoApp.mBrowserToolbar.setProgressVisibility(tab.isLoading());
|
||||
GeckoApp.mDoorHangerPopup.updatePopup();
|
||||
GeckoApp.mBrowserToolbar.setShadowVisibility(!(tab.getURL().startsWith("about:")));
|
||||
notifyListeners(tab, TabEvents.SELECTED);
|
||||
|
||||
if (oldTab != null)
|
||||
GeckoApp.mAppContext.hidePlugins(oldTab, true);
|
||||
@ -198,7 +199,7 @@ public class Tabs implements GeckoEventListener {
|
||||
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
GeckoApp.mAppContext.onTabsChanged(tab);
|
||||
notifyListeners(tab, TabEvents.CLOSED);
|
||||
GeckoApp.mBrowserToolbar.updateTabCountAndAnimate(Tabs.getInstance().getCount());
|
||||
GeckoApp.mDoorHangerPopup.updatePopup();
|
||||
GeckoApp.mAppContext.hidePlugins(tab, true);
|
||||
@ -312,4 +313,45 @@ public class Tabs implements GeckoEventListener {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnTabsChangedListener {
|
||||
public void onTabChanged(Tab tab, TabEvents msg);
|
||||
}
|
||||
|
||||
private static ArrayList<OnTabsChangedListener> mTabsChangedListeners;
|
||||
|
||||
public static void registerOnTabsChangedListener(OnTabsChangedListener listener) {
|
||||
if (mTabsChangedListeners == null)
|
||||
mTabsChangedListeners = new ArrayList<OnTabsChangedListener>();
|
||||
|
||||
mTabsChangedListeners.add(listener);
|
||||
}
|
||||
|
||||
public static void unregisterOnTabsChangedListener(OnTabsChangedListener listener) {
|
||||
if (mTabsChangedListeners == null)
|
||||
return;
|
||||
|
||||
mTabsChangedListeners.remove(listener);
|
||||
}
|
||||
|
||||
public enum TabEvents {
|
||||
CLOSED,
|
||||
START,
|
||||
LOADED,
|
||||
STOP,
|
||||
FAVICON,
|
||||
THUMBNAIL,
|
||||
TITLE,
|
||||
SELECTED
|
||||
}
|
||||
|
||||
public void notifyListeners(Tab tab, TabEvents msg) {
|
||||
if (mTabsChangedListeners == null)
|
||||
return;
|
||||
|
||||
Iterator<OnTabsChangedListener> items = mTabsChangedListeners.iterator();
|
||||
while (items.hasNext()) {
|
||||
items.next().onTabChanged(tab, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener {
|
||||
public class TabsTray extends Activity implements Tabs.OnTabsChangedListener {
|
||||
|
||||
private static int sPreferredHeight;
|
||||
private static int sMaxHeight;
|
||||
@ -107,18 +107,19 @@ public class TabsTray extends Activity implements GeckoApp.OnTabsChangedListener
|
||||
sPreferredHeight = (int) (0.67 * metrics.heightPixels);
|
||||
sMaxHeight = (int) (sPreferredHeight + (0.33 * sListItemHeight));
|
||||
|
||||
GeckoApp.registerOnTabsChangedListener(this);
|
||||
Tabs.getInstance().refreshThumbnails();
|
||||
onTabsChanged(null);
|
||||
Tabs tabs = Tabs.getInstance();
|
||||
tabs.registerOnTabsChangedListener(this);
|
||||
tabs.refreshThumbnails();
|
||||
onTabChanged(null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
GeckoApp.unregisterOnTabsChangedListener(this);
|
||||
Tabs.getInstance().unregisterOnTabsChangedListener(this);
|
||||
}
|
||||
|
||||
public void onTabsChanged(Tab tab) {
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg) {
|
||||
if (Tabs.getInstance().getCount() == 1)
|
||||
finishActivity();
|
||||
|
||||
|
@ -46,6 +46,8 @@ import org.mozilla.gecko.ui.PanZoomController;
|
||||
import org.mozilla.gecko.ui.SimpleScaleGestureDetector;
|
||||
import org.mozilla.gecko.GeckoApp;
|
||||
import org.mozilla.gecko.GeckoEvent;
|
||||
import org.mozilla.gecko.Tabs;
|
||||
import org.mozilla.gecko.Tab;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
@ -72,7 +74,7 @@ import java.util.TimerTask;
|
||||
*
|
||||
* Many methods require that the monitor be held, with a synchronized (controller) { ... } block.
|
||||
*/
|
||||
public class LayerController {
|
||||
public class LayerController implements Tabs.OnTabsChangedListener {
|
||||
private static final String LOGTAG = "GeckoLayerController";
|
||||
|
||||
private Layer mRootLayer; /* The root layer. */
|
||||
@ -123,6 +125,12 @@ public class LayerController {
|
||||
mViewportMetrics = new ViewportMetrics();
|
||||
mPanZoomController = new PanZoomController(this);
|
||||
mView = new LayerView(context, this);
|
||||
|
||||
Tabs.getInstance().registerOnTabsChangedListener(this);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
Tabs.getInstance().unregisterOnTabsChangedListener(this);
|
||||
}
|
||||
|
||||
public void setRoot(Layer layer) { mRootLayer = layer; }
|
||||
@ -465,6 +473,11 @@ public class LayerController {
|
||||
}
|
||||
}
|
||||
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg) {
|
||||
if ((Tabs.getInstance().isSelectedTab(tab) && msg == Tabs.TabEvents.STOP) || msg == Tabs.TabEvents.SELECTED) {
|
||||
mWaitForTouchListeners = tab.getHasTouchListeners();
|
||||
}
|
||||
}
|
||||
public void setWaitForTouchListeners(boolean aValue) {
|
||||
mWaitForTouchListeners = aValue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user