Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3778)

Unified Diff: chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java

Issue 184493006: Rename to ChromiumTestShell package from testshell to shell (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix py lint Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
diff --git a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java b/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
deleted file mode 100644
index 7d791150c896080da4cabb05925d5a6d7229df40..0000000000000000000000000000000000000000
--- a/chrome/android/testshell/java/src/org/chromium/chrome/testshell/TestShellToolbar.java
+++ /dev/null
@@ -1,159 +0,0 @@
-// Copyright 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.testshell;
-
-import android.content.Context;
-import android.graphics.drawable.ClipDrawable;
-import android.util.AttributeSet;
-import android.view.KeyEvent;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.TextView.OnEditorActionListener;
-
-import org.chromium.chrome.browser.EmptyTabObserver;
-import org.chromium.chrome.browser.Tab;
-import org.chromium.chrome.browser.TabObserver;
-import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper;
-import org.chromium.chrome.browser.appmenu.AppMenuHandler;
-
-/**
- * A Toolbar {@link View} that shows the URL and navigation buttons.
- */
-public class TestShellToolbar extends LinearLayout {
- private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
-
- private final Runnable mClearProgressRunnable = new Runnable() {
- @Override
- public void run() {
- mProgressDrawable.setLevel(0);
- }
- };
-
- private EditText mUrlTextView;
- private ClipDrawable mProgressDrawable;
-
- private TestShellTab mTab;
- private final TabObserver mTabObserver = new TabObserverImpl();
-
- private AppMenuHandler mMenuHandler;
- private AppMenuButtonHelper mAppMenuButtonHelper;
-
- /**
- * @param context The Context the view is running in.
- * @param attrs The attributes of the XML tag that is inflating the view.
- */
- public TestShellToolbar(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- /**
- * The toolbar will visually represent the state of {@code tab}.
- * @param tab The Tab that should be represented.
- */
- public void showTab(TestShellTab tab) {
- if (mTab != null) mTab.removeObserver(mTabObserver);
- mTab = tab;
- mTab.addObserver(mTabObserver);
- mUrlTextView.setText(mTab.getContentView().getUrl());
- }
-
- private void onUpdateUrl(String url) {
- mUrlTextView.setText(url);
- }
-
- private void onLoadProgressChanged(int progress) {
- removeCallbacks(mClearProgressRunnable);
- mProgressDrawable.setLevel((int) (100.0 * progress));
- if (progress == 100) postDelayed(mClearProgressRunnable, COMPLETED_PROGRESS_TIMEOUT_MS);
- }
-
- @Override
- protected void onFinishInflate() {
- super.onFinishInflate();
-
- mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackground();
- initializeUrlField();
- initializeMenuButton();
- }
-
- public void setMenuHandler(AppMenuHandler menuHandler) {
- mMenuHandler = menuHandler;
- ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button);
- mAppMenuButtonHelper = new AppMenuButtonHelper(menuButton, mMenuHandler);
- }
-
- private void initializeUrlField() {
- mUrlTextView = (EditText) findViewById(R.id.url);
- mUrlTextView.setOnEditorActionListener(new OnEditorActionListener() {
- @Override
- public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
- if ((actionId != EditorInfo.IME_ACTION_GO) && (event == null ||
- event.getKeyCode() != KeyEvent.KEYCODE_ENTER ||
- event.getKeyCode() != KeyEvent.ACTION_DOWN)) {
- return false;
- }
-
- mTab.loadUrlWithSanitization(mUrlTextView.getText().toString());
- mUrlTextView.clearFocus();
- setKeyboardVisibilityForUrl(false);
- mTab.getContentView().requestFocus();
- return true;
- }
- });
- mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- setKeyboardVisibilityForUrl(hasFocus);
- if (!hasFocus) {
- mUrlTextView.setText(mTab.getContentView().getUrl());
- }
- }
- });
- }
-
- private void initializeMenuButton() {
- ImageButton menuButton = (ImageButton) findViewById(R.id.menu_button);
- menuButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mMenuHandler != null) mMenuHandler.showAppMenu(view, false, false);
- }
- });
- menuButton.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View view, MotionEvent event) {
- return mAppMenuButtonHelper != null && mAppMenuButtonHelper.onTouch(view, event);
- }
- });
- }
-
- private void setKeyboardVisibilityForUrl(boolean visible) {
- InputMethodManager imm = (InputMethodManager) getContext().getSystemService(
- Context.INPUT_METHOD_SERVICE);
- if (visible) {
- imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
- } else {
- imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
- }
- }
-
- private class TabObserverImpl extends EmptyTabObserver {
- @Override
- public void onLoadProgressChanged(Tab tab, int progress) {
- if (tab == mTab) TestShellToolbar.this.onLoadProgressChanged(progress);
- }
-
- @Override
- public void onUpdateUrl(Tab tab, String url) {
- if (tab == mTab) TestShellToolbar.this.onUpdateUrl(url);
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698