Apps on SD Card project.
Settings for Manage Applications that allow the user to choose default application installaction location. Options are: internal flash, SD card, or automatic.
This commit is contained in:
@@ -354,4 +354,18 @@
|
||||
<item>3</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Apps on SD instalaltion location options in ApplicationSettings -->
|
||||
<string-array name="app_install_location_entries">
|
||||
<item>Internal device storage</item>
|
||||
<item>Removable SD card</item>
|
||||
<item>Let the system decide</item>
|
||||
</string-array>
|
||||
|
||||
<!-- Do not translate. -->
|
||||
<string-array name="app_install_location_values" translatable="false">
|
||||
<item>device</item>
|
||||
<item>sdcard</item>
|
||||
<item>auto</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
||||
|
@@ -1633,6 +1633,10 @@ found in the list of installed applications.</string>
|
||||
<string name="force_stop_dlg_title">Force Stop</string>
|
||||
<!-- Manage applications, text for dialog when killing persistent apps-->
|
||||
<string name="force_stop_dlg_text">This application will be restarted right way. Are you sure you want to force stop?</string>
|
||||
<!-- Manage applications, application installation location title -->
|
||||
<string name="app_install_location_title">Preferred install location</string>
|
||||
<!-- Manage applications. application installation location summary -->
|
||||
<string name="app_install_location_summary">Change the preferred installation location for new applications.</string>
|
||||
|
||||
<!-- Services settings screen, setting option name for the user to go to the screen to view running services -->
|
||||
<string name="runningservices_settings_title">Running services</string>
|
||||
|
@@ -25,7 +25,15 @@
|
||||
android:summaryOff="@string/install_unknown_applications"
|
||||
android:summaryOn="@string/install_unknown_applications"
|
||||
android:persistent="false" />
|
||||
|
||||
|
||||
<ListPreference
|
||||
android:key="app_install_location"
|
||||
android:title="@string/app_install_location_title"
|
||||
android:summary="@string/app_install_location_summary"
|
||||
android:persistent="false"
|
||||
android:entries="@array/app_install_location_entries"
|
||||
android:entryValues="@array/app_install_location_values"/>
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="quick_launch"
|
||||
android:title="@string/quick_launch_title"
|
||||
|
@@ -21,21 +21,35 @@ import android.content.DialogInterface;
|
||||
import android.content.res.Configuration;
|
||||
import android.os.Bundle;
|
||||
import android.preference.CheckBoxPreference;
|
||||
import android.preference.ListPreference;
|
||||
import android.preference.Preference;
|
||||
import android.preference.PreferenceActivity;
|
||||
import android.preference.PreferenceScreen;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.provider.Settings;
|
||||
|
||||
public class ApplicationSettings extends PreferenceActivity implements
|
||||
DialogInterface.OnClickListener {
|
||||
|
||||
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
|
||||
private static final String KEY_APP_INSTALL_LOCATION = "app_install_location";
|
||||
private static final String KEY_QUICK_LAUNCH = "quick_launch";
|
||||
|
||||
// App installation location. Default is ask the user.
|
||||
private static final int APP_INSTALL_AUTO = 0;
|
||||
private static final int APP_INSTALL_DEVICE = 1;
|
||||
private static final int APP_INSTALL_SDCARD = 2;
|
||||
|
||||
private static final String APP_INSTALL_DEVICE_ID = "device";
|
||||
private static final String APP_INSTALL_SDCARD_ID = "sdcard";
|
||||
private static final String APP_INSTALL_AUTO_ID = "auto";
|
||||
|
||||
private CheckBoxPreference mToggleAppInstallation;
|
||||
|
||||
|
||||
private ListPreference mInstallLocation;
|
||||
|
||||
private DialogInterface mWarnInstallApps;
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -45,6 +59,23 @@ public class ApplicationSettings extends PreferenceActivity implements
|
||||
mToggleAppInstallation = (CheckBoxPreference) findPreference(KEY_TOGGLE_INSTALL_APPLICATIONS);
|
||||
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
|
||||
|
||||
mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
|
||||
// Is app default install location set?
|
||||
boolean userSetInstLocation = (Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.SET_INSTALL_LOCATION, 0) != 0);
|
||||
if (!userSetInstLocation) {
|
||||
getPreferenceScreen().removePreference(mInstallLocation);
|
||||
} else {
|
||||
mInstallLocation.setValue(getAppInstallLocation());
|
||||
mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
String value = (String) newValue;
|
||||
handleUpdateAppInstallLocation(value);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS) {
|
||||
// No hard keyboard, remove the setting for quick launch
|
||||
Preference quickLaunchSetting = findPreference(KEY_QUICK_LAUNCH);
|
||||
@@ -52,6 +83,24 @@ public class ApplicationSettings extends PreferenceActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleUpdateAppInstallLocation(final String value) {
|
||||
if(APP_INSTALL_DEVICE_ID.equals(value)) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_DEVICE);
|
||||
} else if (APP_INSTALL_SDCARD_ID.equals(value)) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_SDCARD);
|
||||
} else if (APP_INSTALL_AUTO_ID.equals(value)) {
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||
} else {
|
||||
// Should not happen, default to prompt...
|
||||
Settings.System.putInt(getContentResolver(),
|
||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||
}
|
||||
mInstallLocation.setValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -70,7 +119,7 @@ public class ApplicationSettings extends PreferenceActivity implements
|
||||
setNonMarketAppsAllowed(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return super.onPreferenceTreeClick(preferenceScreen, preference);
|
||||
}
|
||||
|
||||
@@ -92,6 +141,21 @@ public class ApplicationSettings extends PreferenceActivity implements
|
||||
Settings.Secure.INSTALL_NON_MARKET_APPS, 0) > 0;
|
||||
}
|
||||
|
||||
private String getAppInstallLocation() {
|
||||
int selectedLocation = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.DEFAULT_INSTALL_LOCATION, APP_INSTALL_AUTO);
|
||||
if (selectedLocation == APP_INSTALL_DEVICE) {
|
||||
return APP_INSTALL_DEVICE_ID;
|
||||
} else if (selectedLocation == APP_INSTALL_SDCARD) {
|
||||
return APP_INSTALL_SDCARD_ID;
|
||||
} else if (selectedLocation == APP_INSTALL_AUTO) {
|
||||
return APP_INSTALL_AUTO_ID;
|
||||
} else {
|
||||
// Default value, should not happen.
|
||||
return APP_INSTALL_AUTO_ID;
|
||||
}
|
||||
}
|
||||
|
||||
private void warnAppInstallation() {
|
||||
mWarnInstallApps = new AlertDialog.Builder(this)
|
||||
.setTitle(getString(R.string.error_title))
|
||||
@@ -101,6 +165,4 @@ public class ApplicationSettings extends PreferenceActivity implements
|
||||
.setNegativeButton(android.R.string.no, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user