Bug 1398409 - 3. Add FormAssistPopup to custom tabs; r=snorp draft
authorJim Chen <nchen@mozilla.com>
Fri, 15 Sep 2017 14:44:50 -0400
changeset 665605 cc7cb725f8b5eb1ab4f53bf285b6f1863f2f4d49
parent 665604 c68b6e5b8711ba021067a6bd7cbeac0d10e2f556
child 665606 cd2303f3eec796a43f3e23ee4f6d0f1a36a45639
push id80117
push userbmo:nchen@mozilla.com
push dateFri, 15 Sep 2017 18:48:05 +0000
reviewerssnorp
bugs1398409
milestone57.0a1
Bug 1398409 - 3. Add FormAssistPopup to custom tabs; r=snorp Add and use FormAssistPopup in custom tabs to show autocomplete lists and form validation messages. MozReview-Commit-ID: AvK70MLQNVN
mobile/android/app/src/main/res/layout/customtabs_activity.xml
mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
--- a/mobile/android/app/src/main/res/layout/customtabs_activity.xml
+++ b/mobile/android/app/src/main/res/layout/customtabs_activity.xml
@@ -22,16 +22,21 @@
 
     <org.mozilla.gecko.GeckoView
         android:id="@+id/gecko_view"
         android:layout_width="fill_parent"
         android:layout_below="@id/actionbar"
         android:layout_height="match_parent"
         android:scrollbars="none"/>
 
+    <org.mozilla.gecko.FormAssistPopup android:id="@+id/form_assist_popup"
+                                       android:layout_width="match_parent"
+                                       android:layout_height="match_parent"
+                                       android:visibility="gone"/>
+
     <org.mozilla.gecko.widget.AnimatedProgressBar
         android:id="@id/page_progress"
         style="@style/Base.Widget.AppCompat.ProgressBar.Horizontal"
         android:layout_width="match_parent"
         android:layout_height="2dp"
         android:layout_alignTop="@id/gecko_view"
         android:background="@drawable/url_bar_bg"
         android:progressDrawable="@drawable/progressbar"
--- a/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/customtabs/CustomTabsActivity.java
@@ -31,16 +31,17 @@ import android.view.MenuItem;
 import android.view.View;
 import android.widget.ListView;
 import android.widget.ProgressBar;
 
 import org.mozilla.gecko.ActivityHandlerHelper;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.DoorHangerPopup;
 import org.mozilla.gecko.EventDispatcher;
+import org.mozilla.gecko.FormAssistPopup;
 import org.mozilla.gecko.GeckoView;
 import org.mozilla.gecko.GeckoViewSettings;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Telemetry;
 import org.mozilla.gecko.TelemetryContract;
 import org.mozilla.gecko.menu.GeckoMenu;
 import org.mozilla.gecko.menu.GeckoMenuInflater;
@@ -76,16 +77,17 @@ public class CustomTabsActivity extends 
     // A state to indicate whether this activity is finishing with customize animation
     private boolean usingCustomAnimation = false;
 
     private MenuItem menuItemControl;
 
     private GeckoView mGeckoView;
     private PromptService mPromptService;
     private DoorHangerPopup mDoorHangerPopup;
+    private FormAssistPopup mFormAssistPopup;
 
     private boolean mCanGoBack = false;
     private boolean mCanGoForward = false;
     private boolean mCanStop = false;
     private String mCurrentUrl;
     private String mCurrentTitle;
     private SecurityInformation mSecurityInformation = null;
 
@@ -115,29 +117,33 @@ public class CustomTabsActivity extends 
 
         mGeckoView.setNavigationListener(this);
         mGeckoView.setProgressListener(this);
         mGeckoView.setContentListener(this);
 
         mPromptService = new PromptService(this, mGeckoView.getEventDispatcher());
         mDoorHangerPopup = new DoorHangerPopup(this, mGeckoView.getEventDispatcher());
 
+        mFormAssistPopup = (FormAssistPopup) findViewById(R.id.form_assist_popup);
+        mFormAssistPopup.create(mGeckoView);
+
         final GeckoViewSettings settings = mGeckoView.getSettings();
         settings.setBoolean(GeckoViewSettings.USE_MULTIPROCESS, false);
 
         if (intent != null && !TextUtils.isEmpty(intent.getDataString())) {
             mGeckoView.loadUri(intent.getDataString());
         } else {
             Log.w(LOGTAG, "No intend found for custom tab");
             finish();
         }
     }
 
     @Override
     public void onDestroy() {
+        mFormAssistPopup.destroy();
         mDoorHangerPopup.destroy();
         mPromptService.destroy();
 
         super.onDestroy();
     }
 
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {