Loading res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4768,6 +4768,8 @@ <!-- Home application selection - uninstall button [CHAR LIMIT=80] --> <string name="home_app_uninstall_button">Uninstall this application</string> <!-- Message to user that Home Settings will be hidden because there is now only one available home application --> <string name="only_one_home_message">Home settings will be hidden until you install another home application.</string> <!-- Warning message when changing a global setting for a tablet.[CHAR LIMIT=none] --> <string name="global_change_warning" product="tablet">This setting affects all users on this tablet.</string> Loading src/com/android/settings/HomeSettings.java +18 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; Loading Loading @@ -50,6 +51,8 @@ public class HomeSettings extends SettingsPreferenceFragment { public static final String CURRENT_HOME = "current_home"; public static final String HOME_SHOW_NOTICE = "show"; PreferenceGroup mPrefGroup; PackageManager mPm; Loading @@ -57,6 +60,7 @@ public class HomeSettings extends SettingsPreferenceFragment { ArrayList<HomeAppPreference> mPrefs; HomeAppPreference mCurrentHome = null; final IntentFilter mHomeFilter; boolean mShowNotice; public HomeSettings() { mHomeFilter = new IntentFilter(Intent.ACTION_MAIN); Loading Loading @@ -126,6 +130,17 @@ public class HomeSettings extends SettingsPreferenceFragment { } } } // If we're down to just one possible home app, back out of this settings // fragment and show a dialog explaining to the user that they won't see // 'Home' settings now until such time as there are multiple available. if (mPrefs.size() < 2) { if (mShowNotice) { mShowNotice = false; Settings.requestHomeNotice(); } finishFragment(); } } void buildHomeActivitiesList() { Loading Loading @@ -176,6 +191,9 @@ public class HomeSettings extends SettingsPreferenceFragment { mPm = getPackageManager(); mPrefGroup = (PreferenceGroup) findPreference("home"); Bundle args = getArguments(); mShowNotice = (args != null) && args.getBoolean(HOME_SHOW_NOTICE, false); } @Override Loading src/com/android/settings/Settings.java +42 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ package com.android.settings; import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.OnAccountsUpdateListener; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; import android.content.ComponentName; Loading @@ -27,7 +31,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; Loading Loading @@ -117,6 +120,10 @@ public class Settings extends PreferenceActivity private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER"; private static final String SAVE_KEY_PARENT_HEADER = "com.android.settings.PARENT_HEADER"; static final int DIALOG_ONLY_ONE_HOME = 1; private static boolean sShowNoHomeNotice = false; private String mFragmentClass; private int mTopLevelHeaderId; private Header mFirstHeader; Loading Loading @@ -684,8 +691,22 @@ public class Settings extends PreferenceActivity getPackageManager().getHomeActivities(homeApps); if (homeApps.size() < 2) { // When there's only one available home app, omit this settings // category entirely at the top level UI. // category entirely at the top level UI. If the user just // uninstalled the penultimate home app candidiate, we also // now tell them about why they aren't seeing 'Home' in the list. if (sShowNoHomeNotice) { sShowNoHomeNotice = false; NoHomeDialogFragment.show(this); } return false; } else { // Okay, we're allowing the Home settings category. Tell it, when // invoked via this front door, that we'll need to be told about the // case when the user uninstalls all but one home app. if (header.fragmentArguments == null) { header.fragmentArguments = new Bundle(); } header.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true); } } catch (Exception e) { // Can't look up the home activity; bail on configuring the icon Loading Loading @@ -727,6 +748,21 @@ public class Settings extends PreferenceActivity return super.getNextButton(); } public static class NoHomeDialogFragment extends DialogFragment { public static void show(Activity parent) { final NoHomeDialogFragment dialog = new NoHomeDialogFragment(); dialog.show(parent.getFragmentManager(), null); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.only_one_home_message) .setPositiveButton(android.R.string.ok, null) .create(); } } private static class HeaderAdapter extends ArrayAdapter<Header> { static final int HEADER_TYPE_CATEGORY = 0; static final int HEADER_TYPE_NORMAL = 1; Loading Loading @@ -918,11 +954,6 @@ public class Settings extends PreferenceActivity ManageAccountsSettings.KEY_ACCOUNT_TYPE); Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType); setHeaderIcon(holder, icon); } else if (header.extras != null && header.extras.containsKey(HomeSettings.CURRENT_HOME)) { ActivityInfo ai = header.extras.getParcelable(HomeSettings.CURRENT_HOME); Drawable icon = ai.loadIcon(getContext().getPackageManager()); setHeaderIcon(holder, icon); } else { holder.icon.setImageResource(header.iconRes); } Loading Loading @@ -1015,6 +1046,10 @@ public class Settings extends PreferenceActivity invalidateHeaders(); } public static void requestHomeNotice() { sShowNoHomeNotice = true; } /* * Settings subclasses for launching independently. */ Loading Loading
res/values/strings.xml +2 −0 Original line number Diff line number Diff line Loading @@ -4768,6 +4768,8 @@ <!-- Home application selection - uninstall button [CHAR LIMIT=80] --> <string name="home_app_uninstall_button">Uninstall this application</string> <!-- Message to user that Home Settings will be hidden because there is now only one available home application --> <string name="only_one_home_message">Home settings will be hidden until you install another home application.</string> <!-- Warning message when changing a global setting for a tablet.[CHAR LIMIT=none] --> <string name="global_change_warning" product="tablet">This setting affects all users on this tablet.</string> Loading
src/com/android/settings/HomeSettings.java +18 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; Loading Loading @@ -50,6 +51,8 @@ public class HomeSettings extends SettingsPreferenceFragment { public static final String CURRENT_HOME = "current_home"; public static final String HOME_SHOW_NOTICE = "show"; PreferenceGroup mPrefGroup; PackageManager mPm; Loading @@ -57,6 +60,7 @@ public class HomeSettings extends SettingsPreferenceFragment { ArrayList<HomeAppPreference> mPrefs; HomeAppPreference mCurrentHome = null; final IntentFilter mHomeFilter; boolean mShowNotice; public HomeSettings() { mHomeFilter = new IntentFilter(Intent.ACTION_MAIN); Loading Loading @@ -126,6 +130,17 @@ public class HomeSettings extends SettingsPreferenceFragment { } } } // If we're down to just one possible home app, back out of this settings // fragment and show a dialog explaining to the user that they won't see // 'Home' settings now until such time as there are multiple available. if (mPrefs.size() < 2) { if (mShowNotice) { mShowNotice = false; Settings.requestHomeNotice(); } finishFragment(); } } void buildHomeActivitiesList() { Loading Loading @@ -176,6 +191,9 @@ public class HomeSettings extends SettingsPreferenceFragment { mPm = getPackageManager(); mPrefGroup = (PreferenceGroup) findPreference("home"); Bundle args = getArguments(); mShowNotice = (args != null) && args.getBoolean(HOME_SHOW_NOTICE, false); } @Override Loading
src/com/android/settings/Settings.java +42 −7 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ package com.android.settings; import android.accounts.Account; import android.accounts.AccountManager; import android.accounts.OnAccountsUpdateListener; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.DialogFragment; import android.app.admin.DevicePolicyManager; import android.content.BroadcastReceiver; import android.content.ComponentName; Loading @@ -27,7 +31,6 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.SharedPreferences; import android.content.pm.ActivityInfo; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; import android.content.pm.ResolveInfo; Loading Loading @@ -117,6 +120,10 @@ public class Settings extends PreferenceActivity private static final String SAVE_KEY_CURRENT_HEADER = "com.android.settings.CURRENT_HEADER"; private static final String SAVE_KEY_PARENT_HEADER = "com.android.settings.PARENT_HEADER"; static final int DIALOG_ONLY_ONE_HOME = 1; private static boolean sShowNoHomeNotice = false; private String mFragmentClass; private int mTopLevelHeaderId; private Header mFirstHeader; Loading Loading @@ -684,8 +691,22 @@ public class Settings extends PreferenceActivity getPackageManager().getHomeActivities(homeApps); if (homeApps.size() < 2) { // When there's only one available home app, omit this settings // category entirely at the top level UI. // category entirely at the top level UI. If the user just // uninstalled the penultimate home app candidiate, we also // now tell them about why they aren't seeing 'Home' in the list. if (sShowNoHomeNotice) { sShowNoHomeNotice = false; NoHomeDialogFragment.show(this); } return false; } else { // Okay, we're allowing the Home settings category. Tell it, when // invoked via this front door, that we'll need to be told about the // case when the user uninstalls all but one home app. if (header.fragmentArguments == null) { header.fragmentArguments = new Bundle(); } header.fragmentArguments.putBoolean(HomeSettings.HOME_SHOW_NOTICE, true); } } catch (Exception e) { // Can't look up the home activity; bail on configuring the icon Loading Loading @@ -727,6 +748,21 @@ public class Settings extends PreferenceActivity return super.getNextButton(); } public static class NoHomeDialogFragment extends DialogFragment { public static void show(Activity parent) { final NoHomeDialogFragment dialog = new NoHomeDialogFragment(); dialog.show(parent.getFragmentManager(), null); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.only_one_home_message) .setPositiveButton(android.R.string.ok, null) .create(); } } private static class HeaderAdapter extends ArrayAdapter<Header> { static final int HEADER_TYPE_CATEGORY = 0; static final int HEADER_TYPE_NORMAL = 1; Loading Loading @@ -918,11 +954,6 @@ public class Settings extends PreferenceActivity ManageAccountsSettings.KEY_ACCOUNT_TYPE); Drawable icon = mAuthHelper.getDrawableForType(getContext(), accType); setHeaderIcon(holder, icon); } else if (header.extras != null && header.extras.containsKey(HomeSettings.CURRENT_HOME)) { ActivityInfo ai = header.extras.getParcelable(HomeSettings.CURRENT_HOME); Drawable icon = ai.loadIcon(getContext().getPackageManager()); setHeaderIcon(holder, icon); } else { holder.icon.setImageResource(header.iconRes); } Loading Loading @@ -1015,6 +1046,10 @@ public class Settings extends PreferenceActivity invalidateHeaders(); } public static void requestHomeNotice() { sShowNoHomeNotice = true; } /* * Settings subclasses for launching independently. */ Loading