Skip to content

Commit

Permalink
Backed out changeset 399980ce108a (bug 1137483)
Browse files Browse the repository at this point in the history
  • Loading branch information
BavarianTomcat committed May 8, 2015
1 parent 59f9d29 commit 58bf9ec
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 50 deletions.
42 changes: 12 additions & 30 deletions mobile/android/base/home/SearchEngineBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
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;
Expand All @@ -34,12 +33,24 @@ public interface OnSearchBarClickListener {
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
Expand Down Expand Up @@ -101,33 +112,4 @@ public View getView(final int position, final View convertView, final ViewGroup
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);
}
}
}
36 changes: 17 additions & 19 deletions mobile/android/base/resources/layout/browser_search.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,24 @@
android:layout_height="0dp"
android:layout_weight="1" />

<view class="org.mozilla.gecko.home.SearchEngineBar$SearchEngineBarContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">

<!-- We add a marginTop so the outer container can draw a divider.
<!-- 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. :(
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"/>
Note: the layout_height value is shared with the inner layout
(search_engine_bar_item at the time of this writing).
</view>
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>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
View (browser_search at the time of this writing). -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_height="48dp"
android:layout_width="72dp"
android:background="@color/pressed_about_page_header_grey">

Expand Down

0 comments on commit 58bf9ec

Please sign in to comment.