OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.content_shell; | 5 package org.chromium.content_shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.drawable.ClipDrawable; | 8 import android.graphics.drawable.ClipDrawable; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 public void run() { | 42 public void run() { |
43 mProgressDrawable.setLevel(0); | 43 mProgressDrawable.setLevel(0); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 private ContentViewCore mContentViewCore; | 47 private ContentViewCore mContentViewCore; |
48 private ContentViewClient mContentViewClient; | 48 private ContentViewClient mContentViewClient; |
49 private EditText mUrlTextView; | 49 private EditText mUrlTextView; |
50 private ImageButton mPrevButton; | 50 private ImageButton mPrevButton; |
51 private ImageButton mNextButton; | 51 private ImageButton mNextButton; |
| 52 private ImageButton mStopButton; |
| 53 private ImageButton mReloadButton; |
52 | 54 |
53 private ClipDrawable mProgressDrawable; | 55 private ClipDrawable mProgressDrawable; |
54 | 56 |
55 private long mNativeShell; | 57 private long mNativeShell; |
56 private ContentViewRenderView mContentViewRenderView; | 58 private ContentViewRenderView mContentViewRenderView; |
57 private WindowAndroid mWindow; | 59 private WindowAndroid mWindow; |
58 | 60 |
59 private boolean mLoading = false; | 61 private boolean mLoading = false; |
60 | 62 |
61 /** | 63 /** |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 208 } |
207 }); | 209 }); |
208 | 210 |
209 mNextButton = (ImageButton) findViewById(R.id.next); | 211 mNextButton = (ImageButton) findViewById(R.id.next); |
210 mNextButton.setOnClickListener(new OnClickListener() { | 212 mNextButton.setOnClickListener(new OnClickListener() { |
211 @Override | 213 @Override |
212 public void onClick(View v) { | 214 public void onClick(View v) { |
213 if (mContentViewCore.canGoForward()) mContentViewCore.goForward(
); | 215 if (mContentViewCore.canGoForward()) mContentViewCore.goForward(
); |
214 } | 216 } |
215 }); | 217 }); |
| 218 mStopButton = (ImageButton)findViewById(R.id.stop); |
| 219 mStopButton.setOnClickListener(new OnClickListener() { |
| 220 @Override |
| 221 public void onClick(View v) { |
| 222 if (mLoading) mContentViewCore.stopLoading(); |
| 223 } |
| 224 }); |
| 225 mReloadButton = (ImageButton)findViewById(R.id.reload); |
| 226 mReloadButton.setOnClickListener(new OnClickListener() { |
| 227 @Override |
| 228 public void onClick(View v) { |
| 229 mContentViewCore.reload(true); |
| 230 } |
| 231 }); |
216 } | 232 } |
217 | 233 |
218 @SuppressWarnings("unused") | 234 @SuppressWarnings("unused") |
219 @CalledByNative | 235 @CalledByNative |
220 private void onUpdateUrl(String url) { | 236 private void onUpdateUrl(String url) { |
221 mUrlTextView.setText(url); | 237 mUrlTextView.setText(url); |
222 } | 238 } |
223 | 239 |
224 @SuppressWarnings("unused") | 240 @SuppressWarnings("unused") |
225 @CalledByNative | 241 @CalledByNative |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 /** | 286 /** |
271 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa
llowed | 287 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa
llowed |
272 * in respective direction. | 288 * in respective direction. |
273 * @param controlId Id of button to update | 289 * @param controlId Id of button to update |
274 * @param enabled enable/disable value | 290 * @param enabled enable/disable value |
275 */ | 291 */ |
276 @CalledByNative | 292 @CalledByNative |
277 private void enableUiControl(int controlId, boolean enabled) { | 293 private void enableUiControl(int controlId, boolean enabled) { |
278 if (controlId == 0) mPrevButton.setEnabled(enabled); | 294 if (controlId == 0) mPrevButton.setEnabled(enabled); |
279 else if (controlId == 1) mNextButton.setEnabled(enabled); | 295 else if (controlId == 1) mNextButton.setEnabled(enabled); |
| 296 else if (controlId == 2) { |
| 297 mStopButton.setVisibility(enabled ? VISIBLE : GONE); |
| 298 mReloadButton.setVisibility(enabled ? GONE : VISIBLE); |
| 299 } |
280 } | 300 } |
281 | 301 |
282 /** | 302 /** |
283 * @return The {@link ViewGroup} currently shown by this Shell. | 303 * @return The {@link ViewGroup} currently shown by this Shell. |
284 */ | 304 */ |
285 public ViewGroup getContentView() { | 305 public ViewGroup getContentView() { |
286 return mContentViewCore.getContainerView(); | 306 return mContentViewCore.getContainerView(); |
287 } | 307 } |
288 | 308 |
289 /** | 309 /** |
290 * @return The {@link ContentViewCore} currently managing the view shown by
this Shell. | 310 * @return The {@link ContentViewCore} currently managing the view shown by
this Shell. |
291 */ | 311 */ |
292 public ContentViewCore getContentViewCore() { | 312 public ContentViewCore getContentViewCore() { |
293 return mContentViewCore; | 313 return mContentViewCore; |
294 } | 314 } |
295 | 315 |
296 private void setKeyboardVisibilityForUrl(boolean visible) { | 316 private void setKeyboardVisibilityForUrl(boolean visible) { |
297 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 317 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
298 Context.INPUT_METHOD_SERVICE); | 318 Context.INPUT_METHOD_SERVICE); |
299 if (visible) { | 319 if (visible) { |
300 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 320 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
301 } else { | 321 } else { |
302 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 322 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
303 } | 323 } |
304 } | 324 } |
305 | 325 |
306 private static native void nativeCloseShell(long shellPtr); | 326 private static native void nativeCloseShell(long shellPtr); |
307 } | 327 } |
OLD | NEW |