Use a queried package name for the IME settings activity.

This fixes a bug that if the package name of the IME settingsActivity
is different from it's class name, it wouldn't find the activity. This
allows the package name to be optionally specified in the XML or it
will be queried, for proper intent resolution.

Change-Id: Ib9e6e8ef7d59ad9e88300529873eed2b39fe9981
This commit is contained in:
Amith Yamasani
2010-03-09 15:03:53 -08:00
parent 29a6e1caa1
commit e086d9ad61

View File

@@ -120,7 +120,11 @@ public class LanguageSettings extends PreferenceActivity {
// If setting activity is available, add a setting screen entry. // If setting activity is available, add a setting screen entry.
if (null != property.getSettingsActivity()) { if (null != property.getSettingsActivity()) {
PreferenceScreen prefScreen = new PreferenceScreen(this, null); PreferenceScreen prefScreen = new PreferenceScreen(this, null);
prefScreen.setKey(property.getSettingsActivity()); String settingsActivity = property.getSettingsActivity();
if (settingsActivity.lastIndexOf("/") < 0) {
settingsActivity = property.getPackageName() + "/" + settingsActivity;
}
prefScreen.setKey(settingsActivity);
prefScreen.setTitle(label); prefScreen.setTitle(label);
if (N == 1) { if (N == 1) {
prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary)); prefScreen.setSummary(getString(R.string.onscreen_keyboard_settings_summary));
@@ -274,6 +278,11 @@ public class LanguageSettings extends PreferenceActivity {
String activityName = pref.getKey(); String activityName = pref.getKey();
String packageName = activityName.substring(0, activityName String packageName = activityName.substring(0, activityName
.lastIndexOf(".")); .lastIndexOf("."));
int slash = activityName.indexOf("/");
if (slash > 0) {
packageName = activityName.substring(0, slash);
activityName = activityName.substring(slash + 1);
}
if (activityName.length() > 0) { if (activityName.length() > 0) {
Intent i = new Intent(Intent.ACTION_MAIN); Intent i = new Intent(Intent.ACTION_MAIN);
i.setClassName(packageName, activityName); i.setClassName(packageName, activityName);