diff --git a/embedding/android/AwesomeBarTabs.java b/embedding/android/AwesomeBarTabs.java index 4e11afcd4ae4..ad70ce759982 100644 --- a/embedding/android/AwesomeBarTabs.java +++ b/embedding/android/AwesomeBarTabs.java @@ -43,6 +43,9 @@ import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.LightingColorFilter; import android.graphics.drawable.Drawable; import android.os.AsyncTask; import android.provider.Browser; @@ -79,6 +82,8 @@ public class AwesomeBarTabs extends TabHost { private static final String LOG_NAME = "AwesomeBarTabs"; + private static final LightingColorFilter tabColorFilter; + private Context mContext; private OnUrlOpenListener mUrlOpenListener; @@ -86,6 +91,48 @@ public class AwesomeBarTabs extends TabHost { private SimpleCursorAdapter mBookmarksAdapter; private SimpleExpandableListAdapter mHistoryAdapter; + static { + // We want to use the same color on the list items (in pressed state) + // and the awesome screen tabs. This code is run only once to pick + // the color of list view's pressed state. + + Resources resources = GeckoApp.mAppContext.getResources(); + + // Load image resource that is used in list items in awesome screen + Drawable listBackground = + resources.getDrawable(android.R.drawable.list_selector_background); + + // Set state of drawable to pressed state so that we can pick its + // color to use in our tabs. + listBackground.setState(new int[] { android.R.attr.state_pressed, + android.R.attr.state_window_focused, + android.R.attr.state_enabled }); + + // This number is arbitrary. We just need the image to + // have some size for picking its color. + int imageBounds = 40; + + // Get currently used drawable (pressed state) and set bounds + // to create a bitmap. + Drawable current = listBackground.getCurrent(); + current.setBounds(0, 0, imageBounds, imageBounds); + + Bitmap bitmap = + Bitmap.createBitmap(imageBounds, imageBounds, Bitmap.Config.ARGB_8888); + + // Draw the current drawable in the bitmap + Canvas canvas = new Canvas(bitmap); + current.draw(canvas); + + // Pick color at central position + int tabColor = bitmap.getPixel(imageBounds / 2, imageBounds / 2); + + // Release bitmap to be garbage collected + bitmap.recycle(); + + tabColorFilter = new LightingColorFilter(Color.WHITE, tabColor); + } + // FIXME: This value should probably come from a // prefs key (just like XUL-based fennec) private static final int MAX_RESULTS = 100; @@ -453,6 +500,9 @@ public class AwesomeBarTabs extends TabHost { (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View indicatorView = inflater.inflate(R.layout.awesomebar_tab_indicator, null); + Drawable background = indicatorView.getBackground(); + background.setColorFilter(tabColorFilter); + TextView title = (TextView) indicatorView.findViewById(R.id.title); title.setText(titleId); diff --git a/embedding/android/Makefile.in b/embedding/android/Makefile.in index 6429d8171a65..df8e600e3841 100644 --- a/embedding/android/Makefile.in +++ b/embedding/android/Makefile.in @@ -271,14 +271,13 @@ RES_LAYOUT += res/layout/crash_reporter.xml endif MOZ_ANDROID_DRAWABLES += embedding/android/resources/drawable/address_bar_bg.xml \ - embedding/android/resources/drawable/awesomebar_tab_focus.9.png \ - embedding/android/resources/drawable/awesomebar_tab_focus_selected.9.png \ + embedding/android/resources/drawable/awesomebar_tab_focus.xml \ + embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml \ embedding/android/resources/drawable/awesomebar_tab_indicator.xml \ - embedding/android/resources/drawable/awesomebar_tab_press.9.png \ - embedding/android/resources/drawable/awesomebar_tab_press_selected.9.png \ - embedding/android/resources/drawable/awesomebar_tab_selected.9.png \ - embedding/android/resources/drawable/awesomebar_tab_separator.9.png \ - embedding/android/resources/drawable/awesomebar_tab_unselected.9.png \ + embedding/android/resources/drawable/awesomebar_tab_press.xml \ + embedding/android/resources/drawable/awesomebar_tab_press_selected.xml \ + embedding/android/resources/drawable/awesomebar_tab_selected.xml \ + embedding/android/resources/drawable/awesomebar_tab_unselected.xml \ embedding/android/resources/drawable/desktop_notification.png \ embedding/android/resources/drawable/favicon.png \ embedding/android/resources/drawable/progress_spinner.xml \ diff --git a/embedding/android/resources/drawable/awesomebar_tab_focus.9.png b/embedding/android/resources/drawable/awesomebar_tab_focus.9.png deleted file mode 100644 index 754e3c5fba9d..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_focus.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_focus.xml b/embedding/android/resources/drawable/awesomebar_tab_focus.xml new file mode 100644 index 000000000000..8a96ba0c2257 --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_focus.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/drawable/awesomebar_tab_focus_selected.9.png b/embedding/android/resources/drawable/awesomebar_tab_focus_selected.9.png deleted file mode 100644 index bd5dda7aa323..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_focus_selected.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml b/embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml new file mode 100644 index 000000000000..a6a619997886 --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_focus_selected.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/drawable/awesomebar_tab_press.9.png b/embedding/android/resources/drawable/awesomebar_tab_press.9.png deleted file mode 100644 index 6d19870cf18f..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_press.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_press.xml b/embedding/android/resources/drawable/awesomebar_tab_press.xml new file mode 100644 index 000000000000..a60f9a3675cd --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_press.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/drawable/awesomebar_tab_press_selected.9.png b/embedding/android/resources/drawable/awesomebar_tab_press_selected.9.png deleted file mode 100755 index b3c85ea63af5..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_press_selected.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_press_selected.xml b/embedding/android/resources/drawable/awesomebar_tab_press_selected.xml new file mode 100644 index 000000000000..a6a619997886 --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_press_selected.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/drawable/awesomebar_tab_selected.9.png b/embedding/android/resources/drawable/awesomebar_tab_selected.9.png deleted file mode 100644 index 60f359506048..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_selected.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_selected.xml b/embedding/android/resources/drawable/awesomebar_tab_selected.xml new file mode 100644 index 000000000000..7fecfa7885ea --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_selected.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/drawable/awesomebar_tab_separator.9.png b/embedding/android/resources/drawable/awesomebar_tab_separator.9.png deleted file mode 100644 index 1905808b83d3..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_separator.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_unselected.9.png b/embedding/android/resources/drawable/awesomebar_tab_unselected.9.png deleted file mode 100644 index 368d67c3fbf2..000000000000 Binary files a/embedding/android/resources/drawable/awesomebar_tab_unselected.9.png and /dev/null differ diff --git a/embedding/android/resources/drawable/awesomebar_tab_unselected.xml b/embedding/android/resources/drawable/awesomebar_tab_unselected.xml new file mode 100644 index 000000000000..8a96ba0c2257 --- /dev/null +++ b/embedding/android/resources/drawable/awesomebar_tab_unselected.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/embedding/android/resources/layout/awesomebar_tab_indicator.xml b/embedding/android/resources/layout/awesomebar_tab_indicator.xml index 862bda9cd3e5..2025be97f522 100644 --- a/embedding/android/resources/layout/awesomebar_tab_indicator.xml +++ b/embedding/android/resources/layout/awesomebar_tab_indicator.xml @@ -9,6 +9,7 @@ + android:layout_height="wrap_content" + android:layout_marginBottom="3dip"/> diff --git a/embedding/android/resources/layout/awesomebar_tabs.xml b/embedding/android/resources/layout/awesomebar_tabs.xml index a02e4a1a59f1..7c25e3bc59e6 100644 --- a/embedding/android/resources/layout/awesomebar_tabs.xml +++ b/embedding/android/resources/layout/awesomebar_tabs.xml @@ -8,8 +8,7 @@ + android:background="@color/awesomebar_background"/>