diff options
author | Leon Scroggins <scroggo@google.com> | 2009-09-18 14:21:08 -0400 |
---|---|---|
committer | Leon Scroggins <scroggo@google.com> | 2009-09-18 15:22:46 -0400 |
commit | a3315564bdf76716f3a21d0f289e9d4e058d5290 (patch) | |
tree | de36aef631c319aaf6bf46ebc8decefb0254a4ce | |
parent | 8f0076b720c9ee1e9ef9d29910c261634fd5fb25 (diff) | |
download | packages_apps_browser-a3315564bdf76716f3a21d0f289e9d4e058d5290.zip packages_apps_browser-a3315564bdf76716f3a21d0f289e9d4e058d5290.tar.gz packages_apps_browser-a3315564bdf76716f3a21d0f289e9d4e058d5290.tar.bz2 |
Give more space to the close button, and highlight separately from tab.
Fix for http://b/issue?id=2126503 and http://b/issue?id=2124781
Change-Id: I4a83223477e553d124ed667d92bc4970a3ebca0e
-rw-r--r-- | res/drawable/close_background.xml | 25 | ||||
-rw-r--r-- | res/layout/tab_view.xml | 12 | ||||
-rw-r--r-- | src/com/android/browser/ActiveTabsPage.java | 23 |
3 files changed, 55 insertions, 5 deletions
diff --git a/res/drawable/close_background.xml b/res/drawable/close_background.xml new file mode 100644 index 0000000..627712f --- /dev/null +++ b/res/drawable/close_background.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<selector xmlns:android="http://schemas.android.com/apk/res/android"> + + <item android:state_window_focused="false" + android:drawable="@android:color/transparent" /> + <item android:state_focused="false" android:state_pressed="true" + android:drawable="@*android:drawable/list_selector_background_transition" /> + <item android:state_focused="false" android:state_pressed="false" + android:drawable="@color/black"/> +</selector> diff --git a/res/layout/tab_view.xml b/res/layout/tab_view.xml index 167621e..1f01d79 100644 --- a/res/layout/tab_view.xml +++ b/res/layout/tab_view.xml @@ -58,11 +58,13 @@ android:layout_marginTop="5dip" android:layout_marginBottom="5dip" /> - <ImageView android:id="@+id/close" - android:src="@drawable/ic_btn_close_panel" + <view class="com.android.browser.ActiveTabsPage$CloseHolder" android:id="@+id/close" android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginLeft="8dip" - android:layout_marginRight="8dip" + android:layout_height="fill_parent" + android:paddingLeft="18dip" + android:paddingRight="18dip" + android:background="@drawable/close_background" + android:src="@drawable/ic_btn_close_panel" + android:scaleType="center" /> </LinearLayout> diff --git a/src/com/android/browser/ActiveTabsPage.java b/src/com/android/browser/ActiveTabsPage.java index 9837ad6..2971e09 100644 --- a/src/com/android/browser/ActiveTabsPage.java +++ b/src/com/android/browser/ActiveTabsPage.java @@ -16,12 +16,15 @@ package com.android.browser; +import android.content.Context; +import android.util.AttributeSet; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.BaseAdapter; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; @@ -74,6 +77,26 @@ public class ActiveTabsPage extends LinearLayout { return super.dispatchKeyEvent(event); } + /** + * Special class to hold the close drawable. Its sole purpose is to allow + * the parent to be pressed without being pressed itself. This way the line + * of a tab can be pressed, but the close button itself is not. + */ + private static class CloseHolder extends ImageView { + public CloseHolder(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + public void setPressed(boolean pressed) { + // If the parent is pressed, do not set to pressed. + if (pressed && ((View) getParent()).isPressed()) { + return; + } + super.setPressed(pressed); + } + } + private class TabsListAdapter extends BaseAdapter { public int getCount() { int count = mControl.getTabCount(); |