Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a27b91d9 authored by alperozturk's avatar alperozturk
Browse files

dont use user

parent 12856e9b
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ import androidx.appcompat.view.ActionMode;
import androidx.appcompat.view.ActionMode.Callback;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.LifecycleOwner;
import androidx.recyclerview.selection.SelectionTracker;

@@ -31,6 +32,7 @@ import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.accountpicker.AccountPickerDialogFragment;
import it.niedermann.owncloud.notes.branding.BrandedSnackbar;
import it.niedermann.owncloud.notes.edit.category.CategoryDialogFragment;
import it.niedermann.owncloud.notes.share.NoteShareFragment;
import it.niedermann.owncloud.notes.shared.util.ShareUtil;

public class MultiSelectedActionModeCallback implements Callback {
@@ -153,6 +155,32 @@ public class MultiSelectedActionModeCallback implements Callback {
            }
            tracker.clearSelection();

            if (selection.size() == 1) {
                final var currentAccount$ = mainViewModel.getCurrentAccount();
                currentAccount$.observe(lifecycleOwner, account -> {
                    currentAccount$.removeObservers(lifecycleOwner);
                    executor.submit(() -> {{
                        final var note = mainViewModel.getFullNote(selection.get(0));
                        final var noteShareFragment = NoteShareFragment.newInstance(note, account);
                        fragmentManager.findFragmentById(R.id.fragment_container_view);
                        FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                        fragmentTransaction.replace(android.R.id.content, noteShareFragment);
                        fragmentTransaction.commit();
                    }});
                });
            } else {
                ShareUtil.openShareDialog(context,
                        context.getResources().getQuantityString(R.plurals.share_multiple, selection.size(), selection.size()),
                        mainViewModel.collectNoteContents(selection));
            }

            /*
             final var selection = new ArrayList<Long>(tracker.getSelection().size());
            for (final var sel : tracker.getSelection()) {
                selection.add(sel);
            }
            tracker.clearSelection();

            executor.submit(() -> {
                if (selection.size() == 1) {
                    final var note = mainViewModel.getFullNote(selection.get(0));
@@ -163,6 +191,8 @@ public class MultiSelectedActionModeCallback implements Callback {
                            mainViewModel.collectNoteContents(selection));
                }
            });
             */

            return true;
        } else if (itemId == R.id.menu_category) {// TODO detect whether all selected notes do have the same category - in this case preselect it
            final var accountLiveData = mainViewModel.getCurrentAccount();
+13 −20
Original line number Diff line number Diff line
@@ -71,18 +71,15 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList

    private FragmentNoteShareBinding binding;
    private Note note;
    private User user;
    private Account account;

    private OnEditShareListener onEditShareListener;
    private ClientFactoryImpl clientFactory;

    public static NoteShareFragment newInstance(Note note, User user, Account account) {
    public static NoteShareFragment newInstance(Note note, Account account) {
        NoteShareFragment fragment = new NoteShareFragment();
        Bundle args = new Bundle();
        args.putSerializable(ARG_NOTE, note);
        args.putSerializable(ARG_ACCOUNT, account);
        args.putParcelable(ARG_USER, user);
        fragment.setArguments(args);
        return fragment;
    }
@@ -96,13 +93,11 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
        if (savedInstanceState != null) {
            note = BundleExtensionsKt.getSerializableArgument(savedInstanceState, ARG_NOTE, Note.class);
            account = BundleExtensionsKt.getSerializableArgument(savedInstanceState, ARG_ACCOUNT, Account.class);
            user = BundleExtensionsKt.getParcelableArgument(savedInstanceState, ARG_USER, User.class);
        } else {
            Bundle arguments = getArguments();
            if (arguments != null) {
                note = BundleExtensionsKt.getSerializableArgument(arguments, ARG_NOTE, Note.class);
                account = BundleExtensionsKt.getSerializableArgument(arguments, ARG_ACCOUNT, Account.class);
                user = BundleExtensionsKt.getParcelableArgument(arguments, ARG_USER, User.class);
            }
        }

@@ -110,7 +105,7 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
            throw new IllegalArgumentException("Note cannot be null");
        }

        if (user == null) {
        if (account == null) {
            throw new IllegalArgumentException("Account cannot be null");
        }
    }
@@ -130,7 +125,6 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
        binding.sharesList.setAdapter(new ShareeListAdapter(requireActivity(),
                new ArrayList<>(),
                this,
                user,
                account));

        binding.sharesList.setLayoutManager(new LinearLayoutManager(requireContext()));
@@ -148,16 +142,6 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
        binding = null;
    }

    @Override
    public void onAttach(@NonNull Context context) {
        super.onAttach(context);
        try {
            onEditShareListener = (OnEditShareListener) context;
        } catch (Exception e) {
            throw new IllegalArgumentException("Calling activity must implement the interface", e);
        }
    }

    @Override
    public void onStart() {
        super.onStart();
@@ -577,7 +561,6 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
        super.onSaveInstanceState(outState);
        outState.putSerializable(ARG_NOTE, note);
        outState.putSerializable(ARG_ACCOUNT, account);
        outState.putParcelable(ARG_USER, user);
    }

    public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
@@ -640,7 +623,7 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
    }

    private void modifyExistingShare(OCShare share, int screenTypePermission) {
        // onEditShareListener.editExistingShare(share, screenTypePermission, !isReshareForbidden(share), capabilities.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_18));
        // editExistingShare(share, screenTypePermission, !isReshareForbidden(share), capabilities.getVersion().isNewerOrEqual(OwnCloudVersion.nextcloud_18));
    }

    @Override
@@ -683,6 +666,16 @@ public class NoteShareFragment extends Fragment implements ShareeListAdapterList
                        }
                    });

    // TODO: IMPLEMENT
    public void editExistingShare(OCShare share, int screenTypePermission, boolean isReshareShown, boolean isExpiryDateShown) {

    }

    // TODO: IMPLEMENT
    public void onShareProcessClosed() {

    }

    public interface OnEditShareListener {
        void editExistingShare(OCShare share, int screenTypePermission, boolean isReshareShown,
                               boolean isExpiryDateShown);
+0 −7
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import it.niedermann.owncloud.notes.share.adapter.holder.LinkShareViewHolder;
import it.niedermann.owncloud.notes.share.adapter.holder.NewLinkShareViewHolder;
import it.niedermann.owncloud.notes.share.adapter.holder.ShareViewHolder;
import it.niedermann.owncloud.notes.share.listener.ShareeListAdapterListener;
import it.niedermann.owncloud.notes.shared.user.User;

/**
 * Adapter to show a user/group/email/remote in Sharing list in file details view.
@@ -38,20 +37,15 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
    private final ShareeListAdapterListener listener;
    private final Activity activity;
    private List<OCShare> shares;
    private final float avatarRadiusDimension;
    private final User user;

    public ShareeListAdapter(Activity activity,
                             List<OCShare> shares,
                             ShareeListAdapterListener listener,
                             User user,
                             Account account) {
        this.activity = activity;
        this.shares = shares;
        this.listener = listener;
        this.user = user;
        this.account = account;
        avatarRadiusDimension = activity.getResources().getDimension(R.dimen.default_icon_size);

        sortShares();
    }
@@ -89,7 +83,6 @@ public class ShareeListAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
                        parent,
                        false),
                        account,
                        user,
                        activity);
            }
        }
+1 −4
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import it.niedermann.owncloud.notes.shared.user.User;

public class ShareViewHolder extends RecyclerView.ViewHolder {
    private ItemShareShareBinding binding;
    private User user;
    private Account account;
    private Context context;

@@ -35,11 +34,9 @@ public class ShareViewHolder extends RecyclerView.ViewHolder {

    public ShareViewHolder(ItemShareShareBinding binding,
                           Account account,
                           User user,
                           Context context) {
        this(binding.getRoot());
        this.binding = binding;
        this.user = user;
        this.account = account;
        this.context = context;
    }
@@ -76,7 +73,7 @@ public class ShareViewHolder extends RecyclerView.ViewHolder {
                        .apply(RequestOptions.circleCropTransform())
                        .into(binding.icon);

                binding.icon.setOnClickListener(v -> listener.showProfileBottomSheet(user, share.getShareWith()));
                // binding.icon.setOnClickListener(v -> listener.showProfileBottomSheet(user, share.getShareWith()));
            default:
                setImage(binding.icon, name, R.drawable.ic_account_circle_grey_24dp);
                break;