summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2010-12-01 19:29:32 -0800
committerJohn Reck <jreck@google.com>2010-12-03 10:28:16 -0800
commit63bb687da46c285f6a71ff47c9f00e46111ffec2 (patch)
tree900c9b592664af561b12290500e7fc77253bb96c /src
parenteff89529627530aef9f7760d8793934ee862470a (diff)
downloadpackages_apps_browser-63bb687da46c285f6a71ff47c9f00e46111ffec2.zip
packages_apps_browser-63bb687da46c285f6a71ff47c9f00e46111ffec2.tar.gz
packages_apps_browser-63bb687da46c285f6a71ff47c9f00e46111ffec2.tar.bz2
Debug settings changes
Bug: 3250498 Makes OpenGL rendering and user agent normally visible in settings->debug Changing the OpenGL setting now automatically restarts the browser Change-Id: I04036b580f2463f77376edb4bee2dfefe3d123ed
Diffstat (limited to 'src')
-rw-r--r--src/com/android/browser/BrowserActivity.java17
-rw-r--r--src/com/android/browser/BrowserPreferencesPage.java2
-rw-r--r--src/com/android/browser/BrowserSettings.java35
-rw-r--r--src/com/android/browser/preferences/DebugPreferencesFragment.java31
4 files changed, 74 insertions, 11 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java
index a8c393a..1c15153 100644
--- a/src/com/android/browser/BrowserActivity.java
+++ b/src/com/android/browser/BrowserActivity.java
@@ -39,6 +39,9 @@ import android.view.accessibility.AccessibilityManager;
public class BrowserActivity extends Activity {
+ public static final String ACTION_RESTART = "--restart--";
+ private static final String EXTRA_STATE = "state";
+
private final static String LOGTAG = "browser";
private final static boolean LOGV_ENABLED =
@@ -94,6 +97,10 @@ public class BrowserActivity extends Activity {
mController.setUi(mUi);
mController.setWebViewFactory((BaseUi) mUi);
+ Bundle state = getIntent().getBundleExtra(EXTRA_STATE);
+ if (state != null && icicle == null) {
+ icicle = state;
+ }
mController.start(icicle, getIntent());
}
@@ -104,6 +111,16 @@ public class BrowserActivity extends Activity {
@Override
protected void onNewIntent(Intent intent) {
+ if (ACTION_RESTART.equals(intent.getAction())) {
+ Bundle outState = new Bundle();
+ mController.onSaveInstanceState(outState);
+ finish();
+ getApplicationContext().startActivity(
+ new Intent(getApplicationContext(), BrowserActivity.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .putExtra(EXTRA_STATE, outState));
+ return;
+ }
mController.handleNewIntent(intent);
}
diff --git a/src/com/android/browser/BrowserPreferencesPage.java b/src/com/android/browser/BrowserPreferencesPage.java
index d93e70f..c47675d 100644
--- a/src/com/android/browser/BrowserPreferencesPage.java
+++ b/src/com/android/browser/BrowserPreferencesPage.java
@@ -34,7 +34,7 @@ public class BrowserPreferencesPage extends PreferenceActivity {
public void onBuildHeaders(List<Header> target) {
loadHeadersFromResource(R.xml.preference_headers, target);
- if (BrowserSettings.getInstance().showDebugSettings()) {
+ if (BrowserSettings.DEV_BUILD || BrowserSettings.getInstance().showDebugSettings()) {
Header debug = new Header();
debug.title = getText(R.string.pref_development_title);
debug.fragment = DebugPreferencesFragment.class.getName();
diff --git a/src/com/android/browser/BrowserSettings.java b/src/com/android/browser/BrowserSettings.java
index ba2f3fe..61ef76b 100644
--- a/src/com/android/browser/BrowserSettings.java
+++ b/src/com/android/browser/BrowserSettings.java
@@ -24,6 +24,7 @@ import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ActivityInfo;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
@@ -68,8 +69,7 @@ import java.util.Observable;
* To remove an observer:
* s.deleteObserver(webView.getSettings());
*/
-public class BrowserSettings extends Observable {
-
+public class BrowserSettings extends Observable implements OnSharedPreferenceChangeListener {
// Private variables for settings
// NOTE: these defaults need to be kept in sync with the XML
// until the performance of PreferenceManager.setDefaultValues()
@@ -164,6 +164,8 @@ public class BrowserSettings extends Observable {
public final static String PREF_AUTOFILL_ENABLED = "autofill_enabled";
public final static String PREF_AUTOFILL_PROFILE = "autofill_profile";
public final static String PREF_AUTOFILL_ACTIVE_PROFILE_ID = "autofill_active_profile_id";
+ public final static String PREF_HARDWARE_ACCEL = "enable_hardware_accel";
+ public final static String PREF_USER_AGENT = "user_agent";
private static final String DESKTOP_USERAGENT = "Mozilla/5.0 (Macintosh; " +
"U; Intel Mac OS X 10_6_3; en-us) AppleWebKit/533.16 (KHTML, " +
@@ -189,6 +191,9 @@ public class BrowserSettings extends Observable {
public static final Uri RLZ_PROVIDER_URI = Uri.parse("content://" + RLZ_PROVIDER + "/");
+ // Set to true to enable some of the about:debug options
+ public static final boolean DEV_BUILD = true;
+
private Controller mController;
// Single instance of the BrowserSettings for use in the Browser app.
@@ -390,6 +395,7 @@ public class BrowserSettings extends Observable {
// PreferenceManager.setDefaultValues is TOO SLOW, need to manually keep
// the defaults in sync
+ p.registerOnSharedPreferenceChangeListener(BrowserSettings.this);
syncSharedPreferences(mContext, p);
synchronized (sSingleton) {
@@ -482,13 +488,13 @@ public class BrowserSettings extends Observable {
tracing = p.getBoolean("enable_tracing", tracing);
lightTouch = p.getBoolean("enable_light_touch", lightTouch);
navDump = p.getBoolean("enable_nav_dump", navDump);
- userAgent = Integer.parseInt(p.getString("user_agent", "0"));
}
- // This setting can only be modified when the debug settings have been
- // enabled but it is read and used by the browser at startup so we must
- // initialize it regardless of the status of the debug settings.
- hardwareAccelerated = p.getBoolean("enable_hardware_accel", hardwareAccelerated);
+ // Only set these on startup if it is a dev build
+ if (DEV_BUILD) {
+ userAgent = Integer.parseInt(p.getString(PREF_USER_AGENT, "0"));
+ hardwareAccelerated = p.getBoolean(PREF_HARDWARE_ACCEL, hardwareAccelerated);
+ }
// JS flags is loaded from DB even if showDebugSettings is false,
// so that it can be set once and be effective all the time.
@@ -642,10 +648,10 @@ public class BrowserSettings extends Observable {
}
/*
- * Package level method for obtaining a single app instance of the
+ * Application level method for obtaining a single app instance of the
* BrowserSettings.
*/
- /*package*/ static BrowserSettings getInstance() {
+ public static BrowserSettings getInstance() {
if (sSingleton == null ) {
sSingleton = new BrowserSettings();
}
@@ -821,4 +827,15 @@ public class BrowserSettings extends Observable {
return null;
}
}
+
+ @Override
+ public void onSharedPreferenceChanged(
+ SharedPreferences p, String key) {
+ if (PREF_HARDWARE_ACCEL.equals(key)) {
+ hardwareAccelerated = p.getBoolean(PREF_HARDWARE_ACCEL, hardwareAccelerated);
+ } else if (PREF_USER_AGENT.equals(key)) {
+ userAgent = Integer.parseInt(p.getString(PREF_USER_AGENT, "0"));
+ update();
+ }
+ }
}
diff --git a/src/com/android/browser/preferences/DebugPreferencesFragment.java b/src/com/android/browser/preferences/DebugPreferencesFragment.java
index d643a97..0a82371 100644
--- a/src/com/android/browser/preferences/DebugPreferencesFragment.java
+++ b/src/com/android/browser/preferences/DebugPreferencesFragment.java
@@ -16,17 +16,46 @@
package com.android.browser.preferences;
+import com.android.browser.BrowserActivity;
+import com.android.browser.BrowserSettings;
+import com.android.browser.Controller;
import com.android.browser.R;
+import android.content.Context;
+import android.content.Intent;
+import android.os.AsyncTask;
import android.os.Bundle;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceChangeListener;
+import android.preference.PreferenceActivity.Header;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager.OnActivityResultListener;
-public class DebugPreferencesFragment extends PreferenceFragment {
+import java.io.IOException;
+import java.io.Serializable;
+
+public class DebugPreferencesFragment extends PreferenceFragment
+ implements OnPreferenceChangeListener {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the XML preferences file
addPreferencesFromResource(R.xml.debug_preferences);
+
+ if (BrowserSettings.getInstance().showDebugSettings()) {
+ addPreferencesFromResource(R.xml.hidden_debug_preferences);
+ }
+
+ Preference e = findPreference(BrowserSettings.PREF_HARDWARE_ACCEL);
+ e.setOnPreferenceChangeListener(this);
+ }
+
+ @Override
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ // Attempt to restart
+ startActivity(new Intent(BrowserActivity.ACTION_RESTART, null,
+ getActivity(), BrowserActivity.class));
+ return true;
}
}