2011-11-18 18:28:17 +00:00
|
|
|
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
2012-05-21 11:12:37 +00:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2011-11-18 18:28:17 +00:00
|
|
|
|
|
|
|
package org.mozilla.gecko;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.drawable.AnimationDrawable;
|
2012-05-31 23:01:50 +00:00
|
|
|
import android.graphics.drawable.ColorDrawable;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.graphics.drawable.Drawable;
|
2012-08-20 04:45:37 +00:00
|
|
|
import android.graphics.Rect;
|
2012-01-27 19:19:13 +00:00
|
|
|
import android.os.Build;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.os.Handler;
|
2012-01-24 20:39:23 +00:00
|
|
|
import android.os.SystemClock;
|
2012-06-15 15:58:13 +00:00
|
|
|
import android.text.TextUtils;
|
2012-01-24 20:39:23 +00:00
|
|
|
import android.util.Log;
|
2012-06-07 17:13:36 +00:00
|
|
|
import android.view.ContextMenu;
|
2012-05-25 22:10:26 +00:00
|
|
|
import android.view.LayoutInflater;
|
2012-06-07 17:13:36 +00:00
|
|
|
import android.view.MenuInflater;
|
2012-08-20 04:45:37 +00:00
|
|
|
import android.view.MotionEvent;
|
|
|
|
import android.view.TouchDelegate;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.view.View;
|
2012-05-31 23:01:50 +00:00
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.view.Window;
|
2012-08-24 13:52:24 +00:00
|
|
|
import android.view.accessibility.AccessibilityNodeInfo;
|
2012-08-23 18:27:11 +00:00
|
|
|
import android.view.animation.AlphaAnimation;
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.DecelerateInterpolator;
|
2012-07-28 00:53:54 +00:00
|
|
|
import android.view.animation.TranslateAnimation;
|
|
|
|
import android.view.inputmethod.InputMethodManager;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.widget.Button;
|
|
|
|
import android.widget.ImageButton;
|
2011-12-15 19:53:04 +00:00
|
|
|
import android.widget.ImageView;
|
2012-08-23 18:27:11 +00:00
|
|
|
import android.widget.FrameLayout;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.widget.LinearLayout;
|
2012-05-31 23:01:50 +00:00
|
|
|
import android.widget.PopupWindow;
|
|
|
|
import android.widget.RelativeLayout;
|
2011-11-18 18:28:17 +00:00
|
|
|
import android.widget.TextSwitcher;
|
2012-07-28 00:53:54 +00:00
|
|
|
import android.widget.TextView;
|
2012-05-25 22:10:26 +00:00
|
|
|
import android.widget.ViewSwitcher;
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-07-28 00:53:54 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
2012-07-18 00:54:54 +00:00
|
|
|
public class BrowserToolbar implements ViewSwitcher.ViewFactory,
|
|
|
|
Tabs.OnTabsChangedListener,
|
2012-08-23 18:27:11 +00:00
|
|
|
GeckoMenu.ActionItemBarPresenter,
|
|
|
|
Animation.AnimationListener {
|
2012-03-21 00:23:06 +00:00
|
|
|
private static final String LOGTAG = "GeckoToolbar";
|
|
|
|
private LinearLayout mLayout;
|
2011-12-07 23:12:51 +00:00
|
|
|
private Button mAwesomeBar;
|
2012-08-23 18:27:11 +00:00
|
|
|
private TextView mTitle;
|
|
|
|
private int mTitlePadding;
|
2012-08-23 18:27:11 +00:00
|
|
|
private boolean mSiteSecurityVisible;
|
2012-09-07 19:11:42 +00:00
|
|
|
private boolean mAnimateSiteSecurity;
|
2011-12-07 23:12:51 +00:00
|
|
|
private ImageButton mTabs;
|
2012-05-24 22:47:49 +00:00
|
|
|
private ImageView mBack;
|
|
|
|
private ImageView mForward;
|
2011-12-07 23:12:51 +00:00
|
|
|
public ImageButton mFavicon;
|
|
|
|
public ImageButton mStop;
|
|
|
|
public ImageButton mSiteSecurity;
|
2012-06-02 18:23:45 +00:00
|
|
|
public ImageButton mReader;
|
2011-12-07 23:12:51 +00:00
|
|
|
private AnimationDrawable mProgressSpinner;
|
|
|
|
private TextSwitcher mTabsCount;
|
2011-12-15 19:53:04 +00:00
|
|
|
private ImageView mShadow;
|
2012-05-31 23:01:50 +00:00
|
|
|
private ImageButton mMenu;
|
|
|
|
private LinearLayout mActionItemBar;
|
|
|
|
private MenuPopup mMenuPopup;
|
2012-07-10 23:10:15 +00:00
|
|
|
private List<View> mFocusOrder;
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-07-28 06:15:39 +00:00
|
|
|
final private BrowserApp mActivity;
|
2012-05-31 23:01:50 +00:00
|
|
|
private LayoutInflater mInflater;
|
2011-12-07 23:12:51 +00:00
|
|
|
private Handler mHandler;
|
2012-05-31 23:01:50 +00:00
|
|
|
private boolean mHasSoftMenuButton;
|
|
|
|
|
2012-06-02 18:23:45 +00:00
|
|
|
private boolean mShowSiteSecurity;
|
|
|
|
private boolean mShowReader;
|
|
|
|
|
2012-05-31 23:01:50 +00:00
|
|
|
private static List<View> sActionItems;
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2011-12-07 23:12:51 +00:00
|
|
|
private int mDuration;
|
|
|
|
private TranslateAnimation mSlideUpIn;
|
|
|
|
private TranslateAnimation mSlideUpOut;
|
|
|
|
private TranslateAnimation mSlideDownIn;
|
|
|
|
private TranslateAnimation mSlideDownOut;
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
private AlphaAnimation mLockFadeIn;
|
|
|
|
private TranslateAnimation mTitleSlideLeft;
|
|
|
|
private TranslateAnimation mTitleSlideRight;
|
|
|
|
|
2011-11-18 18:28:17 +00:00
|
|
|
private int mCount;
|
|
|
|
|
2012-06-08 04:47:22 +00:00
|
|
|
private static final int TABS_CONTRACTED = 1;
|
|
|
|
private static final int TABS_EXPANDED = 2;
|
|
|
|
|
2012-07-28 06:15:39 +00:00
|
|
|
public BrowserToolbar(BrowserApp activity) {
|
|
|
|
// BrowserToolbar is attached to BrowserApp only.
|
|
|
|
mActivity = activity;
|
|
|
|
mInflater = LayoutInflater.from(activity);
|
2012-05-31 23:01:50 +00:00
|
|
|
|
|
|
|
sActionItems = new ArrayList<View>();
|
2012-06-13 17:52:46 +00:00
|
|
|
Tabs.registerOnTabsChangedListener(this);
|
2012-09-07 19:11:42 +00:00
|
|
|
mAnimateSiteSecurity = true;
|
2012-03-21 00:23:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void from(LinearLayout layout) {
|
|
|
|
mLayout = layout;
|
2012-06-02 18:23:45 +00:00
|
|
|
|
|
|
|
mShowSiteSecurity = false;
|
|
|
|
mShowReader = false;
|
2012-01-27 20:28:45 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
mTitle = (TextView) mLayout.findViewById(R.id.awesome_bar_title);
|
|
|
|
mTitlePadding = mTitle.getPaddingRight();
|
|
|
|
if (Build.VERSION.SDK_INT >= 16)
|
|
|
|
mTitle.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
mAwesomeBar = (Button) mLayout.findViewById(R.id.awesome_bar);
|
2011-11-18 18:28:17 +00:00
|
|
|
mAwesomeBar.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.autoHideTabs();
|
2011-11-18 18:28:17 +00:00
|
|
|
onAwesomeBarSearch();
|
|
|
|
}
|
|
|
|
});
|
2012-06-07 17:13:36 +00:00
|
|
|
mAwesomeBar.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
2012-07-28 06:15:39 +00:00
|
|
|
MenuInflater inflater = mActivity.getMenuInflater();
|
2012-06-07 17:13:36 +00:00
|
|
|
inflater.inflate(R.menu.titlebar_contextmenu, menu);
|
|
|
|
|
|
|
|
String clipboard = GeckoAppShell.getClipboardText();
|
2012-06-15 15:58:13 +00:00
|
|
|
if (clipboard == null || TextUtils.isEmpty(clipboard)) {
|
2012-06-07 17:13:36 +00:00
|
|
|
menu.findItem(R.id.pasteandgo).setVisible(false);
|
|
|
|
menu.findItem(R.id.paste).setVisible(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
|
|
|
if (tab != null) {
|
|
|
|
String url = tab.getURL();
|
|
|
|
if (url == null) {
|
|
|
|
menu.findItem(R.id.copyurl).setVisible(false);
|
|
|
|
menu.findItem(R.id.share).setVisible(false);
|
|
|
|
menu.findItem(R.id.add_to_launcher).setVisible(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// if there is no tab, remove anything tab dependent
|
|
|
|
menu.findItem(R.id.copyurl).setVisible(false);
|
|
|
|
menu.findItem(R.id.share).setVisible(false);
|
|
|
|
menu.findItem(R.id.add_to_launcher).setVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
mTabs = (ImageButton) mLayout.findViewById(R.id.tabs);
|
2011-11-18 18:28:17 +00:00
|
|
|
mTabs.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
2012-06-08 04:47:22 +00:00
|
|
|
toggleTabs();
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
});
|
2012-02-01 22:25:50 +00:00
|
|
|
mTabs.setImageLevel(0);
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
mTabsCount = (TextSwitcher) mLayout.findViewById(R.id.tabs_count);
|
2011-12-07 23:12:51 +00:00
|
|
|
mTabsCount.removeAllViews();
|
2012-05-25 22:10:26 +00:00
|
|
|
mTabsCount.setFactory(this);
|
2012-06-08 04:47:22 +00:00
|
|
|
mTabsCount.setText("");
|
2011-12-07 23:12:51 +00:00
|
|
|
mCount = 0;
|
2012-08-24 13:52:24 +00:00
|
|
|
if (Build.VERSION.SDK_INT >= 16) {
|
|
|
|
// This adds the TextSwitcher to the a11y node tree, where we in turn
|
|
|
|
// could make it return an empty info node. If we don't do this the
|
|
|
|
// TextSwitcher's child TextViews get picked up, and we don't want
|
|
|
|
// that since the tabs ImageButton is already properly labeled for
|
|
|
|
// accessibility.
|
|
|
|
mTabsCount.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_YES);
|
|
|
|
mTabsCount.setAccessibilityDelegate(new View.AccessibilityDelegate() {
|
|
|
|
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {}
|
|
|
|
});
|
|
|
|
}
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-05-24 22:47:49 +00:00
|
|
|
mBack = (ImageButton) mLayout.findViewById(R.id.back);
|
|
|
|
mBack.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
|
|
|
Tabs.getInstance().getSelectedTab().doBack();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mForward = (ImageButton) mLayout.findViewById(R.id.forward);
|
|
|
|
mForward.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
|
|
|
Tabs.getInstance().getSelectedTab().doForward();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
Button.OnClickListener faviconListener = new Button.OnClickListener() {
|
2012-05-02 16:07:58 +00:00
|
|
|
public void onClick(View view) {
|
2012-08-23 18:27:11 +00:00
|
|
|
if (mSiteSecurity.getVisibility() != View.VISIBLE)
|
|
|
|
return;
|
2012-08-23 18:27:11 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
SiteIdentityPopup.getInstance().show(mSiteSecurity);
|
2012-08-23 21:54:31 +00:00
|
|
|
}
|
2012-08-23 18:27:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
mFavicon = (ImageButton) mLayout.findViewById(R.id.favicon);
|
|
|
|
mFavicon.setOnClickListener(faviconListener);
|
|
|
|
if (Build.VERSION.SDK_INT >= 16)
|
|
|
|
mFavicon.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
|
|
|
|
|
|
|
|
mSiteSecurity = (ImageButton) mLayout.findViewById(R.id.site_security);
|
|
|
|
mSiteSecurity.setOnClickListener(faviconListener);
|
2012-08-23 18:27:11 +00:00
|
|
|
mSiteSecurityVisible = (mSiteSecurity.getVisibility() == View.VISIBLE);
|
2012-05-02 16:07:58 +00:00
|
|
|
|
2012-07-28 06:15:39 +00:00
|
|
|
mProgressSpinner = (AnimationDrawable) mActivity.getResources().getDrawable(R.drawable.progress_spinner);
|
2011-11-18 18:28:17 +00:00
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
mStop = (ImageButton) mLayout.findViewById(R.id.stop);
|
2011-11-18 18:28:17 +00:00
|
|
|
mStop.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View v) {
|
2012-05-04 19:52:13 +00:00
|
|
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
|
|
|
if (tab != null)
|
|
|
|
tab.doStop();
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-06-02 18:23:45 +00:00
|
|
|
mReader = (ImageButton) mLayout.findViewById(R.id.reader);
|
|
|
|
mReader.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
2012-06-20 18:10:08 +00:00
|
|
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
|
|
|
if (tab != null)
|
|
|
|
tab.readerMode();
|
2012-06-02 18:23:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
mShadow = (ImageView) mLayout.findViewById(R.id.shadow);
|
2011-12-15 19:53:04 +00:00
|
|
|
|
2011-11-18 18:28:17 +00:00
|
|
|
mHandler = new Handler();
|
2012-01-27 19:19:13 +00:00
|
|
|
mSlideUpIn = new TranslateAnimation(0, 0, 40, 0);
|
|
|
|
mSlideUpOut = new TranslateAnimation(0, 0, 0, -40);
|
|
|
|
mSlideDownIn = new TranslateAnimation(0, 0, -40, 0);
|
|
|
|
mSlideDownOut = new TranslateAnimation(0, 0, 0, 40);
|
2011-11-18 18:28:17 +00:00
|
|
|
|
|
|
|
mDuration = 750;
|
|
|
|
mSlideUpIn.setDuration(mDuration);
|
|
|
|
mSlideUpOut.setDuration(mDuration);
|
|
|
|
mSlideDownIn.setDuration(mDuration);
|
|
|
|
mSlideDownOut.setDuration(mDuration);
|
2012-05-31 23:01:50 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
float slideWidth = mActivity.getResources().getDimension(R.dimen.browser_toolbar_lock_width);
|
|
|
|
|
|
|
|
LinearLayout.LayoutParams siteSecParams = (LinearLayout.LayoutParams) mSiteSecurity.getLayoutParams();
|
|
|
|
final float scale = mActivity.getResources().getDisplayMetrics().density;
|
|
|
|
slideWidth += (siteSecParams.leftMargin + siteSecParams.rightMargin) * scale + 0.5f;
|
|
|
|
|
|
|
|
mLockFadeIn = new AlphaAnimation(0.0f, 1.0f);
|
|
|
|
mLockFadeIn.setAnimationListener(this);
|
|
|
|
|
|
|
|
mTitleSlideLeft = new TranslateAnimation(slideWidth, 0, 0, 0);
|
|
|
|
mTitleSlideLeft.setAnimationListener(this);
|
|
|
|
|
|
|
|
mTitleSlideRight = new TranslateAnimation(-slideWidth, 0, 0, 0);
|
|
|
|
mTitleSlideRight.setAnimationListener(this);
|
|
|
|
|
|
|
|
final int lockAnimDuration = 300;
|
|
|
|
mLockFadeIn.setDuration(lockAnimDuration);
|
|
|
|
mTitleSlideLeft.setDuration(lockAnimDuration);
|
|
|
|
mTitleSlideRight.setDuration(lockAnimDuration);
|
|
|
|
|
2012-05-31 23:01:50 +00:00
|
|
|
mMenu = (ImageButton) mLayout.findViewById(R.id.menu);
|
|
|
|
mActionItemBar = (LinearLayout) mLayout.findViewById(R.id.menu_items);
|
2012-07-28 06:15:39 +00:00
|
|
|
mHasSoftMenuButton = !mActivity.hasPermanentMenuKey();
|
2012-05-31 23:01:50 +00:00
|
|
|
|
|
|
|
if (mHasSoftMenuButton) {
|
|
|
|
mMenu.setVisibility(View.VISIBLE);
|
|
|
|
mMenu.setOnClickListener(new Button.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.openOptionsMenu();
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
});
|
2012-08-20 04:45:37 +00:00
|
|
|
|
|
|
|
// Set a touch delegate to Tabs button, so the touch events on its tail
|
|
|
|
// are passed to the menu button.
|
|
|
|
mLayout.post(new Runnable() {
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
int height = mTabs.getHeight();
|
|
|
|
int width = mTabs.getWidth();
|
|
|
|
int tail = (width - height) / 2;
|
|
|
|
Rect bounds = new Rect(width - tail, 0, width, height);
|
|
|
|
mTabs.setTouchDelegate(new TailTouchDelegate(bounds, mMenu));
|
|
|
|
}
|
|
|
|
});
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 11) {
|
2012-07-28 06:15:39 +00:00
|
|
|
View panel = mActivity.getMenuPanel();
|
2012-05-31 23:01:50 +00:00
|
|
|
|
|
|
|
// If panel is null, the app is starting up for the first time;
|
|
|
|
// add this to the popup only if we have a soft menu button.
|
|
|
|
// else, browser-toolbar is initialized on rotation,
|
|
|
|
// and we need to re-attach action-bar items.
|
|
|
|
|
|
|
|
if (panel == null) {
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.onCreatePanelMenu(Window.FEATURE_OPTIONS_PANEL, null);
|
|
|
|
panel = mActivity.getMenuPanel();
|
2012-05-31 23:01:50 +00:00
|
|
|
|
|
|
|
if (mHasSoftMenuButton) {
|
2012-07-28 06:15:39 +00:00
|
|
|
mMenuPopup = new MenuPopup(mActivity);
|
2012-05-31 23:01:50 +00:00
|
|
|
mMenuPopup.setPanelView(panel);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-07-10 23:10:15 +00:00
|
|
|
|
|
|
|
mFocusOrder = Arrays.asList(mBack, mForward, mAwesomeBar, mReader, mSiteSecurity, mStop, mTabs);
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
2012-06-13 05:47:52 +00:00
|
|
|
public View getLayout() {
|
|
|
|
return mLayout;
|
|
|
|
}
|
|
|
|
|
2012-06-08 04:47:22 +00:00
|
|
|
public void requestLayout() {
|
|
|
|
mLayout.invalidate();
|
|
|
|
}
|
|
|
|
|
2012-06-11 22:18:40 +00:00
|
|
|
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
|
|
|
|
switch(msg) {
|
|
|
|
case TITLE:
|
|
|
|
if (Tabs.getInstance().isSelectedTab(tab)) {
|
|
|
|
setTitle(tab.getDisplayTitle());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case START:
|
|
|
|
if (Tabs.getInstance().isSelectedTab(tab)) {
|
|
|
|
updateBackButton(tab.canDoBack());
|
|
|
|
updateForwardButton(tab.canDoForward());
|
|
|
|
Boolean showProgress = (Boolean)data;
|
|
|
|
if (showProgress && tab.getState() == Tab.STATE_LOADING)
|
|
|
|
setProgressVisibility(true);
|
2012-08-26 23:45:07 +00:00
|
|
|
setSecurityMode(tab.getSecurityMode());
|
|
|
|
setReaderMode(tab.getReaderEnabled());
|
2012-06-11 22:18:40 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case STOP:
|
|
|
|
if (Tabs.getInstance().isSelectedTab(tab)) {
|
|
|
|
updateBackButton(tab.canDoBack());
|
|
|
|
updateForwardButton(tab.canDoForward());
|
|
|
|
setProgressVisibility(false);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case RESTORED:
|
|
|
|
case SELECTED:
|
2012-09-07 19:11:42 +00:00
|
|
|
// We should not animate the lock icon when switching or
|
|
|
|
// restoring tabs.
|
|
|
|
mAnimateSiteSecurity = false;
|
|
|
|
// fall through
|
2012-06-11 22:18:40 +00:00
|
|
|
case LOCATION_CHANGE:
|
|
|
|
case LOAD_ERROR:
|
|
|
|
if (Tabs.getInstance().isSelectedTab(tab)) {
|
|
|
|
refresh();
|
|
|
|
}
|
2012-09-07 19:11:42 +00:00
|
|
|
mAnimateSiteSecurity = true;
|
2012-06-11 22:18:40 +00:00
|
|
|
break;
|
|
|
|
case CLOSED:
|
|
|
|
case ADDED:
|
|
|
|
updateTabCountAndAnimate(Tabs.getInstance().getCount());
|
|
|
|
updateBackButton(false);
|
|
|
|
updateForwardButton(false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
@Override
|
|
|
|
public void onAnimationStart(Animation animation) {
|
|
|
|
if (animation.equals(mLockFadeIn)) {
|
|
|
|
if (mSiteSecurityVisible)
|
|
|
|
mSiteSecurity.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationRepeat(Animation animation) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animation animation) {
|
|
|
|
if (animation.equals(mTitleSlideLeft)) {
|
|
|
|
mSiteSecurity.setVisibility(View.GONE);
|
|
|
|
} else if (animation.equals(mTitleSlideRight)) {
|
|
|
|
mSiteSecurity.startAnimation(mLockFadeIn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-25 22:10:26 +00:00
|
|
|
@Override
|
|
|
|
public View makeView() {
|
|
|
|
// This returns a TextView for the TextSwitcher.
|
|
|
|
return mInflater.inflate(R.layout.tabs_counter, null);
|
|
|
|
}
|
|
|
|
|
2011-11-18 18:28:17 +00:00
|
|
|
private void onAwesomeBarSearch() {
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.onSearchRequested();
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void addTab() {
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.addTab();
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
2012-06-08 04:47:22 +00:00
|
|
|
private void toggleTabs() {
|
2012-07-28 06:15:39 +00:00
|
|
|
if (mActivity.areTabsShown()) {
|
|
|
|
if (mActivity.hasTabsSideBar())
|
|
|
|
mActivity.hideTabs();
|
2012-06-21 18:44:35 +00:00
|
|
|
} else {
|
|
|
|
// hide the virtual keyboard
|
|
|
|
InputMethodManager imm =
|
2012-07-28 06:15:39 +00:00
|
|
|
(InputMethodManager) mActivity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
2012-06-21 18:44:35 +00:00
|
|
|
imm.hideSoftInputFromWindow(mTabs.getWindowToken(), 0);
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.showLocalTabs();
|
2012-06-21 18:44:35 +00:00
|
|
|
}
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
2012-02-01 22:25:50 +00:00
|
|
|
public void updateTabCountAndAnimate(int count) {
|
2011-11-18 18:28:17 +00:00
|
|
|
if (mCount > count) {
|
|
|
|
mTabsCount.setInAnimation(mSlideDownIn);
|
|
|
|
mTabsCount.setOutAnimation(mSlideDownOut);
|
|
|
|
} else if (mCount < count) {
|
|
|
|
mTabsCount.setInAnimation(mSlideUpIn);
|
|
|
|
mTabsCount.setOutAnimation(mSlideUpOut);
|
2012-06-08 04:47:22 +00:00
|
|
|
} else {
|
|
|
|
return;
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mTabsCount.setText(String.valueOf(count));
|
2012-07-11 23:11:42 +00:00
|
|
|
mTabs.setContentDescription((count > 1) ?
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.getString(R.string.num_tabs, count) :
|
|
|
|
mActivity.getString(R.string.one_tab));
|
2011-11-18 18:28:17 +00:00
|
|
|
mCount = count;
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
public void run() {
|
2012-07-28 06:15:39 +00:00
|
|
|
((TextView) mTabsCount.getCurrentView()).setTextColor(mActivity.getResources().getColor(R.color.url_bar_text_highlight));
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
}, mDuration);
|
|
|
|
|
|
|
|
mHandler.postDelayed(new Runnable() {
|
|
|
|
public void run() {
|
2012-07-28 06:15:39 +00:00
|
|
|
((TextView) mTabsCount.getCurrentView()).setTextColor(mActivity.getResources().getColor(R.color.tabs_counter_color));
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
}, 2 * mDuration);
|
|
|
|
}
|
|
|
|
|
2012-02-01 22:25:50 +00:00
|
|
|
public void updateTabCount(int count) {
|
|
|
|
mTabsCount.setCurrentText(String.valueOf(count));
|
2012-07-11 23:11:42 +00:00
|
|
|
mTabs.setContentDescription((count > 1) ?
|
2012-07-28 06:15:39 +00:00
|
|
|
mActivity.getString(R.string.num_tabs, count) :
|
|
|
|
mActivity.getString(R.string.one_tab));
|
2012-06-08 04:47:22 +00:00
|
|
|
mCount = count;
|
2012-07-28 06:15:39 +00:00
|
|
|
updateTabs(mActivity.areTabsShown());
|
2012-06-08 04:47:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void updateTabs(boolean areTabsShown) {
|
2012-06-14 18:14:00 +00:00
|
|
|
if (areTabsShown) {
|
|
|
|
mTabs.getBackground().setLevel(TABS_EXPANDED);
|
2012-07-09 20:21:20 +00:00
|
|
|
|
2012-07-28 06:15:39 +00:00
|
|
|
if (!mActivity.hasTabsSideBar()) {
|
2012-07-09 20:21:20 +00:00
|
|
|
mTabs.setImageLevel(0);
|
|
|
|
mTabsCount.setVisibility(View.GONE);
|
|
|
|
mMenu.setImageLevel(TABS_EXPANDED);
|
|
|
|
mMenu.getBackground().setLevel(TABS_EXPANDED);
|
|
|
|
} else {
|
|
|
|
mTabs.setImageLevel(TABS_EXPANDED);
|
|
|
|
}
|
2012-06-14 18:14:00 +00:00
|
|
|
} else {
|
2012-06-08 04:47:22 +00:00
|
|
|
mTabs.setImageLevel(TABS_CONTRACTED);
|
2012-06-14 18:14:00 +00:00
|
|
|
mTabs.getBackground().setLevel(TABS_CONTRACTED);
|
2012-07-09 20:21:20 +00:00
|
|
|
|
2012-07-28 06:15:39 +00:00
|
|
|
if (!mActivity.hasTabsSideBar()) {
|
2012-07-09 20:21:20 +00:00
|
|
|
mTabsCount.setVisibility(View.VISIBLE);
|
|
|
|
mMenu.setImageLevel(TABS_CONTRACTED);
|
|
|
|
mMenu.getBackground().setLevel(TABS_CONTRACTED);
|
|
|
|
}
|
2012-06-14 18:14:00 +00:00
|
|
|
}
|
2012-02-01 22:25:50 +00:00
|
|
|
}
|
|
|
|
|
2011-11-18 18:28:17 +00:00
|
|
|
public void setProgressVisibility(boolean visible) {
|
|
|
|
if (visible) {
|
|
|
|
mFavicon.setImageDrawable(mProgressSpinner);
|
|
|
|
mProgressSpinner.start();
|
2012-07-13 15:36:45 +00:00
|
|
|
setPageActionVisibility(true);
|
2012-01-24 20:39:23 +00:00
|
|
|
Log.i(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - Throbber start");
|
2011-11-18 18:28:17 +00:00
|
|
|
} else {
|
|
|
|
mProgressSpinner.stop();
|
2012-07-13 15:36:45 +00:00
|
|
|
setPageActionVisibility(false);
|
2012-04-23 14:47:46 +00:00
|
|
|
Tab selectedTab = Tabs.getInstance().getSelectedTab();
|
|
|
|
if (selectedTab != null)
|
|
|
|
setFavicon(selectedTab.getFavicon());
|
2012-01-24 20:39:23 +00:00
|
|
|
Log.i(LOGTAG, "zerdatime " + SystemClock.uptimeMillis() + " - Throbber stop");
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-13 15:36:45 +00:00
|
|
|
public void setPageActionVisibility(boolean isLoading) {
|
|
|
|
// Handle the loading mode page actions
|
|
|
|
mStop.setVisibility(isLoading ? View.VISIBLE : View.GONE);
|
2012-06-02 18:23:45 +00:00
|
|
|
|
2012-07-13 15:36:45 +00:00
|
|
|
// Handle the viewing mode page actions
|
2012-08-23 18:27:11 +00:00
|
|
|
setSiteSecurityVisibility(mShowSiteSecurity && !isLoading);
|
2012-07-13 15:36:45 +00:00
|
|
|
mReader.setVisibility(mShowReader && !isLoading ? View.VISIBLE : View.GONE);
|
2012-06-02 18:23:45 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
// We want title to fill the whole space available for it when there are icons
|
|
|
|
// being shown on the right side of the toolbar as the icons already have some
|
|
|
|
// padding in them. This is just to avoid wasting space when icons are shown.
|
|
|
|
mTitle.setPadding(0, 0, (!mShowReader && !isLoading ? mTitlePadding : 0), 0);
|
2012-07-10 23:10:15 +00:00
|
|
|
|
|
|
|
updateFocusOrder();
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
private void setSiteSecurityVisibility(final boolean visible) {
|
|
|
|
if (visible == mSiteSecurityVisible)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mSiteSecurityVisible = visible;
|
|
|
|
|
2012-09-07 19:11:42 +00:00
|
|
|
if (!mAnimateSiteSecurity) {
|
|
|
|
mSiteSecurity.setVisibility(visible ? View.VISIBLE : View.GONE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
mTitle.clearAnimation();
|
|
|
|
mSiteSecurity.clearAnimation();
|
|
|
|
|
|
|
|
// If any of these animations were cancelled as a result of the
|
|
|
|
// clearAnimation() calls above, we need to reset them.
|
|
|
|
mLockFadeIn.reset();
|
|
|
|
mTitleSlideLeft.reset();
|
|
|
|
mTitleSlideRight.reset();
|
|
|
|
|
|
|
|
if (visible)
|
|
|
|
mSiteSecurity.setVisibility(View.INVISIBLE);
|
|
|
|
else
|
|
|
|
mSiteSecurity.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
mTitle.startAnimation(visible ? mTitleSlideRight : mTitleSlideLeft);
|
|
|
|
}
|
|
|
|
|
2012-07-10 23:10:15 +00:00
|
|
|
private void updateFocusOrder() {
|
|
|
|
View prevView = null;
|
|
|
|
|
|
|
|
for (View view : mFocusOrder) {
|
|
|
|
if (view.getVisibility() != View.VISIBLE)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (prevView != null) {
|
|
|
|
view.setNextFocusLeftId(prevView.getId());
|
|
|
|
prevView.setNextFocusRightId(view.getId());
|
|
|
|
}
|
|
|
|
|
|
|
|
prevView = view;
|
|
|
|
}
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
2011-12-15 19:53:04 +00:00
|
|
|
public void setShadowVisibility(boolean visible) {
|
|
|
|
mShadow.setVisibility(visible ? View.VISIBLE : View.GONE);
|
|
|
|
}
|
|
|
|
|
2011-11-18 18:28:17 +00:00
|
|
|
public void setTitle(CharSequence title) {
|
2012-01-17 22:57:21 +00:00
|
|
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
2012-03-16 16:29:37 +00:00
|
|
|
|
|
|
|
// We use about:empty as a placeholder for an external page load and
|
|
|
|
// we don't want to change the title
|
|
|
|
if (tab != null && "about:empty".equals(tab.getURL()))
|
|
|
|
return;
|
|
|
|
|
2012-09-11 17:51:44 +00:00
|
|
|
// Keep the title unchanged if the tab is entering reader mode
|
|
|
|
if (tab != null && tab.isEnteringReaderMode())
|
|
|
|
return;
|
|
|
|
|
2012-01-17 22:57:21 +00:00
|
|
|
// Setting a null title for about:home will ensure we just see
|
|
|
|
// the "Enter Search or Address" placeholder text
|
2012-03-05 21:20:04 +00:00
|
|
|
if (tab != null && "about:home".equals(tab.getURL()))
|
2012-01-17 22:57:21 +00:00
|
|
|
title = null;
|
2012-03-16 16:29:37 +00:00
|
|
|
|
2012-08-23 18:27:11 +00:00
|
|
|
mTitle.setText(title);
|
|
|
|
mAwesomeBar.setContentDescription(title != null ? title : mTitle.getHint());
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setFavicon(Drawable image) {
|
2012-03-07 21:58:31 +00:00
|
|
|
if (Tabs.getInstance().getSelectedTab().getState() == Tab.STATE_LOADING)
|
2011-11-18 18:28:17 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (image != null)
|
|
|
|
mFavicon.setImageDrawable(image);
|
|
|
|
else
|
|
|
|
mFavicon.setImageResource(R.drawable.favicon);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSecurityMode(String mode) {
|
2012-06-02 18:23:45 +00:00
|
|
|
mShowSiteSecurity = true;
|
2012-02-06 19:44:37 +00:00
|
|
|
|
2012-05-02 16:07:58 +00:00
|
|
|
if (mode.equals(SiteIdentityPopup.IDENTIFIED)) {
|
2011-11-18 18:28:17 +00:00
|
|
|
mSiteSecurity.setImageLevel(1);
|
2012-05-02 16:07:58 +00:00
|
|
|
} else if (mode.equals(SiteIdentityPopup.VERIFIED)) {
|
2011-12-15 19:53:04 +00:00
|
|
|
mSiteSecurity.setImageLevel(2);
|
2012-02-06 19:44:37 +00:00
|
|
|
} else {
|
2011-11-18 18:28:17 +00:00
|
|
|
mSiteSecurity.setImageLevel(0);
|
2012-06-02 18:23:45 +00:00
|
|
|
mShowSiteSecurity = false;
|
2012-02-06 19:44:37 +00:00
|
|
|
}
|
2012-07-13 15:36:45 +00:00
|
|
|
|
|
|
|
setPageActionVisibility(mStop.getVisibility() == View.VISIBLE);
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|
2012-01-30 23:10:16 +00:00
|
|
|
|
2012-07-13 15:36:45 +00:00
|
|
|
public void setReaderMode(boolean showReader) {
|
2012-06-02 18:23:45 +00:00
|
|
|
mShowReader = showReader;
|
2012-07-13 15:36:45 +00:00
|
|
|
setPageActionVisibility(mStop.getVisibility() == View.VISIBLE);
|
2012-06-02 18:23:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-21 00:23:06 +00:00
|
|
|
public void setVisibility(int visibility) {
|
|
|
|
mLayout.setVisibility(visibility);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void requestFocusFromTouch() {
|
|
|
|
mLayout.requestFocusFromTouch();
|
|
|
|
}
|
|
|
|
|
2012-05-24 22:47:49 +00:00
|
|
|
public void updateBackButton(boolean enabled) {
|
|
|
|
mBack.setColorFilter(enabled ? 0 : 0xFF999999);
|
|
|
|
mBack.setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateForwardButton(boolean enabled) {
|
|
|
|
mForward.setColorFilter(enabled ? 0 : 0xFF999999);
|
|
|
|
mForward.setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2012-05-31 23:01:50 +00:00
|
|
|
@Override
|
|
|
|
public void addActionItem(View actionItem) {
|
|
|
|
mActionItemBar.addView(actionItem);
|
|
|
|
|
|
|
|
if (!sActionItems.contains(actionItem))
|
|
|
|
sActionItems.add(actionItem);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2012-06-03 06:09:55 +00:00
|
|
|
public void removeActionItem(int index) {
|
|
|
|
mActionItemBar.removeViewAt(index);
|
|
|
|
sActionItems.remove(index);
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getActionItemsCount() {
|
|
|
|
return sActionItems.size();
|
|
|
|
}
|
|
|
|
|
2012-02-16 00:14:02 +00:00
|
|
|
public void show() {
|
2012-06-08 04:47:22 +00:00
|
|
|
mLayout.setVisibility(View.VISIBLE);
|
2012-02-16 00:14:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void hide() {
|
2012-06-08 04:47:22 +00:00
|
|
|
mLayout.setVisibility(View.GONE);
|
2012-02-16 00:14:02 +00:00
|
|
|
}
|
|
|
|
|
2012-01-30 23:10:16 +00:00
|
|
|
public void refresh() {
|
|
|
|
Tab tab = Tabs.getInstance().getSelectedTab();
|
|
|
|
if (tab != null) {
|
2012-03-05 21:20:04 +00:00
|
|
|
String url = tab.getURL();
|
2012-01-30 23:10:16 +00:00
|
|
|
setTitle(tab.getDisplayTitle());
|
|
|
|
setFavicon(tab.getFavicon());
|
2012-08-26 23:45:07 +00:00
|
|
|
setProgressVisibility(tab.getState() == Tab.STATE_LOADING);
|
2012-01-30 23:10:16 +00:00
|
|
|
setSecurityMode(tab.getSecurityMode());
|
2012-07-13 15:36:45 +00:00
|
|
|
setReaderMode(tab.getReaderEnabled());
|
2012-03-05 21:20:04 +00:00
|
|
|
setShadowVisibility((url == null) || !url.startsWith("about:"));
|
2012-02-07 19:37:36 +00:00
|
|
|
updateTabCount(Tabs.getInstance().getCount());
|
2012-05-24 22:47:49 +00:00
|
|
|
updateBackButton(tab.canDoBack());
|
|
|
|
updateForwardButton(tab.canDoForward());
|
2012-01-30 23:10:16 +00:00
|
|
|
}
|
|
|
|
}
|
2012-05-31 23:01:50 +00:00
|
|
|
|
|
|
|
public void destroy() {
|
|
|
|
// The action-items views are reused on rotation.
|
|
|
|
// Remove them from their parent, so they can be re-attached to new parent.
|
|
|
|
mActionItemBar.removeAllViews();
|
|
|
|
}
|
|
|
|
|
2012-06-03 06:08:29 +00:00
|
|
|
public boolean openOptionsMenu() {
|
|
|
|
if (!mHasSoftMenuButton)
|
|
|
|
return false;
|
|
|
|
|
2012-07-24 23:12:12 +00:00
|
|
|
GeckoApp.mAppContext.invalidateOptionsMenu();
|
2012-05-31 23:01:50 +00:00
|
|
|
if (mMenuPopup != null && !mMenuPopup.isShowing())
|
2012-07-09 20:23:16 +00:00
|
|
|
mMenuPopup.showAsDropDown(mMenu);
|
2012-06-03 06:08:29 +00:00
|
|
|
|
|
|
|
return true;
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
2012-06-03 06:08:29 +00:00
|
|
|
public boolean closeOptionsMenu() {
|
|
|
|
if (!mHasSoftMenuButton)
|
|
|
|
return false;
|
|
|
|
|
2012-05-31 23:01:50 +00:00
|
|
|
if (mMenuPopup != null && mMenuPopup.isShowing())
|
|
|
|
mMenuPopup.dismiss();
|
2012-06-03 06:08:29 +00:00
|
|
|
|
|
|
|
return true;
|
2012-05-31 23:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// MenuPopup holds the MenuPanel in Honeycomb/ICS devices with no hardware key
|
2012-07-18 00:54:54 +00:00
|
|
|
public class MenuPopup extends PopupWindow {
|
2012-05-31 23:01:50 +00:00
|
|
|
private RelativeLayout mPanel;
|
|
|
|
|
|
|
|
public MenuPopup(Context context) {
|
|
|
|
super(context);
|
|
|
|
setFocusable(true);
|
|
|
|
|
|
|
|
// Setting a null background makes the popup to not close on touching outside.
|
|
|
|
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
|
|
|
setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT,
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT);
|
|
|
|
|
|
|
|
LayoutInflater inflater = LayoutInflater.from(context);
|
|
|
|
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.menu_popup, null);
|
|
|
|
setContentView(layout);
|
|
|
|
|
|
|
|
mPanel = (RelativeLayout) layout.findViewById(R.id.menu_panel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPanelView(View view) {
|
|
|
|
mPanel.removeAllViews();
|
|
|
|
mPanel.addView(view);
|
|
|
|
}
|
|
|
|
}
|
2012-08-20 04:45:37 +00:00
|
|
|
|
|
|
|
private class TailTouchDelegate extends TouchDelegate {
|
|
|
|
public TailTouchDelegate(Rect bounds, View delegateView) {
|
|
|
|
super(bounds, delegateView);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onTouchEvent(MotionEvent event) {
|
|
|
|
switch (event.getAction()) {
|
|
|
|
case MotionEvent.ACTION_DOWN:
|
|
|
|
// Android bug 36445: Touch Delegation not reset on ACTION_DOWN.
|
|
|
|
if (!super.onTouchEvent(event)) {
|
|
|
|
MotionEvent cancelEvent = MotionEvent.obtain(event);
|
|
|
|
cancelEvent.setAction(MotionEvent.ACTION_CANCEL);
|
|
|
|
super.onTouchEvent(cancelEvent);
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return super.onTouchEvent(event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-18 18:28:17 +00:00
|
|
|
}
|