Chromium Code Reviews| 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) | |
| 223 mContentViewCore.stopLoading(); | |
|
Ted C
2014/08/28 16:21:13
in java, braces are required unless the statement
| |
| 224 } | |
| 225 }); | |
| 226 mReloadButton = (ImageButton)findViewById(R.id.reload); | |
| 227 mReloadButton.setOnClickListener(new OnClickListener() { | |
| 228 @Override | |
| 229 public void onClick(View v) { | |
| 230 mContentViewCore.reload(true); | |
| 231 } | |
| 232 }); | |
| 216 } | 233 } |
| 217 | 234 |
| 218 @SuppressWarnings("unused") | 235 @SuppressWarnings("unused") |
| 219 @CalledByNative | 236 @CalledByNative |
| 220 private void onUpdateUrl(String url) { | 237 private void onUpdateUrl(String url) { |
| 221 mUrlTextView.setText(url); | 238 mUrlTextView.setText(url); |
| 222 } | 239 } |
| 223 | 240 |
| 224 @SuppressWarnings("unused") | 241 @SuppressWarnings("unused") |
| 225 @CalledByNative | 242 @CalledByNative |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 /** | 287 /** |
| 271 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed | 288 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa llowed |
| 272 * in respective direction. | 289 * in respective direction. |
| 273 * @param controlId Id of button to update | 290 * @param controlId Id of button to update |
| 274 * @param enabled enable/disable value | 291 * @param enabled enable/disable value |
| 275 */ | 292 */ |
| 276 @CalledByNative | 293 @CalledByNative |
| 277 private void enableUiControl(int controlId, boolean enabled) { | 294 private void enableUiControl(int controlId, boolean enabled) { |
| 278 if (controlId == 0) mPrevButton.setEnabled(enabled); | 295 if (controlId == 0) mPrevButton.setEnabled(enabled); |
| 279 else if (controlId == 1) mNextButton.setEnabled(enabled); | 296 else if (controlId == 1) mNextButton.setEnabled(enabled); |
| 297 else if (controlId == 2) { | |
| 298 mStopButton.setVisibility(enabled ? VISIBLE : GONE); | |
| 299 mReloadButton.setVisibility(enabled ? GONE : VISIBLE); | |
| 300 } | |
| 280 } | 301 } |
| 281 | 302 |
| 282 /** | 303 /** |
| 283 * @return The {@link ViewGroup} currently shown by this Shell. | 304 * @return The {@link ViewGroup} currently shown by this Shell. |
| 284 */ | 305 */ |
| 285 public ViewGroup getContentView() { | 306 public ViewGroup getContentView() { |
| 286 return mContentViewCore.getContainerView(); | 307 return mContentViewCore.getContainerView(); |
| 287 } | 308 } |
| 288 | 309 |
| 289 /** | 310 /** |
| 290 * @return The {@link ContentViewCore} currently managing the view shown by this Shell. | 311 * @return The {@link ContentViewCore} currently managing the view shown by this Shell. |
| 291 */ | 312 */ |
| 292 public ContentViewCore getContentViewCore() { | 313 public ContentViewCore getContentViewCore() { |
| 293 return mContentViewCore; | 314 return mContentViewCore; |
| 294 } | 315 } |
| 295 | 316 |
| 296 private void setKeyboardVisibilityForUrl(boolean visible) { | 317 private void setKeyboardVisibilityForUrl(boolean visible) { |
| 297 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( | 318 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( |
| 298 Context.INPUT_METHOD_SERVICE); | 319 Context.INPUT_METHOD_SERVICE); |
| 299 if (visible) { | 320 if (visible) { |
| 300 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 321 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 301 } else { | 322 } else { |
| 302 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 323 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 303 } | 324 } |
| 304 } | 325 } |
| 305 | 326 |
| 306 private static native void nativeCloseShell(long shellPtr); | 327 private static native void nativeCloseShell(long shellPtr); |
| 307 } | 328 } |
| OLD | NEW |