Search in sources :

Example 1 with ResolverDrawerLayout

use of com.android.internal.widget.ResolverDrawerLayout in project android_frameworks_base by ResurrectionRemix.

the class ResolverActivity method onCreate.

protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
    setTheme(R.style.Theme_DeviceDefault_Resolver);
    super.onCreate(savedInstanceState);
    // Determine whether we should show that intent is forwarded
    // from managed profile to owner or other way around.
    setProfileSwitchMessageId(intent.getContentUserHint());
    try {
        mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
    } catch (RemoteException e) {
        mLaunchedFromUid = -1;
    }
    if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) {
        // Gulp!
        finish();
        return;
    }
    mPm = getPackageManager();
    mPackageMonitor.register(this, getMainLooper(), false);
    mRegistered = true;
    final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    mIconDpi = am.getLauncherLargeIconDensity();
    // Add our initial intent as the first item, regardless of what else has already been added.
    mIntents.add(0, new Intent(intent));
    final String referrerPackage = getReferrerPackageName();
    mResolverComparator = new ResolverComparator(this, getTargetIntent(), referrerPackage);
    if (configureContentView(mIntents, initialIntents, rList, alwaysUseOption)) {
        return;
    }
    final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
    if (rdl != null) {
        rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {

            @Override
            public void onDismissed() {
                finish();
            }
        });
        if (isVoiceInteraction()) {
            rdl.setCollapsed(false);
        }
        mResolverDrawerLayout = rdl;
    }
    if (title == null) {
        title = getTitleForAction(intent.getAction(), defaultTitleRes);
    }
    if (!TextUtils.isEmpty(title)) {
        final TextView titleView = (TextView) findViewById(R.id.title);
        if (titleView != null) {
            titleView.setText(title);
        }
        setTitle(title);
        // Try to initialize the title icon if we have a view for it and a title to match
        final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
        if (titleIcon != null) {
            ApplicationInfo ai = null;
            try {
                if (!TextUtils.isEmpty(referrerPackage)) {
                    ai = mPm.getApplicationInfo(referrerPackage, 0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Could not find referrer package " + referrerPackage);
            }
            if (ai != null) {
                titleIcon.setImageDrawable(ai.loadIcon(mPm));
            }
        }
    }
    final ImageView iconView = (ImageView) findViewById(R.id.icon);
    final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
    if (iconView != null && iconInfo != null) {
        new LoadIconIntoViewTask(iconInfo, iconView).execute();
    }
    if (alwaysUseOption || mAdapter.hasFilteredItem()) {
        final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonLayout != null) {
            buttonLayout.setVisibility(View.VISIBLE);
            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
        } else {
            mAlwaysUseOption = false;
        }
    }
    if (mAdapter.hasFilteredItem()) {
        setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false);
        mOnceButton.setEnabled(true);
    }
    mProfileView = findViewById(R.id.profile_button);
    if (mProfileView != null) {
        mProfileView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final DisplayResolveInfo dri = mAdapter.getOtherProfile();
                if (dri == null) {
                    return;
                }
                // Do not show the profile switch message anymore.
                mProfileSwitchMessageId = -1;
                onTargetSelected(dri, false);
                finish();
            }
        });
        bindProfileView();
    }
    if (isVoiceInteraction()) {
        onSetupVoiceInteraction();
    }
    final Set<String> categories = intent.getCategories();
    MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED : MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED, intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : ""));
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ViewGroup(android.view.ViewGroup) ApplicationInfo(android.content.pm.ApplicationInfo) LabeledIntent(android.content.pm.LabeledIntent) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager) ResolverDrawerLayout(com.android.internal.widget.ResolverDrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Example 2 with ResolverDrawerLayout

use of com.android.internal.widget.ResolverDrawerLayout in project android_frameworks_base by AOSPA.

the class ResolverActivity method onCreate.

protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
    setTheme(R.style.Theme_DeviceDefault_Resolver);
    super.onCreate(savedInstanceState);
    // Determine whether we should show that intent is forwarded
    // from managed profile to owner or other way around.
    setProfileSwitchMessageId(intent.getContentUserHint());
    try {
        mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
    } catch (RemoteException e) {
        mLaunchedFromUid = -1;
    }
    if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) {
        // Gulp!
        finish();
        return;
    }
    mPm = getPackageManager();
    mPackageMonitor.register(this, getMainLooper(), false);
    mRegistered = true;
    final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    mIconDpi = am.getLauncherLargeIconDensity();
    // Add our initial intent as the first item, regardless of what else has already been added.
    mIntents.add(0, new Intent(intent));
    final String referrerPackage = getReferrerPackageName();
    mResolverComparator = new ResolverComparator(this, getTargetIntent(), referrerPackage);
    if (configureContentView(mIntents, initialIntents, rList, alwaysUseOption)) {
        return;
    }
    final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
    if (rdl != null) {
        rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {

            @Override
            public void onDismissed() {
                finish();
            }
        });
        if (isVoiceInteraction()) {
            rdl.setCollapsed(false);
        }
        mResolverDrawerLayout = rdl;
    }
    if (title == null) {
        title = getTitleForAction(intent.getAction(), defaultTitleRes);
    }
    if (!TextUtils.isEmpty(title)) {
        final TextView titleView = (TextView) findViewById(R.id.title);
        if (titleView != null) {
            titleView.setText(title);
        }
        setTitle(title);
        // Try to initialize the title icon if we have a view for it and a title to match
        final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
        if (titleIcon != null) {
            ApplicationInfo ai = null;
            try {
                if (!TextUtils.isEmpty(referrerPackage)) {
                    ai = mPm.getApplicationInfo(referrerPackage, 0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Could not find referrer package " + referrerPackage);
            }
            if (ai != null) {
                titleIcon.setImageDrawable(ai.loadIcon(mPm));
            }
        }
    }
    final ImageView iconView = (ImageView) findViewById(R.id.icon);
    final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
    if (iconView != null && iconInfo != null) {
        new LoadIconIntoViewTask(iconInfo, iconView).execute();
    }
    if (alwaysUseOption || mAdapter.hasFilteredItem()) {
        final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonLayout != null) {
            buttonLayout.setVisibility(View.VISIBLE);
            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
        } else {
            mAlwaysUseOption = false;
        }
    }
    if (mAdapter.hasFilteredItem()) {
        setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false);
        mOnceButton.setEnabled(true);
    }
    mProfileView = findViewById(R.id.profile_button);
    if (mProfileView != null) {
        mProfileView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final DisplayResolveInfo dri = mAdapter.getOtherProfile();
                if (dri == null) {
                    return;
                }
                // Do not show the profile switch message anymore.
                mProfileSwitchMessageId = -1;
                onTargetSelected(dri, false);
                finish();
            }
        });
        bindProfileView();
    }
    if (isVoiceInteraction()) {
        onSetupVoiceInteraction();
    }
    final Set<String> categories = intent.getCategories();
    MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED : MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED, intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : ""));
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ViewGroup(android.view.ViewGroup) ApplicationInfo(android.content.pm.ApplicationInfo) LabeledIntent(android.content.pm.LabeledIntent) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager) ResolverDrawerLayout(com.android.internal.widget.ResolverDrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Example 3 with ResolverDrawerLayout

use of com.android.internal.widget.ResolverDrawerLayout in project platform_frameworks_base by android.

the class ResolverActivity method onCreate.

protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
    setTheme(R.style.Theme_DeviceDefault_Resolver);
    super.onCreate(savedInstanceState);
    // Determine whether we should show that intent is forwarded
    // from managed profile to owner or other way around.
    setProfileSwitchMessageId(intent.getContentUserHint());
    try {
        mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
    } catch (RemoteException e) {
        mLaunchedFromUid = -1;
    }
    if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) {
        // Gulp!
        finish();
        return;
    }
    mPm = getPackageManager();
    mPackageMonitor.register(this, getMainLooper(), false);
    mRegistered = true;
    final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    mIconDpi = am.getLauncherLargeIconDensity();
    // Add our initial intent as the first item, regardless of what else has already been added.
    mIntents.add(0, new Intent(intent));
    final String referrerPackage = getReferrerPackageName();
    mResolverComparator = new ResolverComparator(this, getTargetIntent(), referrerPackage);
    if (configureContentView(mIntents, initialIntents, rList, alwaysUseOption)) {
        return;
    }
    final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
    if (rdl != null) {
        rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {

            @Override
            public void onDismissed() {
                finish();
            }
        });
        if (isVoiceInteraction()) {
            rdl.setCollapsed(false);
        }
        mResolverDrawerLayout = rdl;
    }
    if (title == null) {
        title = getTitleForAction(intent.getAction(), defaultTitleRes);
    }
    if (!TextUtils.isEmpty(title)) {
        final TextView titleView = (TextView) findViewById(R.id.title);
        if (titleView != null) {
            titleView.setText(title);
        }
        setTitle(title);
        // Try to initialize the title icon if we have a view for it and a title to match
        final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
        if (titleIcon != null) {
            ApplicationInfo ai = null;
            try {
                if (!TextUtils.isEmpty(referrerPackage)) {
                    ai = mPm.getApplicationInfo(referrerPackage, 0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Could not find referrer package " + referrerPackage);
            }
            if (ai != null) {
                titleIcon.setImageDrawable(ai.loadIcon(mPm));
            }
        }
    }
    final ImageView iconView = (ImageView) findViewById(R.id.icon);
    final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
    if (iconView != null && iconInfo != null) {
        new LoadIconIntoViewTask(iconInfo, iconView).execute();
    }
    if (alwaysUseOption || mAdapter.hasFilteredItem()) {
        final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonLayout != null) {
            buttonLayout.setVisibility(View.VISIBLE);
            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
        } else {
            mAlwaysUseOption = false;
        }
    }
    if (mAdapter.hasFilteredItem()) {
        setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false);
        mOnceButton.setEnabled(true);
    }
    mProfileView = findViewById(R.id.profile_button);
    if (mProfileView != null) {
        mProfileView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final DisplayResolveInfo dri = mAdapter.getOtherProfile();
                if (dri == null) {
                    return;
                }
                // Do not show the profile switch message anymore.
                mProfileSwitchMessageId = -1;
                onTargetSelected(dri, false);
                finish();
            }
        });
        bindProfileView();
    }
    if (isVoiceInteraction()) {
        onSetupVoiceInteraction();
    }
    final Set<String> categories = intent.getCategories();
    MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED : MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED, intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : ""));
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ViewGroup(android.view.ViewGroup) ApplicationInfo(android.content.pm.ApplicationInfo) LabeledIntent(android.content.pm.LabeledIntent) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager) ResolverDrawerLayout(com.android.internal.widget.ResolverDrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Example 4 with ResolverDrawerLayout

use of com.android.internal.widget.ResolverDrawerLayout in project android_frameworks_base by DirtyUnicorns.

the class ResolverActivity method onCreate.

protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
    setTheme(R.style.Theme_DeviceDefault_Resolver);
    super.onCreate(savedInstanceState);
    // Determine whether we should show that intent is forwarded
    // from managed profile to owner or other way around.
    setProfileSwitchMessageId(intent.getContentUserHint());
    try {
        mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
    } catch (RemoteException e) {
        mLaunchedFromUid = -1;
    }
    if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) {
        // Gulp!
        finish();
        return;
    }
    mPm = getPackageManager();
    mPackageMonitor.register(this, getMainLooper(), false);
    mRegistered = true;
    final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    mIconDpi = am.getLauncherLargeIconDensity();
    // Add our initial intent as the first item, regardless of what else has already been added.
    mIntents.add(0, new Intent(intent));
    final String referrerPackage = getReferrerPackageName();
    mResolverComparator = new ResolverComparator(this, getTargetIntent(), referrerPackage);
    if (configureContentView(mIntents, initialIntents, rList, alwaysUseOption)) {
        return;
    }
    final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
    if (rdl != null) {
        rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {

            @Override
            public void onDismissed() {
                finish();
            }
        });
        if (isVoiceInteraction()) {
            rdl.setCollapsed(false);
        }
        mResolverDrawerLayout = rdl;
    }
    if (title == null) {
        title = getTitleForAction(intent.getAction(), defaultTitleRes);
    }
    if (!TextUtils.isEmpty(title)) {
        final TextView titleView = (TextView) findViewById(R.id.title);
        if (titleView != null) {
            titleView.setText(title);
        }
        setTitle(title);
        // Try to initialize the title icon if we have a view for it and a title to match
        final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
        if (titleIcon != null) {
            ApplicationInfo ai = null;
            try {
                if (!TextUtils.isEmpty(referrerPackage)) {
                    ai = mPm.getApplicationInfo(referrerPackage, 0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Could not find referrer package " + referrerPackage);
            }
            if (ai != null) {
                titleIcon.setImageDrawable(ai.loadIcon(mPm));
            }
        }
    }
    final ImageView iconView = (ImageView) findViewById(R.id.icon);
    final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
    if (iconView != null && iconInfo != null) {
        new LoadIconIntoViewTask(iconInfo, iconView).execute();
    }
    if (alwaysUseOption || mAdapter.hasFilteredItem()) {
        final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonLayout != null) {
            buttonLayout.setVisibility(View.VISIBLE);
            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
        } else {
            mAlwaysUseOption = false;
        }
    }
    if (mAdapter.hasFilteredItem()) {
        setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false);
        mOnceButton.setEnabled(true);
    }
    mProfileView = findViewById(R.id.profile_button);
    if (mProfileView != null) {
        mProfileView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final DisplayResolveInfo dri = mAdapter.getOtherProfile();
                if (dri == null) {
                    return;
                }
                // Do not show the profile switch message anymore.
                mProfileSwitchMessageId = -1;
                onTargetSelected(dri, false);
                finish();
            }
        });
        bindProfileView();
    }
    if (isVoiceInteraction()) {
        onSetupVoiceInteraction();
    }
    final Set<String> categories = intent.getCategories();
    MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED : MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED, intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : ""));
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ViewGroup(android.view.ViewGroup) ApplicationInfo(android.content.pm.ApplicationInfo) LabeledIntent(android.content.pm.LabeledIntent) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager) ResolverDrawerLayout(com.android.internal.widget.ResolverDrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Example 5 with ResolverDrawerLayout

use of com.android.internal.widget.ResolverDrawerLayout in project android_frameworks_base by crdroidandroid.

the class ResolverActivity method onCreate.

protected void onCreate(Bundle savedInstanceState, Intent intent, CharSequence title, int defaultTitleRes, Intent[] initialIntents, List<ResolveInfo> rList, boolean alwaysUseOption) {
    setTheme(R.style.Theme_DeviceDefault_Resolver);
    super.onCreate(savedInstanceState);
    // Determine whether we should show that intent is forwarded
    // from managed profile to owner or other way around.
    setProfileSwitchMessageId(intent.getContentUserHint());
    try {
        mLaunchedFromUid = ActivityManagerNative.getDefault().getLaunchedFromUid(getActivityToken());
    } catch (RemoteException e) {
        mLaunchedFromUid = -1;
    }
    if (mLaunchedFromUid < 0 || UserHandle.isIsolated(mLaunchedFromUid)) {
        // Gulp!
        finish();
        return;
    }
    mPm = getPackageManager();
    mPackageMonitor.register(this, getMainLooper(), false);
    mRegistered = true;
    final ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
    mIconDpi = am.getLauncherLargeIconDensity();
    // Add our initial intent as the first item, regardless of what else has already been added.
    mIntents.add(0, new Intent(intent));
    final String referrerPackage = getReferrerPackageName();
    mResolverComparator = new ResolverComparator(this, getTargetIntent(), referrerPackage);
    if (configureContentView(mIntents, initialIntents, rList, alwaysUseOption)) {
        return;
    }
    final ResolverDrawerLayout rdl = (ResolverDrawerLayout) findViewById(R.id.contentPanel);
    if (rdl != null) {
        rdl.setOnDismissedListener(new ResolverDrawerLayout.OnDismissedListener() {

            @Override
            public void onDismissed() {
                finish();
            }
        });
        if (isVoiceInteraction()) {
            rdl.setCollapsed(false);
        }
        mResolverDrawerLayout = rdl;
    }
    if (title == null) {
        title = getTitleForAction(intent.getAction(), defaultTitleRes);
    }
    if (!TextUtils.isEmpty(title)) {
        final TextView titleView = (TextView) findViewById(R.id.title);
        if (titleView != null) {
            titleView.setText(title);
        }
        setTitle(title);
        // Try to initialize the title icon if we have a view for it and a title to match
        final ImageView titleIcon = (ImageView) findViewById(R.id.title_icon);
        if (titleIcon != null) {
            ApplicationInfo ai = null;
            try {
                if (!TextUtils.isEmpty(referrerPackage)) {
                    ai = mPm.getApplicationInfo(referrerPackage, 0);
                }
            } catch (NameNotFoundException e) {
                Log.e(TAG, "Could not find referrer package " + referrerPackage);
            }
            if (ai != null) {
                titleIcon.setImageDrawable(ai.loadIcon(mPm));
            }
        }
    }
    final ImageView iconView = (ImageView) findViewById(R.id.icon);
    final DisplayResolveInfo iconInfo = mAdapter.getFilteredItem();
    if (iconView != null && iconInfo != null) {
        new LoadIconIntoViewTask(iconInfo, iconView).execute();
    }
    if (alwaysUseOption || mAdapter.hasFilteredItem()) {
        final ViewGroup buttonLayout = (ViewGroup) findViewById(R.id.button_bar);
        if (buttonLayout != null) {
            buttonLayout.setVisibility(View.VISIBLE);
            mAlwaysButton = (Button) buttonLayout.findViewById(R.id.button_always);
            mOnceButton = (Button) buttonLayout.findViewById(R.id.button_once);
        } else {
            mAlwaysUseOption = false;
        }
    }
    if (mAdapter.hasFilteredItem()) {
        mFilteredItemContainer = (ViewGroup) findViewById(R.id.filtered_item_container);
        mFilteredItemContainer.setOnLongClickListener(new View.OnLongClickListener() {

            @Override
            public boolean onLongClick(View v) {
                DisplayResolveInfo filteredItem = mAdapter.getFilteredItem();
                if (filteredItem == null) {
                    return false;
                }
                showTargetDetails(filteredItem.getResolveInfo());
                return true;
            }
        });
        setAlwaysButtonEnabled(true, mAdapter.getFilteredPosition(), false);
        mOnceButton.setEnabled(true);
    }
    mProfileView = findViewById(R.id.profile_button);
    if (mProfileView != null) {
        mProfileView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                final DisplayResolveInfo dri = mAdapter.getOtherProfile();
                if (dri == null) {
                    return;
                }
                // Do not show the profile switch message anymore.
                mProfileSwitchMessageId = -1;
                onTargetSelected(dri, false);
                finish();
            }
        });
        bindProfileView();
    }
    if (isVoiceInteraction()) {
        onSetupVoiceInteraction();
    }
    final Set<String> categories = intent.getCategories();
    MetricsLogger.action(this, mAdapter.hasFilteredItem() ? MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_APP_FEATURED : MetricsProto.MetricsEvent.ACTION_SHOW_APP_DISAMBIG_NONE_FEATURED, intent.getAction() + ":" + intent.getType() + ":" + (categories != null ? Arrays.toString(categories.toArray()) : ""));
}
Also used : NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) ViewGroup(android.view.ViewGroup) ApplicationInfo(android.content.pm.ApplicationInfo) LabeledIntent(android.content.pm.LabeledIntent) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager) ResolverDrawerLayout(com.android.internal.widget.ResolverDrawerLayout) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) RemoteException(android.os.RemoteException)

Aggregations

ActivityManager (android.app.ActivityManager)5 Intent (android.content.Intent)5 ApplicationInfo (android.content.pm.ApplicationInfo)5 LabeledIntent (android.content.pm.LabeledIntent)5 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)5 RemoteException (android.os.RemoteException)5 View (android.view.View)5 ViewGroup (android.view.ViewGroup)5 AbsListView (android.widget.AbsListView)5 AdapterView (android.widget.AdapterView)5 ImageView (android.widget.ImageView)5 ListView (android.widget.ListView)5 TextView (android.widget.TextView)5 ResolverDrawerLayout (com.android.internal.widget.ResolverDrawerLayout)5