Let Settings app use InputMethodInfo#loadIcon()
This is a follow up CL to my previous CL [1], which attempted to show
the most appropriate IME icon even when multiple IMEs are implemented
in a single APK.
This CL simplifies the way how IME icon is obtained in the Settings
app, by simply using InputMethodInfo#loadIcon(), which already does
what we want.
Notable user-visible behavior changes are:
- Like before my previous CL was submitted, android:logo will not be
used in the IME settings (again).
- Icons shown in IME settings start having (user) badges like other
settings pages.
- If no icon is available in IME,
PackageManager#getDefaultActivityIcon() will be used. This is
actually consistent with other settings pages.
[1]: I406ccc0d53e6ec69793c2fc8be8c6c1c90b34811
2cae5b8952
Bug: 28204635
Fix: 131432102
Test: Manually verified as follows.
1. Build aosp_taimen-userdebug and flash it
2. Install TestDPC.
3. Set up a work profile
4. Open Settings App -> System -> Languages & input
-> Advanced -> Virtual keyboard for work
5. Make sure the icon of "Android Keyboard (AOSP)" has a small badge.
6. Tap "Manage keyboards"
7. Make sure the icon of "Android Keyboard (AOSP)" has the same icon
as the step 5.
8. Open Settings App -> System -> Languages & input
-> Virtual keyboard
9. Make sure the icon of "Android Keyboard (AOSP)" does not have a
small badge on it.
10. Tap "Manage keyboards"
11. Make sure the icon of "Android Keyboard (AOSP)" has the same icon
as the step 9.
Change-Id: Ie9be1eb3071abcc2df7723ceb10d76fe458c4808
This commit is contained in:
@@ -20,8 +20,6 @@ import android.app.Activity;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
@@ -48,7 +46,6 @@ import java.util.List;
|
||||
public final class VirtualKeyboardFragment extends SettingsPreferenceFragment implements Indexable {
|
||||
|
||||
private static final String ADD_VIRTUAL_KEYBOARD_SCREEN = "add_virtual_keyboard_screen";
|
||||
private static final Drawable NO_ICON = new ColorDrawable(Color.TRANSPARENT);
|
||||
|
||||
private final ArrayList<InputMethodPreference> mInputMethodPreferenceList = new ArrayList<>();
|
||||
private InputMethodManager mImm;
|
||||
@@ -89,14 +86,7 @@ public final class VirtualKeyboardFragment extends SettingsPreferenceFragment im
|
||||
final InputMethodInfo imi = imis.get(i);
|
||||
final boolean isAllowedByOrganization = permittedList == null
|
||||
|| permittedList.contains(imi.getPackageName());
|
||||
Drawable icon;
|
||||
try {
|
||||
// TODO: Consider other ways to retrieve an icon to show here.
|
||||
icon = getActivity().getPackageManager().getApplicationIcon(imi.getPackageName());
|
||||
} catch (Exception e) {
|
||||
// TODO: Consider handling the error differently perhaps by showing default icons.
|
||||
icon = NO_ICON;
|
||||
}
|
||||
final Drawable icon = imi.loadIcon(context.getPackageManager());
|
||||
final InputMethodPreference pref = new InputMethodPreference(
|
||||
context,
|
||||
imi,
|
||||
|
Reference in New Issue
Block a user