Skip to content

Feature - Share Functionality #2574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 129 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
8c5e87f
add layout
alperozturk96 Jan 27, 2025
f7acd88
add fragment
alperozturk96 Jan 27, 2025
9f825a8
add some logic
alperozturk96 Jan 27, 2025
612e400
add viewholders
alperozturk96 Jan 27, 2025
0dec990
add UsersAndGroupsSearchConfig
alperozturk96 Jan 27, 2025
547b732
add ShareLinkToDialog
alperozturk96 Jan 27, 2025
34f4a5a
add FileDetailSharingMenuBottomSheetDialog
alperozturk96 Jan 27, 2025
843fda2
add QuickSharingPermissionsBottomSheetDialog
alperozturk96 Jan 27, 2025
479124e
add SharePasswordDialogFragment
alperozturk96 Jan 27, 2025
1847eda
add RetrieveHoverCardAsyncTask
alperozturk96 Jan 27, 2025
12856e9
first successfull build
alperozturk96 Jan 28, 2025
a27b91d
dont use user
alperozturk96 Jan 28, 2025
635ba0e
convert to activity
alperozturk96 Jan 28, 2025
1e12048
use branded activity
alperozturk96 Jan 28, 2025
35fa976
add share api
alperozturk96 Jan 28, 2025
c2867eb
use share api
alperozturk96 Jan 28, 2025
c4b11ef
fix parsing for sharee
alperozturk96 Jan 29, 2025
9d8c065
bind suggestions to UI
alperozturk96 Jan 29, 2025
e157d86
bind suggestions to UI
alperozturk96 Jan 29, 2025
484677b
add to-do
alperozturk96 Jan 29, 2025
af49ff3
Rename .java to .kt
alperozturk96 Jan 29, 2025
b2c7f9f
add icon for suggestion
alperozturk96 Jan 29, 2025
092ebd2
add READ_CONTACTS permission
alperozturk96 Jan 29, 2025
d52e1bd
fix share internal link
alperozturk96 Jan 29, 2025
6224f49
hide shared_with_you_container
alperozturk96 Jan 29, 2025
2d00a24
add previous functionality
alperozturk96 Jan 29, 2025
1c83a3d
add NoteShareDetailActivity
alperozturk96 Jan 29, 2025
2fa741d
cleanup translations
alperozturk96 Jan 29, 2025
fb20691
add create share
alperozturk96 Jan 30, 2025
560aef1
add create share
alperozturk96 Jan 30, 2025
72d9af1
cleanup
alperozturk96 Jan 30, 2025
99073a1
add progress bar for search
alperozturk96 Jan 30, 2025
f11ba65
updated CreateShareResponse
alperozturk96 Jan 30, 2025
015f6b4
dont use blocking get
alperozturk96 Jan 30, 2025
39b1265
add update logic
alperozturk96 Jan 31, 2025
bfa547c
add updateShareInformation
alperozturk96 Jan 31, 2025
0a159b3
add edit
alperozturk96 Jan 31, 2025
b7cedb3
add missing functionality
alperozturk96 Jan 31, 2025
bd0fc3e
add search_close_btn
alperozturk96 Jan 31, 2025
e1da399
fix UsersAndGroupsSearchProvider
alperozturk96 Jan 31, 2025
a4644a1
fix UsersAndGroupsSearchProvider
alperozturk96 Jan 31, 2025
30344ac
fix getSharees
alperozturk96 Jan 31, 2025
9920b40
fix add
alperozturk96 Feb 3, 2025
1f505d3
add getShares
alperozturk96 Feb 3, 2025
98b5446
add fetch and save logic
alperozturk96 Feb 3, 2025
9694a65
fix build
alperozturk96 Feb 3, 2025
848b2ca
fix more action bottom sheet
alperozturk96 Feb 3, 2025
fed14ff
fix removeShare
alperozturk96 Feb 4, 2025
5e02a85
remove unused functionalities
alperozturk96 Feb 4, 2025
279ac4d
remove unused functionalities
alperozturk96 Feb 4, 2025
ea1e5d7
add new capabilities
alperozturk96 Feb 4, 2025
90741fa
add new capabilities
alperozturk96 Feb 4, 2025
7d2db4d
save capabilities as entity
alperozturk96 Feb 4, 2025
82c0c61
fix flow
alperozturk96 Feb 4, 2025
9b1e334
fix update logic
alperozturk96 Feb 4, 2025
3d5d6ab
separate logic
alperozturk96 Feb 4, 2025
7fc7a9d
remove duplicated logic
alperozturk96 Feb 4, 2025
cef1f0c
remove duplicated logic
alperozturk96 Feb 4, 2025
b6df0e9
add ShareAttributes versions
alperozturk96 Feb 4, 2025
11766b4
fix condition for shouldUseShareAttributesV2
alperozturk96 Feb 4, 2025
e4a9f1c
fix avatar loader
alperozturk96 Feb 4, 2025
02116e9
use ScheduledExecutorService
alperozturk96 Feb 4, 2025
66fd0b9
shutdown ScheduledExecutorService onDestroy
alperozturk96 Feb 4, 2025
2a2d022
remove unused codes
alperozturk96 Feb 4, 2025
de64c43
BrandedBottomSheetDialog
alperozturk96 Feb 4, 2025
502a058
BrandedViewHolder
alperozturk96 Feb 4, 2025
00ba5f9
fix colors
alperozturk96 Feb 4, 2025
a44bc82
add ARG_EXP_DATE_SHOWN
alperozturk96 Feb 4, 2025
933486d
add TODOs
alperozturk96 Feb 4, 2025
64ec92d
fix updateShare
alperozturk96 Feb 5, 2025
dcbd41a
fix getSharesForNotesAndSaveShareEntities
alperozturk96 Feb 5, 2025
ba15c67
fix getSharesForNotesAndSaveShareEntities
alperozturk96 Feb 5, 2025
be3b159
fix duplicated items
alperozturk96 Feb 5, 2025
19842c5
fix accountOwnsFile
alperozturk96 Feb 5, 2025
705bb37
skip all types but users, as E2E secure share is only allowed to user…
alperozturk96 Feb 5, 2025
50a38af
optimize imports
alperozturk96 Feb 5, 2025
cee9c47
fix compilation error
alperozturk96 Feb 14, 2025
055e23f
add some logic
alperozturk96 Jan 27, 2025
370c4bd
first successfull build
alperozturk96 Jan 28, 2025
534257e
fix build
alperozturk96 Feb 3, 2025
54ff709
add createPublicShareLink
alperozturk96 Feb 5, 2025
74b2d47
fix createPublicShareLink
alperozturk96 Feb 5, 2025
95be6c1
add copyAndShareFileLink
alperozturk96 Feb 5, 2025
a2b285b
clean imports
alperozturk96 Feb 5, 2025
876f997
add fix me
alperozturk96 Feb 5, 2025
ae00490
add missing field for oc share
alperozturk96 Feb 5, 2025
96d05c3
add isSharedViaLink
alperozturk96 Feb 6, 2025
a715566
fix json parsing
alperozturk96 Feb 6, 2025
b71874b
fix git conflicts
alperozturk96 Feb 14, 2025
9cbae8a
add some logic
alperozturk96 Jan 27, 2025
0d00294
first successfull build
alperozturk96 Jan 28, 2025
5b96d8a
fix build
alperozturk96 Feb 3, 2025
7446b35
add createPublicShareLink
alperozturk96 Feb 5, 2025
c82dedd
add copyAndShareFileLink
alperozturk96 Feb 5, 2025
5fb2419
add setShareWithYou
alperozturk96 Feb 10, 2025
2c3bbf4
fix else logic
alperozturk96 Feb 10, 2025
88bf3fd
remove unnecessary delay logic
alperozturk96 Feb 10, 2025
e8c4131
fix
alperozturk96 Feb 10, 2025
06839b6
fix
alperozturk96 Feb 10, 2025
48670cf
fix git conflicts
alperozturk96 Feb 14, 2025
097a1c2
remove note
alperozturk96 Feb 14, 2025
bd3ef72
check resharing
alperozturk96 Feb 17, 2025
fdd8a2b
Merge pull request #2578 from nextcloud/feature/shared-with-you
tobiasKaminsky Feb 18, 2025
3f7c920
Merge pull request #2575 from nextcloud/feature/public-share
tobiasKaminsky Feb 18, 2025
8f2bc70
add getShareFromNote
alperozturk96 Feb 18, 2025
5576e04
check public share permission
alperozturk96 Feb 18, 2025
90ed413
merge master
alperozturk96 Feb 18, 2025
a67fbd7
merge master
alperozturk96 Feb 18, 2025
7f8cbc7
remove unused functions and add todos
alperozturk96 Feb 18, 2025
01df2e3
fail fast handleContactResult
alperozturk96 Feb 18, 2025
1a00750
add FIXME
alperozturk96 Feb 18, 2025
0c75ba5
fix crashes
alperozturk96 Feb 19, 2025
4898e09
fix crashes
alperozturk96 Feb 19, 2025
2adf41f
check shareType
alperozturk96 Feb 19, 2025
ca134d9
add loading layout
alperozturk96 Feb 19, 2025
50c103d
check shares
alperozturk96 Feb 19, 2025
a0808aa
add FilesSpecificViewThemeUtils
alperozturk96 Feb 21, 2025
e576292
fix toOCShare
alperozturk96 Feb 21, 2025
db6f425
fix isHideFileDownload
alperozturk96 Feb 21, 2025
6a279c8
solve git conflict
alperozturk96 Feb 21, 2025
8228c47
solve git conflict
alperozturk96 Feb 21, 2025
dbe2bf1
fix git conflict
alperozturk96 Apr 2, 2025
7bc133a
fix git conflict
alperozturk96 Apr 2, 2025
8cb5ad9
Merge branch 'main' into feature/internal-share
alperozturk96 Apr 3, 2025
6557a20
simplify
alperozturk96 Apr 3, 2025
ff1527a
fix duplication and avatar
alperozturk96 Apr 3, 2025
73e7f7d
fix git conflicts
alperozturk96 Apr 14, 2025
4ef5822
Merge branch 'main' into feature/internal-share
alperozturk96 Apr 17, 2025
cce12b8
inject SharePasswordDialogListener
alperozturk96 Apr 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ ext {
dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'

implementation 'com.google.guava:guava:31.1-android'
Copy link
Collaborator Author

@alperozturk96 alperozturk96 Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for to fix following build error:

 error: cannot access ListenableFuture
public class SyncWorker extends Worker {
       ^
  class file for com.google.common.util.concurrent.ListenableFuture not found

implementation ('commons-httpclient:commons-httpclient:3.1') {
exclude group: 'commons-logging', module: 'commons-logging'
}

implementation("com.github.nextcloud:android-library:2.19.0") {
Copy link
Collaborator Author

@alperozturk96 alperozturk96 Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for

android.lib.resources.shares.OCShare
android.lib.resources.shares.ShareType
...

exclude group: 'org.ogce', module: 'xpp3'
}

// Nextcloud SSO
implementation 'com.github.nextcloud.android-common:ui:48ed8e86d9'
implementation 'com.github.nextcloud:Android-SingleSignOn:1.3.2'
Expand Down
15 changes: 14 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<uses-permission android:name="android.permission.READ_CONTACTS" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for NoteShareActivity.requestContactPermissionLauncher()

<uses-permission android:name="com.owncloud.android.providers.PERMISSION" />
<queries>
<package android:name="com.nextcloud.client" />
<package android:name="com.nextcloud.android.beta" />
Expand Down Expand Up @@ -47,10 +48,22 @@
android:value=".android.activity.NotesListViewActivity" />
</activity>

<activity
android:name=".share.NoteShareActivity" />

<activity
android:name=".share.NoteShareDetailActivity" />

<activity
android:name=".importaccount.ImportAccountActivity"
android:label="@string/add_account" />

<activity
android:name=".shared.util.clipboard.CopyToClipboardActivity"
android:exported="false"
android:icon="@drawable/shared_via_link"
android:label="@string/copy_link" />

<activity
android:name=".AppendToNoteActivity"
android:label="@string/append_to_note"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
import androidx.annotation.NonNull;
import androidx.fragment.app.DialogFragment;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.material.dialog.MaterialAlertDialogBuilder;

import it.niedermann.owncloud.notes.NotesApplication;
Expand All @@ -30,6 +28,7 @@
import it.niedermann.owncloud.notes.manageaccounts.ManageAccountsActivity;
import it.niedermann.owncloud.notes.persistence.NotesRepository;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.share.helper.AvatarLoader;

/**
* Displays all available {@link Account} entries and provides basic operations for them, like adding or switching
Expand Down Expand Up @@ -74,11 +73,7 @@ public Dialog onCreateDialog(Bundle savedInstanceState) {

binding.accountName.setText(currentLocalAccount.getDisplayName());
binding.accountHost.setText(Uri.parse(currentLocalAccount.getUrl()).getHost());
Glide.with(requireContext())
.load(currentLocalAccount.getUrl() + "/index.php/avatar/" + Uri.encode(currentLocalAccount.getUserName()) + "/64")
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(binding.currentAccountItemAvatar);
AvatarLoader.INSTANCE.load(requireContext(), binding.currentAccountItemAvatar, currentLocalAccount);
binding.accountLayout.setOnClickListener((v) -> dismiss());

final var adapter = new AccountSwitcherAdapter((localAccount -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.share.helper.AvatarLoader;

public class AccountSwitcherViewHolder extends RecyclerView.ViewHolder {

Expand All @@ -34,12 +30,7 @@ public AccountSwitcherViewHolder(@NonNull View itemView) {
public void bind(@NonNull Account localAccount, @NonNull Consumer<Account> onAccountClick) {
binding.accountName.setText(localAccount.getDisplayName());
binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost());
Glide.with(itemView.getContext())
.load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64"))
.placeholder(R.drawable.ic_account_circle_grey_24dp)
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(binding.accountItemAvatar);
AvatarLoader.INSTANCE.load(itemView.getContext(), binding.accountItemAvatar, localAccount);
itemView.setOnClickListener((v) -> onAccountClick.accept(localAccount));
binding.accountContextMenu.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package it.niedermann.owncloud.notes.branding

import android.content.Context
import androidx.annotation.ColorInt
import com.google.android.material.bottomsheet.BottomSheetDialog

abstract class BrandedBottomSheetDialog(context: Context) : BottomSheetDialog(context), Branded {

override fun onStart() {
super.onStart()

@ColorInt val color = BrandingUtil.readBrandMainColor(context)
applyBrand(color)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package it.niedermann.owncloud.notes.branding

import android.view.View
import androidx.annotation.ColorInt
import androidx.recyclerview.widget.RecyclerView

abstract class BrandedViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView), Branded {

fun bindBranding() {
@ColorInt val color = BrandingUtil.readBrandMainColor(itemView.context)
applyBrand(color)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
if (content == null) {
throw new IllegalArgumentException(PARAM_NOTE_ID + " is not given, argument " + PARAM_NEWNOTE + " is missing and " + PARAM_CONTENT + " is missing.");
} else {
note = new Note(-1, null, Calendar.getInstance(), NoteUtil.generateNoteTitle(content), content, getString(R.string.category_readonly), false, null, DBStatus.VOID, -1, "", 0);
note = new Note(-1, null, Calendar.getInstance(), NoteUtil.generateNoteTitle(content), content, getString(R.string.category_readonly), false, null, DBStatus.VOID, -1, "", 0, false, false);
requireActivity().runOnUiThread(() -> onNoteLoaded(note));
requireActivity().invalidateOptionsMenu();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private void launchNewNote() {
if (content == null) {
content = "";
}
final var newNote = new Note(null, Calendar.getInstance(), NoteUtil.generateNonEmptyNoteTitle(content, this), content, categoryTitle, favorite, null);
final var newNote = new Note(null, Calendar.getInstance(), NoteUtil.generateNonEmptyNoteTitle(content, this), content, categoryTitle, favorite, null, false, false);
fragment = getNewNoteFragment(newNote);
replaceFragment();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import it.niedermann.owncloud.notes.persistence.CapabilitiesWorker;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.share.helper.AvatarLoader;
import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod;
import it.niedermann.owncloud.notes.shared.model.IResponseCallback;
import it.niedermann.owncloud.notes.shared.model.NavigationCategory;
Expand Down Expand Up @@ -517,7 +518,7 @@ public void onError(@NonNull Throwable t) {
public void onSelectionChanged() {
super.onSelectionChanged();
if (tracker.hasSelection() && mActionMode == null) {
mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback(MainActivity.this, coordinatorLayout, binding.activityNotesListView.fabCreate, mainViewModel, MainActivity.this, canMoveNoteToAnotherAccounts, tracker, getSupportFragmentManager()));
mActionMode = startSupportActionMode(new MultiSelectedActionModeCallback(MainActivity.this,MainActivity.this, coordinatorLayout, binding.activityNotesListView.fabCreate, mainViewModel, MainActivity.this, canMoveNoteToAnotherAccounts, tracker, getSupportFragmentManager()));
}
if (mActionMode != null) {
if (tracker.hasSelection()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
package it.niedermann.owncloud.notes.main;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.TypedValue;
import android.view.Menu;
import android.view.MenuItem;
Expand All @@ -31,6 +33,7 @@
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.NoteShareActivity;
import it.niedermann.owncloud.notes.shared.util.ShareUtil;

public class MultiSelectedActionModeCallback implements Callback {
Expand All @@ -53,8 +56,11 @@ public class MultiSelectedActionModeCallback implements Callback {
private final SelectionTracker<Long> tracker;
@NonNull
private final FragmentManager fragmentManager;
@NonNull
private final MainActivity mainActivity;

public MultiSelectedActionModeCallback(
@NonNull MainActivity mainActivity,
@NonNull Context context,
@NonNull View view,
@NonNull View anchorView,
Expand All @@ -63,6 +69,7 @@ public MultiSelectedActionModeCallback(
boolean canMoveNoteToAnotherAccounts,
@NonNull SelectionTracker<Long> tracker,
@NonNull FragmentManager fragmentManager) {
this.mainActivity = mainActivity;
this.context = context;
this.view = view;
this.anchorView = anchorView;
Expand Down Expand Up @@ -153,16 +160,26 @@ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
}
tracker.clearSelection();

executor.submit(() -> {
if (selection.size() == 1) {
final var note = mainViewModel.getFullNote(selection.get(0));
ShareUtil.openShareDialog(context, note.getTitle(), note.getContent());
} else {
ShareUtil.openShareDialog(context,
context.getResources().getQuantityString(R.plurals.share_multiple, selection.size(), selection.size()),
mainViewModel.collectNoteContents(selection));
}
});
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));
Bundle bundle = new Bundle();
bundle.putSerializable(NoteShareActivity.ARG_NOTE, note);
bundle.putSerializable(NoteShareActivity.ARG_ACCOUNT, account);
Intent intent = new Intent(mainActivity, NoteShareActivity.class);
intent.putExtras(bundle);
mainActivity.startActivity(intent);
}});
});
} else {
ShareUtil.openShareDialog(context,
context.getResources().getQuantityString(R.plurals.share_multiple, selection.size(), selection.size()),
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
import androidx.appcompat.widget.PopupMenu;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;

import it.niedermann.nextcloud.sso.glide.SingleSignOnUrl;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.branding.BrandingUtil;
import it.niedermann.owncloud.notes.databinding.ItemAccountChooseBinding;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.share.helper.AvatarLoader;

public class ManageAccountViewHolder extends RecyclerView.ViewHolder {

Expand All @@ -43,11 +40,7 @@ public void bind(
) {
binding.accountName.setText(localAccount.getUserName());
binding.accountHost.setText(Uri.parse(localAccount.getUrl()).getHost());
Glide.with(itemView.getContext())
.load(new SingleSignOnUrl(localAccount.getAccountName(), localAccount.getUrl() + "/index.php/avatar/" + Uri.encode(localAccount.getUserName()) + "/64"))
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(binding.accountItemAvatar);
AvatarLoader.INSTANCE.load(itemView.getContext(), binding.accountItemAvatar, localAccount);
itemView.setOnClickListener((v) -> callback.onSelect(localAccount));
binding.accountContextMenu.setVisibility(VISIBLE);
binding.accountContextMenu.setOnClickListener((v) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializer;
import com.google.gson.Strictness;
import com.nextcloud.android.sso.api.NextcloudAPI;
import com.nextcloud.android.sso.model.SingleSignOnAccount;

Expand All @@ -29,8 +30,10 @@
import it.niedermann.owncloud.notes.persistence.sync.FilesAPI;
import it.niedermann.owncloud.notes.persistence.sync.NotesAPI;
import it.niedermann.owncloud.notes.persistence.sync.OcsAPI;
import it.niedermann.owncloud.notes.persistence.sync.ShareAPI;
import it.niedermann.owncloud.notes.shared.model.ApiVersion;
import it.niedermann.owncloud.notes.shared.model.Capabilities;
import okhttp3.ResponseBody;
import retrofit2.NextcloudRetrofitApiBuilder;
import retrofit2.Retrofit;

Expand All @@ -47,12 +50,14 @@ public class ApiProvider {

private static final String API_ENDPOINT_OCS = "/ocs/v2.php/cloud/";
private static final String API_ENDPOINT_FILES ="/ocs/v2.php/apps/files/api/v1/";
private static final String API_ENDPOINT_FILES_SHARING ="/ocs/v2.php/apps/files_sharing/api/v1/";

private static final Map<String, NextcloudAPI> API_CACHE = new ConcurrentHashMap<>();

private static final Map<String, OcsAPI> API_CACHE_OCS = new ConcurrentHashMap<>();
private static final Map<String, NotesAPI> API_CACHE_NOTES = new ConcurrentHashMap<>();
private static final Map<String, FilesAPI> API_CACHE_FILES = new ConcurrentHashMap<>();
private static final Map<String, ShareAPI> API_CACHE_FILES_SHARING = new ConcurrentHashMap<>();


public static ApiProvider getInstance() {
Expand Down Expand Up @@ -96,13 +101,23 @@ public synchronized FilesAPI getFilesAPI(@NonNull Context context, @NonNull Sing
return filesAPI;
}

public synchronized ShareAPI getShareAPI(@NonNull Context context, @NonNull SingleSignOnAccount ssoAccount) {
if (API_CACHE_FILES_SHARING.containsKey(ssoAccount.name)) {
return API_CACHE_FILES_SHARING.get(ssoAccount.name);
}
final var shareAPI = new NextcloudRetrofitApiBuilder(getNextcloudAPI(context, ssoAccount), API_ENDPOINT_FILES_SHARING).create(ShareAPI.class);
API_CACHE_FILES_SHARING.put(ssoAccount.name, shareAPI);
return shareAPI;
}

private synchronized NextcloudAPI getNextcloudAPI(@NonNull Context context, @NonNull SingleSignOnAccount ssoAccount) {
if (API_CACHE.containsKey(ssoAccount.name)) {
return API_CACHE.get(ssoAccount.name);
} else {
Log.v(TAG, "NextcloudRequest account: " + ssoAccount.name);
final var nextcloudAPI = new NextcloudAPI(context.getApplicationContext(), ssoAccount,
new GsonBuilder()
.setStrictness(Strictness.LENIENT)
.excludeFieldsWithoutExposeAnnotation()
.registerTypeHierarchyAdapter(Calendar.class, (JsonSerializer<Calendar>) (src, typeOfSrc, ctx) -> new JsonPrimitive(src.getTimeInMillis() / 1_000))
.registerTypeHierarchyAdapter(Calendar.class, (JsonDeserializer<Calendar>) (src, typeOfSrc, ctx) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public Result doWork() {
for (final var account : repo.getAccounts()) {
try {
final var ssoAccount = AccountImporter.getSingleSignOnAccount(getApplicationContext(), account.getAccountName());

Log.i(TAG, "Refreshing capabilities for " + ssoAccount.name);
final var capabilities = CapabilitiesClient.getCapabilities(getApplicationContext(), ssoAccount, account.getCapabilitiesETag(), ApiProvider.getInstance());
repo.updateCapabilitiesETag(account.getId(), capabilities.getETag());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@
import androidx.sqlite.db.SupportSQLiteDatabase;

import it.niedermann.owncloud.notes.persistence.dao.AccountDao;
import it.niedermann.owncloud.notes.persistence.dao.CapabilitiesDao;
import it.niedermann.owncloud.notes.persistence.dao.CategoryOptionsDao;
import it.niedermann.owncloud.notes.persistence.dao.NoteDao;
import it.niedermann.owncloud.notes.persistence.dao.ShareDao;
import it.niedermann.owncloud.notes.persistence.dao.WidgetNotesListDao;
import it.niedermann.owncloud.notes.persistence.dao.WidgetSingleNoteDao;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.CategoryOptions;
import it.niedermann.owncloud.notes.persistence.entity.Converters;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.persistence.entity.NotesListWidgetData;
import it.niedermann.owncloud.notes.persistence.entity.ShareEntity;
import it.niedermann.owncloud.notes.persistence.entity.SingleNoteWidgetData;
import it.niedermann.owncloud.notes.persistence.migration.Migration_10_11;
import it.niedermann.owncloud.notes.persistence.migration.Migration_11_12;
Expand All @@ -43,15 +46,18 @@
import it.niedermann.owncloud.notes.persistence.migration.Migration_23_24;
import it.niedermann.owncloud.notes.persistence.migration.Migration_24_25;
import it.niedermann.owncloud.notes.persistence.migration.Migration_9_10;
import it.niedermann.owncloud.notes.shared.model.Capabilities;

@Database(
entities = {
Account.class,
Note.class,
CategoryOptions.class,
SingleNoteWidgetData.class,
NotesListWidgetData.class
}, version = 25
NotesListWidgetData.class,
ShareEntity.class,
Capabilities.class
}, version = 26
)
@TypeConverters({Converters.class})
public abstract class NotesDatabase extends RoomDatabase {
Expand Down Expand Up @@ -115,4 +121,8 @@ public void onCreate(@NonNull SupportSQLiteDatabase db) {
public abstract WidgetSingleNoteDao getWidgetSingleNoteDao();

public abstract WidgetNotesListDao getWidgetNotesListDao();

public abstract ShareDao getShareDao();

public abstract CapabilitiesDao getCapabilitiesDao();
}
Loading
Loading