mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 0602fff3681d (bug 1137483) for suspicion this made the rc2 test failing more frequently on a CLOSED TREE
This commit is contained in:
parent
35b772267f
commit
e1a9edca6d
@ -65,8 +65,7 @@ import android.widget.TextView;
|
||||
* Fragment that displays frecency search results in a ListView.
|
||||
*/
|
||||
public class BrowserSearch extends HomeFragment
|
||||
implements GeckoEventListener,
|
||||
SearchEngineBar.OnSearchBarClickListener {
|
||||
implements GeckoEventListener {
|
||||
|
||||
@RobocopTarget
|
||||
public interface SuggestClientFactory {
|
||||
@ -125,9 +124,6 @@ public class BrowserSearch extends HomeFragment
|
||||
// The list showing search results
|
||||
private HomeListView mList;
|
||||
|
||||
// The bar on the bottom of the screen displaying search engine options.
|
||||
private SearchEngineBar mSearchEngineBar;
|
||||
|
||||
// Client that performs search suggestion queries.
|
||||
// Public for testing.
|
||||
@RobocopTarget
|
||||
@ -272,7 +268,6 @@ public class BrowserSearch extends HomeFragment
|
||||
// If the style of the list changes, inflate it from an XML.
|
||||
mView = (LinearLayout) inflater.inflate(R.layout.browser_search, container, false);
|
||||
mList = (HomeListView) mView.findViewById(R.id.home_list_view);
|
||||
mSearchEngineBar = (SearchEngineBar) mView.findViewById(R.id.search_engine_bar);
|
||||
|
||||
return mView;
|
||||
}
|
||||
@ -284,9 +279,6 @@ public class BrowserSearch extends HomeFragment
|
||||
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
|
||||
"SearchEngines:Data");
|
||||
|
||||
mSearchEngineBar.setAdapter(null);
|
||||
mSearchEngineBar = null;
|
||||
|
||||
mList.setAdapter(null);
|
||||
mList = null;
|
||||
|
||||
@ -358,12 +350,6 @@ public class BrowserSearch extends HomeFragment
|
||||
registerForContextMenu(mList);
|
||||
EventDispatcher.getInstance().registerGeckoThreadListener(this,
|
||||
"SearchEngines:Data");
|
||||
|
||||
// If the view backed by this Fragment is being recreated, we will not receive
|
||||
// a new search engine data event so refresh the new search engine bar's data
|
||||
// & Views with the data we have.
|
||||
mSearchEngineBar.setSearchEngines(mSearchEngines);
|
||||
mSearchEngineBar.setOnSearchBarClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -601,8 +587,6 @@ public class BrowserSearch extends HomeFragment
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
mSearchEngineBar.setSearchEngines(mSearchEngines);
|
||||
|
||||
// Show suggestions opt-in prompt only if suggestions are not enabled yet,
|
||||
// user hasn't been prompted and we're not on a private browsing tab.
|
||||
if (!mSuggestionsEnabled && !suggestionsPrompted && mSuggestClient != null) {
|
||||
@ -615,11 +599,6 @@ public class BrowserSearch extends HomeFragment
|
||||
filterSuggestions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSearchBarClickListener(final SearchEngine searchEngine) {
|
||||
mSearchListener.onSearch(searchEngine, mSearchTerm);
|
||||
}
|
||||
|
||||
private void maybeSetSuggestClient(final String suggestTemplate, final boolean isPrivate) {
|
||||
if (mSuggestClient != null || isPrivate) {
|
||||
return;
|
||||
|
@ -1,115 +0,0 @@
|
||||
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.gecko.home;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.BaseAdapter;
|
||||
|
||||
import org.mozilla.gecko.R;
|
||||
import org.mozilla.gecko.widget.FaviconView;
|
||||
import org.mozilla.gecko.widget.TwoWayView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SearchEngineBar extends TwoWayView
|
||||
implements AdapterView.OnItemClickListener {
|
||||
private static final String LOGTAG = "Gecko" + SearchEngineBar.class.getSimpleName();
|
||||
|
||||
public interface OnSearchBarClickListener {
|
||||
public void onSearchBarClickListener(SearchEngine searchEngine);
|
||||
}
|
||||
|
||||
private final SearchEngineAdapter adapter;
|
||||
private OnSearchBarClickListener onSearchBarClickListener;
|
||||
|
||||
private final Paint dividerPaint;
|
||||
|
||||
public SearchEngineBar(final Context context, final AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
|
||||
adapter = new SearchEngineAdapter();
|
||||
setAdapter(adapter);
|
||||
setOnItemClickListener(this);
|
||||
|
||||
dividerPaint = new Paint();
|
||||
dividerPaint.setColor(getResources().getColor(R.color.divider_light));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(final Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
|
||||
canvas.drawLine(0, 0, getWidth(), 0, dividerPaint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(final AdapterView<?> parent, final View view, final int position,
|
||||
final long id) {
|
||||
if (onSearchBarClickListener == null) {
|
||||
throw new IllegalStateException(
|
||||
OnSearchBarClickListener.class.getSimpleName() + " is not initialized");
|
||||
}
|
||||
|
||||
final SearchEngine searchEngine = adapter.getItem(position);
|
||||
onSearchBarClickListener.onSearchBarClickListener(searchEngine);
|
||||
}
|
||||
|
||||
protected void setOnSearchBarClickListener(final OnSearchBarClickListener listener) {
|
||||
onSearchBarClickListener = listener;
|
||||
}
|
||||
|
||||
protected void setSearchEngines(final List<SearchEngine> searchEngines) {
|
||||
adapter.setSearchEngines(searchEngines);
|
||||
}
|
||||
|
||||
public class SearchEngineAdapter extends BaseAdapter {
|
||||
List<SearchEngine> searchEngines = new ArrayList<>();
|
||||
|
||||
public void setSearchEngines(final List<SearchEngine> searchEngines) {
|
||||
this.searchEngines = searchEngines;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return searchEngines.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SearchEngine getItem(final int position) {
|
||||
return searchEngines.get(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(final int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(final int position, final View convertView, final ViewGroup parent) {
|
||||
final View view;
|
||||
if (convertView == null) {
|
||||
view = LayoutInflater.from(getContext()).inflate(R.layout.search_engine_bar_item, parent, false);
|
||||
} else {
|
||||
view = convertView;
|
||||
}
|
||||
|
||||
final FaviconView faviconView = (FaviconView) view.findViewById(R.id.search_engine_icon);
|
||||
final SearchEngine searchEngine = searchEngines.get(position);
|
||||
faviconView.updateAndScaleImage(searchEngine.getIcon(), searchEngine.getEngineIdentifier());
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
@ -340,7 +340,6 @@ gbjar.sources += [
|
||||
'home/RemoteTabsSplitPlaneFragment.java',
|
||||
'home/RemoteTabsStaticFragment.java',
|
||||
'home/SearchEngine.java',
|
||||
'home/SearchEngineBar.java',
|
||||
'home/SearchEngineRow.java',
|
||||
'home/SearchLoader.java',
|
||||
'home/SimpleCursorLoader.java',
|
||||
|
@ -1,12 +0,0 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item android:state_pressed="true"
|
||||
android:drawable="@color/about_page_header_grey" />
|
||||
|
||||
<item android:drawable="@android:color/transparent"/>
|
||||
|
||||
</selector>
|
@ -19,24 +19,4 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<!-- The desired layout_height is 48dp. We add paddingTop so we have
|
||||
space to dynamically draw the divider in onDraw. Preferably, we'd
|
||||
wrap_content on the inner layout, but TwoWayView ignores wrap_content. :(
|
||||
|
||||
Note: the layout_height value is shared with the inner layout
|
||||
(search_engine_bar_item at the time of this writing).
|
||||
|
||||
listSelector is too slow for showing pressed state
|
||||
so we set the pressed colors on the child. -->
|
||||
<org.mozilla.gecko.home.SearchEngineBar
|
||||
android:id="@+id/search_engine_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="49dp"
|
||||
android:paddingTop="1dp"
|
||||
android:orientation="horizontal"
|
||||
android:background="#fff"
|
||||
android:choiceMode="singleChoice"
|
||||
android:listSelector="@android:color/transparent"
|
||||
android:cacheColorHint="@android:color/transparent"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!-- TwoWayView doesn't let us set the margin around items (except as
|
||||
gecko:itemMargin, but that doesn't increase the hit area) so we
|
||||
have to surround the main View by a ViewGroup to create a pressable margin.
|
||||
|
||||
Note: the layout_height values are shared with the parent
|
||||
View (browser_search at the time of this writing). -->
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_height="48dp"
|
||||
android:layout_width="72dp"
|
||||
android:background="@color/pressed_about_page_header_grey">
|
||||
|
||||
<!-- Width & height are set to make the Favicons as sharp as possible
|
||||
based on asset size. -->
|
||||
<org.mozilla.gecko.widget.FaviconView
|
||||
android:id="@+id/search_engine_icon"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
</FrameLayout>
|
Loading…
Reference in New Issue
Block a user