Bug 698220: The tabs should be restored when awesomebar is rotated. [r=mfinkle]
authorSriram Ramasubramanian <sriram@mozilla.com>
Mon, 31 Oct 2011 13:07:23 -0700
changeset 83426 9bffa9a8cfe450986a53f6c5a45fe29ebfcd54ca
parent 83425 d34b5885abe8f7619b48cbca46e73c1d2e6ed362
child 83427 24cbdc53a4ee9b185f084265b63eda983046f06c
push id519
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 00:38:35 +0000
treeherdermozilla-beta@788ea1ef610b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs698220
milestone10.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 698220: The tabs should be restored when awesomebar is rotated. [r=mfinkle]
embedding/android/AndroidManifest.xml.in
embedding/android/AwesomeBar.java
--- a/embedding/android/AndroidManifest.xml.in
+++ b/embedding/android/AndroidManifest.xml.in
@@ -124,16 +124,17 @@
             <intent-filter>
                 <action android:name="android.intent.action.CREATE_SHORTCUT" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>
         </activity>
 
         <activity android:name="org.mozilla.gecko.AwesomeBar"
                   android:theme="@android:style/Theme.Translucent"
+                  android:configChanges="orientation"
                   android:windowSoftInputMode="stateAlwaysVisible|adjustResize"
                   android:windowIsTranslucent="true"
                   android:windowContentOverlay="@null"
                   android:windowNoTitle="true"
                   android:windowIsFloating="true"
                   android:backgroundDimEnabled="false">
         </activity>
 
--- a/embedding/android/AwesomeBar.java
+++ b/embedding/android/AwesomeBar.java
@@ -39,16 +39,17 @@
 
 package org.mozilla.gecko;
 
 import java.io.File;
 
 import android.app.Activity;
 import android.content.Intent;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.text.Editable;
 import android.text.TextWatcher;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.View;
 import android.view.Window;
 import android.view.inputmethod.InputMethodManager;
@@ -60,16 +61,17 @@ public class AwesomeBar extends Activity
     static final String CURRENT_URL_KEY = "currenturl";
     static final String TYPE_KEY = "type";
     static enum Type { ADD, EDIT };
 
     private static final String LOG_NAME = "AwesomeBar";
 
     private String mType;
     private AwesomeBarTabs mAwesomeTabs;
+    private EditText mText;
 
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
 
         Log.d(LOG_NAME, "creating awesomebar");
 
         requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -77,66 +79,71 @@ public class AwesomeBar extends Activity
 
         mAwesomeTabs = (AwesomeBarTabs) findViewById(R.id.awesomebar_tabs);
         mAwesomeTabs.setOnUrlOpenListener(new AwesomeBarTabs.OnUrlOpenListener() {
             public void onUrlOpen(AwesomeBarTabs tabs, String url) {
                 openUrlAndFinish(url);
             }
         });
 
-        final EditText text = (EditText)findViewById(R.id.awesomebar_text);
+        mText = (EditText)findViewById(R.id.awesomebar_text);
 
         Intent intent = getIntent();
         String currentUrl = intent.getStringExtra(CURRENT_URL_KEY);
         mType = intent.getStringExtra(TYPE_KEY);
         if (currentUrl != null) {
-            text.setText(currentUrl);
-            text.selectAll();
+            mText.setText(currentUrl);
+            mText.selectAll();
         }
 
-        text.addTextChangedListener(new TextWatcher() {
+        mText.addTextChangedListener(new TextWatcher() {
             public void afterTextChanged(Editable s) {
                 // do nothing
             }
 
             public void beforeTextChanged(CharSequence s, int start, int count,
                                           int after) {
                 // do nothing
             }
 
             public void onTextChanged(CharSequence s, int start, int before,
                                       int count) {
                 mAwesomeTabs.filter(s.toString());
             }
         });
 
-        text.setOnKeyListener(new View.OnKeyListener() {
+        mText.setOnKeyListener(new View.OnKeyListener() {
             public boolean onKey(View v, int keyCode, KeyEvent event) {
                 if (keyCode == KeyEvent.KEYCODE_ENTER) {
                     if (event.getAction() != KeyEvent.ACTION_DOWN)
                         return true;
 
-                    openUrlAndFinish(text.getText().toString());
+                    openUrlAndFinish(mText.getText().toString());
                     return true;
                 } else {
                     return false;
                 }
             }
         });
 
-        text.setOnFocusChangeListener(new View.OnFocusChangeListener() {
+        mText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
             public void onFocusChange(View v, boolean hasFocus) {
                 if (!hasFocus) {
                     InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
                     imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
                 }
             }
         });
     }
 
+    @Override
+    public void onConfigurationChanged(Configuration newConfiguration) {
+        super.onConfigurationChanged(newConfiguration);
+    }
+
     private void openUrlAndFinish(String url) {
         Intent resultIntent = new Intent();
         resultIntent.putExtra(URL_KEY, url);
         resultIntent.putExtra(TYPE_KEY, mType);
 
         setResult(Activity.RESULT_OK, resultIntent);
         finish();
     }