1571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins/* 20f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck * Copyright (C) 2011 The Android Open Source Project 3571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * 4571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * Licensed under the Apache License, Version 2.0 (the "License"); 5571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * you may not use this file except in compliance with the License. 6571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * You may obtain a copy of the License at 7571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * 8571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * http://www.apache.org/licenses/LICENSE-2.0 9571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * 10571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * Unless required by applicable law or agreed to in writing, software 11571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * distributed under the License is distributed on an "AS IS" BASIS, 12571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * See the License for the specific language governing permissions and 14571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins * limitations under the License. 15571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins */ 16571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginspackage com.android.browser; 17571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins 18de463761d9f92f665ac6158eba041ed89319426bMichael Kolbimport android.animation.Animator; 19de463761d9f92f665ac6158eba041ed89319426bMichael Kolbimport android.animation.AnimatorListenerAdapter; 20de463761d9f92f665ac6158eba041ed89319426bMichael Kolbimport android.animation.AnimatorSet; 21de463761d9f92f665ac6158eba041ed89319426bMichael Kolbimport android.animation.ObjectAnimator; 22571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginsimport android.content.Context; 23a60fffaa18e26b29880c7ce21548af4f8ec0e443John Reckimport android.content.Intent; 24de463761d9f92f665ac6158eba041ed89319426bMichael Kolbimport android.content.res.Configuration; 25571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginsimport android.content.res.Resources; 26034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reckimport android.graphics.Bitmap; 27571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginsimport android.graphics.drawable.Drawable; 281ce7813e6a0e42510fc1b3db5f5bb35999e1e87aMichael Kolbimport android.text.TextUtils; 290f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reckimport android.util.AttributeSet; 30571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginsimport android.view.View; 315a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolbimport android.widget.ImageButton; 32571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scrogginsimport android.widget.ImageView; 33571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins 34315d502edce27bb4e93e53134f1a43b8f5c45588Michael Kolbimport com.android.browser.UI.ComboViews; 350b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolbimport com.android.browser.UrlInputView.StateListener; 36315d502edce27bb4e93e53134f1a43b8f5c45588Michael Kolb 370b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolbpublic class NavigationBarTablet extends NavigationBarBase implements StateListener { 388233facddcc51865d612a919d450db6954aa48e3Michael Kolb 39a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb private Drawable mStopDrawable; 40a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb private Drawable mReloadDrawable; 4130adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb private String mStopDescription; 4230adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb private String mRefreshDescription; 43c7485ae06c6d5d33c57a03d02bbeed54edb3c66fMichael Kolb 4411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb private View mUrlContainer; 455a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb private ImageButton mBackButton; 465a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb private ImageButton mForwardButton; 4731d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb private ImageView mStar; 48e3524d8049879deb11a4f4bbff637872d5b21ce5Michael Kolb private ImageView mUrlIcon; 49e3524d8049879deb11a4f4bbff637872d5b21ce5Michael Kolb private ImageView mSearchButton; 50a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb private ImageView mStopButton; 51a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb private View mAllButton; 52b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb private View mClearButton; 530b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb private View mVoiceButton; 54de463761d9f92f665ac6158eba041ed89319426bMichael Kolb private View mNavButtons; 55cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb private Drawable mFocusDrawable; 56cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb private Drawable mUnfocusDrawable; 57de463761d9f92f665ac6158eba041ed89319426bMichael Kolb private boolean mHideNavButtons; 58034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck private Drawable mFaviconDrawable; 5981b6f83b7032f22fdaaa514afda2448f801b73daMichael Kolb 600f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public NavigationBarTablet(Context context) { 610f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck super(context); 620f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck init(context); 630f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 640f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 650f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public NavigationBarTablet(Context context, AttributeSet attrs) { 660f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck super(context, attrs); 670f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck init(context); 680f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 690f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 700f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public NavigationBarTablet(Context context, AttributeSet attrs, int defStyle) { 710f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck super(context, attrs, defStyle); 720f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck init(context); 730f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 740f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 750f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck private void init(Context context) { 760f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck Resources resources = context.getResources(); 775a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb mStopDrawable = resources.getDrawable(R.drawable.ic_stop_holo_dark); 785a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb mReloadDrawable = resources.getDrawable(R.drawable.ic_refresh_holo_dark); 7930adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb mStopDescription = resources.getString(R.string.accessibility_button_stop); 8030adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb mRefreshDescription = resources.getString(R.string.accessibility_button_refresh); 81cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb mFocusDrawable = resources.getDrawable( 82cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb R.drawable.textfield_active_holo_dark); 83cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb mUnfocusDrawable = resources.getDrawable( 84cfa3af5c59abb38c895416a80ef16da0ec1b5287Michael Kolb R.drawable.textfield_default_holo_dark); 85de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mHideNavButtons = resources.getBoolean(R.bool.hide_nav_buttons); 86fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb } 87571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins 887cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb @Override 890f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck protected void onFinishInflate() { 900f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck super.onFinishInflate(); 91fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb mAllButton = findViewById(R.id.all_btn); 92fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb // TODO: Change enabled states based on whether you can go 93571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins // back/forward. Probably should be done inside onPageStarted. 94de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons = findViewById(R.id.navbuttons); 955a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb mBackButton = (ImageButton) findViewById(R.id.back); 965a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb mForwardButton = (ImageButton) findViewById(R.id.forward); 97e3524d8049879deb11a4f4bbff637872d5b21ce5Michael Kolb mUrlIcon = (ImageView) findViewById(R.id.url_icon); 9831d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mStar = (ImageView) findViewById(R.id.star); 99a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mStopButton = (ImageView) findViewById(R.id.stop); 100e3524d8049879deb11a4f4bbff637872d5b21ce5Michael Kolb mSearchButton = (ImageView) findViewById(R.id.search); 101b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb mClearButton = findViewById(R.id.clear); 1020b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mVoiceButton = findViewById(R.id.voice); 10331d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mUrlContainer = findViewById(R.id.urlbar_focused); 104a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mBackButton.setOnClickListener(this); 105a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mForwardButton.setOnClickListener(this); 106a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mStar.setOnClickListener(this); 107a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mAllButton.setOnClickListener(this); 108a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mStopButton.setOnClickListener(this); 109a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb mSearchButton.setOnClickListener(this); 110b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb mClearButton.setOnClickListener(this); 1110b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mVoiceButton.setOnClickListener(this); 11231d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mUrlInput.setContainer(mUrlContainer); 1130b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mUrlInput.setStateListener(this); 1140f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck } 1150f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck 116de463761d9f92f665ac6158eba041ed89319426bMichael Kolb public void onConfigurationChanged(Configuration config) { 117de463761d9f92f665ac6158eba041ed89319426bMichael Kolb super.onConfigurationChanged(config); 118de463761d9f92f665ac6158eba041ed89319426bMichael Kolb Resources res = mContext.getResources(); 119de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mHideNavButtons = res.getBoolean(R.bool.hide_nav_buttons); 120de463761d9f92f665ac6158eba041ed89319426bMichael Kolb if (mUrlInput.hasFocus()) { 121de463761d9f92f665ac6158eba041ed89319426bMichael Kolb if (mHideNavButtons && (mNavButtons.getVisibility() == View.VISIBLE)) { 122de463761d9f92f665ac6158eba041ed89319426bMichael Kolb int aw = mNavButtons.getMeasuredWidth(); 123de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setVisibility(View.GONE); 124de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setAlpha(0f); 125de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setTranslationX(-aw); 126de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } else if (!mHideNavButtons && (mNavButtons.getVisibility() == View.GONE)) { 127de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setVisibility(View.VISIBLE); 128de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setAlpha(1f); 129de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setTranslationX(0); 130de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 131de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 132de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 133de463761d9f92f665ac6158eba041ed89319426bMichael Kolb 1340f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck @Override 1350f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public void setTitleBar(TitleBar titleBar) { 1360f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck super.setTitleBar(titleBar); 137dc2ee1bfb50b7bec0cf3215e3d298b246dc71101Michael Kolb setFocusState(false); 13831d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb } 13931d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb 1405a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb void updateNavigationState(Tab tab) { 141ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck if (tab != null) { 142ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mBackButton.setImageResource(tab.canGoBack() 1435a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb ? R.drawable.ic_back_holo_dark 1445a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb : R.drawable.ic_back_disabled_holo_dark); 145ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mForwardButton.setImageResource(tab.canGoForward() 1465a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb ? R.drawable.ic_forward_holo_dark 1475a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb : R.drawable.ic_forward_disabled_holo_dark); 1485a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb } 149b8b2af8be793c442add61afbe852d55ef978361cJohn Reck updateUrlIcon(); 1505a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb } 1515a72f1858c2f73be3558c6cdaa2c84b4c36fa748Michael Kolb 15231d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb @Override 153387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount public void onTabDataChanged(Tab tab) { 154387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount super.onTabDataChanged(tab); 155387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount showHideStar(tab); 156387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount } 157387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount 158387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount @Override 1594cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins public void setCurrentUrlIsBookmark(boolean isBookmark) { 16031d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mStar.setActivated(isBookmark); 1614cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins } 1624cd97793901e8f5681cf642d0b2684697964a37aLeon Scroggins 163a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb @Override 164a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb public void onClick(View v) { 165c832e5e47b6d91a3d805c71848c863696ea8c892Michael Kolb if ((mBackButton == v) && (mUiController.getCurrentTab() != null)) { 166ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mUiController.getCurrentTab().goBack(); 167c832e5e47b6d91a3d805c71848c863696ea8c892Michael Kolb } else if ((mForwardButton == v) && (mUiController.getCurrentTab() != null)) { 168ef654f1dd80f55609060005342fc4f2cde62990cJohn Reck mUiController.getCurrentTab().goForward(); 169a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb } else if (mStar == v) { 170a60fffaa18e26b29880c7ce21548af4f8ec0e443John Reck Intent intent = mUiController.createBookmarkCurrentPageIntent(true); 171a60fffaa18e26b29880c7ce21548af4f8ec0e443John Reck if (intent != null) { 172a60fffaa18e26b29880c7ce21548af4f8ec0e443John Reck getContext().startActivity(intent); 173a60fffaa18e26b29880c7ce21548af4f8ec0e443John Reck } 174a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb } else if (mAllButton == v) { 175315d502edce27bb4e93e53134f1a43b8f5c45588Michael Kolb mUiController.bookmarksOrHistoryPicker(ComboViews.Bookmarks); 176a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb } else if (mSearchButton == v) { 1775ff5c8b88968fa794eab4b7a263cae25f05bd4d3Michael Kolb mBaseUi.editUrl(true, true); 178a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb } else if (mStopButton == v) { 179a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb stopOrRefresh(); 180b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb } else if (mClearButton == v) { 18131d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb clearOrClose(); 1820b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb } else if (mVoiceButton == v) { 1830b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mUiController.startVoiceRecognizer(); 18411d1978d8d16004598347abc93918b54a5ef760bMichael Kolb } else { 18511d1978d8d16004598347abc93918b54a5ef760bMichael Kolb super.onClick(v); 186fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb } 187fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb } 188fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb 18931d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb private void clearOrClose() { 190f3174a588cdf63ef59055998c23aad4b36b7856eNarayan Kamath if (TextUtils.isEmpty(mUrlInput.getText())) { 19131d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb // close 1927cdc4906fc5852297a9a254c3251ad2f4dead6eeMichael Kolb mUrlInput.clearFocus(); 19331d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb } else { 19431d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb // clear 19531d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mUrlInput.setText(""); 19631d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb } 19731d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb } 19831d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb 199034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck @Override 200034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck public void setFavicon(Bitmap icon) { 201034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck mFaviconDrawable = mBaseUi.getFaviconDrawable(icon); 202034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck updateUrlIcon(); 203034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck } 204034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck 205b8b2af8be793c442add61afbe852d55ef978361cJohn Reck void updateUrlIcon() { 206034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck if (mUrlInput.hasFocus()) { 207034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); 208034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck } else { 2095ff5c8b88968fa794eab4b7a263cae25f05bd4d3Michael Kolb if (mFaviconDrawable == null) { 2105ff5c8b88968fa794eab4b7a263cae25f05bd4d3Michael Kolb mFaviconDrawable = mBaseUi.getFaviconDrawable(null); 211034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck } 2125ff5c8b88968fa794eab4b7a263cae25f05bd4d3Michael Kolb mUrlIcon.setImageDrawable(mFaviconDrawable); 213034637c74e84153bd1f7cdd922daaeb9f6af9b8eJohn Reck } 214b8b2af8be793c442add61afbe852d55ef978361cJohn Reck } 215b8b2af8be793c442add61afbe852d55ef978361cJohn Reck 21611d1978d8d16004598347abc93918b54a5ef760bMichael Kolb @Override 21711d1978d8d16004598347abc93918b54a5ef760bMichael Kolb protected void setFocusState(boolean focus) { 21811d1978d8d16004598347abc93918b54a5ef760bMichael Kolb super.setFocusState(focus); 219dc2ee1bfb50b7bec0cf3215e3d298b246dc71101Michael Kolb if (focus) { 220de463761d9f92f665ac6158eba041ed89319426bMichael Kolb if (mHideNavButtons) { 221de463761d9f92f665ac6158eba041ed89319426bMichael Kolb hideNavButtons(); 222de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 223b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb mSearchButton.setVisibility(View.GONE); 22431d469bca6f6d5a8b444b7dac8038a1b75cd7e43Michael Kolb mStar.setVisibility(View.GONE); 225e3524d8049879deb11a4f4bbff637872d5b21ce5Michael Kolb mUrlIcon.setImageResource(R.drawable.ic_search_holo_dark); 226b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb } else { 227de463761d9f92f665ac6158eba041ed89319426bMichael Kolb if (mHideNavButtons) { 228de463761d9f92f665ac6158eba041ed89319426bMichael Kolb showNavButtons(); 229de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 230387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount showHideStar(mUiController.getCurrentTab()); 2310f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck if (mTitleBar.useQuickControls()) { 232376b54116e38b3b94c4d64663d1bff38352b0e59Michael Kolb mSearchButton.setVisibility(View.GONE); 233376b54116e38b3b94c4d64663d1bff38352b0e59Michael Kolb } else { 234376b54116e38b3b94c4d64663d1bff38352b0e59Michael Kolb mSearchButton.setVisibility(View.VISIBLE); 235376b54116e38b3b94c4d64663d1bff38352b0e59Michael Kolb } 236b8b2af8be793c442add61afbe852d55ef978361cJohn Reck updateUrlIcon(); 237b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb } 2387e5b8b5ab04edd6cfe3acc4dadca42b11ba484c3John Reck mUrlContainer.setBackgroundDrawable(focus 2397e5b8b5ab04edd6cfe3acc4dadca42b11ba484c3John Reck ? mFocusDrawable : mUnfocusDrawable); 240b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb } 241b7b115e301334f813275aa13e7a2cc27bf15fe6aMichael Kolb 242a2b2ba8da913f26c820e49d3e43158e2fe6ebebaMichael Kolb private void stopOrRefresh() { 2431392b8397e3c8ea093cb04afb9c6ab164c13189fMichael Kolb if (mUiController == null) return; 2440f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck if (mTitleBar.isInLoad()) { 2458233facddcc51865d612a919d450db6954aa48e3Michael Kolb mUiController.stopLoading(); 246571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins } else { 2476645084149895ec23ed325c1c93003456144f1f2Michael Kolb if (mUiController.getCurrentTopWebView() != null) { 2486645084149895ec23ed325c1c93003456144f1f2Michael Kolb mUiController.getCurrentTopWebView().reload(); 2496645084149895ec23ed325c1c93003456144f1f2Michael Kolb } 250571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins } 251571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins } 252571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins 253fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb @Override 2540f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public void onProgressStarted() { 25546f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb mStopButton.setImageDrawable(mStopDrawable); 25630adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb mStopButton.setContentDescription(mStopDescription); 25746f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb } 25846f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb 25946f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb @Override 2600f602f3933dcd88702fdb514b6611e3066ca7a2bJohn Reck public void onProgressStopped() { 26146f987eca738a36e2c8382aaec6c7ef2ae2482aeMichael Kolb mStopButton.setImageDrawable(mReloadDrawable); 26230adae6ebf17a724d24066a200432e6b22a4eeffMichael Kolb mStopButton.setContentDescription(mRefreshDescription); 263fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb } 264fe25199a6f975c67d28afcc1de56b0f987b66cd8Michael Kolb 265bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb private AnimatorSet mAnimation; 266bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 267de463761d9f92f665ac6158eba041ed89319426bMichael Kolb private void hideNavButtons() { 268bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb if (mBaseUi.blockFocusAnimations()) { 269bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mNavButtons.setVisibility(View.GONE); 270bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb return; 271bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb } 272de463761d9f92f665ac6158eba041ed89319426bMichael Kolb int awidth = mNavButtons.getMeasuredWidth(); 273de463761d9f92f665ac6158eba041ed89319426bMichael Kolb Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, View.TRANSLATION_X, 0, - awidth); 274de463761d9f92f665ac6158eba041ed89319426bMichael Kolb Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", mUrlContainer.getLeft(), 275de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mUrlContainer.getPaddingLeft()); 276de463761d9f92f665ac6158eba041ed89319426bMichael Kolb Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 1f, 0f); 277bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation = new AnimatorSet(); 278bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation.playTogether(anim1, anim2, anim3); 279bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation.addListener(new AnimatorListenerAdapter() { 280de463761d9f92f665ac6158eba041ed89319426bMichael Kolb @Override 281de463761d9f92f665ac6158eba041ed89319426bMichael Kolb public void onAnimationEnd(Animator animation) { 282de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setVisibility(View.GONE); 283bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation = null; 284de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 285de463761d9f92f665ac6158eba041ed89319426bMichael Kolb }); 286bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation.setDuration(150); 287bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation.start(); 288de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 289de463761d9f92f665ac6158eba041ed89319426bMichael Kolb 290de463761d9f92f665ac6158eba041ed89319426bMichael Kolb private void showNavButtons() { 291bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb if (mAnimation != null) { 292bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb mAnimation.cancel(); 293bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb } 294de463761d9f92f665ac6158eba041ed89319426bMichael Kolb mNavButtons.setVisibility(View.VISIBLE); 2950b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mNavButtons.setTranslationX(0); 296bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb if (!mBaseUi.blockFocusAnimations()) { 297bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb int awidth = mNavButtons.getMeasuredWidth(); 298bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb Animator anim1 = ObjectAnimator.ofFloat(mNavButtons, 299bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb View.TRANSLATION_X, -awidth, 0); 300bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb Animator anim2 = ObjectAnimator.ofInt(mUrlContainer, "left", 0, 301bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb awidth); 302bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb Animator anim3 = ObjectAnimator.ofFloat(mNavButtons, View.ALPHA, 303bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb 0f, 1f); 304bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb AnimatorSet combo = new AnimatorSet(); 305bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb combo.playTogether(anim1, anim2, anim3); 306bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb combo.setDuration(150); 307bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb combo.start(); 308bae0cb200f6ad93ce61c5781100f4b6ac0cb6649Michael Kolb } 309de463761d9f92f665ac6158eba041ed89319426bMichael Kolb } 310de463761d9f92f665ac6158eba041ed89319426bMichael Kolb 311387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount private void showHideStar(Tab tab) { 312387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount // hide the bookmark star for data URLs 313387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount if (tab != null && tab.inForeground()) { 314387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount int starVisibility = View.VISIBLE; 315387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount String url = tab.getUrl(); 316387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount if (DataUri.isDataUri(url)) { 317387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount starVisibility = View.GONE; 318387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount } 319387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount mStar.setVisibility(starVisibility); 320387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount } 321387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount } 322387d45d2284c7fd7f12cbadc96161f946ae29cadGeorge Mount 3230b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb @Override 3240b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb public void onStateChanged(int state) { 325e721cc3336e6364475d0b9b0d7a6e46758f0e0b0Michael Kolb mVoiceButton.setVisibility(View.GONE); 3260b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb switch(state) { 3270b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb case STATE_NORMAL: 3280b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mClearButton.setVisibility(View.GONE); 3290b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb break; 3300b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb case STATE_HIGHLIGHTED: 3310b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mClearButton.setVisibility(View.GONE); 332e721cc3336e6364475d0b9b0d7a6e46758f0e0b0Michael Kolb if ((mUiController != null) && mUiController.supportsVoice()) { 333e721cc3336e6364475d0b9b0d7a6e46758f0e0b0Michael Kolb mVoiceButton.setVisibility(View.VISIBLE); 334e721cc3336e6364475d0b9b0d7a6e46758f0e0b0Michael Kolb } 3350b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb break; 3360b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb case STATE_EDITED: 3370b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb mClearButton.setVisibility(View.VISIBLE); 3380b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb break; 3390b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb } 3400b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb } 3410b12912da64ff5b2917d4f50eb91df2e76457d08Michael Kolb 342571b3762a5eb9e492283e0a1e437edd209fdc0deLeon Scroggins} 343