diff options
Diffstat (limited to 'src')
25 files changed, 34 insertions, 1609 deletions
diff --git a/src/com/android/browser/AutoFillProfileDatabase.java b/src/com/android/browser/AutoFillProfileDatabase.java index 9666926..3bd9dac 100644 --- a/src/com/android/browser/AutoFillProfileDatabase.java +++ b/src/com/android/browser/AutoFillProfileDatabase.java @@ -22,7 +22,6 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.provider.BaseColumns; import android.util.Log; -import android.webkit.WebSettingsClassic.AutoFillProfile; public class AutoFillProfileDatabase { @@ -95,34 +94,6 @@ public class AutoFillProfileDatabase { return writable ? mOpenHelper.getWritableDatabase() : mOpenHelper.getReadableDatabase(); } - public void addOrUpdateProfile(final int id, AutoFillProfile profile) { - final String sql = "INSERT OR REPLACE INTO " + PROFILES_TABLE_NAME + " (" - + Profiles._ID + "," - + Profiles.FULL_NAME + "," - + Profiles.EMAIL_ADDRESS + "," - + Profiles.COMPANY_NAME + "," - + Profiles.ADDRESS_LINE_1 + "," - + Profiles.ADDRESS_LINE_2 + "," - + Profiles.CITY + "," - + Profiles.STATE + "," - + Profiles.ZIP_CODE + "," - + Profiles.COUNTRY + "," - + Profiles.PHONE_NUMBER - + ") VALUES (?,?,?,?,?,?,?,?,?,?,?);"; - final Object[] params = { id, - profile.getFullName(), - profile.getEmailAddress(), - profile.getCompanyName(), - profile.getAddressLine1(), - profile.getAddressLine2(), - profile.getCity(), - profile.getState(), - profile.getZipCode(), - profile.getCountry(), - profile.getPhoneNumber() }; - getDatabase(true).execSQL(sql, params); - } - public Cursor getProfile(int id) { final String[] cols = { Profiles.FULL_NAME, diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java deleted file mode 100644 index 68b325e..0000000 --- a/src/com/android/browser/AutoFillSettingsFragment.java +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (C) 2010 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.Fragment; -import android.content.Context; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.Log; -import android.view.View; -import android.view.ViewGroup; -import android.view.View.OnClickListener; -import android.view.LayoutInflater; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.inputmethod.InputMethodManager; -import android.webkit.WebSettingsClassic.AutoFillProfile; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; - -public class AutoFillSettingsFragment extends Fragment { - - private static final String LOGTAG = "AutoFillSettingsFragment"; - - private EditText mFullNameEdit; - private EditText mEmailEdit; - private EditText mCompanyEdit; - private EditText mAddressLine1Edit; - private EditText mAddressLine2Edit; - private EditText mCityEdit; - private EditText mStateEdit; - private EditText mZipEdit; - private EditText mCountryEdit; - private EditText mPhoneEdit; - - private MenuItem mSaveMenuItem; - - private boolean mInitialised; - - // Used to display toast after DB interactions complete. - private Handler mHandler; - private BrowserSettings mSettings; - - private final static int PROFILE_SAVED_MSG = 100; - private final static int PROFILE_DELETED_MSG = 101; - - // For now we support just one profile so it's safe to hardcode the - // id to 1 here. In the future this unique identifier will be set - // dynamically. - private int mUniqueId = 1; - - private class PhoneNumberValidator implements TextWatcher { - // Keep in sync with kPhoneNumberLength in chrome/browser/autofill/phone_number.cc - private static final int PHONE_NUMBER_LENGTH = 7; - private static final String PHONE_NUMBER_SEPARATORS_REGEX = "[\\s\\.\\(\\)-]"; - - public void afterTextChanged(Editable s) { - String phoneNumber = s.toString(); - int phoneNumberLength = phoneNumber.length(); - - // Strip out any phone number separators. - phoneNumber = phoneNumber.replaceAll(PHONE_NUMBER_SEPARATORS_REGEX, ""); - - int strippedPhoneNumberLength = phoneNumber.length(); - - if (phoneNumberLength > 0 && strippedPhoneNumberLength < PHONE_NUMBER_LENGTH) { - mPhoneEdit.setError(getResources().getText( - R.string.autofill_profile_editor_phone_number_invalid)); - } else { - mPhoneEdit.setError(null); - } - - updateSaveMenuItemState(); - } - - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - } - - private class FieldChangedListener implements TextWatcher { - public void afterTextChanged(Editable s) { - updateSaveMenuItemState(); - } - - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } - - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - } - - private TextWatcher mFieldChangedListener = new FieldChangedListener(); - - public AutoFillSettingsFragment() { - mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - Context c = getActivity(); - switch (msg.what) { - case PROFILE_SAVED_MSG: - if (c != null) { - Toast.makeText(c, R.string.autofill_profile_successful_save, - Toast.LENGTH_SHORT).show(); - closeEditor(); - } - break; - - case PROFILE_DELETED_MSG: - if (c != null) { - Toast.makeText(c, R.string.autofill_profile_successful_delete, - Toast.LENGTH_SHORT).show(); - } - break; - } - } - }; - } - - @Override - public void onCreate(Bundle savedState) { - super.onCreate(savedState); - setHasOptionsMenu(true); - mSettings = BrowserSettings.getInstance(); - } - - @Override - public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { - inflater.inflate(R.menu.autofill_profile_editor, menu); - mSaveMenuItem = menu.findItem(R.id.autofill_profile_editor_save_profile_menu_id); - updateSaveMenuItemState(); - } - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.autofill_profile_editor_delete_profile_menu_id: - // Clear the UI. - mFullNameEdit.setText(""); - mEmailEdit.setText(""); - mCompanyEdit.setText(""); - mAddressLine1Edit.setText(""); - mAddressLine2Edit.setText(""); - mCityEdit.setText(""); - mStateEdit.setText(""); - mZipEdit.setText(""); - mCountryEdit.setText(""); - mPhoneEdit.setText(""); - - // Update browser settings and native with a null profile. This will - // trigger the current profile to get deleted from the DB. - mSettings.setAutoFillProfile(null, - mHandler.obtainMessage(PROFILE_DELETED_MSG)); - updateSaveMenuItemState(); - return true; - - case R.id.autofill_profile_editor_save_profile_menu_id: - AutoFillProfile newProfile = new AutoFillProfile( - mUniqueId, - mFullNameEdit.getText().toString(), - mEmailEdit.getText().toString(), - mCompanyEdit.getText().toString(), - mAddressLine1Edit.getText().toString(), - mAddressLine2Edit.getText().toString(), - mCityEdit.getText().toString(), - mStateEdit.getText().toString(), - mZipEdit.getText().toString(), - mCountryEdit.getText().toString(), - mPhoneEdit.getText().toString()); - - mSettings.setAutoFillProfile(newProfile, - mHandler.obtainMessage(PROFILE_SAVED_MSG)); - return true; - - default: - return false; - } - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - View v = inflater.inflate(R.layout.autofill_settings_fragment, container, false); - - mFullNameEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_name_edit); - mEmailEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_email_address_edit); - mCompanyEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_company_name_edit); - mAddressLine1Edit = (EditText)v.findViewById( - R.id.autofill_profile_editor_address_line_1_edit); - mAddressLine2Edit = (EditText)v.findViewById( - R.id.autofill_profile_editor_address_line_2_edit); - mCityEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_city_edit); - mStateEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_state_edit); - mZipEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_zip_code_edit); - mCountryEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_country_edit); - mPhoneEdit = (EditText)v.findViewById(R.id.autofill_profile_editor_phone_number_edit); - - mFullNameEdit.addTextChangedListener(mFieldChangedListener); - mEmailEdit.addTextChangedListener(mFieldChangedListener); - mCompanyEdit.addTextChangedListener(mFieldChangedListener); - mAddressLine1Edit.addTextChangedListener(mFieldChangedListener); - mAddressLine2Edit.addTextChangedListener(mFieldChangedListener); - mCityEdit.addTextChangedListener(mFieldChangedListener); - mStateEdit.addTextChangedListener(mFieldChangedListener); - mZipEdit.addTextChangedListener(mFieldChangedListener); - mCountryEdit.addTextChangedListener(mFieldChangedListener); - mPhoneEdit.addTextChangedListener(new PhoneNumberValidator()); - - // Populate the text boxes with any pre existing AutoFill data. - AutoFillProfile activeProfile = mSettings.getAutoFillProfile(); - if (activeProfile != null) { - mFullNameEdit.setText(activeProfile.getFullName()); - mEmailEdit.setText(activeProfile.getEmailAddress()); - mCompanyEdit.setText(activeProfile.getCompanyName()); - mAddressLine1Edit.setText(activeProfile.getAddressLine1()); - mAddressLine2Edit.setText(activeProfile.getAddressLine2()); - mCityEdit.setText(activeProfile.getCity()); - mStateEdit.setText(activeProfile.getState()); - mZipEdit.setText(activeProfile.getZipCode()); - mCountryEdit.setText(activeProfile.getCountry()); - mPhoneEdit.setText(activeProfile.getPhoneNumber()); - } - - mInitialised = true; - - updateSaveMenuItemState(); - - return v; - } - - private void updateSaveMenuItemState() { - if (mSaveMenuItem == null) { - return; - } - - if (!mInitialised) { - mSaveMenuItem.setEnabled(false); - return; - } - - boolean currentState = mSaveMenuItem.isEnabled(); - boolean newState = (mFullNameEdit.getText().toString().length() > 0 || - mEmailEdit.getText().toString().length() > 0 || - mCompanyEdit.getText().toString().length() > 0 || - mAddressLine1Edit.getText().toString().length() > 0 || - mAddressLine2Edit.getText().toString().length() > 0 || - mCityEdit.getText().toString().length() > 0 || - mStateEdit.getText().toString().length() > 0 || - mZipEdit.getText().toString().length() > 0 || - mCountryEdit.getText().toString().length() > 0) && - mPhoneEdit.getError() == null; - - if (currentState != newState) { - mSaveMenuItem.setEnabled(newState); - } - } - - private void closeEditor() { - // Hide the IME if the user wants to close while an EditText has focus - InputMethodManager imm = (InputMethodManager) getActivity().getSystemService( - Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(getView().getWindowToken(), 0); - if (getFragmentManager().getBackStackEntryCount() > 0) { - getFragmentManager().popBackStack(); - } else { - getActivity().finish(); - } - } -} diff --git a/src/com/android/browser/AutofillHandler.java b/src/com/android/browser/AutofillHandler.java deleted file mode 100644 index 5b0320d..0000000 --- a/src/com/android/browser/AutofillHandler.java +++ /dev/null @@ -1,283 +0,0 @@ - -/* - * Copyright (C) 2011 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.content.Context; -import android.content.SharedPreferences; -import android.content.SharedPreferences.Editor; -import android.database.Cursor; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Message; -import android.preference.PreferenceManager; -import android.provider.ContactsContract; -import android.util.Log; -import android.webkit.WebSettingsClassic.AutoFillProfile; - -import java.util.concurrent.CountDownLatch; - -public class AutofillHandler { - - private AutoFillProfile mAutoFillProfile; - // Default to zero. In the case no profile is set up, the initial - // value will come from the AutoFillSettingsFragment when the user - // creates a profile. Otherwise, we'll read the ID of the last used - // profile from the prefs db. - private int mAutoFillActiveProfileId; - private static final int NO_AUTOFILL_PROFILE_SET = 0; - - private CountDownLatch mLoaded = new CountDownLatch(1); - private Context mContext; - - private static final String LOGTAG = "AutofillHandler"; - - public AutofillHandler(Context context) { - mContext = context.getApplicationContext(); - } - - /** - * Load settings from the browser app's database. It is performed in - * an AsyncTask as it involves plenty of slow disk IO. - * NOTE: Strings used for the preferences must match those specified - * in the various preference XML files. - */ - public void asyncLoadFromDb() { - // Run the initial settings load in an AsyncTask as it hits the - // disk multiple times through SharedPreferences and SQLite. We - // need to be certain though that this has completed before we start - // to load pages though, so in the worst case we will block waiting - // for it to finish in BrowserActivity.onCreate(). - new LoadFromDb().start(); - } - - private void waitForLoad() { - try { - mLoaded.await(); - } catch (InterruptedException e) { - Log.w(LOGTAG, "Caught exception while waiting for AutofillProfile to load."); - } - } - - private class LoadFromDb extends Thread { - - @Override - public void run() { - // Note the lack of synchronization over mAutoFillActiveProfileId and - // mAutoFillProfile here. This is because we control all other access - // to these members through the public functions of this class, and they - // all wait for this thread via the mLoaded CountDownLatch. - - SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(mContext); - - // Read the last active AutoFill profile id. - mAutoFillActiveProfileId = p.getInt( - PreferenceKeys.PREF_AUTOFILL_ACTIVE_PROFILE_ID, - mAutoFillActiveProfileId); - - // Load the autofill profile data from the database. We use a database separate - // to the browser preference DB to make it easier to support multiple profiles - // and switching between them. Note that this may block startup if this DB lookup - // is extremely slow. We do this to ensure that if there's a profile set, the - // user never sees the "setup Autofill" option. - AutoFillProfileDatabase autoFillDb = AutoFillProfileDatabase.getInstance(mContext); - Cursor c = autoFillDb.getProfile(mAutoFillActiveProfileId); - - if (c.getCount() > 0) { - c.moveToFirst(); - - String fullName = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.FULL_NAME)); - String email = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.EMAIL_ADDRESS)); - String company = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.COMPANY_NAME)); - String addressLine1 = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.ADDRESS_LINE_1)); - String addressLine2 = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.ADDRESS_LINE_2)); - String city = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.CITY)); - String state = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.STATE)); - String zip = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.ZIP_CODE)); - String country = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.COUNTRY)); - String phone = c.getString(c.getColumnIndex( - AutoFillProfileDatabase.Profiles.PHONE_NUMBER)); - mAutoFillProfile = new AutoFillProfile(mAutoFillActiveProfileId, - fullName, email, company, addressLine1, addressLine2, city, - state, zip, country, phone); - } - c.close(); - autoFillDb.close(); - - // At this point we've loaded the profile if there was one, so let any thread - // waiting on initialization continue. - mLoaded.countDown(); - - // Synchronization note: strictly speaking, it's possible that mAutoFillProfile - // may get a value after we check below, but that's OK. This check is only an - // optimisation, and we do a proper synchronized check further down when it comes - // to actually setting the inferred profile. - if (mAutoFillProfile == null) { - // We did not load a profile from disk. Try to infer one from the user's - // "me" contact. - final Uri profileUri = Uri.withAppendedPath(ContactsContract.Profile.CONTENT_URI, - ContactsContract.Contacts.Data.CONTENT_DIRECTORY); - String name = getContactField(profileUri, - ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME, - ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE); - // Only attempt to read other data and set a profile if we could successfully - // get a name. - if (name != null) { - String email = getContactField(profileUri, - ContactsContract.CommonDataKinds.Email.ADDRESS, - ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE); - String phone = getContactField(profileUri, - ContactsContract.CommonDataKinds.Phone.NUMBER, - ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); - String company = getContactField(profileUri, - ContactsContract.CommonDataKinds.Organization.COMPANY, - ContactsContract.CommonDataKinds.Organization.CONTENT_ITEM_TYPE); - - // Can't easily get structured postal address information (even using - // CommonDataKinds.StructuredPostal) so omit prepopulating that for now. - // When querying structured postal data, it often all comes back as a string - // inside the "street" field. - - synchronized(AutofillHandler.this) { - // Only use this profile if one hasn't been set inbetween the - // inital import and this thread getting to this point. - if (mAutoFillProfile == null) { - setAutoFillProfile(new AutoFillProfile(1, name, email, company, - null, null, null, null, null, null, phone), null); - } - } - } - } - } - - private String getContactField(Uri uri, String field, String itemType) { - String result = null; - - Cursor c = mContext.getContentResolver().query(uri, new String[] { field }, - ContactsContract.Data.MIMETYPE + "=?", new String[] { itemType }, null); - - if (c == null) { - return null; - } - - try { - // Just use the first returned value if we get more than one. - if (c.moveToFirst()) { - result = c.getString(0); - } - } finally { - c.close(); - } - return result; - } - } - - public synchronized void setAutoFillProfile(AutoFillProfile profile, Message msg) { - waitForLoad(); - int profileId = NO_AUTOFILL_PROFILE_SET; - if (profile != null) { - profileId = profile.getUniqueId(); - // Update the AutoFill DB with the new profile. - new SaveProfileToDbTask(msg).execute(profile); - } else { - // Delete the current profile. - if (mAutoFillProfile != null) { - new DeleteProfileFromDbTask(msg).execute(mAutoFillProfile.getUniqueId()); - } - } - // Make sure we set mAutoFillProfile before calling setActiveAutoFillProfileId - // Calling setActiveAutoFillProfileId will trigger an update of WebViews - // which will expect a new profile to be set - mAutoFillProfile = profile; - setActiveAutoFillProfileId(profileId); - } - - public synchronized AutoFillProfile getAutoFillProfile() { - waitForLoad(); - return mAutoFillProfile; - } - - private synchronized void setActiveAutoFillProfileId(int activeProfileId) { - mAutoFillActiveProfileId = activeProfileId; - Editor ed = PreferenceManager. - getDefaultSharedPreferences(mContext).edit(); - ed.putInt(PreferenceKeys.PREF_AUTOFILL_ACTIVE_PROFILE_ID, activeProfileId); - ed.apply(); - } - - private abstract class AutoFillProfileDbTask<T> extends AsyncTask<T, Void, Void> { - AutoFillProfileDatabase mAutoFillProfileDb; - Message mCompleteMessage; - - public AutoFillProfileDbTask(Message msg) { - mCompleteMessage = msg; - } - - @Override - protected void onPostExecute(Void result) { - if (mCompleteMessage != null) { - mCompleteMessage.sendToTarget(); - } - mAutoFillProfileDb.close(); - } - - @Override - abstract protected Void doInBackground(T... values); - } - - - private class SaveProfileToDbTask extends AutoFillProfileDbTask<AutoFillProfile> { - public SaveProfileToDbTask(Message msg) { - super(msg); - } - - @Override - protected Void doInBackground(AutoFillProfile... values) { - mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext); - synchronized (AutofillHandler.this) { - assert mAutoFillActiveProfileId != NO_AUTOFILL_PROFILE_SET; - AutoFillProfile newProfile = values[0]; - mAutoFillProfileDb.addOrUpdateProfile(mAutoFillActiveProfileId, newProfile); - } - return null; - } - } - - private class DeleteProfileFromDbTask extends AutoFillProfileDbTask<Integer> { - public DeleteProfileFromDbTask(Message msg) { - super(msg); - } - - @Override - protected Void doInBackground(Integer... values) { - mAutoFillProfileDb = AutoFillProfileDatabase.getInstance(mContext); - int id = values[0]; - assert id > 0; - mAutoFillProfileDb.dropProfile(id); - return null; - } - } -} diff --git a/src/com/android/browser/BaseUi.java b/src/com/android/browser/BaseUi.java index 3ba3182..6b10459 100644 --- a/src/com/android/browser/BaseUi.java +++ b/src/com/android/browser/BaseUi.java @@ -46,7 +46,6 @@ import android.view.WindowManager; import android.view.inputmethod.InputMethodManager; import android.webkit.WebChromeClient; import android.webkit.WebView; -import android.webkit.WebViewClassic; import android.widget.FrameLayout; import android.widget.ImageButton; import android.widget.LinearLayout; diff --git a/src/com/android/browser/BrowserPreferencesPage.java b/src/com/android/browser/BrowserPreferencesPage.java index 6e6da17..9b538e0 100644 --- a/src/com/android/browser/BrowserPreferencesPage.java +++ b/src/com/android/browser/BrowserPreferencesPage.java @@ -25,7 +25,10 @@ import android.view.MenuItem; import com.android.browser.preferences.BandwidthPreferencesFragment; import com.android.browser.preferences.DebugPreferencesFragment; +import java.util.Arrays; +import java.util.HashSet; import java.util.List; +import java.util.Set; public class BrowserPreferencesPage extends PreferenceActivity { @@ -98,4 +101,16 @@ public class BrowserPreferencesPage extends PreferenceActivity { return intent; } + private static final Set<String> sKnownFragments = new HashSet<String>(Arrays.asList( + "com.android.browser.preferences.GeneralPreferencesFragment", + "com.android.browser.preferences.PrivacySecurityPreferencesFragment", + "com.android.browser.preferences.AccessibilityPreferencesFragment", + "com.android.browser.preferences.AdvancedPreferencesFragment", + "com.android.browser.preferences.BandwidthPreferencesFragment", + "com.android.browser.preferences.LabPreferencesFragment")); + + @Override + protected boolean isValidFragment(String fragmentName) { + return sKnownFragments.contains(fragmentName); + } } diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java index 95afa71..ed44394 100644 --- a/src/com/android/browser/BrowserSettings.java +++ b/src/com/android/browser/BrowserSettings.java @@ -38,8 +38,6 @@ import android.webkit.WebSettings.LayoutAlgorithm; import android.webkit.WebSettings.PluginState; import android.webkit.WebSettings.TextSize; import android.webkit.WebSettings.ZoomDensity; -import android.webkit.WebSettingsClassic; -import android.webkit.WebSettingsClassic.AutoFillProfile; import android.webkit.WebStorage; import android.webkit.WebView; import android.webkit.WebViewDatabase; @@ -111,7 +109,6 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, private LinkedList<WeakReference<WebSettings>> mManagedSettings; private Controller mController; private WebStorageSizeManager mWebStorageSizeManager; - private AutofillHandler mAutofillHandler; private WeakHashMap<WebSettings, String> mCustomUserAgents; private static boolean sInitialized = false; private boolean mNeedsSharedSync = true; @@ -140,10 +137,8 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, private BrowserSettings(Context context) { mContext = context.getApplicationContext(); mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext); - mAutofillHandler = new AutofillHandler(mContext); mManagedSettings = new LinkedList<WeakReference<WebSettings>>(); mCustomUserAgents = new WeakHashMap<WebSettings, String>(); - mAutofillHandler.asyncLoadFromDb(); BackgroundHandler.execute(mSetup); } @@ -277,31 +272,6 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, } else { settings.setUserAgentString(USER_AGENTS[getUserAgent()]); } - - if (!(settings instanceof WebSettingsClassic)) return; - - WebSettingsClassic settingsClassic = (WebSettingsClassic) settings; - settingsClassic.setHardwareAccelSkiaEnabled(isSkiaHardwareAccelerated()); - settingsClassic.setShowVisualIndicator(enableVisualIndicator()); - settingsClassic.setForceUserScalable(forceEnableUserScalable()); - settingsClassic.setDoubleTapZoom(getDoubleTapZoom()); - settingsClassic.setAutoFillEnabled(isAutofillEnabled()); - settingsClassic.setAutoFillProfile(getAutoFillProfile()); - - boolean useInverted = useInvertedRendering(); - settingsClassic.setProperty(WebViewProperties.gfxInvertedScreen, - useInverted ? "true" : "false"); - if (useInverted) { - settingsClassic.setProperty(WebViewProperties.gfxInvertedScreenContrast, - Float.toString(getInvertedContrast())); - } - - if (isDebugEnabled()) { - settingsClassic.setProperty(WebViewProperties.gfxEnableCpuUploadPath, - enableCpuUploadPath() ? "true" : "false"); - } - - settingsClassic.setLinkPrefetchEnabled(mLinkPrefetchAllowed); } /** @@ -335,19 +305,6 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, // origin policy for file access settings.setAllowUniversalAccessFromFileURLs(false); settings.setAllowFileAccessFromFileURLs(false); - - if (!(settings instanceof WebSettingsClassic)) return; - - WebSettingsClassic settingsClassic = (WebSettingsClassic) settings; - settingsClassic.setPageCacheCapacity(getPageCacheCapacity()); - // WebView should be preserving the memory as much as possible. - // However, apps like browser wish to turn on the performance mode which - // would require more memory. - // TODO: We need to dynamically allocate/deallocate temporary memory for - // apps which are trying to use minimal memory. Currently, double - // buffering is always turned on, which is unnecessary. - settingsClassic.setProperty(WebViewProperties.gfxUseMinimalMemory, "false"); - settingsClassic.setWorkersEnabled(true); // This only affects V8. } private void syncSharedSettings() { @@ -523,19 +480,6 @@ public class BrowserSettings implements OnSharedPreferenceChangeListener, updateSearchEngine(false); } - public AutoFillProfile getAutoFillProfile() { - return mAutofillHandler.getAutoFillProfile(); - } - - public void setAutoFillProfile(AutoFillProfile profile, Message msg) { - mAutofillHandler.setAutoFillProfile(profile, msg); - // Auto-fill will reuse the same profile ID when making edits to the profile, - // so we need to force a settings sync (otherwise the SharedPreferences - // manager will optimise out the call to onSharedPreferenceChanged(), as - // it thinks nothing has changed). - syncManagedSettings(); - } - public void toggleDebugSettings() { setDebugEnabled(!isDebugEnabled()); } diff --git a/src/com/android/browser/BrowserWebView.java b/src/com/android/browser/BrowserWebView.java index 99e0587..3e3672c 100644 --- a/src/com/android/browser/BrowserWebView.java +++ b/src/com/android/browser/BrowserWebView.java @@ -22,9 +22,7 @@ import android.util.AttributeSet; import android.view.View; import android.webkit.WebChromeClient; import android.webkit.WebStorage; -import android.webkit.WebStorageClassic; import android.webkit.WebView; -import android.webkit.WebViewClassic; import android.webkit.WebViewClient; import java.util.Map; @@ -32,7 +30,7 @@ import java.util.Map; /** * Manage WebView scroll events */ -public class BrowserWebView extends WebView implements WebViewClassic.TitleBarDelegate { +public class BrowserWebView extends WebView { public interface OnScrollChangedListener { void onScrollChanged(int l, int t, int oldl, int oldt); @@ -80,11 +78,6 @@ public class BrowserWebView extends WebView implements WebViewClassic.TitleBarDe super(context); } - public static boolean isClassic() { - // Using WebStorage for convenience of access in a static method. - return WebStorage.getInstance() instanceof WebStorageClassic; - } - @Override public void setWebChromeClient(WebChromeClient client) { mWebChromeClient = client; @@ -109,18 +102,10 @@ public class BrowserWebView extends WebView implements WebViewClassic.TitleBarDe mTitleBar = title; } - // From TitleBarDelegate - @Override public int getTitleHeight() { return (mTitleBar != null) ? mTitleBar.getEmbeddedHeight() : 0; } - // From TitleBarDelegate - @Override - public void onSetEmbeddedTitleBar(final View title) { - // TODO: Remove this method; it is never invoked. - } - public boolean hasTitleBar() { return (mTitleBar != null); } diff --git a/src/com/android/browser/BrowserWebViewFactory.java b/src/com/android/browser/BrowserWebViewFactory.java index 66d9e78..f976b07 100644 --- a/src/com/android/browser/BrowserWebViewFactory.java +++ b/src/com/android/browser/BrowserWebViewFactory.java @@ -65,6 +65,9 @@ public class BrowserWebViewFactory implements WebViewFactory { // settings final BrowserSettings s = BrowserSettings.getInstance(); s.startManagingSettings(w.getSettings()); + + // Remote Web Debugging is always enabled + WebView.setWebContentsDebuggingEnabled(true); } } diff --git a/src/com/android/browser/ComboViewActivity.java b/src/com/android/browser/ComboViewActivity.java index 91d574e..7053c9b 100644 --- a/src/com/android/browser/ComboViewActivity.java +++ b/src/com/android/browser/ComboViewActivity.java @@ -71,14 +71,6 @@ public class ComboViewActivity extends Activity implements CombinedBookmarksCall mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args); - if (BrowserWebView.isClassic()) { - // TODO: history page should be able to work in Classic mode, but there's some - // provider name conflict. (Snapshot would never work in that mode though). - mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), - BrowserHistoryPage.class, args); - mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_snapshots), - BrowserSnapshotPage.class, args); - } if (savedInstanceState != null) { bar.setSelectedNavigationItem( diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java index 7b7fcd4..2d716a8 100644 --- a/src/com/android/browser/Controller.java +++ b/src/com/android/browser/Controller.java @@ -78,7 +78,6 @@ import android.webkit.WebChromeClient; import android.webkit.WebIconDatabase; import android.webkit.WebSettings; import android.webkit.WebView; -import android.webkit.WebViewClassic; import android.widget.Toast; import com.android.browser.IntentHandler.UrlData; @@ -131,7 +130,6 @@ public class Controller final static int COMBO_VIEW = 1; final static int PREFERENCES_PAGE = 3; final static int FILE_SELECTED = 4; - final static int AUTOFILL_SETUP = 5; final static int VOICE_RESULT = 6; private final static int WAKELOCK_TIMEOUT = 5 * 60 * 1000; // 5 minutes @@ -260,7 +258,6 @@ public class Controller @Override public void start(final Intent intent) { - if (BrowserWebView.isClassic()) WebViewClassic.setShouldMonitorWebCoreThread(); // mCrashRecoverHandler has any previously saved state. mCrashRecoveryHandler.startRecovery(intent); } @@ -356,9 +353,6 @@ public class Controller } // Read JavaScript flags if it exists. String jsFlags = getSettings().getJsEngineFlags(); - if (jsFlags.trim().length() != 0 && BrowserWebView.isClassic()) { - WebViewClassic.fromWebView(getCurrentWebView()).setJsFlags(jsFlags); - } if (intent != null && BrowserActivity.ACTION_SHOW_BOOKMARKS.equals(intent.getAction())) { bookmarksOrHistoryPicker(ComboViews.Bookmarks); @@ -1166,15 +1160,6 @@ public class Controller if (null == mUploadHandler) break; mUploadHandler.onResult(resultCode, intent); break; - case AUTOFILL_SETUP: - // Determine whether a profile was actually set up or not - // and if so, send the message back to the WebTextView to - // fill the form with the new profile. - if (getSettings().getAutoFillProfile() != null) { - mAutoFillSetupMessage.sendToTarget(); - mAutoFillSetupMessage = null; - } - break; case COMBO_VIEW: if (intent == null || resultCode != Activity.RESULT_OK) { break; @@ -1196,12 +1181,8 @@ public class Controller long id = intent.getLongExtra( ComboViewActivity.EXTRA_OPEN_SNAPSHOT, -1); if (id >= 0) { - if (BrowserWebView.isClassic()) { - createNewSnapshotTab(id, true); - } else { - Toast.makeText(mActivity, "Snapshot Tab requires WebViewClassic", - Toast.LENGTH_LONG).show(); - } + Toast.makeText(mActivity, "Snapshot Tab no longer supported", + Toast.LENGTH_LONG).show(); } } break; @@ -1323,15 +1304,6 @@ public class Controller menu.setGroupVisible(R.id.ANCHOR_MENU, type == WebView.HitTestResult.SRC_ANCHOR_TYPE || type == WebView.HitTestResult.SRC_IMAGE_ANCHOR_TYPE); - boolean hitText = type == WebView.HitTestResult.SRC_ANCHOR_TYPE - || type == WebView.HitTestResult.PHONE_TYPE - || type == WebView.HitTestResult.EMAIL_TYPE - || type == WebView.HitTestResult.GEO_TYPE; - menu.setGroupVisible(R.id.SELECT_TEXT_MENU, hitText); - if (hitText) { - menu.findItem(R.id.select_text_menu_id) - .setOnMenuItemClickListener(new SelectText(webview)); - } // Setup custom handling depending on the type switch (type) { case WebView.HitTestResult.PHONE_TYPE: @@ -1648,12 +1620,6 @@ public class Controller findOnPage(); break; - case R.id.save_snapshot_menu_id: - final Tab source = getTabControl().getCurrentTab(); - if (source == null) break; - new SaveSnapshotTask(source).execute(); - break; - case R.id.page_info_menu_id: showPageInfo(); break; @@ -1719,69 +1685,6 @@ public class Controller return true; } - private class SaveSnapshotTask extends AsyncTask<Void, Void, Long> - implements OnCancelListener { - - private Tab mTab; - private Dialog mProgressDialog; - private ContentValues mValues; - - private SaveSnapshotTask(Tab tab) { - mTab = tab; - } - - @Override - protected void onPreExecute() { - CharSequence message = mActivity.getText(R.string.saving_snapshot); - mProgressDialog = ProgressDialog.show(mActivity, null, message, - true, true, this); - mValues = mTab.createSnapshotValues(); - } - - @Override - protected Long doInBackground(Void... params) { - if (!mTab.saveViewState(mValues)) { - return null; - } - if (isCancelled()) { - String path = mValues.getAsString(Snapshots.VIEWSTATE_PATH); - File file = mActivity.getFileStreamPath(path); - if (!file.delete()) { - file.deleteOnExit(); - } - return null; - } - final ContentResolver cr = mActivity.getContentResolver(); - Uri result = cr.insert(Snapshots.CONTENT_URI, mValues); - if (result == null) { - return null; - } - long id = ContentUris.parseId(result); - return id; - } - - @Override - protected void onPostExecute(Long id) { - if (isCancelled()) { - return; - } - mProgressDialog.dismiss(); - if (id == null) { - Toast.makeText(mActivity, R.string.snapshot_failed, - Toast.LENGTH_SHORT).show(); - return; - } - Bundle b = new Bundle(); - b.putLong(BrowserSnapshotPage.EXTRA_ANIMATE_ID, id); - mUi.showComboView(ComboViews.Snapshots, b); - } - - @Override - public void onCancel(DialogInterface dialog) { - cancel(true); - } - } - @Override public void toggleUserAgent() { WebView web = getCurrentWebView(); @@ -2250,25 +2153,6 @@ public class Controller } } - private static class SelectText implements OnMenuItemClickListener { - private WebViewClassic mWebView; - - @Override - public boolean onMenuItemClick(MenuItem item) { - if (mWebView != null) { - return mWebView.selectText(); - } - return false; - } - - public SelectText(WebView webView) { - if (BrowserWebView.isClassic()) { - mWebView = WebViewClassic.fromWebView(webView); - } - } - - } - /********************** TODO: UI stuff *****************************/ // these methods have been copied, they still need to be cleaned up @@ -2457,21 +2341,6 @@ public class Controller return tab; } - @Override - public SnapshotTab createNewSnapshotTab(long snapshotId, boolean setActive) { - SnapshotTab tab = null; - if (mTabControl.canCreateNewTab()) { - tab = mTabControl.createSnapshotTab(snapshotId); - addTab(tab); - if (setActive) { - setActiveTab(tab); - } - } else { - mUi.showMaxTabsWarning(); - } - return tab; - } - /** * @param tab the tab to switch to * @return boolean True if we successfully switched to a different tab. If @@ -2744,19 +2613,7 @@ public class Controller return true; } break; - case KeyEvent.KEYCODE_A: - if (ctrl && BrowserWebView.isClassic()) { - WebViewClassic.fromWebView(webView).selectAll(); - return true; - } - break; // case KeyEvent.KEYCODE_B: // menu - case KeyEvent.KEYCODE_C: - if (ctrl && BrowserWebView.isClassic()) { - WebViewClassic.fromWebView(webView).copySelection(); - return true; - } - break; // case KeyEvent.KEYCODE_D: // menu // case KeyEvent.KEYCODE_E: // in Chrome: puts '?' in URL bar // case KeyEvent.KEYCODE_F: // menu @@ -2835,18 +2692,6 @@ public class Controller } @Override - public void setupAutoFill(Message message) { - // Open the settings activity at the AutoFill profile fragment so that - // the user can create a new profile. When they return, we will dispatch - // the message so that we can autofill the form using their new profile. - Intent intent = new Intent(mActivity, BrowserPreferencesPage.class); - intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, - AutoFillSettingsFragment.class.getName()); - mAutoFillSetupMessage = message; - mActivity.startActivityForResult(intent, AUTOFILL_SETUP); - } - - @Override public boolean onSearchRequested() { mUi.editUrl(false, true); return true; diff --git a/src/com/android/browser/IntentHandler.java b/src/com/android/browser/IntentHandler.java index 7107a9e..1b8dfc7 100644 --- a/src/com/android/browser/IntentHandler.java +++ b/src/com/android/browser/IntentHandler.java @@ -179,25 +179,6 @@ public class IntentHandler { } } } else { - if (BrowserWebView.isClassic() && !urlData.isEmpty() - && urlData.mUrl.startsWith("about:debug")) { - if ("about:debug.dom".equals(urlData.mUrl)) { - current.getWebViewClassic().dumpDomTree(false); - } else if ("about:debug.dom.file".equals(urlData.mUrl)) { - current.getWebViewClassic().dumpDomTree(true); - } else if ("about:debug.render".equals(urlData.mUrl)) { - current.getWebViewClassic().dumpRenderTree(false); - } else if ("about:debug.render.file".equals(urlData.mUrl)) { - current.getWebViewClassic().dumpRenderTree(true); - } else if ("about:debug.display".equals(urlData.mUrl)) { - current.getWebViewClassic().dumpDisplayTree(); - } else if ("about:debug.nav".equals(urlData.mUrl)) { - current.getWebView().debugDump(); - } else { - mSettings.toggleDebugSettings(); - } - return; - } // Get rid of the subwindow if it exists mController.dismissSubWindow(current); // If the current Tab is being used as an application tab, diff --git a/src/com/android/browser/KeyChainLookup.java b/src/com/android/browser/KeyChainLookup.java deleted file mode 100644 index 4d5f694..0000000 --- a/src/com/android/browser/KeyChainLookup.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 201 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.content.Context; -import android.os.AsyncTask; -import android.security.KeyChain; -import android.security.KeyChainException; -import android.webkit.ClientCertRequestHandler; -import java.security.PrivateKey; -import java.security.cert.X509Certificate; - -final class KeyChainLookup extends AsyncTask<Void, Void, Void> { - private final Context mContext; - private final ClientCertRequestHandler mHandler; - private final String mAlias; - KeyChainLookup(Context context, ClientCertRequestHandler handler, String alias) { - mContext = context.getApplicationContext(); - mHandler = handler; - mAlias = alias; - } - @Override protected Void doInBackground(Void... params) { - PrivateKey privateKey; - X509Certificate[] certificateChain; - try { - privateKey = KeyChain.getPrivateKey(mContext, mAlias); - certificateChain = KeyChain.getCertificateChain(mContext, mAlias); - } catch (InterruptedException e) { - mHandler.ignore(); - return null; - } catch (KeyChainException e) { - mHandler.ignore(); - return null; - } - mHandler.proceed(privateKey, certificateChain); - return null; - } -} diff --git a/src/com/android/browser/NetworkStateHandler.java b/src/com/android/browser/NetworkStateHandler.java index 9201f0f..618fde5 100644 --- a/src/com/android/browser/NetworkStateHandler.java +++ b/src/com/android/browser/NetworkStateHandler.java @@ -24,7 +24,6 @@ import android.content.IntentFilter; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.webkit.WebView; -import android.webkit.WebViewClassic; import com.android.browser.BrowserSettings; @@ -114,8 +113,5 @@ public class NetworkStateHandler { private void sendNetworkType(String type, String subtype) { WebView w = mController.getCurrentWebView(); - if (w != null && BrowserWebView.isClassic()) { - WebViewClassic.fromWebView(w).setNetworkType(type, subtype); - } } } diff --git a/src/com/android/browser/PreloadController.java b/src/com/android/browser/PreloadController.java index 881f19e..acd9709 100644 --- a/src/com/android/browser/PreloadController.java +++ b/src/com/android/browser/PreloadController.java @@ -246,11 +246,6 @@ public class PreloadController implements WebViewController { } @Override - public void setupAutoFill(Message message) { - if (LOGD_ENABLED) Log.d(LOGTAG, "setupAutoFill()"); - } - - @Override public void bookmarkedStatusHasChanged(Tab tab) { if (LOGD_ENABLED) Log.d(LOGTAG, "bookmarkedStatusHasChanged()"); } diff --git a/src/com/android/browser/SnapshotBar.java b/src/com/android/browser/SnapshotBar.java deleted file mode 100644 index 51e1226..0000000 --- a/src/com/android/browser/SnapshotBar.java +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2011 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.content.Context; -import android.graphics.Bitmap; -import android.os.Handler; -import android.os.Message; -import android.text.TextUtils; -import android.util.AttributeSet; -import android.view.MenuItem; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.ViewConfiguration; -import android.view.ViewPropertyAnimator; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.PopupMenu.OnMenuItemClickListener; -import android.widget.TextView; - -import com.android.browser.UI.ComboViews; - -import java.text.DateFormat; -import java.util.Date; - -public class SnapshotBar extends LinearLayout implements OnClickListener { - - private static final int MSG_SHOW_TITLE = 1; - private static final long DURATION_SHOW_DATE = BaseUi.HIDE_TITLEBAR_DELAY; - - private ImageView mFavicon; - private TextView mDate; - private TextView mTitle; - private View mBookmarks; - private TitleBar mTitleBar; - private View mTabSwitcher; - private View mOverflowMenu; - private View mToggleContainer; - private boolean mIsAnimating; - private ViewPropertyAnimator mTitleAnimator, mDateAnimator; - private float mAnimRadius = 20f; - - public SnapshotBar(Context context) { - super(context); - } - - public SnapshotBar(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public SnapshotBar(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setTitleBar(TitleBar titleBar) { - mTitleBar = titleBar; - setFavicon(null); - } - - private Handler mHandler = new Handler() { - @Override - public void handleMessage(Message msg) { - if (msg.what == MSG_SHOW_TITLE) { - mIsAnimating = false; - showTitle(); - mTitleBar.getUi().showTitleBarForDuration(); - } - } - }; - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mFavicon = (ImageView) findViewById(R.id.favicon); - mDate = (TextView) findViewById(R.id.date); - mTitle = (TextView) findViewById(R.id.title); - mBookmarks = findViewById(R.id.all_btn); - mTabSwitcher = findViewById(R.id.tab_switcher); - mOverflowMenu = findViewById(R.id.more); - mToggleContainer = findViewById(R.id.toggle_container); - - if (mBookmarks != null) { - mBookmarks.setOnClickListener(this); - } - if (mTabSwitcher != null) { - mTabSwitcher.setOnClickListener(this); - } - if (mOverflowMenu != null) { - mOverflowMenu.setOnClickListener(this); - boolean showMenu = !ViewConfiguration.get(getContext()) - .hasPermanentMenuKey(); - mOverflowMenu.setVisibility(showMenu ? VISIBLE : GONE); - } - if (mToggleContainer != null) { - mToggleContainer.setOnClickListener(this); - resetAnimation(); - } - } - - @Override - protected void onLayout(boolean changed, int l, int t, int r, int b) { - super.onLayout(changed, l, t, r, b); - if (mToggleContainer != null) { - mAnimRadius = mToggleContainer.getHeight() / 2f; - } - } - - void resetAnimation() { - if (mToggleContainer == null) { - // No animation needed/used - return; - } - if (mTitleAnimator != null) { - mTitleAnimator.cancel(); - mTitleAnimator = null; - } - if (mDateAnimator != null) { - mDateAnimator.cancel(); - mDateAnimator = null; - } - mIsAnimating = false; - mHandler.removeMessages(MSG_SHOW_TITLE); - mTitle.setAlpha(1f); - mTitle.setTranslationY(0f); - mTitle.setRotationX(0f); - mDate.setAlpha(0f); - mDate.setTranslationY(-mAnimRadius); - mDate.setRotationX(90f); - } - - private void showDate() { - mTitleAnimator = mTitle.animate() - .alpha(0f) - .translationY(mAnimRadius) - .rotationX(-90f); - mDateAnimator = mDate.animate() - .alpha(1f) - .translationY(0f) - .rotationX(0f); - } - - private void showTitle() { - mTitleAnimator = mTitle.animate() - .alpha(1f) - .translationY(0f) - .rotationX(0f); - mDateAnimator = mDate.animate() - .alpha(0f) - .translationY(-mAnimRadius) - .rotationX(90f); - } - - @Override - public void onClick(View v) { - if (mBookmarks == v) { - mTitleBar.getUiController().bookmarksOrHistoryPicker(ComboViews.Bookmarks); - } else if (mTabSwitcher == v) { - ((PhoneUi) mTitleBar.getUi()).toggleNavScreen(); - } else if (mOverflowMenu == v) { - NavigationBarBase navBar = mTitleBar.getNavigationBar(); - if (navBar instanceof NavigationBarPhone) { - ((NavigationBarPhone)navBar).showMenu(mOverflowMenu); - } - } else if (mToggleContainer == v && !mIsAnimating) { - mIsAnimating = true; - showDate(); - mTitleBar.getUi().showTitleBar(); - Message m = mHandler.obtainMessage(MSG_SHOW_TITLE); - mHandler.sendMessageDelayed(m, DURATION_SHOW_DATE); - } - } - - public void onTabDataChanged(Tab tab) { - if (!tab.isSnapshot()) return; - SnapshotTab snapshot = (SnapshotTab) tab; - DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG); - mDate.setText(dateFormat.format(new Date(snapshot.getDateCreated()))); - String title = snapshot.getTitle(); - if (TextUtils.isEmpty(title)) { - title = UrlUtils.stripUrl(snapshot.getUrl()); - } - mTitle.setText(title); - setFavicon(tab.getFavicon()); - resetAnimation(); - } - - public void setFavicon(Bitmap icon) { - if (mFavicon == null) return; - mFavicon.setImageDrawable(mTitleBar.getUi().getFaviconDrawable(icon)); - } - - public boolean isAnimating() { - return mIsAnimating; - } - -} diff --git a/src/com/android/browser/SnapshotTab.java b/src/com/android/browser/SnapshotTab.java deleted file mode 100644 index e14f095..0000000 --- a/src/com/android/browser/SnapshotTab.java +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (C) 2011 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.content.ContentResolver; -import android.content.ContentUris; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.graphics.BitmapFactory; -import android.net.Uri; -import android.os.AsyncTask; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.Log; -import android.webkit.WebView; -import android.webkit.WebViewClassic; - -import com.android.browser.provider.SnapshotProvider.Snapshots; - -import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.Map; -import java.util.zip.GZIPInputStream; - - -public class SnapshotTab extends Tab { - - private static final String LOGTAG = "SnapshotTab"; - - private long mSnapshotId; - private LoadData mLoadTask; - private WebViewFactory mWebViewFactory; - private int mBackgroundColor; - private long mDateCreated; - private boolean mIsLive; - - public SnapshotTab(WebViewController wvcontroller, long snapshotId) { - super(wvcontroller, null, null); - mSnapshotId = snapshotId; - mWebViewFactory = mWebViewController.getWebViewFactory(); - WebView web = mWebViewFactory.createWebView(false); - setWebView(web); - loadData(); - } - - @Override - void putInForeground() { - if (getWebView() == null) { - WebView web = mWebViewFactory.createWebView(false); - if (mBackgroundColor != 0) { - web.setBackgroundColor(mBackgroundColor); - } - setWebView(web); - loadData(); - } - super.putInForeground(); - } - - @Override - void putInBackground() { - if (getWebView() == null) return; - super.putInBackground(); - } - - void loadData() { - if (mLoadTask == null) { - mLoadTask = new LoadData(this, mContext); - mLoadTask.execute(); - } - } - - @Override - void addChildTab(Tab child) { - if (mIsLive) { - super.addChildTab(child); - } else { - throw new IllegalStateException("Snapshot tabs cannot have child tabs!"); - } - } - - @Override - public boolean isSnapshot() { - return !mIsLive; - } - - public long getSnapshotId() { - return mSnapshotId; - } - - @Override - public ContentValues createSnapshotValues() { - if (mIsLive) { - return super.createSnapshotValues(); - } - return null; - } - - @Override - public Bundle saveState() { - if (mIsLive) { - return super.saveState(); - } - return null; - } - - public long getDateCreated() { - return mDateCreated; - } - - @Override - public void loadUrl(String url, Map<String, String> headers) { - if (!mIsLive) { - mIsLive = true; - getWebViewClassic().clearViewState(); - } - super.loadUrl(url, headers); - } - - @Override - public boolean canGoBack() { - return super.canGoBack() || mIsLive; - } - - @Override - public boolean canGoForward() { - return mIsLive && super.canGoForward(); - } - - @Override - public void goBack() { - if (super.canGoBack()) { - super.goBack(); - } else { - mIsLive = false; - getWebView().stopLoading(); - loadData(); - } - } - - static class LoadData extends AsyncTask<Void, Void, Cursor> { - - static final String[] PROJECTION = new String[] { - Snapshots._ID, // 0 - Snapshots.URL, // 1 - Snapshots.TITLE, // 2 - Snapshots.FAVICON, // 3 - Snapshots.VIEWSTATE, // 4 - Snapshots.BACKGROUND, // 5 - Snapshots.DATE_CREATED, // 6 - Snapshots.VIEWSTATE_PATH, // 7 - }; - static final int SNAPSHOT_ID = 0; - static final int SNAPSHOT_URL = 1; - static final int SNAPSHOT_TITLE = 2; - static final int SNAPSHOT_FAVICON = 3; - static final int SNAPSHOT_VIEWSTATE = 4; - static final int SNAPSHOT_BACKGROUND = 5; - static final int SNAPSHOT_DATE_CREATED = 6; - static final int SNAPSHOT_VIEWSTATE_PATH = 7; - - private SnapshotTab mTab; - private ContentResolver mContentResolver; - private Context mContext; - - public LoadData(SnapshotTab t, Context context) { - mTab = t; - mContentResolver = context.getContentResolver(); - mContext = context; - } - - @Override - protected Cursor doInBackground(Void... params) { - long id = mTab.mSnapshotId; - Uri uri = ContentUris.withAppendedId(Snapshots.CONTENT_URI, id); - return mContentResolver.query(uri, PROJECTION, null, null, null); - } - - private InputStream getInputStream(Cursor c) throws FileNotFoundException { - String path = c.getString(SNAPSHOT_VIEWSTATE_PATH); - if (!TextUtils.isEmpty(path)) { - return mContext.openFileInput(path); - } - byte[] data = c.getBlob(SNAPSHOT_VIEWSTATE); - ByteArrayInputStream bis = new ByteArrayInputStream(data); - return bis; - } - - @Override - protected void onPostExecute(Cursor result) { - try { - if (result.moveToFirst()) { - mTab.mCurrentState.mTitle = result.getString(SNAPSHOT_TITLE); - mTab.mCurrentState.mUrl = result.getString(SNAPSHOT_URL); - byte[] favicon = result.getBlob(SNAPSHOT_FAVICON); - if (favicon != null) { - mTab.mCurrentState.mFavicon = BitmapFactory - .decodeByteArray(favicon, 0, favicon.length); - } - WebViewClassic web = mTab.getWebViewClassic(); - if (web != null) { - InputStream ins = getInputStream(result); - GZIPInputStream stream = new GZIPInputStream(ins); - web.loadViewState(stream); - } - mTab.mBackgroundColor = result.getInt(SNAPSHOT_BACKGROUND); - mTab.mDateCreated = result.getLong(SNAPSHOT_DATE_CREATED); - mTab.mWebViewController.onPageFinished(mTab); - } - } catch (Exception e) { - Log.w(LOGTAG, "Failed to load view state, closing tab", e); - mTab.mWebViewController.closeTab(mTab); - } finally { - if (result != null) { - result.close(); - } - mTab.mLoadTask = null; - } - } - - } - - @Override - protected void persistThumbnail() { - if (mIsLive) { - super.persistThumbnail(); - } - } -} diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java index d4fd751..5d564a1 100644 --- a/src/com/android/browser/Tab.java +++ b/src/com/android/browser/Tab.java @@ -47,7 +47,6 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewStub; import android.webkit.BrowserDownloadListener; -import android.webkit.ClientCertRequestHandler; import android.webkit.ConsoleMessage; import android.webkit.GeolocationPermissions; import android.webkit.HttpAuthHandler; @@ -62,9 +61,7 @@ import android.webkit.WebResourceResponse; import android.webkit.WebStorage; import android.webkit.WebView; import android.webkit.WebView.PictureListener; -import android.webkit.WebViewClassic; import android.webkit.WebViewClient; -import android.webkit.WebViewClientClassicExt; import android.widget.CheckBox; import android.widget.Toast; @@ -327,7 +324,7 @@ class Tab implements PictureListener { // WebViewClient implementation for the main WebView // ------------------------------------------------------------------------- - private final WebViewClientClassicExt mWebViewClient = new WebViewClientClassicExt() { + private final WebViewClient mWebViewClient = new WebViewClient() { private Message mDontResend; private Message mResend; @@ -563,56 +560,7 @@ class Tab implements PictureListener { } } - /** - * Called when an SSL error occurred while loading a resource, but the - * WebView but chose to proceed anyway based on a decision retained - * from a previous response to onReceivedSslError(). We update our - * security state to reflect this. - */ - @Override - public void onProceededAfterSslError(WebView view, SslError error) { - handleProceededAfterSslError(error); - } - - /** - * Displays client certificate request to the user. - */ - @Override - public void onReceivedClientCertRequest(final WebView view, - final ClientCertRequestHandler handler, final String host_and_port) { - if (!mInForeground) { - handler.ignore(); - return; - } - int colon = host_and_port.lastIndexOf(':'); - String host; - int port; - if (colon == -1) { - host = host_and_port; - port = -1; - } else { - String portString = host_and_port.substring(colon + 1); - try { - port = Integer.parseInt(portString); - host = host_and_port.substring(0, colon); - } catch (NumberFormatException e) { - host = host_and_port; - port = -1; - } - } - KeyChain.choosePrivateKeyAlias( - mWebViewController.getActivity(), new KeyChainAliasCallback() { - @Override public void alias(String alias) { - if (alias == null) { - handler.cancel(); - return; - } - new KeyChainLookup(mContext, handler, alias).execute(); - } - }, null, null, host, port, null); - } - - /** + /** * Handles an HTTP authentication request. * * @param handler The authentication handler @@ -1028,39 +976,6 @@ class Tab implements PictureListener { mWebViewController.getVisitedHistory(callback); } - @Override - public void setupAutoFill(Message message) { - // Prompt the user to set up their profile. - final Message msg = message; - AlertDialog.Builder builder = new AlertDialog.Builder(mContext); - LayoutInflater inflater = (LayoutInflater) mContext.getSystemService( - Context.LAYOUT_INFLATER_SERVICE); - final View layout = inflater.inflate(R.layout.setup_autofill_dialog, null); - - builder.setView(layout) - .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int id) { - CheckBox disableAutoFill = (CheckBox) layout.findViewById( - R.id.setup_autofill_dialog_disable_autofill); - - if (disableAutoFill.isChecked()) { - // Disable autofill and show a toast with how to turn it on again. - mSettings.setAutofillEnabled(false); - Toast.makeText(mContext, - R.string.autofill_setup_dialog_negative_toast, - Toast.LENGTH_LONG).show(); - } else { - // Take user to the AutoFill profile editor. When they return, - // we will send the message that we pass here which will trigger - // the form to get filled out with their new profile. - mWebViewController.setupAutoFill(msg); - } - } - }) - .setNegativeButton(R.string.cancel, null) - .show(); - } }; // ------------------------------------------------------------------------- @@ -1069,12 +984,12 @@ class Tab implements PictureListener { // Subclass of WebViewClient used in subwindows to notify the main // WebViewClient of certain WebView activities. - private static class SubWindowClient extends WebViewClientClassicExt { + private static class SubWindowClient extends WebViewClient { // The main WebViewClient. - private final WebViewClientClassicExt mClient; + private final WebViewClient mClient; private final WebViewController mController; - SubWindowClient(WebViewClientClassicExt client, WebViewController controller) { + SubWindowClient(WebViewClient client, WebViewController controller) { mClient = client; mController = controller; } @@ -1100,11 +1015,6 @@ class Tab implements PictureListener { mClient.onReceivedSslError(view, handler, error); } @Override - public void onReceivedClientCertRequest(WebView view, - ClientCertRequestHandler handler, String host_and_port) { - mClient.onReceivedClientCertRequest(view, handler, host_and_port); - } - @Override public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { mClient.onReceivedHttpAuthRequest(view, handler, host, realm); @@ -1314,9 +1224,6 @@ class Tab implements PictureListener { // does a redirect after a period of time. The user could have // switched to another tab while waiting for the download to start. mMainView.setDownloadListener(mDownloadListener); - if (BrowserWebView.isClassic()) { - getWebViewClassic().setWebBackForwardListClient(mWebBackForwardListClient); - } TabControl tc = mWebViewController.getTabControl(); if (tc != null && tc.getOnThumbnailUpdatedListener() != null) { mMainView.setPictureListener(this); @@ -1552,18 +1459,6 @@ class Tab implements PictureListener { return mMainView; } - /** - * Return the underlying WebViewClassic implementation. As with getWebView, - * this maybe null for background tabs. - * @return The main WebView of this tab. - */ - WebViewClassic getWebViewClassic() { - if (!BrowserWebView.isClassic()) { - return null; - } - return WebViewClassic.fromWebView(mMainView); - } - void setViewContainer(View container) { mContainer = container; } @@ -1845,63 +1740,14 @@ class Tab implements PictureListener { * Must be called on the UI thread */ public ContentValues createSnapshotValues() { - WebViewClassic web = getWebViewClassic(); - if (web == null) return null; - ContentValues values = new ContentValues(); - values.put(Snapshots.TITLE, mCurrentState.mTitle); - values.put(Snapshots.URL, mCurrentState.mUrl); - values.put(Snapshots.BACKGROUND, web.getPageBackgroundColor()); - values.put(Snapshots.DATE_CREATED, System.currentTimeMillis()); - values.put(Snapshots.FAVICON, compressBitmap(getFavicon())); - Bitmap screenshot = Controller.createScreenshot(mMainView, - Controller.getDesiredThumbnailWidth(mContext), - Controller.getDesiredThumbnailHeight(mContext)); - values.put(Snapshots.THUMBNAIL, compressBitmap(screenshot)); - return values; + return null; } /** * Probably want to call this on a background thread */ public boolean saveViewState(ContentValues values) { - WebViewClassic web = getWebViewClassic(); - if (web == null) return false; - String path = UUID.randomUUID().toString(); - SaveCallback callback = new SaveCallback(); - OutputStream outs = null; - try { - outs = mContext.openFileOutput(path, Context.MODE_PRIVATE); - GZIPOutputStream stream = new GZIPOutputStream(outs); - synchronized (callback) { - web.saveViewState(stream, callback); - callback.wait(); - } - stream.flush(); - stream.close(); - } catch (Exception e) { - Log.w(LOGTAG, "Failed to save view state", e); - if (outs != null) { - try { - outs.close(); - } catch (IOException ignore) {} - } - File file = mContext.getFileStreamPath(path); - if (file.exists() && !file.delete()) { - file.deleteOnExit(); - } - return false; - } - File savedFile = mContext.getFileStreamPath(path); - if (!callback.mResult) { - if (!savedFile.delete()) { - savedFile.deleteOnExit(); - } - return false; - } - long size = savedFile.length(); - values.put(Snapshots.VIEWSTATE_PATH, path); - values.put(Snapshots.VIEWSTATE_SIZE, size); - return true; + return false; } public byte[] compressBitmap(Bitmap bitmap) { diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java index 150ece0..8cb500d 100644 --- a/src/com/android/browser/TabControl.java +++ b/src/com/android/browser/TabControl.java @@ -216,12 +216,6 @@ class TabControl { return createNewTab(false); } - SnapshotTab createSnapshotTab(long snapshotId) { - SnapshotTab t = new SnapshotTab(mController, snapshotId); - mTabs.add(t); - return t; - } - /** * Remove the parent child relationships from all tabs. */ @@ -670,7 +664,7 @@ class TabControl { // Display the new current tab mCurrentTab = mTabs.indexOf(newTab); WebView mainView = newTab.getWebView(); - boolean needRestore = !newTab.isSnapshot() && (mainView == null); + boolean needRestore = mainView == null; if (needRestore) { // Same work as in createNewTab() except don't do new Tab() mainView = createNewWebView(); diff --git a/src/com/android/browser/TitleBar.java b/src/com/android/browser/TitleBar.java index a0cc857..83c6626 100644 --- a/src/com/android/browser/TitleBar.java +++ b/src/com/android/browser/TitleBar.java @@ -53,7 +53,6 @@ public class TitleBar extends RelativeLayout { private AutologinBar mAutoLogin; private NavigationBarBase mNavBar; private boolean mUseQuickControls; - private SnapshotBar mSnapshotBar; //state private boolean mShowing; @@ -91,16 +90,6 @@ public class TitleBar extends RelativeLayout { mAutoLogin.setTitleBar(this); } - private void inflateSnapshotBar() { - if (mSnapshotBar != null) { - return; - } - - ViewStub stub = (ViewStub) findViewById(R.id.snapshotbar_stub); - mSnapshotBar = (SnapshotBar) stub.inflate(); - mSnapshotBar.setTitleBar(this); - } - @Override protected void onConfigurationChanged(Configuration config) { super.onConfigurationChanged(config); @@ -119,14 +108,10 @@ public class TitleBar extends RelativeLayout { } private void setFixedTitleBar() { - boolean isFixed = !mUseQuickControls - && !mContext.getResources().getBoolean(R.bool.hide_title); - isFixed |= mAccessibilityManager.isEnabled(); - isFixed |= !BrowserWebView.isClassic(); // If getParent() returns null, we are initializing ViewGroup parent = (ViewGroup)getParent(); - if (mIsFixedTitleBar == isFixed && parent != null) return; - mIsFixedTitleBar = isFixed; + if (mIsFixedTitleBar && parent != null) return; + mIsFixedTitleBar = true; setSkipTitleBarAnimations(true); show(); setSkipTitleBarAnimations(false); @@ -365,9 +350,7 @@ public class TitleBar extends RelativeLayout { } public boolean wantsToBeVisible() { - return inAutoLogin() - || (mSnapshotBar != null && mSnapshotBar.getVisibility() == View.VISIBLE - && mSnapshotBar.isAnimating()); + return inAutoLogin(); } private boolean inAutoLogin() { @@ -419,20 +402,7 @@ public class TitleBar extends RelativeLayout { } public void onTabDataChanged(Tab tab) { - if (mSnapshotBar != null) { - mSnapshotBar.onTabDataChanged(tab); - } - - if (tab.isSnapshot()) { - inflateSnapshotBar(); - mSnapshotBar.setVisibility(VISIBLE); - mNavBar.setVisibility(GONE); - } else { - if (mSnapshotBar != null) { - mSnapshotBar.setVisibility(GONE); - } - mNavBar.setVisibility(VISIBLE); - } + mNavBar.setVisibility(VISIBLE); } public void onScrollChanged() { diff --git a/src/com/android/browser/UiController.java b/src/com/android/browser/UiController.java index 683e473..f00f1a2 100644 --- a/src/com/android/browser/UiController.java +++ b/src/com/android/browser/UiController.java @@ -91,8 +91,6 @@ public interface UiController { boolean onOptionsItemSelected(MenuItem item); - SnapshotTab createNewSnapshotTab(long snapshotId, boolean setActive); - void loadUrl(Tab tab, String url); void setBlockEvents(boolean block); diff --git a/src/com/android/browser/UrlUtils.java b/src/com/android/browser/UrlUtils.java index e24000c..16b670b 100644 --- a/src/com/android/browser/UrlUtils.java +++ b/src/com/android/browser/UrlUtils.java @@ -33,6 +33,7 @@ public class UrlUtils { "(" + // begin group for schema "(?:http|https|file):\\/\\/" + "|(?:inline|data|about|javascript):" + + "|(?:.*:.*@)" + ")" + "(.*)" ); diff --git a/src/com/android/browser/WebViewController.java b/src/com/android/browser/WebViewController.java index e814ff9..498f8e7 100644 --- a/src/com/android/browser/WebViewController.java +++ b/src/com/android/browser/WebViewController.java @@ -111,8 +111,6 @@ public interface WebViewController { void closeTab(Tab tab); - void setupAutoFill(Message message); - void bookmarkedStatusHasChanged(Tab tab); void showAutoLogin(Tab tab); diff --git a/src/com/android/browser/XLargeUi.java b/src/com/android/browser/XLargeUi.java index df7a586..0d9b00e 100644 --- a/src/com/android/browser/XLargeUi.java +++ b/src/com/android/browser/XLargeUi.java @@ -32,7 +32,6 @@ import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; import android.webkit.WebView; -import android.webkit.WebViewClassic; import java.util.List; @@ -117,9 +116,6 @@ public class XLargeUi extends BaseUi { void stopWebViewScrolling() { BrowserWebView web = (BrowserWebView) mUiController.getCurrentWebView(); - if (web != null && BrowserWebView.isClassic()) { - WebViewClassic.fromWebView(web).stopScroll(); - } } @Override diff --git a/src/com/android/browser/preferences/GeneralPreferencesFragment.java b/src/com/android/browser/preferences/GeneralPreferencesFragment.java index c018474..26fb05f 100644 --- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java +++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java @@ -198,17 +198,4 @@ public class GeneralPreferencesFragment extends PreferenceFragment } return null; } - - @Override - public void onResume() { - super.onResume(); - - refreshUi(); - } - - void refreshUi() { - PreferenceScreen autoFillSettings = - (PreferenceScreen)findPreference(PreferenceKeys.PREF_AUTOFILL_PROFILE); - autoFillSettings.setDependency(PreferenceKeys.PREF_AUTOFILL_ENABLED); - } } diff --git a/src/com/android/browser/preferences/InvertedContrastPreview.java b/src/com/android/browser/preferences/InvertedContrastPreview.java index 2b8ad47..988f64a 100644 --- a/src/com/android/browser/preferences/InvertedContrastPreview.java +++ b/src/com/android/browser/preferences/InvertedContrastPreview.java @@ -19,8 +19,6 @@ package com.android.browser.preferences; import android.content.Context; import android.text.TextUtils; import android.util.AttributeSet; -import android.webkit.WebSettingsClassic; -import android.webkit.WebViewClassic; import com.android.browser.BrowserSettings; import com.android.browser.BrowserWebView; @@ -76,17 +74,6 @@ public class InvertedContrastPreview extends WebViewPreview { @Override protected void updatePreview(boolean forceReload) { - if (mWebView == null || !BrowserWebView.isClassic()) return; - - WebSettingsClassic ws = WebViewClassic.fromWebView(mWebView).getSettings(); - BrowserSettings bs = BrowserSettings.getInstance(); - ws.setProperty(WebViewProperties.gfxInvertedScreen, - bs.useInvertedRendering() ? "true" : "false"); - ws.setProperty(WebViewProperties.gfxInvertedScreenContrast, - Float.toString(bs.getInvertedContrast())); - if (forceReload) { - mWebView.loadData(mHtml, "text/html", null); - } } } |