| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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; |
| 11 import android.view.KeyEvent; | 11 import android.view.KeyEvent; |
| 12 import android.view.View; | 12 import android.view.View; |
| 13 import android.view.inputmethod.EditorInfo; | 13 import android.view.inputmethod.EditorInfo; |
| 14 import android.view.inputmethod.InputMethodManager; | 14 import android.view.inputmethod.InputMethodManager; |
| 15 import android.widget.EditText; | 15 import android.widget.EditText; |
| 16 import android.widget.FrameLayout; | 16 import android.widget.FrameLayout; |
| 17 import android.widget.ImageButton; | 17 import android.widget.ImageButton; |
| 18 import android.widget.LinearLayout; | 18 import android.widget.LinearLayout; |
| 19 import android.widget.TextView; | 19 import android.widget.TextView; |
| 20 import android.widget.TextView.OnEditorActionListener; | 20 import android.widget.TextView.OnEditorActionListener; |
| 21 | 21 |
| 22 import org.chromium.base.CalledByNative; | 22 import org.chromium.base.CalledByNative; |
| 23 import org.chromium.base.JNINamespace; | 23 import org.chromium.base.JNINamespace; |
| 24 import org.chromium.content.browser.ContentView; | 24 import org.chromium.content.browser.ContentView; |
| 25 import org.chromium.content.browser.ContentViewRenderView; | 25 import org.chromium.content.browser.ContentViewRenderView; |
| 26 import org.chromium.content.browser.LoadUrlParams; | 26 import org.chromium.content.browser.LoadUrlParams; |
| 27 import org.chromium.ui.gfx.NativeWindow; | 27 import org.chromium.ui.gfx.WindowAndroid; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Container for the various UI components that make up a shell window. | 30 * Container for the various UI components that make up a shell window. |
| 31 */ | 31 */ |
| 32 @JNINamespace("content") | 32 @JNINamespace("content") |
| 33 public class Shell extends LinearLayout { | 33 public class Shell extends LinearLayout { |
| 34 | 34 |
| 35 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 35 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
| 36 | 36 |
| 37 private Runnable mClearProgressRunnable = new Runnable() { | 37 private Runnable mClearProgressRunnable = new Runnable() { |
| 38 @Override | 38 @Override |
| 39 public void run() { | 39 public void run() { |
| 40 mProgressDrawable.setLevel(0); | 40 mProgressDrawable.setLevel(0); |
| 41 } | 41 } |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow
nstream. | 44 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow
nstream. |
| 45 private ContentView mContentView; | 45 private ContentView mContentView; |
| 46 private EditText mUrlTextView; | 46 private EditText mUrlTextView; |
| 47 private ImageButton mPrevButton; | 47 private ImageButton mPrevButton; |
| 48 private ImageButton mNextButton; | 48 private ImageButton mNextButton; |
| 49 | 49 |
| 50 private ClipDrawable mProgressDrawable; | 50 private ClipDrawable mProgressDrawable; |
| 51 | 51 |
| 52 private ContentViewRenderView mContentViewRenderView; | 52 private ContentViewRenderView mContentViewRenderView; |
| 53 private NativeWindow mWindow; | 53 private WindowAndroid mWindow; |
| 54 | 54 |
| 55 private boolean mLoading = false; | 55 private boolean mLoading = false; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * Constructor for inflating via XML. | 58 * Constructor for inflating via XML. |
| 59 */ | 59 */ |
| 60 public Shell(Context context, AttributeSet attrs) { | 60 public Shell(Context context, AttributeSet attrs) { |
| 61 super(context, attrs); | 61 super(context, attrs); |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 75 new FrameLayout.LayoutParams( | 75 new FrameLayout.LayoutParams( |
| 76 FrameLayout.LayoutParams.MATCH_PARENT, | 76 FrameLayout.LayoutParams.MATCH_PARENT, |
| 77 FrameLayout.LayoutParams.MATCH_PARENT)); | 77 FrameLayout.LayoutParams.MATCH_PARENT)); |
| 78 } | 78 } |
| 79 mContentViewRenderView = contentViewRenderView; | 79 mContentViewRenderView = contentViewRenderView; |
| 80 } | 80 } |
| 81 | 81 |
| 82 /** | 82 /** |
| 83 * @param window The owning window for this shell. | 83 * @param window The owning window for this shell. |
| 84 */ | 84 */ |
| 85 public void setWindow(NativeWindow window) { | 85 public void setWindow(WindowAndroid window) { |
| 86 mWindow = window; | 86 mWindow = window; |
| 87 } | 87 } |
| 88 | 88 |
| 89 /** | 89 /** |
| 90 * @return Whether or not the Shell is loading content. | 90 * @return Whether or not the Shell is loading content. |
| 91 */ | 91 */ |
| 92 public boolean isLoading() { | 92 public boolean isLoading() { |
| 93 return mLoading; | 93 return mLoading; |
| 94 } | 94 } |
| 95 | 95 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 private void setKeyboardVisibilityForUrl(boolean visible) { | 237 private void setKeyboardVisibilityForUrl(boolean visible) { |
| 238 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 238 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
| 239 Context.INPUT_METHOD_SERVICE); | 239 Context.INPUT_METHOD_SERVICE); |
| 240 if (visible) { | 240 if (visible) { |
| 241 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 241 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 242 } else { | 242 } else { |
| 243 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 243 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 } | 246 } |
| OLD | NEW |