Bug 806937: Private tabs support for awesomescreen. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Fri, 16 Nov 2012 00:41:53 -0800
changeset 123635 ff583cde143c31c44d4fd14fe926b201660d1b02
parent 123634 dd259d461971a8e209979332fa70cb4bf5f6de36
child 123636 90213ba4193721782c55b9180d2869268fc68490
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs806937
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 806937: Private tabs support for awesomescreen. [r=mfinkle]
mobile/android/base/AwesomeBar.java
mobile/android/base/CustomEditText.java
mobile/android/base/GeckoViewsFactory.java
mobile/android/base/Makefile.in
mobile/android/base/resources/layout-large-v11/awesomebar_search.xml.in
mobile/android/base/resources/layout-xlarge-v11/awesomebar_search.xml.in
mobile/android/base/resources/layout/awesomebar_search.xml.in
mobile/android/base/resources/values/colors.xml
--- a/mobile/android/base/AwesomeBar.java
+++ b/mobile/android/base/AwesomeBar.java
@@ -114,22 +114,36 @@ public class AwesomeBar extends GeckoAct
         mGoButton.setOnClickListener(new Button.OnClickListener() {
             public void onClick(View v) {
                 openUserEnteredAndFinish(mText.getText().toString());
             }
         });
 
         Intent intent = getIntent();
         String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
-        mTarget = intent.getStringExtra(TARGET_KEY);
         if (currentUrl != null) {
             mText.setText(currentUrl);
             mText.selectAll();
         }
 
+        mTarget = intent.getStringExtra(TARGET_KEY);
+        if (mTarget.equals(Target.CURRENT_TAB.name())) {
+            Tab tab = Tabs.getInstance().getSelectedTab();
+            if (tab != null && tab.isPrivate()) {
+                BrowserToolbarBackground mAddressBarBg = (BrowserToolbarBackground) findViewById(R.id.address_bar_bg);
+                mAddressBarBg.setPrivateMode(true);
+
+                TabsButton mTabs = (TabsButton) findViewById(R.id.dummy_tab);
+                if (mTabs != null)
+                    mTabs.setPrivateMode(true);
+
+                mText.setPrivateMode(true);
+            }
+        }
+
         mText.setOnKeyPreImeListener(new CustomEditText.OnKeyPreImeListener() {
             public boolean onKeyPreIme(View v, int keyCode, KeyEvent event) {
                 // We only want to process one event per tap
                 if (event.getAction() != KeyEvent.ACTION_DOWN)
                     return false;
 
                 if (keyCode == KeyEvent.KEYCODE_ENTER) {
                     // If the AwesomeBar has a composition string, don't submit the text yet.
--- a/mobile/android/base/CustomEditText.java
+++ b/mobile/android/base/CustomEditText.java
@@ -4,19 +4,18 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import android.content.Context;
 import android.util.AttributeSet;
 import android.view.KeyEvent;
 import android.view.View;
-import android.widget.EditText;
 
-public class CustomEditText extends EditText {
+public class CustomEditText extends GeckoEditText {
     OnKeyPreImeListener mOnKeyPreImeListener;
     OnSelectionChangedListener mOnSelectionChangedListener;
     OnWindowFocusChangeListener mOnWindowFocusChangeListener;
 
     public CustomEditText(Context context, AttributeSet attrs) {
         super(context, attrs);
         mOnKeyPreImeListener = null;
     }
@@ -62,9 +61,18 @@ public class CustomEditText extends Edit
     }
 
     @Override
     public void onWindowFocusChanged(boolean hasFocus) {
         super.onWindowFocusChanged(hasFocus);
         if (mOnWindowFocusChangeListener != null)
             mOnWindowFocusChangeListener.onWindowFocusChanged(hasFocus);
     }
+
+    @Override
+    public void setPrivateMode(boolean isPrivate) {
+        super.setPrivateMode(isPrivate);
+
+        // android:textColorHighlight cannot support a ColorStateList.
+        int colorId = isPrivate ? R.color.url_bar_text_highlight_pb : R.color.url_bar_text_highlight;
+        setHighlightColor(getContext().getResources().getColor(colorId));
+    }
 }
--- a/mobile/android/base/GeckoViewsFactory.java
+++ b/mobile/android/base/GeckoViewsFactory.java
@@ -81,16 +81,18 @@ public final class GeckoViewsFactory imp
             else if (TextUtils.equals(viewName, "TabsPanelButton"))
                 return new TabsPanelButton(context, attrs);
             else if (TextUtils.equals(viewName, "TextSelectionHandle"))
                 return new TextSelectionHandle(context, attrs);
             else if (TextUtils.equals(viewName, "gfx.LayerView"))
                 return new LayerView(context, attrs);
             else if (TextUtils.equals(viewName, "Button"))
                 return new GeckoButton(context, attrs);
+            else if (TextUtils.equals(viewName, "EditText"))
+                return new GeckoEditText(context, attrs);
             else if (TextUtils.equals(viewName, "FrameLayout"))
                 return new GeckoFrameLayout(context, attrs);
             else if (TextUtils.equals(viewName, "ImageButton"))
                 return new GeckoImageButton(context, attrs);
             else if (TextUtils.equals(viewName, "ImageView"))
                 return new GeckoImageView(context, attrs);
             else if (TextUtils.equals(viewName, "LinearLayout"))
                 return new GeckoLinearLayout(context, attrs);
--- a/mobile/android/base/Makefile.in
+++ b/mobile/android/base/Makefile.in
@@ -188,16 +188,17 @@ FENNEC_JAVA_FILES = \
 ifdef MOZ_WEBSMS_BACKEND
 FENNEC_JAVA_FILES += GeckoSmsManager.java
 endif
 
 FENNEC_PP_JAVA_VIEW_FILES = \
   GeckoButton.java \
   GeckoImageButton.java \
   GeckoImageView.java \
+  GeckoEditText.java \
   GeckoFrameLayout.java \
   GeckoLinearLayout.java \
   GeckoRelativeLayout.java \
   GeckoTextSwitcher.java \
   GeckoTextView.java \
   $(NULL)
 
 FENNEC_PP_JAVA_FILES = \
--- a/mobile/android/base/resources/layout-large-v11/awesomebar_search.xml.in
+++ b/mobile/android/base/resources/layout-large-v11/awesomebar_search.xml.in
@@ -3,33 +3,36 @@
 <!-- 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/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
                 style="@style/AwesomeBar">
 
-    <org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
+    <org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
+                                                android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"
                                                 android:layout_alignParentTop="true"
                                                 android:layout_alignParentRight="true"
                                                 gecko:curveTowards="none"
                                                 android:background="@drawable/address_bar_bg"/>
 
     <view class="org.mozilla.gecko.CustomEditText"
           android:id="@+id/awesomebar_text"
           style="@style/AddressBar.Button"
           android:background="@drawable/address_bar_url"
           android:layout_margin="6dip"
           android:layout_alignParentBottom="true"
           android:layout_centerVertical="true"
           android:paddingLeft="15dip"
           android:paddingRight="40dip"
           android:hint="@string/awesomebar_default_text"
+          android:textColor="@color/awesome_bar_title"
+          android:textColorHint="@color/awesome_bar_title_hint"
           android:textColorHighlight="@color/url_bar_text_highlight"
           android:inputType="textUri|textNoSuggestions"
           android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen"
           android:selectAllOnFocus="true"
           android:singleLine="true"
           android:gravity="center_vertical|left">
               <requestFocus/>
     </view>
--- a/mobile/android/base/resources/layout-xlarge-v11/awesomebar_search.xml.in
+++ b/mobile/android/base/resources/layout-xlarge-v11/awesomebar_search.xml.in
@@ -3,17 +3,18 @@
 <!-- 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/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
                 style="@style/AwesomeBar">
 
-    <org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
+    <org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
+                                                android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"
                                                 android:layout_alignParentTop="true"
                                                 android:layout_alignParentRight="true"
                                                 gecko:curveTowards="none"
                                                 android:background="@drawable/address_bar_bg"/>
 
     <org.mozilla.gecko.TabsButton android:id="@+id/dummy_tab"
                                   style="@style/AddressBar.ImageButton"
@@ -33,16 +34,18 @@
           android:layout_marginTop="6dip"
           android:layout_marginBottom="6dip"
           android:layout_toRightOf="@id/dummy_tab"
           android:layout_alignParentBottom="true"
           android:layout_centerVertical="true"
           android:paddingLeft="15dip"
           android:paddingRight="40dip"
           android:hint="@string/awesomebar_default_text"
+          android:textColor="@color/awesome_bar_title"
+          android:textColorHint="@color/awesome_bar_title_hint"
           android:textColorHighlight="@color/url_bar_text_highlight"
           android:inputType="textUri|textNoSuggestions"
           android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen"
           android:selectAllOnFocus="true"
           android:singleLine="true"
           android:gravity="center_vertical|left">
               <requestFocus/>
     </view>
--- a/mobile/android/base/resources/layout/awesomebar_search.xml.in
+++ b/mobile/android/base/resources/layout/awesomebar_search.xml.in
@@ -3,33 +3,36 @@
 <!-- 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/. -->
 
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                 xmlns:gecko="http://schemas.android.com/apk/res/@ANDROID_PACKAGE_NAME@"
                 style="@style/AwesomeBar">
 
-    <org.mozilla.gecko.BrowserToolbarBackground android:layout_width="fill_parent"
+    <org.mozilla.gecko.BrowserToolbarBackground android:id="@+id/address_bar_bg"
+                                                android:layout_width="fill_parent"
                                                 android:layout_height="fill_parent"
                                                 android:layout_alignParentTop="true"
                                                 android:layout_alignParentRight="true"
                                                 gecko:curveTowards="none"
                                                 android:background="@drawable/address_bar_bg"/>
 
     <view class="org.mozilla.gecko.CustomEditText"
           android:id="@+id/awesomebar_text"
           style="@style/AddressBar.Button"
           android:background="@drawable/address_bar_url"
           android:layout_margin="4dip"
           android:layout_alignParentBottom="true"
           android:layout_centerVertical="true"
           android:paddingLeft="15dip"
           android:paddingRight="40dip"
           android:hint="@string/awesomebar_default_text"
+          android:textColor="@color/awesome_bar_title"
+          android:textColorHint="@color/awesome_bar_title_hint"
           android:textColorHighlight="@color/url_bar_text_highlight"
           android:inputType="textUri|textNoSuggestions"
           android:imeOptions="actionSearch|flagNoExtractUi|flagNoFullscreen"
           android:selectAllOnFocus="true"
           android:singleLine="true"
           android:gravity="center_vertical|left">
               <requestFocus/>
     </view>
--- a/mobile/android/base/resources/values/colors.xml
+++ b/mobile/android/base/resources/values/colors.xml
@@ -7,14 +7,15 @@
   <color name="splash_background">#000000</color>
   <color name="splash_msgfont">#ffffff</color>
   <color name="splash_urlfont">#000000</color>
   <color name="splash_content">#ffffff</color>
   <color name="doorhanger_link">#ACC4D5</color>
   <color name="validation_message_text">#ffffff</color>
   <color name="identity_verified">#77BAFF</color>
   <color name="identity_identified">#B7D46A</color>
-  <color name="url_bar_text_highlight">#FF9500</color>
+  <color name="url_bar_text_highlight">#FFFF9500</color>
+  <color name="url_bar_text_highlight_pb">#FFD06BFF</color>
   <color name="suggestion_primary">#dddddd</color>
   <color name="suggestion_pressed">#bbbbbb</color>
   <color name="abouthome_topsite_shadow">#1000</color>
 </resources>