Search in sources :

Example 1 with SendButtonData

use of com.owncloud.android.ui.components.SendButtonData in project android by nextcloud.

the class SendFilesDialog method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.send_files_fragment, container, false);
    // populate send apps
    Intent sendIntent = IntentUtil.createSendIntent(requireContext(), files);
    List<ResolveInfo> matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0);
    if (matches.isEmpty()) {
        Toast.makeText(getContext(), R.string.no_send_app, Toast.LENGTH_SHORT).show();
        dismiss();
        return null;
    }
    List<SendButtonData> sendButtonDataList = setupSendButtonData(matches);
    SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent);
    RecyclerView sendButtonsView = view.findViewById(R.id.send_button_recycler_view);
    sendButtonsView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
    sendButtonsView.setAdapter(new SendButtonAdapter(sendButtonDataList, clickListener));
    return view;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SendButtonAdapter(com.owncloud.android.ui.adapter.SendButtonAdapter) Intent(android.content.Intent) SendButtonData(com.owncloud.android.ui.components.SendButtonData) RecyclerView(androidx.recyclerview.widget.RecyclerView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) Nullable(androidx.annotation.Nullable)

Example 2 with SendButtonData

use of com.owncloud.android.ui.components.SendButtonData in project android by nextcloud.

the class SendShareDialog method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    view = inflater.inflate(R.layout.send_share_fragment, container, false);
    LinearLayout sendShareButtons = view.findViewById(R.id.send_share_buttons);
    View divider = view.findViewById(R.id.divider);
    // Share with people
    TextView sharePeopleText = view.findViewById(R.id.share_people_button);
    sharePeopleText.setOnClickListener(v -> shareFile(file));
    ImageView sharePeopleImageView = view.findViewById(R.id.share_people_icon);
    themeShareButtonImage(sharePeopleImageView);
    sharePeopleImageView.setOnClickListener(v -> shareFile(file));
    // Share via link button
    TextView shareLinkText = view.findViewById(R.id.share_link_button);
    shareLinkText.setOnClickListener(v -> shareByLink());
    ImageView shareLinkImageView = view.findViewById(R.id.share_link_icon);
    themeShareButtonImage(shareLinkImageView);
    shareLinkImageView.setOnClickListener(v -> shareByLink());
    if (hideNcSharingOptions) {
        sendShareButtons.setVisibility(View.GONE);
        divider.setVisibility(View.GONE);
    } else if (file.isSharedWithMe() && !file.canReshare()) {
        showResharingNotAllowedSnackbar();
        if (file.isFolder()) {
            shareLinkText.setVisibility(View.GONE);
            shareLinkImageView.setVisibility(View.GONE);
            sharePeopleText.setVisibility(View.GONE);
            sharePeopleImageView.setVisibility(View.GONE);
            getDialog().hide();
        } else {
            shareLinkText.setEnabled(false);
            shareLinkText.setAlpha(0.3f);
            shareLinkImageView.setEnabled(false);
            shareLinkImageView.setAlpha(0.3f);
            sharePeopleText.setEnabled(false);
            sharePeopleText.setAlpha(0.3f);
            sharePeopleImageView.setEnabled(false);
            sharePeopleImageView.setAlpha(0.3f);
        }
    }
    // populate send apps
    Intent sendIntent = IntentUtil.createSendIntent(requireContext(), file);
    List<SendButtonData> sendButtonDataList = setupSendButtonData(sendIntent);
    if ("off".equalsIgnoreCase(getContext().getString(R.string.send_files_to_other_apps))) {
        sharePeopleText.setVisibility(View.GONE);
    }
    SendButtonAdapter.ClickListener clickListener = setupSendButtonClickListener(sendIntent);
    RecyclerView sendButtonsView = view.findViewById(R.id.send_button_recycler_view);
    sendButtonsView.setLayoutManager(new GridLayoutManager(getActivity(), 4));
    sendButtonsView.setAdapter(new SendButtonAdapter(sendButtonDataList, clickListener));
    return view;
}
Also used : GridLayoutManager(androidx.recyclerview.widget.GridLayoutManager) SendButtonAdapter(com.owncloud.android.ui.adapter.SendButtonAdapter) TextView(android.widget.TextView) Intent(android.content.Intent) SendButtonData(com.owncloud.android.ui.components.SendButtonData) RecyclerView(androidx.recyclerview.widget.RecyclerView) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout) Nullable(androidx.annotation.Nullable)

Example 3 with SendButtonData

use of com.owncloud.android.ui.components.SendButtonData in project android by nextcloud.

the class SendShareDialog method setupSendButtonData.

@NonNull
private List<SendButtonData> setupSendButtonData(Intent sendIntent) {
    Drawable icon;
    SendButtonData sendButtonData;
    CharSequence label;
    List<ResolveInfo> matches = requireActivity().getPackageManager().queryIntentActivities(sendIntent, 0);
    List<SendButtonData> sendButtonDataList = new ArrayList<>(matches.size());
    for (ResolveInfo match : matches) {
        icon = match.loadIcon(requireActivity().getPackageManager());
        label = match.loadLabel(requireActivity().getPackageManager());
        sendButtonData = new SendButtonData(icon, label, match.activityInfo.packageName, match.activityInfo.name);
        sendButtonDataList.add(sendButtonData);
    }
    return sendButtonDataList;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) SendButtonData(com.owncloud.android.ui.components.SendButtonData) NonNull(androidx.annotation.NonNull)

Example 4 with SendButtonData

use of com.owncloud.android.ui.components.SendButtonData in project android by nextcloud.

the class SendFilesDialog method setupSendButtonData.

@NonNull
private List<SendButtonData> setupSendButtonData(List<ResolveInfo> matches) {
    Drawable icon;
    SendButtonData sendButtonData;
    CharSequence label;
    List<SendButtonData> sendButtonDataList = new ArrayList<>(matches.size());
    for (ResolveInfo match : matches) {
        icon = match.loadIcon(requireActivity().getPackageManager());
        label = match.loadLabel(requireActivity().getPackageManager());
        sendButtonData = new SendButtonData(icon, label, match.activityInfo.packageName, match.activityInfo.name);
        sendButtonDataList.add(sendButtonData);
    }
    return sendButtonDataList;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Drawable(android.graphics.drawable.Drawable) ArrayList(java.util.ArrayList) SendButtonData(com.owncloud.android.ui.components.SendButtonData) NonNull(androidx.annotation.NonNull)

Aggregations

SendButtonData (com.owncloud.android.ui.components.SendButtonData)4 ResolveInfo (android.content.pm.ResolveInfo)3 Intent (android.content.Intent)2 Drawable (android.graphics.drawable.Drawable)2 View (android.view.View)2 NonNull (androidx.annotation.NonNull)2 Nullable (androidx.annotation.Nullable)2 GridLayoutManager (androidx.recyclerview.widget.GridLayoutManager)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 SendButtonAdapter (com.owncloud.android.ui.adapter.SendButtonAdapter)2 ArrayList (java.util.ArrayList)2 ImageView (android.widget.ImageView)1 LinearLayout (android.widget.LinearLayout)1 TextView (android.widget.TextView)1