FileDocCategorySizeDatePackage
ApplicationSettings.javaAPI DocAndroid 1.5 API3743Wed May 06 22:42:48 BST 2009com.android.settings

ApplicationSettings

public class ApplicationSettings extends android.preference.PreferenceActivity implements DialogInterface.OnClickListener

Fields Summary
private static final String
KEY_TOGGLE_INSTALL_APPLICATIONS
private static final String
KEY_QUICK_LAUNCH
private android.preference.CheckBoxPreference
mToggleAppInstallation
private android.content.DialogInterface
mWarnInstallApps
Constructors Summary
Methods Summary
private booleanisNonMarketAppsAllowed()

        return Settings.Secure.getInt(getContentResolver(), 
                                      Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
    
public voidonClick(android.content.DialogInterface dialog, int which)

        if (dialog == mWarnInstallApps && which == DialogInterface.BUTTON1) {
            setNonMarketAppsAllowed(true);
            mToggleAppInstallation.setChecked(true);
        }
    
protected voidonCreate(android.os.Bundle icicle)

    
    
        
        super.onCreate(icicle);

        addPreferencesFromResource(R.xml.application_settings);

        mToggleAppInstallation = (CheckBoxPreference) findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
        mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());

        if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) {
            // No hard keyboard, remove the setting for quick launch
            Preference quickLaunchSetting = findPreference(KEY_QUICK_LAUNCH);
            getPreferenceScreen().removePreference(quickLaunchSetting);
        }
    
public booleanonPreferenceTreeClick(android.preference.PreferenceScreen preferenceScreen, android.preference.Preference preference)

        if (preference == mToggleAppInstallation) {
            if (mToggleAppInstallation.isChecked()) {
                mToggleAppInstallation.setChecked(false);
                warnAppInstallation();
            } else {
                setNonMarketAppsAllowed(false);
            }
        }
        
        return super.onPreferenceTreeClick(preferenceScreen, preference);
    
private voidsetNonMarketAppsAllowed(boolean enabled)

        // Change the system setting
        Settings.Secure.putInt(getContentResolver(), Settings.Secure.INSTALL_NON_MARKET_APPS, 
                                enabled ? 1 : 0);
    
private voidwarnAppInstallation()

        mWarnInstallApps = new AlertDialog.Builder(this)
                .setTitle(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();