Refactoring in Settings/Applications

Battery, Development moved to main menu.
Unknown sources moved to Security.
Main menu links directly to ManageApplications.
ApplicationSettings was kept in case an other app referenced it.

Change-Id: I0271d4222cfc192f9235f21e06bf3b56f77db1a4
This commit is contained in:
Gilles Debunne
2011-06-21 12:47:17 -07:00
parent f61d5570ee
commit 2c88a877f8
10 changed files with 102 additions and 95 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 775 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 B

View File

@@ -1321,7 +1321,7 @@
<!-- Main Settings screen setting option name to go into the sound settings screen --> <!-- Main Settings screen setting option name to go into the sound settings screen -->
<string name="sound_settings_title">Sound</string> <string name="sound_settings_title">Sound</string>
<!-- Main Settings screen setting option name to go into the display settings screen --> <!-- Main Settings screen setting option name to go into the display settings screen -->
<string name="display_settings_title">Screen</string> <string name="display_settings_title">Display</string>
<!-- Sound settings screen heading --> <!-- Sound settings screen heading -->
<string name="sound_settings">Sound settings</string> <string name="sound_settings">Sound settings</string>
<!-- Sound settings screen, setting option name checkbox --> <!-- Sound settings screen, setting option name checkbox -->
@@ -2668,7 +2668,7 @@ found in the list of installed applications.</string>
<skip /> <skip />
<!-- Activity title for App Fuel Gauge summary --> <!-- Activity title for App Fuel Gauge summary -->
<string name="power_usage_summary_title">Battery use</string> <string name="power_usage_summary_title">Battery</string>
<!-- Activity title summary for App Fuel Gauge summary --> <!-- Activity title summary for App Fuel Gauge summary -->
<string name="power_usage_summary">What has been using the battery</string> <string name="power_usage_summary">What has been using the battery</string>
<!-- Message to show when battery usage data is not available [CHAR LIMIT=30] --> <!-- Message to show when battery usage data is not available [CHAR LIMIT=30] -->
@@ -3118,11 +3118,11 @@ found in the list of installed applications.</string>
<!-- Sound settings screen, setting option summary text --> <!-- Sound settings screen, setting option summary text -->
<string name="emergency_tone_summary">Set behavior when an emergency call is placed</string> <string name="emergency_tone_summary">Set behavior when an emergency call is placed</string>
<!-- Privacy Settings screen --><skip /> <!-- Backup and reset Settings screen --><skip />
<!-- Privacy settings menu title --> <!-- Backup and reset settings menu title -->
<string name="privacy_settings">Privacy</string> <string name="privacy_settings">Backup &amp; reset</string>
<!-- Privacy settings activity title --> <!-- Privacy settings activity title -->
<string name="privacy_settings_title">Privacy settings</string> <string name="privacy_settings_title">Backup &amp; reset</string>
<!-- Backup section title --> <!-- Backup section title -->
<string name="backup_section_title">Backup and restore</string> <string name="backup_section_title">Backup and restore</string>
<!-- Personal data section title --> <!-- Personal data section title -->

View File

@@ -14,6 +14,13 @@
limitations under the License. limitations under the License.
--> -->
<!--
This code is deprecated. This screen is no longer used in Settings.
The ApplicationSettings class is kept in case an external app references it directly.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/applications_settings_header" android:title="@string/applications_settings_header"
android:summary="@string/applications_settings_summary" android:summary="@string/applications_settings_summary"
@@ -40,20 +47,6 @@
android:value="com.android.settings.Settings$StorageUseActivity" /> android:value="com.android.settings.Settings$StorageUseActivity" />
</PreferenceScreen> </PreferenceScreen>
<PreferenceScreen
android:key="power_usage"
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
android:title="@string/power_usage_summary_title"
android:summary="@string/power_usage_summary">
</PreferenceScreen>
<CheckBoxPreference
android:key="toggle_install_applications"
android:title="@string/install_applications"
android:summaryOff="@string/install_unknown_applications"
android:summaryOn="@string/install_unknown_applications"
android:persistent="false" />
<CheckBoxPreference <CheckBoxPreference
android:key="toggle_advanced_settings" android:key="toggle_advanced_settings"
android:title="@string/advanced_settings" android:title="@string/advanced_settings"
@@ -80,12 +73,5 @@
</PreferenceScreen> </PreferenceScreen>
--> -->
<PreferenceScreen
android:title="@string/development_settings_title"
android:summary="@string/development_settings_summary"
android:fragment="com.android.settings.DevelopmentSettings">
</PreferenceScreen>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -39,10 +39,19 @@
<PreferenceCategory android:title="@string/device_admin_title" <PreferenceCategory android:title="@string/device_admin_title"
android:persistent="false"> android:persistent="false">
<Preference android:title="@string/manage_device_admin" <Preference android:title="@string/manage_device_admin"
android:summary="@string/manage_device_admin_summary" android:summary="@string/manage_device_admin_summary"
android:persistent="false" android:persistent="false"
android:fragment="com.android.settings.DeviceAdminSettings"/> android:fragment="com.android.settings.DeviceAdminSettings"/>
<CheckBoxPreference
android:key="toggle_install_applications"
android:title="@string/install_applications"
android:summaryOff="@string/install_unknown_applications"
android:summaryOn="@string/install_unknown_applications"
android:persistent="false" />
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory android:title="@string/credentials_title" <PreferenceCategory android:title="@string/credentials_title"

View File

@@ -92,9 +92,16 @@
android:icon="@drawable/ic_settings_storage" android:icon="@drawable/ic_settings_storage"
android:title="@string/storage_settings" /> android:title="@string/storage_settings" />
<!-- Battery -->
<header
android:id="@+id/battery_settings"
android:fragment="com.android.settings.fuelgauge.PowerUsageSummary"
android:icon="@drawable/ic_settings_battery"
android:title="@string/power_usage_summary_title" />
<!-- Application Settings --> <!-- Application Settings -->
<header <header
android:fragment="com.android.settings.ApplicationSettings" android:fragment="com.android.settings.applications.ManageApplications"
android:icon="@drawable/ic_settings_applications" android:icon="@drawable/ic_settings_applications"
android:title="@string/applications_settings" android:title="@string/applications_settings"
android:id="@+id/application_settings" /> android:id="@+id/application_settings" />
@@ -133,13 +140,6 @@
android:title="@string/security_settings_title" android:title="@string/security_settings_title"
android:id="@+id/security_settings" /> android:id="@+id/security_settings" />
<!-- Privacy -->
<header
android:fragment="com.android.settings.PrivacySettings"
android:icon="@drawable/ic_settings_privacy"
android:title="@string/privacy_settings"
android:id="@+id/privacy_settings" />
<!-- Language --> <!-- Language -->
<header <header
android:id="@+id/language_settings" android:id="@+id/language_settings"
@@ -147,6 +147,13 @@
android:icon="@drawable/ic_settings_language" android:icon="@drawable/ic_settings_language"
android:title="@string/language_settings" /> android:title="@string/language_settings" />
<!-- Backup and reset -->
<header
android:fragment="com.android.settings.PrivacySettings"
android:icon="@drawable/ic_settings_privacy"
android:title="@string/privacy_settings"
android:id="@+id/privacy_settings" />
<!-- SYSTEM --> <!-- SYSTEM -->
<header android:title="@string/header_category_system" /> <header android:title="@string/header_category_system" />
@@ -172,6 +179,13 @@
android:icon="@drawable/ic_settings_accessibility" android:icon="@drawable/ic_settings_accessibility"
android:title="@string/accessibility_settings" /> android:title="@string/accessibility_settings" />
<!-- Development -->
<header
android:id="@+id/development_settings"
android:fragment="com.android.settings.DevelopmentSettings"
android:icon="@drawable/ic_settings_development"
android:title="@string/development_settings_title" />
<!-- About Device --> <!-- About Device -->
<header <header
android:id="@+id/about_settings" android:id="@+id/about_settings"

View File

@@ -16,23 +16,17 @@
package com.android.settings; package com.android.settings;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle; import android.os.Bundle;
import android.preference.CheckBoxPreference; import android.preference.CheckBoxPreference;
import android.preference.ListPreference; import android.preference.ListPreference;
import android.preference.Preference; import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener; import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceScreen;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log;
public class ApplicationSettings extends SettingsPreferenceFragment implements public class ApplicationSettings extends SettingsPreferenceFragment {
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_TOGGLE_ADVANCED_SETTINGS = "toggle_advanced_settings";
private static final String KEY_APP_INSTALL_LOCATION = "app_install_location"; private static final String KEY_APP_INSTALL_LOCATION = "app_install_location";
@@ -45,10 +39,8 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
private static final String APP_INSTALL_SDCARD_ID = "sdcard"; private static final String APP_INSTALL_SDCARD_ID = "sdcard";
private static final String APP_INSTALL_AUTO_ID = "auto"; private static final String APP_INSTALL_AUTO_ID = "auto";
private CheckBoxPreference mToggleAppInstallation;
private CheckBoxPreference mToggleAdvancedSettings; private CheckBoxPreference mToggleAdvancedSettings;
private ListPreference mInstallLocation; private ListPreference mInstallLocation;
private DialogInterface mWarnInstallApps;
@Override @Override
public void onCreate(Bundle icicle) { public void onCreate(Bundle icicle) {
@@ -56,10 +48,6 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.application_settings); addPreferencesFromResource(R.xml.application_settings);
mToggleAppInstallation = (CheckBoxPreference)findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
mToggleAdvancedSettings = (CheckBoxPreference)findPreference( mToggleAdvancedSettings = (CheckBoxPreference)findPreference(
KEY_TOGGLE_ADVANCED_SETTINGS); KEY_TOGGLE_ADVANCED_SETTINGS);
mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled()); mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
@@ -106,24 +94,9 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
mInstallLocation.setValue(value); mInstallLocation.setValue(value);
} }
@Override
public void onDestroy() {
super.onDestroy();
if (mWarnInstallApps != null) {
mWarnInstallApps.dismiss();
}
}
@Override @Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
if (preference == mToggleAppInstallation) { if (preference == mToggleAdvancedSettings) {
if (mToggleAppInstallation.isChecked()) {
mToggleAppInstallation.setChecked(false);
warnAppInstallation();
} else {
setNonMarketAppsAllowed(false);
}
} else if (preference == mToggleAdvancedSettings) {
boolean value = mToggleAdvancedSettings.isChecked(); boolean value = mToggleAdvancedSettings.isChecked();
setAdvancedSettingsEnabled(value); setAdvancedSettingsEnabled(value);
} }
@@ -131,19 +104,6 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);
} }
public void onClick(DialogInterface dialog, int which) {
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
setNonMarketAppsAllowed(true);
mToggleAppInstallation.setChecked(true);
}
}
private void setNonMarketAppsAllowed(boolean enabled) {
// Change the system setting
Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS,
enabled ? 1 : 0);
}
private boolean isAdvancedSettingsEnabled() { private boolean isAdvancedSettingsEnabled() {
return Settings.System.getInt(getContentResolver(), return Settings.System.getInt(getContentResolver(),
Settings.System.ADVANCED_SETTINGS, Settings.System.ADVANCED_SETTINGS,
@@ -160,11 +120,6 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
getActivity().sendBroadcast(intent); getActivity().sendBroadcast(intent);
} }
private boolean isNonMarketAppsAllowed() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
}
private String getAppInstallLocation() { private String getAppInstallLocation() {
int selectedLocation = Settings.System.getInt(getContentResolver(), int selectedLocation = Settings.System.getInt(getContentResolver(),
Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO); Settings.Secure.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
@@ -179,15 +134,4 @@ public class ApplicationSettings extends SettingsPreferenceFragment implements
return APP_INSTALL_AUTO_ID; return APP_INSTALL_AUTO_ID;
} }
} }
private void warnAppInstallation() {
// TODO: DialogFragment?
mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(
getResources().getString(R.string.error_title))
.setIcon(com.android.internal.R.drawable.ic_dialog_alert)
.setMessage(getResources().getString(R.string.install_all_warning))
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, null)
.show();
}
} }

View File

@@ -19,8 +19,10 @@ package com.android.settings;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT; import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import android.app.AlertDialog;
import android.app.admin.DevicePolicyManager; import android.app.admin.DevicePolicyManager;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.os.Vibrator; import android.os.Vibrator;
@@ -43,7 +45,7 @@ import java.util.ArrayList;
* Gesture lock pattern settings. * Gesture lock pattern settings.
*/ */
public class SecuritySettings extends SettingsPreferenceFragment public class SecuritySettings extends SettingsPreferenceFragment
implements OnPreferenceChangeListener { implements OnPreferenceChangeListener, DialogInterface.OnClickListener {
// Lock Settings // Lock Settings
private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change"; private static final String KEY_UNLOCK_SET_OR_CHANGE = "unlock_set_or_change";
@@ -58,6 +60,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_SIM_LOCK = "sim_lock"; private static final String KEY_SIM_LOCK = "sim_lock";
private static final String KEY_SHOW_PASSWORD = "show_password"; private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_RESET_CREDENTIALS = "reset_credentials"; private static final String KEY_RESET_CREDENTIALS = "reset_credentials";
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
DevicePolicyManager mDPM; DevicePolicyManager mDPM;
@@ -72,6 +75,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
private Preference mResetCredentials; private Preference mResetCredentials;
private CheckBoxPreference mToggleAppInstallation;
private DialogInterface mWarnInstallApps;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
@@ -167,9 +173,50 @@ public class SecuritySettings extends SettingsPreferenceFragment
// Credential storage // Credential storage
mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS); mResetCredentials = root.findPreference(KEY_RESET_CREDENTIALS);
mToggleAppInstallation = (CheckBoxPreference) findPreference(
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
return root; return root;
} }
private boolean isNonMarketAppsAllowed() {
return Settings.Secure.getInt(getContentResolver(),
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
}
private void setNonMarketAppsAllowed(boolean enabled) {
// Change the system setting
Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS,
enabled ? 1 : 0);
}
private void warnAppInstallation() {
// TODO: DialogFragment?
mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(
getResources().getString(R.string.error_title))
.setIcon(com.android.internal.R.drawable.ic_dialog_alert)
.setMessage(getResources().getString(R.string.install_all_warning))
.setPositiveButton(android.R.string.yes, this)
.setNegativeButton(android.R.string.no, null)
.show();
}
public void onClick(DialogInterface dialog, int which) {
if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON_POSITIVE) {
setNonMarketAppsAllowed(true);
mToggleAppInstallation.setChecked(true);
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (mWarnInstallApps != null) {
mWarnInstallApps.dismiss();
}
}
private void setupLockAfterPreference() { private void setupLockAfterPreference() {
// Compatible with pre-Froyo // Compatible with pre-Froyo
long currentTimeout = Settings.Secure.getLong(getContentResolver(), long currentTimeout = Settings.Secure.getLong(getContentResolver(),
@@ -272,6 +319,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
} else if (preference == mShowPassword) { } else if (preference == mShowPassword) {
Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD,
mShowPassword.isChecked() ? 1 : 0); mShowPassword.isChecked() ? 1 : 0);
} else if (preference == mToggleAppInstallation) {
if (mToggleAppInstallation.isChecked()) {
mToggleAppInstallation.setChecked(false);
warnAppInstallation();
} else {
setNonMarketAppsAllowed(false);
}
} else { } else {
// If we didn't handle it, let preferences handle it. // If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference); return super.onPreferenceTreeClick(preferenceScreen, preference);