diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2009-02-20 07:38:33 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-02-20 07:38:33 -0800 |
commit | 1a16d15d91a3896065ceeb4972231eb5656a6f6c (patch) | |
tree | ec4708fe84992407a5094fa14bfe71fd355ac5bf | |
parent | 7561d4fd03750ad668c9a8d513753060c19f28ee (diff) | |
download | packages_apps_browser-1a16d15d91a3896065ceeb4972231eb5656a6f6c.zip packages_apps_browser-1a16d15d91a3896065ceeb4972231eb5656a6f6c.tar.gz packages_apps_browser-1a16d15d91a3896065ceeb4972231eb5656a6f6c.tar.bz2 |
auto import from //branches/cupcake/...@132569
-rw-r--r-- | Android.mk | 3 | ||||
-rw-r--r-- | res/layout/add_new_bookmark.xml | 6 | ||||
-rw-r--r-- | src/com/android/browser/GearsDialog.java | 148 | ||||
-rw-r--r-- | src/com/android/browser/GearsDialogService.java | 96 | ||||
-rw-r--r-- | src/com/android/browser/IGearsDialogService.aidl | 6 |
5 files changed, 4 insertions, 255 deletions
@@ -9,8 +9,7 @@ LOCAL_JAVA_LIBRARIES := android.test.runner LOCAL_STATIC_JAVA_LIBRARIES := googlelogin-client -LOCAL_SRC_FILES := $(call all-subdir-java-files) \ - src/com/android/browser/IGearsDialogService.aidl +LOCAL_SRC_FILES := $(call all-subdir-java-files) LOCAL_PACKAGE_NAME := Browser diff --git a/res/layout/add_new_bookmark.xml b/res/layout/add_new_bookmark.xml index 0335574..bb56b93 100644 --- a/res/layout/add_new_bookmark.xml +++ b/res/layout/add_new_bookmark.xml @@ -26,12 +26,12 @@ android:gravity="center_vertical" > <ImageView android:id="@+id/favicon" - android:layout_width="48dip" - android:layout_height="48dip" + android:layout_width="wrap_content" + android:layout_height="wrap_content" android:layout_marginLeft="5dip" android:layout_marginRight="11dip" android:focusable="false" - android:src="@android:drawable/ic_menu_add" + android:src="@*android:drawable/sym_action_add" android:scaleType="fitCenter" /> <LinearLayout diff --git a/src/com/android/browser/GearsDialog.java b/src/com/android/browser/GearsDialog.java deleted file mode 100644 index 62a8aaa..0000000 --- a/src/com/android/browser/GearsDialog.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.browser; - -import android.app.Activity; -import android.content.ComponentName; -import android.content.Context; -import android.content.Intent; -import android.content.res.Configuration; -import android.net.Uri; -import android.os.Bundle; -import android.util.Log; -import android.view.View; -import android.widget.Button; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; - -import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.webkit.WebSettings; - -import android.view.KeyEvent; -import android.view.ViewGroup.LayoutParams; - -import android.widget.LinearLayout; - -public class GearsDialog extends Activity { - - private static final String TAG = "GearsDialog"; - - private WebView webview; - - private String htmlContent; - private String dialogArguments; - - private boolean dismissed = false; - - @Override - public void onCreate(Bundle icicle) { - super.onCreate(icicle); - webview = new WebView(this); - webview.getSettings().setJavaScriptEnabled(true); - webview.addJavascriptInterface(this, "bridge"); - - setContentView(webview); - setTitle("Gears"); - } - - @Override - public void onStart() { - super.onStart(); - loadHTML(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - // In case we reach this point without - // notifying GearsDialogService, we do it now. - if (!dismissed) { - notifyEndOfDialog(); - } - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - Intent i = getIntent(); - boolean inSettings = i.getBooleanExtra("inSettings", false); - // If we are called from the settings, we - // dismiss ourselve upon rotation - if (inSettings) { - notifyEndOfDialog(); - finish(); - } - } - - /** - * Load the HTML content in the WebView - */ - private void loadHTML() { - Intent i = getIntent(); - htmlContent = i.getStringExtra("htmlContent"); - dialogArguments = i.getStringExtra("dialogArguments"); - webview.loadDataWithBaseURL("", htmlContent, "text/html", "", ""); - } - - /** - * Signal to GearsDialogService that we are done. - */ - private void notifyEndOfDialog() { - GearsDialogService.signalFinishedDialog(); - dismissed = true; - } - - /** - * Intercepts the back key to immediately notify - * GearsDialogService that we are done. - */ - public boolean dispatchKeyEvent(KeyEvent event) { - if (event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.isDown()) { - notifyEndOfDialog(); - } - return super.dispatchKeyEvent(event); - } - - /** - * Returns a json-formatted string containing the information - * about the site. - * This method is accessible through the javascript bridge. - */ - public String getDialogArguments() { - return dialogArguments; - } - - /** - * Set the results string and closes the dialog. - * This method is accessible through the javascript bridge. - */ - public void closeDialog(String results) { - GearsDialogService.closeDialog(results); - notifyEndOfDialog(); - finish(); - } - - /** - * Debug method outputting a message. - * This method is accessible through the javascript bridge. - */ - public void log(String msg) { - Log.v(TAG, msg); - } -} diff --git a/src/com/android/browser/GearsDialogService.java b/src/com/android/browser/GearsDialogService.java deleted file mode 100644 index b92ff47..0000000 --- a/src/com/android/browser/GearsDialogService.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.browser; - -import android.app.Service; -import android.util.Log; -import android.content.Intent; -import android.os.IBinder; - -import android.content.Intent; -import android.content.ContentValues; -import android.content.ActivityNotFoundException; - -import java.util.concurrent.locks.Condition; -import java.util.concurrent.locks.Lock; -import java.util.concurrent.locks.ReentrantLock; - -import java.lang.InterruptedException; - -public class GearsDialogService extends Service { - private static final String TAG = "GearsDialogService"; - private final String DIALOG_PACKAGE = "com.android.browser"; - private final String DIALOG_CLASS = DIALOG_PACKAGE + ".GearsDialog"; - - public static Lock lock = new ReentrantLock(); - public static Condition dialogFinished = lock.newCondition(); - public static String results = null; - - @Override - public IBinder onBind(Intent intent) { - if (IGearsDialogService.class.getName().equals(intent.getAction())) { - return mBinder; - } - return null; - } - - private final IGearsDialogService.Stub mBinder = new IGearsDialogService.Stub() { - public String showDialog(String htmlContent, String dialogArguments, - boolean inSettings) { - return GearsDialogService.this.showDialog(htmlContent, dialogArguments, - inSettings); - } - }; - - public static void closeDialog(String res) { - results = res; - } - - public static void signalFinishedDialog() { - lock.lock(); - dialogFinished.signal(); - lock.unlock(); - } - - /** - * Show a 'true' modal dialog displaying html content, necessary - * for Gears. The method starts the GearsDialog activity, passing - * the necessary parameters to it, and then wait until the activity - * is finished. When the dialog closes, it sets the variable results. - */ - public String showDialog(String htmlContent, String dialogArguments, - boolean inSettings) { - try { - Intent intent = new Intent(); - intent.setClassName(DIALOG_PACKAGE, DIALOG_CLASS); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - intent.putExtra("htmlContent", htmlContent); - intent.putExtra("dialogArguments", dialogArguments); - intent.putExtra("inSettings", inSettings); - lock.lock(); - startActivity(intent); - dialogFinished.await(); - } catch (InterruptedException e) { - Log.e(TAG, "exception e: " + e); - } catch (ActivityNotFoundException e) { - Log.e(TAG, "exception e: " + e); - } finally { - lock.unlock(); - } - return results; - } -} diff --git a/src/com/android/browser/IGearsDialogService.aidl b/src/com/android/browser/IGearsDialogService.aidl deleted file mode 100644 index 02b30a2..0000000 --- a/src/com/android/browser/IGearsDialogService.aidl +++ /dev/null @@ -1,6 +0,0 @@ -package com.android.browser; - -interface IGearsDialogService { - String showDialog(String htmlContent, String dialogArguments, - boolean inSettings); -} |