Search in sources :

Example 1 with AssistUtils

use of com.android.internal.app.AssistUtils in project android_frameworks_base by ResurrectionRemix.

the class KeyboardShortcuts method getDefaultApplicationShortcuts.

private KeyboardShortcutGroup getDefaultApplicationShortcuts() {
    final int userId = mContext.getUserId();
    List<KeyboardShortcutInfo> keyboardShortcutInfoAppItems = new ArrayList<>();
    // Assist.
    final AssistUtils assistUtils = new AssistUtils(mContext);
    final ComponentName assistComponent = assistUtils.getAssistComponentForUser(userId);
    PackageInfo assistPackageInfo = null;
    try {
        assistPackageInfo = mPackageManager.getPackageInfo(assistComponent.getPackageName(), 0, userId);
    } catch (RemoteException e) {
        Log.e(TAG, "PackageManagerService is dead");
    }
    if (assistPackageInfo != null) {
        final Icon assistIcon = Icon.createWithResource(assistPackageInfo.applicationInfo.packageName, assistPackageInfo.applicationInfo.icon);
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_assist), assistIcon, KeyEvent.KEYCODE_UNKNOWN, KeyEvent.META_META_ON));
    }
    // Browser.
    final Icon browserIcon = getIconForIntentCategory(Intent.CATEGORY_APP_BROWSER, userId);
    if (browserIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_browser), browserIcon, KeyEvent.KEYCODE_B, KeyEvent.META_META_ON));
    }
    // Contacts.
    final Icon contactsIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CONTACTS, userId);
    if (contactsIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_contacts), contactsIcon, KeyEvent.KEYCODE_C, KeyEvent.META_META_ON));
    }
    // Email.
    final Icon emailIcon = getIconForIntentCategory(Intent.CATEGORY_APP_EMAIL, userId);
    if (emailIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_email), emailIcon, KeyEvent.KEYCODE_E, KeyEvent.META_META_ON));
    }
    // Messaging.
    final Icon messagingIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MESSAGING, userId);
    if (messagingIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_im), messagingIcon, KeyEvent.KEYCODE_T, KeyEvent.META_META_ON));
    }
    // Music.
    final Icon musicIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MUSIC, userId);
    if (musicIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_music), musicIcon, KeyEvent.KEYCODE_P, KeyEvent.META_META_ON));
    }
    // Calendar.
    final Icon calendarIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CALENDAR, userId);
    if (calendarIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_calendar), calendarIcon, KeyEvent.KEYCODE_L, KeyEvent.META_META_ON));
    }
    final int itemsSize = keyboardShortcutInfoAppItems.size();
    if (itemsSize == 0) {
        return null;
    }
    // Sorts by label, case insensitive with nulls and/or empty labels last.
    Collections.sort(keyboardShortcutInfoAppItems, mApplicationItemsComparator);
    return new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_applications), keyboardShortcutInfoAppItems, true);
}
Also used : KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) AssistUtils(com.android.internal.app.AssistUtils) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon) RemoteException(android.os.RemoteException)

Example 2 with AssistUtils

use of com.android.internal.app.AssistUtils in project android_frameworks_base by AOSPA.

the class KeyboardShortcuts method getDefaultApplicationShortcuts.

private KeyboardShortcutGroup getDefaultApplicationShortcuts() {
    final int userId = mContext.getUserId();
    List<KeyboardShortcutInfo> keyboardShortcutInfoAppItems = new ArrayList<>();
    // Assist.
    final AssistUtils assistUtils = new AssistUtils(mContext);
    final ComponentName assistComponent = assistUtils.getAssistComponentForUser(userId);
    PackageInfo assistPackageInfo = null;
    try {
        assistPackageInfo = mPackageManager.getPackageInfo(assistComponent.getPackageName(), 0, userId);
    } catch (RemoteException e) {
        Log.e(TAG, "PackageManagerService is dead");
    }
    if (assistPackageInfo != null) {
        final Icon assistIcon = Icon.createWithResource(assistPackageInfo.applicationInfo.packageName, assistPackageInfo.applicationInfo.icon);
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_assist), assistIcon, KeyEvent.KEYCODE_UNKNOWN, KeyEvent.META_META_ON));
    }
    // Browser.
    final Icon browserIcon = getIconForIntentCategory(Intent.CATEGORY_APP_BROWSER, userId);
    if (browserIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_browser), browserIcon, KeyEvent.KEYCODE_B, KeyEvent.META_META_ON));
    }
    // Contacts.
    final Icon contactsIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CONTACTS, userId);
    if (contactsIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_contacts), contactsIcon, KeyEvent.KEYCODE_C, KeyEvent.META_META_ON));
    }
    // Email.
    final Icon emailIcon = getIconForIntentCategory(Intent.CATEGORY_APP_EMAIL, userId);
    if (emailIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_email), emailIcon, KeyEvent.KEYCODE_E, KeyEvent.META_META_ON));
    }
    // Messaging.
    final Icon messagingIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MESSAGING, userId);
    if (messagingIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_im), messagingIcon, KeyEvent.KEYCODE_T, KeyEvent.META_META_ON));
    }
    // Music.
    final Icon musicIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MUSIC, userId);
    if (musicIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_music), musicIcon, KeyEvent.KEYCODE_P, KeyEvent.META_META_ON));
    }
    // Calendar.
    final Icon calendarIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CALENDAR, userId);
    if (calendarIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_calendar), calendarIcon, KeyEvent.KEYCODE_L, KeyEvent.META_META_ON));
    }
    final int itemsSize = keyboardShortcutInfoAppItems.size();
    if (itemsSize == 0) {
        return null;
    }
    // Sorts by label, case insensitive with nulls and/or empty labels last.
    Collections.sort(keyboardShortcutInfoAppItems, mApplicationItemsComparator);
    return new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_applications), keyboardShortcutInfoAppItems, true);
}
Also used : KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) AssistUtils(com.android.internal.app.AssistUtils) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon) RemoteException(android.os.RemoteException)

Example 3 with AssistUtils

use of com.android.internal.app.AssistUtils in project android_frameworks_base by crdroidandroid.

the class KeyboardShortcuts method getDefaultApplicationShortcuts.

private KeyboardShortcutGroup getDefaultApplicationShortcuts() {
    final int userId = mContext.getUserId();
    List<KeyboardShortcutInfo> keyboardShortcutInfoAppItems = new ArrayList<>();
    // Assist.
    final AssistUtils assistUtils = new AssistUtils(mContext);
    final ComponentName assistComponent = assistUtils.getAssistComponentForUser(userId);
    PackageInfo assistPackageInfo = null;
    try {
        assistPackageInfo = mPackageManager.getPackageInfo(assistComponent.getPackageName(), 0, userId);
    } catch (RemoteException e) {
        Log.e(TAG, "PackageManagerService is dead");
    }
    if (assistPackageInfo != null) {
        final Icon assistIcon = Icon.createWithResource(assistPackageInfo.applicationInfo.packageName, assistPackageInfo.applicationInfo.icon);
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_assist), assistIcon, KeyEvent.KEYCODE_UNKNOWN, KeyEvent.META_META_ON));
    }
    // Browser.
    final Icon browserIcon = getIconForIntentCategory(Intent.CATEGORY_APP_BROWSER, userId);
    if (browserIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_browser), browserIcon, KeyEvent.KEYCODE_B, KeyEvent.META_META_ON));
    }
    // Contacts.
    final Icon contactsIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CONTACTS, userId);
    if (contactsIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_contacts), contactsIcon, KeyEvent.KEYCODE_C, KeyEvent.META_META_ON));
    }
    // Email.
    final Icon emailIcon = getIconForIntentCategory(Intent.CATEGORY_APP_EMAIL, userId);
    if (emailIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_email), emailIcon, KeyEvent.KEYCODE_E, KeyEvent.META_META_ON));
    }
    // Messaging.
    final Icon messagingIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MESSAGING, userId);
    if (messagingIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_im), messagingIcon, KeyEvent.KEYCODE_T, KeyEvent.META_META_ON));
    }
    // Music.
    final Icon musicIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MUSIC, userId);
    if (musicIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_music), musicIcon, KeyEvent.KEYCODE_P, KeyEvent.META_META_ON));
    }
    // Calendar.
    final Icon calendarIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CALENDAR, userId);
    if (calendarIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_calendar), calendarIcon, KeyEvent.KEYCODE_L, KeyEvent.META_META_ON));
    }
    final int itemsSize = keyboardShortcutInfoAppItems.size();
    if (itemsSize == 0) {
        return null;
    }
    // Sorts by label, case insensitive with nulls and/or empty labels last.
    Collections.sort(keyboardShortcutInfoAppItems, mApplicationItemsComparator);
    return new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_applications), keyboardShortcutInfoAppItems, true);
}
Also used : KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) AssistUtils(com.android.internal.app.AssistUtils) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon) RemoteException(android.os.RemoteException)

Example 4 with AssistUtils

use of com.android.internal.app.AssistUtils in project android_frameworks_base by DirtyUnicorns.

the class KeyboardShortcuts method getDefaultApplicationShortcuts.

private KeyboardShortcutGroup getDefaultApplicationShortcuts() {
    final int userId = mContext.getUserId();
    List<KeyboardShortcutInfo> keyboardShortcutInfoAppItems = new ArrayList<>();
    // Assist.
    final AssistUtils assistUtils = new AssistUtils(mContext);
    final ComponentName assistComponent = assistUtils.getAssistComponentForUser(userId);
    PackageInfo assistPackageInfo = null;
    try {
        assistPackageInfo = mPackageManager.getPackageInfo(assistComponent.getPackageName(), 0, userId);
    } catch (RemoteException e) {
        Log.e(TAG, "PackageManagerService is dead");
    }
    if (assistPackageInfo != null) {
        final Icon assistIcon = Icon.createWithResource(assistPackageInfo.applicationInfo.packageName, assistPackageInfo.applicationInfo.icon);
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_assist), assistIcon, KeyEvent.KEYCODE_UNKNOWN, KeyEvent.META_META_ON));
    }
    // Browser.
    final Icon browserIcon = getIconForIntentCategory(Intent.CATEGORY_APP_BROWSER, userId);
    if (browserIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_browser), browserIcon, KeyEvent.KEYCODE_B, KeyEvent.META_META_ON));
    }
    // Contacts.
    final Icon contactsIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CONTACTS, userId);
    if (contactsIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_contacts), contactsIcon, KeyEvent.KEYCODE_C, KeyEvent.META_META_ON));
    }
    // Email.
    final Icon emailIcon = getIconForIntentCategory(Intent.CATEGORY_APP_EMAIL, userId);
    if (emailIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_email), emailIcon, KeyEvent.KEYCODE_E, KeyEvent.META_META_ON));
    }
    // Messaging.
    final Icon messagingIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MESSAGING, userId);
    if (messagingIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_im), messagingIcon, KeyEvent.KEYCODE_T, KeyEvent.META_META_ON));
    }
    // Music.
    final Icon musicIcon = getIconForIntentCategory(Intent.CATEGORY_APP_MUSIC, userId);
    if (musicIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_music), musicIcon, KeyEvent.KEYCODE_P, KeyEvent.META_META_ON));
    }
    // Calendar.
    final Icon calendarIcon = getIconForIntentCategory(Intent.CATEGORY_APP_CALENDAR, userId);
    if (calendarIcon != null) {
        keyboardShortcutInfoAppItems.add(new KeyboardShortcutInfo(mContext.getString(R.string.keyboard_shortcut_group_applications_calendar), calendarIcon, KeyEvent.KEYCODE_L, KeyEvent.META_META_ON));
    }
    final int itemsSize = keyboardShortcutInfoAppItems.size();
    if (itemsSize == 0) {
        return null;
    }
    // Sorts by label, case insensitive with nulls and/or empty labels last.
    Collections.sort(keyboardShortcutInfoAppItems, mApplicationItemsComparator);
    return new KeyboardShortcutGroup(mContext.getString(R.string.keyboard_shortcut_group_applications), keyboardShortcutInfoAppItems, true);
}
Also used : KeyboardShortcutGroup(android.view.KeyboardShortcutGroup) AssistUtils(com.android.internal.app.AssistUtils) PackageInfo(android.content.pm.PackageInfo) ArrayList(java.util.ArrayList) KeyboardShortcutInfo(android.view.KeyboardShortcutInfo) ComponentName(android.content.ComponentName) Icon(android.graphics.drawable.Icon) RemoteException(android.os.RemoteException)

Example 5 with AssistUtils

use of com.android.internal.app.AssistUtils in project android_packages_apps_Settings by LineageOS.

the class DefaultAssistPicker method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    mAssistUtils = new AssistUtils(context);
}
Also used : AssistUtils(com.android.internal.app.AssistUtils)

Aggregations

AssistUtils (com.android.internal.app.AssistUtils)27 ComponentName (android.content.ComponentName)12 Test (org.junit.Test)7 PackageInfo (android.content.pm.PackageInfo)5 Icon (android.graphics.drawable.Icon)5 RemoteException (android.os.RemoteException)5 KeyboardShortcutGroup (android.view.KeyboardShortcutGroup)5 KeyboardShortcutInfo (android.view.KeyboardShortcutInfo)5 ArrayList (java.util.ArrayList)5