Bug 806937: Private tabs support for awesomescreen. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Fri, 16 Nov 2012 00:41:53 -0800
changeset 114395 585a7f8fc448a9c54097956ebb85585d902af363
parent 114394 984a10bc4125972a06cc58e5e44fe77867be9051
child 114396 abfc930bc7cd5d76974f6b9c2b45b9e372094577
push id23917
push useremorley@mozilla.com
push dateThu, 29 Nov 2012 14:20:29 +0000
treeherdermozilla-central@c72d38e7a212 [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,35 @@ 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())) {
+            if (Tabs.getInstance().getSelectedTab().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>