Search in sources :

Example 1 with ActivityResolveInfo

use of com.dgmltn.shareeverywhere.ActivityChooserModel.ActivityResolveInfo in project Android-ShareEverywhere by dgmltn.

the class ShareActionProvider method onPrepareSubMenu.

@Override
public void onPrepareSubMenu(SubMenu subMenu) {
    super.onPrepareSubMenu(subMenu);
    // Clear since the order of items may change.
    subMenu.clear();
    ActivityChooserModel dataModel = mShareView.getActivityChooserModel();
    final int expandedActivityCount = dataModel.getActivityCount();
    final int collapsedActivityCount = Math.min(expandedActivityCount, ShareView.DEFAULT_INITIAL_ACTIVITY_COUNT);
    // Populate the sub-menu with a sub set of the activities.
    for (int i = 0; i < collapsedActivityCount; i++) {
        ActivityResolveInfo activity = dataModel.getActivity(i);
        subMenu.add(0, i, i, activity.label).setIcon(activity.icon).setOnMenuItemClickListener(mShareView.mCallbacks);
    }
    if (collapsedActivityCount < expandedActivityCount) {
        // Add a sub-menu for showing all activities as a list item.
        SubMenu expandedSubMenu = subMenu.addSubMenu(Menu.NONE, collapsedActivityCount, collapsedActivityCount, mContext.getString(R.string.See_all___));
        for (int i = 0; i < expandedActivityCount; i++) {
            ActivityResolveInfo activity = dataModel.getActivity(i);
            expandedSubMenu.add(0, i, i, activity.label).setIcon(activity.icon).setOnMenuItemClickListener(mShareView.mCallbacks);
        }
    }
}
Also used : SubMenu(android.view.SubMenu) ActivityResolveInfo(com.dgmltn.shareeverywhere.ActivityChooserModel.ActivityResolveInfo)

Example 2 with ActivityResolveInfo

use of com.dgmltn.shareeverywhere.ActivityChooserModel.ActivityResolveInfo in project Android-ShareEverywhere by dgmltn.

the class ShareView method updateAppearance.

/**
	 * Updates the buttons state.
	 */
private void updateAppearance() {
    // Expand overflow button.
    if (mAdapter.getCount() > 0) {
        mExpandActivityOverflowButton.setEnabled(true);
    } else {
        mExpandActivityOverflowButton.setEnabled(false);
    }
    // Default activity button.
    final int activityCount = mAdapter.getActivityCount();
    final int historySize = mAdapter.getHistorySize();
    if (activityCount > 0 && historySize > 0 && mDisplayDefaultActivityButton) {
        mDefaultActivityButton.setVisibility(VISIBLE);
        ActivityResolveInfo activity = mAdapter.getDefaultActivity();
        mDefaultActivityButtonImage.setImageDrawable(activity.icon);
        if (mDefaultActionButtonContentDescription != 0) {
            String contentDescription = mContext.getString(mDefaultActionButtonContentDescription, activity.label);
            mDefaultActivityButton.setContentDescription(contentDescription);
        //TODO: CheatSheet.setup(mDefaultActivityButton);
        }
        // Work-around for #415.
        mAdapter.setShowDefaultActivity(false, false);
    } else {
        mDefaultActivityButton.setVisibility(View.GONE);
    }
    // Activity chooser content.
    if (mDefaultActivityButton.getVisibility() == VISIBLE) {
        mActivityChooserContent.setBackgroundResource(mBackgroundResId);
    } else {
        mActivityChooserContent.setBackgroundResource(0);
        mActivityChooserContent.setPadding(0, 0, 0, 0);
    }
}
Also used : ActivityResolveInfo(com.dgmltn.shareeverywhere.ActivityChooserModel.ActivityResolveInfo)

Aggregations

ActivityResolveInfo (com.dgmltn.shareeverywhere.ActivityChooserModel.ActivityResolveInfo)2 SubMenu (android.view.SubMenu)1