зеркало из https://github.com/mozilla/gecko-dev.git
Bug 806937: Private tabs support for awesomebar tabs. [r=mfinkle]
This commit is contained in:
Родитель
4cd657c324
Коммит
7052c26cb6
|
@ -61,7 +61,7 @@ public class AwesomeBar extends GeckoActivity {
|
|||
static final String SEARCH_KEY = "search";
|
||||
static final String USER_ENTERED_KEY = "user_entered";
|
||||
static final String READING_LIST_KEY = "reading_list";
|
||||
static enum Target { NEW_TAB, CURRENT_TAB };
|
||||
public static enum Target { NEW_TAB, CURRENT_TAB };
|
||||
|
||||
private String mTarget;
|
||||
private AwesomeBarTabs mAwesomeTabs;
|
||||
|
@ -137,6 +137,7 @@ public class AwesomeBar extends GeckoActivity {
|
|||
mText.setPrivateMode(true);
|
||||
}
|
||||
}
|
||||
mAwesomeTabs.setTarget(mTarget);
|
||||
|
||||
mText.setOnKeyPreImeListener(new CustomEditText.OnKeyPreImeListener() {
|
||||
public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
|
||||
|
|
|
@ -7,6 +7,7 @@ package org.mozilla.gecko;
|
|||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v4.view.PagerAdapter;
|
||||
|
@ -17,10 +18,8 @@ import android.view.MotionEvent;
|
|||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TabHost;
|
||||
import android.widget.TabWidget;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class AwesomeBarTabs extends TabHost {
|
||||
private static final String LOGTAG = "GeckoAwesomeBarTabs";
|
||||
|
@ -31,6 +30,8 @@ public class AwesomeBarTabs extends TabHost {
|
|||
private OnUrlOpenListener mUrlOpenListener;
|
||||
private View.OnTouchListener mListTouchListener;
|
||||
private boolean mSearching = false;
|
||||
private String mTarget;
|
||||
private Background mBackground;
|
||||
private ViewPager mViewPager;
|
||||
private AwesomePagerAdapter mPagerAdapter;
|
||||
|
||||
|
@ -133,6 +134,8 @@ public class AwesomeBarTabs extends TabHost {
|
|||
}
|
||||
};
|
||||
|
||||
mBackground = (Background) findViewById(R.id.awesomebar_background);
|
||||
|
||||
mTabs = new AwesomeBarTab[] {
|
||||
new AllPagesTab(mContext),
|
||||
new BookmarksTab(mContext),
|
||||
|
@ -173,16 +176,27 @@ public class AwesomeBarTabs extends TabHost {
|
|||
private void styleSelectedTab() {
|
||||
int selIndex = mViewPager.getCurrentItem();
|
||||
TabWidget tabWidget = getTabWidget();
|
||||
for (int i = 0; i < tabWidget.getTabCount(); i++) {
|
||||
if (i == selIndex)
|
||||
continue;
|
||||
|
||||
if (i == (selIndex - 1))
|
||||
tabWidget.getChildTabViewAt(i).getBackground().setLevel(1);
|
||||
else if (i == (selIndex + 1))
|
||||
tabWidget.getChildTabViewAt(i).getBackground().setLevel(2);
|
||||
else
|
||||
tabWidget.getChildTabViewAt(i).getBackground().setLevel(0);
|
||||
for (int i = 0; i < tabWidget.getTabCount(); i++) {
|
||||
GeckoTextView view = (GeckoTextView) tabWidget.getChildTabViewAt(i);
|
||||
if (mTarget != null && mTarget.equals(AwesomeBar.Target.CURRENT_TAB.name())) {
|
||||
if (Tabs.getInstance().getSelectedTab().isPrivate()) {
|
||||
if (i == selIndex)
|
||||
view.setPrivateMode(false);
|
||||
else
|
||||
view.setPrivateMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (i == selIndex)
|
||||
continue;
|
||||
|
||||
if (i == (selIndex - 1))
|
||||
view.getBackground().setLevel(1);
|
||||
else if (i == (selIndex + 1))
|
||||
view.getBackground().setLevel(2);
|
||||
else
|
||||
view.getBackground().setLevel(0);
|
||||
}
|
||||
|
||||
if (selIndex == 0)
|
||||
|
@ -198,7 +212,7 @@ public class AwesomeBarTabs extends TabHost {
|
|||
|
||||
|
||||
private View addAwesomeTab(String id, int titleId, final int contentId) {
|
||||
TextView indicatorView = (TextView) mInflater.inflate(R.layout.awesomebar_tab_indicator, null);
|
||||
GeckoTextView indicatorView = (GeckoTextView) mInflater.inflate(R.layout.awesomebar_tab_indicator, null);
|
||||
indicatorView.setText(titleId);
|
||||
|
||||
getTabWidget().addView(indicatorView);
|
||||
|
@ -272,7 +286,16 @@ public class AwesomeBarTabs extends TabHost {
|
|||
return getBookmarksTab().isInReadingList();
|
||||
}
|
||||
|
||||
public static class Background extends LinearLayout
|
||||
public void setTarget(String target) {
|
||||
mTarget = target;
|
||||
styleSelectedTab();
|
||||
if (mTarget.equals(AwesomeBar.Target.CURRENT_TAB.name())) {
|
||||
if (Tabs.getInstance().getSelectedTab().isPrivate())
|
||||
mBackground.setPrivateMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Background extends GeckoLinearLayout
|
||||
implements LightweightTheme.OnChangeListener {
|
||||
private GeckoActivity mActivity;
|
||||
|
||||
|
@ -299,12 +322,16 @@ public class AwesomeBarTabs extends TabHost {
|
|||
if (drawable == null)
|
||||
return;
|
||||
|
||||
StateListDrawable stateList = new StateListDrawable();
|
||||
stateList.addState(new int[] { R.attr.state_private }, mActivity.getResources().getDrawable(R.drawable.address_bar_bg_private));
|
||||
stateList.addState(new int[] {}, drawable);
|
||||
|
||||
int[] padding = new int[] { getPaddingLeft(),
|
||||
getPaddingTop(),
|
||||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundDrawable(drawable);
|
||||
setBackgroundDrawable(stateList);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
|
@ -315,7 +342,7 @@ public class AwesomeBarTabs extends TabHost {
|
|||
getPaddingRight(),
|
||||
getPaddingBottom()
|
||||
};
|
||||
setBackgroundResource(R.drawable.abouthome_bg_repeat);
|
||||
setBackgroundResource(R.drawable.awesomebar_tabs_bg);
|
||||
setPadding(padding[0], padding[1], padding[2], padding[3]);
|
||||
}
|
||||
|
||||
|
|
|
@ -227,6 +227,7 @@ FENNEC_PP_XML_FILES = \
|
|||
res/color/tabs_counter_color.xml \
|
||||
res/drawable/address_bar_bg.xml \
|
||||
res/drawable/address_bar_url.xml \
|
||||
res/drawable/awesomebar_tabs_bg.xml \
|
||||
res/drawable/menu_level.xml \
|
||||
res/drawable/tabs_button.xml \
|
||||
res/drawable/tabs_level.xml \
|
||||
|
@ -485,6 +486,7 @@ RES_ANIM = \
|
|||
|
||||
RES_DRAWABLE_NODPI = \
|
||||
res/drawable-nodpi/abouthome_bg.png \
|
||||
res/drawable-nodpi/abouthome_bg_pb.png \
|
||||
res/drawable-nodpi/tabs_tray_bg.png \
|
||||
res/drawable-nodpi/tabs_tray_bg_pb.png \
|
||||
res/drawable-nodpi/tabs_tray_selected_bg.png \
|
||||
|
@ -1031,6 +1033,7 @@ endif
|
|||
MOZ_ANDROID_DRAWABLES += \
|
||||
$(SYNC_RES_DRAWABLE) \
|
||||
mobile/android/base/resources/drawable/abouthome_bg_repeat.xml \
|
||||
mobile/android/base/resources/drawable/abouthome_bg_pb_repeat.xml \
|
||||
mobile/android/base/resources/drawable/abouthome_divider.xml \
|
||||
mobile/android/base/resources/drawable/abouthome_promo_box.xml \
|
||||
mobile/android/base/resources/drawable/action_bar_button.xml \
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.8 KiB |
|
@ -0,0 +1,8 @@
|
|||
<?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/. -->
|
||||
|
||||
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:src="@drawable/abouthome_bg_pb"
|
||||
android:tileMode="repeat"/>
|
|
@ -0,0 +1,16 @@
|
|||
#filter substitution
|
||||
<?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/. -->
|
||||
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@">
|
||||
|
||||
<!-- private browsing mode -->
|
||||
<item gecko:state_private="true" android:drawable="@drawable/abouthome_bg_pb_repeat"/>
|
||||
|
||||
<!-- normal mode -->
|
||||
<item android:drawable="@drawable/abouthome_bg_repeat"/>
|
||||
|
||||
</selector>
|
|
@ -3,14 +3,14 @@
|
|||
- 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/. -->
|
||||
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/awesomebar_tab_indicator"
|
||||
android:padding="10dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textSize="13sp"
|
||||
android:textColor="#222222"/>
|
||||
<Gecko.TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/awesomebar_tab_indicator"
|
||||
android:padding="10dp"
|
||||
android:singleLine="true"
|
||||
android:ellipsize="marquee"
|
||||
android:textSize="13sp"
|
||||
android:textColor="@color/awesome_bar_title"/>
|
||||
|
|
|
@ -9,10 +9,11 @@
|
|||
android:layout_height="fill_parent">
|
||||
|
||||
<view class="org.mozilla.gecko.AwesomeBarTabs.Background"
|
||||
android:id="@+id/awesomebar_background"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/abouthome_bg_repeat">
|
||||
android:background="@drawable/awesomebar_tabs_bg">
|
||||
|
||||
<LinearLayout android:id="@+id/tab_widget_container"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
Загрузка…
Ссылка в новой задаче