OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.shell; | 5 package org.chromium.chrome.shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
9 import android.graphics.drawable.ClipDrawable; | 9 import android.graphics.drawable.ClipDrawable; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 private ClipDrawable mProgressDrawable; | 45 private ClipDrawable mProgressDrawable; |
46 | 46 |
47 private ChromeShellTab mTab; | 47 private ChromeShellTab mTab; |
48 private final TabObserver mTabObserver; | 48 private final TabObserver mTabObserver; |
49 | 49 |
50 private AppMenuHandler mMenuHandler; | 50 private AppMenuHandler mMenuHandler; |
51 private AppMenuButtonHelper mAppMenuButtonHelper; | 51 private AppMenuButtonHelper mAppMenuButtonHelper; |
52 | 52 |
53 private SuggestionPopup mSuggestionPopup; | 53 private SuggestionPopup mSuggestionPopup; |
54 | 54 |
55 private ImageButton mStopButton; | 55 private ImageButton mStopReloadButton; |
56 private ImageButton mReloadButton; | 56 private boolean mLoading; |
57 | 57 |
58 /** | 58 /** |
59 * @param context The Context the view is running in. | 59 * @param context The Context the view is running in. |
60 * @param attrs The attributes of the XML tag that is inflating the view. | 60 * @param attrs The attributes of the XML tag that is inflating the view. |
61 */ | 61 */ |
62 public ChromeShellToolbar(Context context, AttributeSet attrs) { | 62 public ChromeShellToolbar(Context context, AttributeSet attrs) { |
63 super(context, attrs); | 63 super(context, attrs); |
64 // When running performance benchmark, we don't want to observe the tab | 64 // When running performance benchmark, we don't want to observe the tab |
65 // invalidation which would interfere with browser's processing content | 65 // invalidation which would interfere with browser's processing content |
66 // frame. See crbug.com/394976. | 66 // frame. See crbug.com/394976. |
(...skipping 16 matching lines...) Expand all Loading... | |
83 mUrlTextView.setText(mTab.getContentViewCore().getUrl()); | 83 mUrlTextView.setText(mTab.getContentViewCore().getUrl()); |
84 } | 84 } |
85 | 85 |
86 private void onUpdateUrl(String url) { | 86 private void onUpdateUrl(String url) { |
87 mUrlTextView.setText(url); | 87 mUrlTextView.setText(url); |
88 } | 88 } |
89 | 89 |
90 private void onLoadProgressChanged(int progress) { | 90 private void onLoadProgressChanged(int progress) { |
91 removeCallbacks(mClearProgressRunnable); | 91 removeCallbacks(mClearProgressRunnable); |
92 mProgressDrawable.setLevel(100 * progress); | 92 mProgressDrawable.setLevel(100 * progress); |
93 boolean isLoading = progress != 100; | 93 mLoading = progress != 100; |
94 mStopButton.setVisibility(isLoading ? VISIBLE : GONE); | 94 if (mLoading) mStopReloadButton.setImageResource(R.drawable.btn_stop_nor mal); |
Bernhard Bauer
2014/09/08 07:58:42
If one branch of if-else uses braces, the other on
ankit
2014/09/08 09:23:08
Done.
| |
95 mReloadButton.setVisibility(isLoading ? GONE : VISIBLE); | 95 else { |
96 if (!isLoading) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_T IMEOUT_MS); | 96 mStopReloadButton.setImageResource(R.drawable.btn_reload_normal); |
97 postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS); | |
98 } | |
97 } | 99 } |
98 | 100 |
99 /** | 101 /** |
100 * Closes the suggestion popup. | 102 * Closes the suggestion popup. |
101 */ | 103 */ |
102 public void hideSuggestions() { | 104 public void hideSuggestions() { |
103 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); | 105 if (mSuggestionPopup != null) mSuggestionPopup.hideSuggestions(); |
104 } | 106 } |
105 | 107 |
106 @Override | 108 @Override |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 }); | 177 }); |
176 menuButton.setOnTouchListener(new OnTouchListener() { | 178 menuButton.setOnTouchListener(new OnTouchListener() { |
177 @Override | 179 @Override |
178 public boolean onTouch(View view, MotionEvent event) { | 180 public boolean onTouch(View view, MotionEvent event) { |
179 return mAppMenuButtonHelper != null && mAppMenuButtonHelper.onTo uch(view, event); | 181 return mAppMenuButtonHelper != null && mAppMenuButtonHelper.onTo uch(view, event); |
180 } | 182 } |
181 }); | 183 }); |
182 } | 184 } |
183 | 185 |
184 private void initializeStopReloadButton() { | 186 private void initializeStopReloadButton() { |
185 mStopButton = (ImageButton)findViewById(R.id.stop); | 187 mStopReloadButton = (ImageButton)findViewById(R.id.stop_reload_button); |
186 mStopButton.setOnClickListener(new OnClickListener() { | 188 mStopReloadButton.setOnClickListener(new OnClickListener() { |
187 @Override | 189 @Override |
188 public void onClick(View v) { | 190 public void onClick(View v) { |
189 mTab.getContentViewCore().stopLoading(); | 191 if (mLoading) mTab.getContentViewCore().stopLoading(); |
Bernhard Bauer
2014/09/08 07:58:42
Putting the if-statement and the body on the same
ankit
2014/09/08 09:23:08
Done.
| |
190 } | 192 else mTab.getContentViewCore().reload(true); |
191 }); | |
192 mReloadButton = (ImageButton)findViewById(R.id.reload); | |
193 mReloadButton.setOnClickListener(new OnClickListener() { | |
194 @Override | |
195 public void onClick(View v) { | |
196 mTab.getContentViewCore().reload(true); | |
197 } | 193 } |
198 }); | 194 }); |
199 } | 195 } |
200 | 196 |
201 /** | 197 /** |
202 * @return Current tab that is shown by ChromeShell. | 198 * @return Current tab that is shown by ChromeShell. |
203 */ | 199 */ |
204 public ChromeShellTab getCurrentTab() { | 200 public ChromeShellTab getCurrentTab() { |
205 return mTab; | 201 return mTab; |
206 } | 202 } |
(...skipping 23 matching lines...) Expand all Loading... | |
230 public void onLoadProgressChanged(Tab tab, int progress) { | 226 public void onLoadProgressChanged(Tab tab, int progress) { |
231 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); | 227 if (tab == mTab) ChromeShellToolbar.this.onLoadProgressChanged(progr ess); |
232 } | 228 } |
233 | 229 |
234 @Override | 230 @Override |
235 public void onUpdateUrl(Tab tab, String url) { | 231 public void onUpdateUrl(Tab tab, String url) { |
236 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); | 232 if (tab == mTab) ChromeShellToolbar.this.onUpdateUrl(url); |
237 } | 233 } |
238 } | 234 } |
239 } | 235 } |
OLD | NEW |