advanced settings

Change-Id: Ibc3889e2ab0569f851ec46fe4d1cb1b4920ea5be
This commit is contained in:
Joe Onorato
2011-04-06 18:26:20 -07:00
parent 7c79299672
commit 4c0c2bea9e
3 changed files with 46 additions and 4 deletions

View File

@@ -2108,6 +2108,10 @@
from unknown sources. You agree that you are solely responsible for any
damage to your phone or loss of data that may result from using
these applications.</string>
<!-- Applications settings screen, setting check box title. If checked, applications show more settings options. -->
<string name="advanced_settings">Advanced settings</string>
<!-- Applications settings screen, setting check box summary. This is the summary for "Advanced settings" checkbox -->
<string name="advanced_settings_summary">Enable more settings options.</string>
<!-- Manage applications, individual application info screen title. For example, if they click on "Browser" in "Manage applications", the title of the next screen will be this -->
<string name="application_info_label">Application info</string>
<!-- Manage applications, individual application info screen, section heading for stuff relating to an app's storage settings. -->

View File

@@ -54,6 +54,13 @@
android:summaryOn="@string/install_unknown_applications"
android:persistent="false" />
<CheckBoxPreference
android:key="toggle_advanced_settings"
android:title="@string/advanced_settings"
android:summaryOff="@string/advanced_settings_summary"
android:summaryOn="@string/advanced_settings_summary"
android:persistent="false" />
<ListPreference
android:key="app_install_location"
android:title="@string/app_install_location_title"

View File

@@ -18,6 +18,7 @@ package com.android.settings;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
@@ -26,11 +27,13 @@ import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.provider.Settings;
import android.util.Log;
public class ApplicationSettings extends SettingsPreferenceFragment implements
DialogInterface.OnClickListener {
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
private static final String KEY_TOGGLE_ADVANCED_SETTINGS = "toggle_advanced_settings";
private static final String KEY_APP_INSTALL_LOCATION = "app_install_location";
// App installation location. Default is ask the user.
@@ -43,9 +46,8 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
private static final String APP_INSTALL_AUTO_ID = "auto";
private CheckBoxPreference mToggleAppInstallation;
private CheckBoxPreference mToggleAdvancedSettings;
private ListPreference mInstallLocation;
private DialogInterface mWarnInstallApps;
@Override
@@ -54,9 +56,19 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.application_settings);
mToggleAppInstallation = (CheckBoxPreference) findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation = (CheckBoxPreference)findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
mToggleAdvancedSettings = (CheckBoxPreference)findPreference(
KEY_TOGGLE_ADVANCED_SETTINGS);
mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
// not ready for prime time yet
if (false) {
getPreferenceScreen().removePreference(mInstallLocation);
}
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
// Is app default install location set?
boolean userSetInstLocation = (Settings.System.getInt(getContentResolver(),
@@ -110,6 +122,9 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
} else {
setNonMarketAppsAllowed(false);
}
} else if (preference == mToggleAdvancedSettings) {
boolean value = mToggleAdvancedSettings.isChecked();
setAdvancedSettingsEnabled(value);
}
return super.onPreferenceTreeClick(preferenceScreen, preference);
@@ -128,6 +143,22 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
enabled ? 1 : 0);
}
private boolean isAdvancedSettingsEnabled() {
return Settings.System.getInt(getContentResolver(),
Settings.System.ADVANCED_SETTINGS,
Settings.System.ADVANCED_SETTINGS_DEFAULT) > 0;
}
private void setAdvancedSettingsEnabled(boolean enabled) {
int value = enabled ? 1 : 0;
// Change the system setting
Settings.Secure.putInt(getContentResolver(), Settings.System.ADVANCED_SETTINGS, value);
// TODO: the settings thing should broadcast this for thread safety purposes.
Intent intent = new Intent(Intent.ACTION_ADVANCED_SETTINGS_CHANGED);
intent.putExtra("state", value);
getActivity().sendBroadcast(intent);
}
private boolean isNonMarketAppsAllowed() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;