import com.google.android.googleapps.IGoogleLoginService;
import com.google.android.googlelogin.GoogleLoginServiceConstants;
-import com.google.android.providers.GoogleSettings.Partner;
import android.app.Activity;
import android.app.ActivityManager;
import android.graphics.drawable.PaintDrawable;
import android.hardware.SensorListener;
import android.hardware.SensorManager;
-import android.location.Location;
-import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.net.WebAddress;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
-import android.os.SystemProperties;
-import android.preference.PreferenceManager;
import android.provider.Browser;
import android.provider.Contacts;
import android.provider.Downloads;
import android.provider.MediaStore;
-import android.provider.Settings;
import android.provider.Contacts.Intents.Insert;
import android.text.IClipboard;
import android.text.TextUtils;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedList;
-import java.util.Locale;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
mResolver = getContentResolver();
- setBaseSearchUrl(PreferenceManager.getDefaultSharedPreferences(this)
- .getString("search_url", ""));
-
//
// start MASF proxy service
//
String query = inUrl.substring(2);
switch (shortcut) {
case SHORTCUT_GOOGLE_SEARCH:
- return composeSearchUrl(query);
+ return URLUtil.composeSearchUrl(query, QuickSearch_G, QUERY_PLACE_HOLDER);
case SHORTCUT_WIKIPEDIA_SEARCH:
return URLUtil.composeSearchUrl(query, QuickSearch_W, QUERY_PLACE_HOLDER);
case SHORTCUT_DICTIONARY_SEARCH:
}
Browser.addSearchUrl(mResolver, inUrl);
- return composeSearchUrl(inUrl);
- }
-
- /* package */ String composeSearchUrl(String search) {
- return URLUtil.composeSearchUrl(search, QuickSearch_G,
- QUERY_PLACE_HOLDER);
- }
-
- /* package */void setBaseSearchUrl(String url) {
- if (url == null || url.length() == 0) {
- /*
- * get the google search url based on the SIM. Default is US. NOTE:
- * This code uses resources to optionally select the search Uri,
- * based on the MCC value from the SIM. The default string will most
- * likely be fine. It is parameterized to accept info from the
- * Locale, the language code is the first parameter (%1$s) and the
- * country code is the second (%2$s). This code must function in the
- * same way as a similar lookup in
- * com.android.googlesearch.SuggestionProvider#onCreate(). If you
- * change either of these functions, change them both. (The same is
- * true for the underlying resource strings, which are stored in
- * mcc-specific xml files.)
- */
- Locale l = Locale.getDefault();
- String language = l.getLanguage();
- String country = l.getCountry().toLowerCase();
- // Chinese and Portuguese have two langauge variants.
- if ("zh".equals(language)) {
- if ("cn".equals(country)) {
- language = "zh-CN";
- } else if ("tw".equals(country)) {
- language = "zh-TW";
- }
- } else if ("pt".equals(language)) {
- if ("br".equals(country)) {
- language = "pt-BR";
- } else if ("pt".equals(country)) {
- language = "pt-PT";
- }
- }
- QuickSearch_G = getResources().getString(
- R.string.google_search_base,
- language,
- country)
- + "client=ms-"
- + Partner.getString(this.getContentResolver(), Partner.CLIENT_ID)
- + "&source=android-" + GOOGLE_SEARCH_SOURCE_SUGGEST + "&q=%s";
- } else {
- QuickSearch_G = url;
- }
+ return URLUtil.composeSearchUrl(inUrl, QuickSearch_G, QUERY_PLACE_HOLDER);
}
private final static int LOCK_ICON_UNSECURE = 0;
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.FILL_PARENT);
- // We may provide UI to customize these
- // Google search from the browser
- static String QuickSearch_G;
+ // Google search
+ final static String QuickSearch_G = "http://www.google.com/m?q=%s";
// Wikipedia search
final static String QuickSearch_W = "http://en.wikipedia.org/w/index.php?search=%s&go=Go";
// Dictionary search
+++ /dev/null
-/*
- * 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.AlertDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.preference.EditTextPreference;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.text.util.Regex;
-import android.util.AttributeSet;
-
-public class BrowserSearchpagePreference extends EditTextPreference implements
- TextWatcher {
-
- public BrowserSearchpagePreference(Context context, AttributeSet attrs,
- int defStyle) {
- super(context, attrs, defStyle);
- getEditText().addTextChangedListener(this);
- }
-
- public BrowserSearchpagePreference(Context context, AttributeSet attrs) {
- super(context, attrs);
- getEditText().addTextChangedListener(this);
- }
-
- public BrowserSearchpagePreference(Context context) {
- super(context);
- getEditText().addTextChangedListener(this);
- }
-
- public void afterTextChanged(Editable s) {
- AlertDialog dialog = (AlertDialog) getDialog();
- // This callback is called before the dialog has been fully constructed
- if (dialog != null) {
- String string = s.toString();
- int length = string.length();
- int first = length > 0 ? string
- .indexOf(BrowserActivity.QUERY_PLACE_HOLDER) : -1;
- int last = length > 0 ? string
- .lastIndexOf(BrowserActivity.QUERY_PLACE_HOLDER) : -1;
- dialog.getButton(DialogInterface.BUTTON_POSITIVE).setEnabled(
- length == 0 || (first > 0 && first == last));
- }
- }
-
- public void beforeTextChanged(CharSequence s, int start, int count,
- int after) {
- }
-
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-}
import com.google.android.providers.GoogleSettings.Partner;
-import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
-import android.content.pm.ActivityInfo;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
-import android.os.SystemProperties;
-import android.view.WindowManager;
-import android.webkit.CacheManager;
import android.webkit.CookieManager;
import android.webkit.WebView;
import android.webkit.WebViewDatabase;
navDump = p.getBoolean("enable_nav_dump", navDump);
doFlick = p.getBoolean("enable_flick", doFlick);
userAgent = Integer.parseInt(p.getString("user_agent", "0"));
- mTabControl.getBrowserActivity().setBaseSearchUrl(
- p.getString("search_url", ""));
}
update();
}