This is the layout for the Geolocation permissions prompt.
-->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<com.android.browser.GeolocationPermissionsPrompt
+ xmlns:android="http://schemas.android.com/apk/res/android"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</LinearLayout>
</LinearLayout>
-</LinearLayout>
+</com.android.browser.GeolocationPermissionsPrompt>
android:layout_weight="1" />
<!-- Geolocation permissions prompt -->
- <com.android.browser.GeolocationPermissionsPrompt
- android:id="@+id/geolocation_permissions_prompt"
+ <ViewStub android:id="@+id/geolocation_permissions_prompt"
+ android:layout="@layout/geolocation_permissions_prompt"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
public GeolocationPermissionsPrompt(Context context, AttributeSet attrs) {
super(context, attrs);
- LayoutInflater factory = LayoutInflater.from(context);
- factory.inflate(R.layout.geolocation_permissions_prompt, this);
+ }
+ void init() {
mInner = (LinearLayout) findViewById(R.id.inner);
mMessage = (TextView) findViewById(R.id.message);
mShareButton = (Button) findViewById(R.id.share_button);
mDontShareButton = (Button) findViewById(R.id.dont_share_button);
mRemember = (CheckBox) findViewById(R.id.remember);
- setButtonClickListeners();
+
+ final GeolocationPermissionsPrompt me = this;
+ mShareButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ me.handleButtonClick(true);
+ }
+ });
+ mDontShareButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ me.handleButtonClick(false);
+ }
+ });
}
/**
}
/**
- * Sets the on click listeners for the buttons.
- */
- private void setButtonClickListeners() {
- final GeolocationPermissionsPrompt me = this;
- mShareButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- me.handleButtonClick(true);
- }
- });
- mDontShareButton.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- me.handleButtonClick(false);
- }
- });
- }
-
- /**
* Handles a click on one the buttons by invoking the callback.
*/
private void handleButtonClick(boolean allow) {
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewStub;
import android.view.View.OnClickListener;
import android.webkit.ConsoleMessage;
import android.webkit.CookieSyncManager;
public void onGeolocationPermissionsShowPrompt(String origin,
GeolocationPermissions.Callback callback) {
if (mInForeground) {
- mGeolocationPermissionsPrompt.show(origin, callback);
+ getGeolocationPermissionsPrompt().show(origin, callback);
}
}
*/
@Override
public void onGeolocationPermissionsHidePrompt() {
- if (mInForeground) {
+ if (mInForeground && mGeolocationPermissionsPrompt != null) {
mGeolocationPermissionsPrompt.hide();
}
}
// WebView, as well as any other UI elements associated with the tab.
mContainer = mInflateService.inflate(R.layout.tab, null);
- mGeolocationPermissionsPrompt =
- (GeolocationPermissionsPrompt) mContainer.findViewById(
- R.id.geolocation_permissions_prompt);
-
mDownloadListener = new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
}
// If the WebView is changing, the page will be reloaded, so any ongoing
// Geolocation permission requests are void.
- mGeolocationPermissionsPrompt.hide();
+ if (mGeolocationPermissionsPrompt != null) {
+ mGeolocationPermissionsPrompt.hide();
+ }
// Just remove the old one.
FrameLayout wrapper =
* @return The geolocation permissions prompt for this tab.
*/
GeolocationPermissionsPrompt getGeolocationPermissionsPrompt() {
+ if (mGeolocationPermissionsPrompt == null) {
+ ViewStub stub = (ViewStub) mContainer
+ .findViewById(R.id.geolocation_permissions_prompt);
+ mGeolocationPermissionsPrompt = (GeolocationPermissionsPrompt) stub
+ .inflate();
+ mGeolocationPermissionsPrompt.init();
+ }
return mGeolocationPermissionsPrompt;
}