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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/NavigationPopup.java

Issue 12578027: Removed 'show full history' from navigation popup. Cleaned up associated dead code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-show-full-history-from-menu-222282
Patch Set: Removed broken test (checking click on show full history which we removed) Created 7 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.graphics.Bitmap; 8 import android.graphics.Bitmap;
9 import android.graphics.Color; 9 import android.graphics.Color;
10 import android.graphics.drawable.BitmapDrawable; 10 import android.graphics.drawable.BitmapDrawable;
(...skipping 30 matching lines...) Expand all
41 public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt emClickListener { 41 public class NavigationPopup extends ListPopupWindow implements AdapterView.OnIt emClickListener {
42 42
43 private static final int LIST_ITEM_HEIGHT_DP = 48; 43 private static final int LIST_ITEM_HEIGHT_DP = 48;
44 private static final int FAVICON_SIZE_DP = 16; 44 private static final int FAVICON_SIZE_DP = 16;
45 private static final int PADDING_DP = 8; 45 private static final int PADDING_DP = 8;
46 private static final int TEXT_SIZE_SP = 18; 46 private static final int TEXT_SIZE_SP = 18;
47 47
48 private static final int MAXIMUM_HISTORY_ITEMS = 8; 48 private static final int MAXIMUM_HISTORY_ITEMS = 8;
49 49
50 private final Context mContext; 50 private final Context mContext;
51 private final NavigationPopupDelegate mDelegate;
52 private final NavigationClient mNavigationClient; 51 private final NavigationClient mNavigationClient;
53 private final NavigationHistory mHistory; 52 private final NavigationHistory mHistory;
54 private final NavigationAdapter mAdapter; 53 private final NavigationAdapter mAdapter;
55 private final TextView mShowHistoryView;
56 54
57 private final int mListItemHeight; 55 private final int mListItemHeight;
58 private final int mFaviconSize; 56 private final int mFaviconSize;
59 private final int mPadding; 57 private final int mPadding;
60 58
61 private int mNativeNavigationPopup; 59 private int mNativeNavigationPopup;
62 60
63 /** 61 /**
64 * Delegate functionality required to operate on the history.
65 */
66 public interface NavigationPopupDelegate {
67 /** Open the complete browser history page */
68 void openHistory();
69 }
70
71 /**
72 * Constructs a new popup with the given history information. 62 * Constructs a new popup with the given history information.
73 * 63 *
74 * @param context The context used for building the popup. 64 * @param context The context used for building the popup.
75 * @param delegate The delegate that handles history actions outside of the given
76 * {@link ContentViewCore}.
77 * @param navigationClient The owner of the history being displayed. 65 * @param navigationClient The owner of the history being displayed.
78 * @param isForward Whether to request forward navigation entries. 66 * @param isForward Whether to request forward navigation entries.
79 */ 67 */
80 public NavigationPopup( 68 public NavigationPopup(
81 Context context, NavigationPopupDelegate delegate, 69 Context context, NavigationClient navigationClient, boolean isForwar d) {
82 NavigationClient navigationClient, boolean isForward) {
83 super(context, null, android.R.attr.popupMenuStyle); 70 super(context, null, android.R.attr.popupMenuStyle);
84 mContext = context; 71 mContext = context;
85 assert delegate != null : "NavigationPopup requires non-null delegate.";
86 mDelegate = delegate;
87 mNavigationClient = navigationClient; 72 mNavigationClient = navigationClient;
88 mHistory = mNavigationClient.getDirectedNavigationHistory( 73 mHistory = mNavigationClient.getDirectedNavigationHistory(
89 isForward, MAXIMUM_HISTORY_ITEMS); 74 isForward, MAXIMUM_HISTORY_ITEMS);
90 mAdapter = new NavigationAdapter(); 75 mAdapter = new NavigationAdapter();
91 76
92 float density = mContext.getResources().getDisplayMetrics().density; 77 float density = mContext.getResources().getDisplayMetrics().density;
93 mListItemHeight = (int) (density * LIST_ITEM_HEIGHT_DP); 78 mListItemHeight = (int) (density * LIST_ITEM_HEIGHT_DP);
94 mFaviconSize = (int) (density * FAVICON_SIZE_DP); 79 mFaviconSize = (int) (density * FAVICON_SIZE_DP);
95 mPadding = (int) (density * PADDING_DP); 80 mPadding = (int) (density * PADDING_DP);
96 81
97 setModal(true); 82 setModal(true);
98 setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED); 83 setInputMethodMode(PopupWindow.INPUT_METHOD_NOT_NEEDED);
99 setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); 84 setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
100 setOnItemClickListener(this); 85 setOnItemClickListener(this);
101 86
102 FixedViewInfo footerInfo = new ListView(context).new FixedViewInfo(); 87 setAdapter(new HeaderViewListAdapter(null, null, mAdapter));
103 mShowHistoryView = createListItem();
104 mShowHistoryView.setText(R.string.show_history_label);
105 footerInfo.isSelectable = true;
106 footerInfo.view = mShowHistoryView;
107 ArrayList<FixedViewInfo> footerInfoList = new ArrayList<FixedViewInfo>(1 );
108 footerInfoList.add(footerInfo);
109 setAdapter(new HeaderViewListAdapter(null, footerInfoList, mAdapter));
110 } 88 }
111 89
112 /** 90 /**
113 * @return The URL of the page for managing history.
114 */
115 public static String getHistoryUrl() {
116 return nativeGetHistoryUrl();
117 }
118
119 /**
120 * @return Whether a navigation popup is valid for the given page. 91 * @return Whether a navigation popup is valid for the given page.
121 */ 92 */
122 public boolean shouldBeShown() { 93 public boolean shouldBeShown() {
123 return mHistory.getEntryCount() > 0; 94 return mHistory.getEntryCount() > 0;
124 } 95 }
125 96
126 @Override 97 @Override
127 public void show() { 98 public void show() {
128 if (mNativeNavigationPopup == 0) initializeNative(); 99 if (mNativeNavigationPopup == 0) initializeNative();
129 super.show(); 100 super.show();
(...skipping 24 matching lines...) Expand all
154 } 125 }
155 nativeFetchFaviconForUrl(mNativeNavigationPopup, nativeGetHistoryUrl()); 126 nativeFetchFaviconForUrl(mNativeNavigationPopup, nativeGetHistoryUrl());
156 } 127 }
157 128
158 @CalledByNative 129 @CalledByNative
159 private void onFaviconUpdated(String url, Object favicon) { 130 private void onFaviconUpdated(String url, Object favicon) {
160 for (int i = 0; i < mHistory.getEntryCount(); i++) { 131 for (int i = 0; i < mHistory.getEntryCount(); i++) {
161 NavigationEntry entry = mHistory.getEntryAtIndex(i); 132 NavigationEntry entry = mHistory.getEntryAtIndex(i);
162 if (TextUtils.equals(url, entry.getUrl())) entry.updateFavicon((Bitm ap) favicon); 133 if (TextUtils.equals(url, entry.getUrl())) entry.updateFavicon((Bitm ap) favicon);
163 } 134 }
164 if (TextUtils.equals(url, nativeGetHistoryUrl())) {
165 updateBitmapForTextView(mShowHistoryView, (Bitmap) favicon);
166 }
167 mAdapter.notifyDataSetChanged(); 135 mAdapter.notifyDataSetChanged();
168 } 136 }
169 137
170 @Override 138 @Override
171 public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 139 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
172 if (position == mHistory.getEntryCount()) { 140 NavigationEntry entry = (NavigationEntry) parent.getItemAtPosition(posit ion);
173 mDelegate.openHistory(); 141 mNavigationClient.goToNavigationIndex(entry.getIndex());
174 } else {
175 NavigationEntry entry = (NavigationEntry) parent.getItemAtPosition(p osition);
176 mNavigationClient.goToNavigationIndex(entry.getIndex());
177 }
178 dismiss(); 142 dismiss();
179 } 143 }
180 144
181 private TextView createListItem() { 145 private TextView createListItem() {
182 TextView view = new TextView(mContext); 146 TextView view = new TextView(mContext);
183 view.setSingleLine(); 147 view.setSingleLine();
184 view.setTextSize(TEXT_SIZE_SP); 148 view.setTextSize(TEXT_SIZE_SP);
185 view.setMinimumHeight(mListItemHeight); 149 view.setMinimumHeight(mListItemHeight);
186 view.setGravity(Gravity.CENTER_VERTICAL); 150 view.setGravity(Gravity.CENTER_VERTICAL);
187 view.setCompoundDrawablePadding(mPadding); 151 view.setCompoundDrawablePadding(mPadding);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 return view; 200 return view;
237 } 201 }
238 } 202 }
239 203
240 private static native String nativeGetHistoryUrl(); 204 private static native String nativeGetHistoryUrl();
241 205
242 private native int nativeInit(); 206 private native int nativeInit();
243 private native void nativeDestroy(int nativeNavigationPopup); 207 private native void nativeDestroy(int nativeNavigationPopup);
244 private native void nativeFetchFaviconForUrl(int nativeNavigationPopup, Stri ng url); 208 private native void nativeFetchFaviconForUrl(int nativeNavigationPopup, Stri ng url);
245 } 209 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/NavigationPopupTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698