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

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

add missing functionality

parent 0a159b31
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import com.owncloud.android.lib.resources.shares.OCShare
import it.niedermann.owncloud.notes.share.model.CreateShareRequest
import it.niedermann.owncloud.notes.share.model.CreateShareResponse
import it.niedermann.owncloud.notes.share.model.UpdateShareInformationRequest
import it.niedermann.owncloud.notes.share.model.UpdateSharePermissionRequest
import it.niedermann.owncloud.notes.share.model.UpdateShareRequest
import it.niedermann.owncloud.notes.shared.model.OcsResponse
import retrofit2.Call
@@ -37,8 +38,8 @@ interface ShareAPI {
        subfiles: Boolean
    ): Call<OcsResponse<MutableList<OCShare>>>

    @DELETE("shares")
    fun deleteShare(remoteShareId: Long): Call<EmptyResponse>
    @DELETE("shares/{shareId}")
    fun removeShare(@Path("shareId") shareId: Long): Call<EmptyResponse>

    @PATCH("shares")
    fun updateShare(@Body request: UpdateShareRequest): Call<OcsResponse<CreateShareResponse>>
@@ -51,4 +52,10 @@ interface ShareAPI {
        @Path("shareId") shareId: Long,
        @Body request: UpdateShareInformationRequest
    ): Call<OcsResponse<CreateShareResponse>>

    @PATCH("shares/{shareId}")
    fun updateSharePermission(
        @Path("shareId") shareId: Long,
        @Body request: UpdateSharePermissionRequest
    ): Call<OcsResponse<CreateShareResponse>>
}
+25 −39
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.ContactsContract;
@@ -31,6 +30,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.snackbar.Snackbar;
import com.nextcloud.android.sso.helper.SingleAccountHelper;
import com.owncloud.android.lib.common.operations.RemoteOperationResult;
import com.owncloud.android.lib.common.utils.Log_OC;
import com.owncloud.android.lib.resources.shares.OCShare;
@@ -85,6 +85,7 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
    private Note note;
    private Account account;
    private ClientFactoryImpl clientFactory;
    private ShareRepository repository;

    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -92,7 +93,20 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
        binding = ActivityNoteShareBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initializeArguments();
    }

    private void initializeArguments() {
        Bundle bundler = getIntent().getExtras();
        note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class);
        account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class);
        clientFactory = new ClientFactoryImpl(this);

        new Thread(() -> {{
            try {
                final var ssoAcc = SingleAccountHelper.getCurrentSingleSignOnAccount(NoteShareActivity.this);
                repository = new ShareRepository(NoteShareActivity.this, ssoAcc);

                runOnUiThread(() -> {
                    binding.sharesList.setAdapter(new ShareeListAdapter(this, new ArrayList<>(), this, account));
                    binding.sharesList.setLayoutManager(new LinearLayoutManager(this));
                    binding.pickContactEmailBtn.setOnClickListener(v -> checkContactPermission());
@@ -101,13 +115,12 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
                    setupView();
                    refreshCapabilitiesFromDB();
                    refreshSharesFromDB();
                });
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }}).start();

    private void initializeArguments() {
        Bundle bundler = getIntent().getExtras();
        note = BundleExtensionsKt.getSerializableArgument(bundler, ARG_NOTE, Note.class);
        account = BundleExtensionsKt.getSerializableArgument(bundler, ARG_ACCOUNT, Account.class);
        clientFactory = new ClientFactoryImpl(this);
        if (note == null) {
            throw new IllegalArgumentException("Note cannot be null");
        }
@@ -157,7 +170,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
        }

        SuggestionAdapter suggestionAdapter = new SuggestionAdapter(this, null);
        ShareRepository repository = new ShareRepository(this);
        UsersAndGroupsSearchProvider provider = new UsersAndGroupsSearchProvider(this, repository);

        binding.searchView.setSuggestionsAdapter(suggestionAdapter);
@@ -433,7 +445,7 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
    }

    private void unshareWith(OCShare share) {
        // fileOperationsHelper.unshareShare(file, share);
        repository.removeShare(share.getId());
    }

    /**
@@ -590,14 +602,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
        outState.putSerializable(ARG_ACCOUNT, account);
    }

    public void avatarGenerated(Drawable avatarDrawable, Object callContext) {
        binding.sharedWithYouAvatar.setImageDrawable(avatarDrawable);
    }

    public boolean shouldCallGeneratedCallback(String tag, Object callContext) {
        return false;
    }

    private boolean isReshareForbidden(OCShare share) {
        return false;
        // return ShareType.FEDERATED == share.getShareType() || capabilities != null && capabilities.getFilesSharingResharing().isFalse();
@@ -640,7 +644,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
            showSendLinkTo(share);
        }
         */

    }

    @Override
@@ -663,7 +666,7 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap

    @Override
    public void onQuickPermissionChanged(OCShare share, int permission) {
       // fileOperationsHelper.setPermissionsToShare(share, permission);
       repository.updateSharePermission(share.getId(), permission);
    }

    //launcher for contact permission
@@ -701,16 +704,6 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
                        }
                    });

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

    }

    // TODO: IMPLEMENT
    public void onShareProcessClosed() {

    }

    @Override
    public void applyBrand(int color) {
        final var util = BrandingUtil.of(color, this);
@@ -718,11 +711,4 @@ public class NoteShareActivity extends BrandedActivity implements ShareeListAdap
        util.androidx.themeToolbarSearchView(binding.searchView);
        util.platform.themeHorizontalProgressBar(binding.progressBar);
    }

    public interface OnEditShareListener {
        void editExistingShare(OCShare share, int screenTypePermission, boolean isReshareShown,
                               boolean isExpiryDateShown);

        void onShareProcessClosed();
    }
}
+13 −12
Original line number Diff line number Diff line
@@ -98,7 +98,11 @@ class NoteShareDetailActivity : BrandedActivity(),

        // capabilities = CapabilityUtils.getCapability(context)

        repository = ShareRepository(this)
        lifecycleScope.launch(Dispatchers.IO) {
            val ssoAcc = SingleAccountHelper.getCurrentSingleSignOnAccount(this@NoteShareDetailActivity)
            repository = ShareRepository(this@NoteShareDetailActivity, ssoAcc)

            withContext(Dispatchers.Main) {
                if (shareProcessStep == SCREEN_TYPE_PERMISSION) {
                    showShareProcessFirst()
                } else {
@@ -106,6 +110,8 @@ class NoteShareDetailActivity : BrandedActivity(),
                }
                implementClickEvents()
            }
        }
    }


    override fun applyBrand(color: Int) {
@@ -492,7 +498,6 @@ class NoteShareDetailActivity : BrandedActivity(),
            }

            repository.updateShareInformation(
                ssoAcc,
                share!!.id,
                binding.shareProcessEnterPassword.text.toString().trim(),
                chosenExpDateInMills,
@@ -517,12 +522,9 @@ class NoteShareDetailActivity : BrandedActivity(),
        val noteText = binding.noteText.text.toString().trim()

        lifecycleScope.launch(Dispatchers.IO) {
            val ssoAcc =
                SingleAccountHelper.getCurrentSingleSignOnAccount(this@NoteShareDetailActivity)

            // if modifying existing share then directly update the note and send email
            val result = if (share != null && share?.note != noteText) {
                repository.updateShare(ssoAcc, share!!.id, noteText)
                repository.updateShare(share!!.id, noteText)
            } else {
                if (note == null || shareeName == null) {
                    Log_OC.d(TAG, "validateShareProcessSecond cancelled")
@@ -530,7 +532,6 @@ class NoteShareDetailActivity : BrandedActivity(),
                }

                repository.addShare(
                    ssoAcc,
                    note!!,
                    shareType,
                    shareeName!!,
+3 −4
Original line number Diff line number Diff line
@@ -7,16 +7,15 @@ import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.owncloud.android.lib.resources.shares.OCShare;
import com.owncloud.android.lib.resources.shares.ShareType;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemAddPublicShareBinding;
import it.niedermann.owncloud.notes.databinding.ItemInternalShareLinkBinding;
import it.niedermann.owncloud.notes.databinding.ItemShareLinkShareBinding;
+2 −2
Original line number Diff line number Diff line
@@ -5,12 +5,12 @@ import android.content.Context;
import android.graphics.PorterDuff;
import android.view.View;

import com.owncloud.android.lib.resources.shares.OCShare;

import androidx.annotation.NonNull;
import androidx.core.content.res.ResourcesCompat;
import androidx.recyclerview.widget.RecyclerView;

import com.owncloud.android.lib.resources.shares.OCShare;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemInternalShareLinkBinding;
import it.niedermann.owncloud.notes.share.listener.ShareeListAdapterListener;
Loading