Backed out 5 changesets (bug 1137483) under suspicion of making robocop-2 really really orange CLOSED TREE

Backed out changeset a4228f6ef8ce (bug 1137483)
Backed out changeset 22567ae1d44d (bug 1137483)
Backed out changeset f6c941bae296 (bug 1137483)
Backed out changeset 94f0cc466288 (bug 1137483)
Backed out changeset 395b45ace9c0 (bug 1137483)
This commit is contained in:
Wes Kocher 2015-04-28 16:16:58 -07:00
parent ca80503fb6
commit 4484887727
8 changed files with 19 additions and 241 deletions

View File

@ -2616,16 +2616,6 @@ public class BrowserApp extends GeckoApp
fm.beginTransaction().add(R.id.search_container, mBrowserSearch, BROWSER_SEARCH_TAG).commitAllowingStateLoss();
mBrowserSearch.setUserVisibleHint(true);
// We want to adjust the window size when the keyboard appears to bring the
// SearchEngineBar above the keyboard. However, adjusting the window size
// when hiding the keyboard results in graphical glitches where the keyboard was
// because nothing was being drawn underneath (bug 933422). This can be
// prevented drawing content under the keyboard (i.e. in the Window).
//
// We do this here because there are glitches when unlocking a device with
// BrowserSearch in the foreground if we use BrowserSearch.onStart/Stop.
getActivity().getWindow().setBackgroundDrawableResource(android.R.color.white);
}
private void hideBrowserSearch() {
@ -2642,8 +2632,6 @@ public class BrowserApp extends GeckoApp
getSupportFragmentManager().beginTransaction()
.remove(mBrowserSearch).commitAllowingStateLoss();
mBrowserSearch.setUserVisibleHint(false);
getWindow().setBackgroundDrawable(null);
}
/**

View File

@ -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
@ -230,6 +226,23 @@ public class BrowserSearch extends HomeFragment
mSearchEngines = null;
}
@Override
public void onStart() {
super.onStart();
// Adjusting the window size when showing the keyboard results in the underlying
// activity being painted when the keyboard is hidden (bug 933422). This can be
// prevented by not resizing the window.
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING);
}
@Override
public void onStop() {
super.onStop();
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
}
@Override
public void onResume() {
super.onResume();
@ -255,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;
}
@ -267,9 +279,6 @@ public class BrowserSearch extends HomeFragment
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"SearchEngines:Data");
mSearchEngineBar.setAdapter(null);
mSearchEngineBar = null;
mList.setAdapter(null);
mList = null;
@ -341,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
@ -584,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) {
@ -598,14 +599,6 @@ public class BrowserSearch extends HomeFragment
filterSuggestions();
}
@Override
public void onSearchBarClickListener(final SearchEngine searchEngine) {
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM,
"searchenginebar");
mSearchListener.onSearch(searchEngine, mSearchTerm);
}
private void maybeSetSuggestClient(final String suggestTemplate, final boolean isPrivate) {
if (mSuggestClient != null || isPrivate) {
return;

View File

@ -1,137 +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 android.widget.FrameLayout;
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;
public SearchEngineBar(final Context context, final AttributeSet attrs) {
super(context, attrs);
adapter = new SearchEngineAdapter();
setAdapter(adapter);
setOnItemClickListener(this);
}
@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());
final View container = view.findViewById(R.id.search_engine_icon_container);
final String desc = getResources().getString(R.string.search_bar_item_desc, searchEngine.getEngineIdentifier());
container.setContentDescription(desc);
return view;
}
}
/**
* A Container to surround the SearchEngineBar. This is necessary so we can draw
* a divider across the entire width of the screen, but have the inner list layout
* not take up the full width of the screen so it can be centered within this container
* if there aren't enough items that it needs to scroll.
*
* Note: a better implementation would have this View inflating an inner layout so
* the containing layout doesn't need two "SearchEngineBar" Views but it wasn't
* worth the refactor time.
*/
@SuppressWarnings("unused") // via XML
public static class SearchEngineBarContainer extends FrameLayout {
private final Paint dividerPaint;
public SearchEngineBarContainer(final Context context, final AttributeSet attrs) {
super(context, attrs);
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);
}
}
}

View File

@ -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',

View File

@ -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>

View File

@ -19,31 +19,4 @@
android:layout_height="0dp"
android:layout_weight="1" />
<!-- The window background is set to our desired color, #fff, so
reduce overdraw by not drawing the background.
Note: this needs to be transparent and not null because we
draw a divider in onDraw. -->
<view class="org.mozilla.gecko.home.SearchEngineBar$SearchEngineBarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent">
<!-- We add a marginTop so the outer container can draw a divider.
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="wrap_content"
android:layout_height="48dp"
android:layout_marginTop="1dp"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:choiceMode="singleChoice"
android:listSelector="@android:color/transparent"
android:cacheColorHint="@android:color/transparent"/>
</view>
</LinearLayout>

View File

@ -77,6 +77,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/browser_chrome"
android:background="@android:color/white"
android:visibility="invisible"/>
<!-- When focus is cleared from from BrowserToolbar's EditText to

View File

@ -1,27 +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:id="@+id/search_engine_icon_container"
android:layout_height="match_parent"
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>