Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,12 @@ dependencies {

// Nextcloud SSO
implementation 'com.github.nextcloud.android-common:ui:0.28.0'
implementation 'com.github.nextcloud:Android-SingleSignOn:1.3.2'
implementation "com.github.stefan-niedermann.android-commons:shared-preferences:$androidCommonsVersion"
implementation("com.github.nextcloud:Android-SingleSignOn:$singleSignOnVersion") {
version {
strictly(singleSignOnVersion)
}
}
implementation "com.github.stefan-niedermann.android-commons:shared-preferences:$androidCommonsVersion"
implementation "com.github.stefan-niedermann.android-commons:reactive-livedata:$androidCommonsVersion"
implementation "com.github.stefan-niedermann.android-commons:util:$androidCommonsVersion"
implementation "com.github.stefan-niedermann.nextcloud-commons:sso-glide:$commonsVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private void registerFilesAppType() {
return;
}

FilesAppTypeRegistry.getInstance().init(new FilesAppType(packageId, accountType, FilesAppType.Type.PROD));
FilesAppTypeRegistry.getInstance().init(new FilesAppType(packageId, accountType, FilesAppType.Stage.PROD));
}

public static BrandingUtil brandingUtil() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ private static Intent generateTrashbinIntent(@NonNull Context context, @NonNull
// https://github.com/nextcloud/android/pull/8405#issuecomment-852966877
final int minVersionCode = 30170090;
try {
Optional<FilesAppType> prod = FilesAppTypeRegistry.getInstance().getTypes().stream().filter(t -> t.type == FilesAppType.Type.PROD).findFirst();
Optional<FilesAppType> dev = FilesAppTypeRegistry.getInstance().getTypes().stream().filter(t -> t.type == FilesAppType.Type.DEV).findFirst();
Optional<FilesAppType> prod = FilesAppTypeRegistry.getInstance().getTypes().stream().filter(t -> t.stage() == FilesAppType.Stage.PROD).findFirst();
Optional<FilesAppType> dev = FilesAppTypeRegistry.getInstance().getTypes().stream().filter(t -> t.stage() == FilesAppType.Stage.DEV).findFirst();
if (prod.isPresent() && VersionCheckHelper.getNextcloudFilesVersionCode(context, prod.get()) > minVersionCode) {
return generateTrashbinAppIntent(context, account, prod.get());
} else if (dev.isPresent() && VersionCheckHelper.getNextcloudFilesVersionCode(context, dev.get()) > minVersionCode) {
Expand All @@ -105,7 +105,7 @@ private static Intent generateTrashbinIntent(@NonNull Context context, @NonNull

private static Intent generateTrashbinAppIntent(@NonNull Context context, @NonNull Account account, FilesAppType type) throws PackageManager.NameNotFoundException {
final var packageManager = context.getPackageManager();
final String packageName = type.packageId;
final String packageName = type.packageId();
final var intent = new Intent();
intent.setClassName(packageName, "com.owncloud.android.ui.trashbin.TrashbinActivity");
if (packageManager.resolveActivity(intent, 0) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
*/
package it.niedermann.owncloud.notes.persistence;

import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED;
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;
import static it.niedermann.owncloud.notes.shared.model.DBStatus.LOCAL_DELETED;
import static it.niedermann.owncloud.notes.shared.util.NoteUtil.generateNoteExcerpt;

import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;

import com.nextcloud.android.sso.AccountImporter;
import com.nextcloud.android.sso.api.ParsedResponse;
import com.nextcloud.android.sso.exceptions.NextcloudApiNotRespondingException;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException;
import com.nextcloud.android.sso.exceptions.NextcloudNetworkException;
import com.nextcloud.android.sso.exceptions.TokenMismatchException;
import com.nextcloud.android.sso.model.SingleSignOnAccount;
import com.owncloud.android.lib.common.utils.Log_OC;

import java.util.ArrayList;
import java.util.Calendar;
Expand All @@ -26,7 +33,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import it.niedermann.owncloud.notes.BuildConfig;
import it.niedermann.owncloud.notes.persistence.entity.Account;
Expand All @@ -36,13 +42,6 @@
import it.niedermann.owncloud.notes.shared.model.ISyncCallback;
import it.niedermann.owncloud.notes.shared.model.SyncResultStatus;
import it.niedermann.owncloud.notes.shared.util.ApiVersionUtil;
import retrofit2.Response;

import static it.niedermann.owncloud.notes.shared.model.DBStatus.LOCAL_DELETED;
import static it.niedermann.owncloud.notes.shared.util.NoteUtil.generateNoteExcerpt;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.net.HttpURLConnection.HTTP_NOT_MODIFIED;
import static java.net.HttpURLConnection.HTTP_UNAVAILABLE;


/**
Expand Down Expand Up @@ -221,8 +220,13 @@ private boolean pullRemoteChanges() {
}
localAccount.setModified(accountFromDatabase.getModified());
localAccount.setETag(accountFromDatabase.getETag());
final var modified = localAccount.getModified();
if (modified == null) {
Log_OC.e(TAG, "modified is null cannot fetch notes");
return false;
}

final var fetchResponse = notesAPI.getNotes(localAccount.getModified(), localAccount.getETag()).blockingSingle();
final var fetchResponse = notesAPI.getNotes(modified, localAccount.getETag()).blockingSingle();
final var remoteNotes = fetchResponse.getResponse();
final var remoteIDs = new HashSet<Long>();
// pull remote changes: update or create each remote note
Expand Down Expand Up @@ -288,8 +292,12 @@ private boolean pullRemoteChanges() {
}
} else if (cause.getClass() == NextcloudApiNotRespondingException.class || cause instanceof NextcloudApiNotRespondingException) {
apiProvider.invalidateAPICache(ssoAccount);
} else if (cause.getClass() == NextcloudNetworkException.class) {
Log.w(TAG, "Network connectivity issue during sync");
return true;
}
}

exceptions.add(t);
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.nextcloud.android.sso.api.EmptyResponse;
import com.nextcloud.android.sso.api.NextcloudAPI;
import com.nextcloud.android.sso.api.ParsedResponse;
import com.nextcloud.android.sso.exceptions.NextcloudNetworkException;

import java.util.Calendar;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public void testPushLocalChanges() {

@Test
public void testPullRemoteChanges() {
when(account.getModified()).thenReturn(Calendar.getInstance());
when(repo.getAccountById(anyLong())).thenReturn(account);
when(repo.getIdMap(anyLong())).thenReturn(Map.of(1000L, 1L, 2000L, 2L));
when(repo.updateIfNotModifiedLocallyAndAnyRemoteColumnHasChanged(anyLong(), anyLong(), anyString(), anyBoolean(), anyString(), anyString(), anyString(), anyString())).thenReturn(1);
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ buildscript {
kotlinVersion = '2.2.20'
commonsVersion = '2.3.7'
androidCommonsVersion = '1.1.0'
singleSignOnVersion = "17df25ce03d98b9d868249b41f7300bff6c54f3e"
}
repositories {
mavenCentral()
Expand Down
40 changes: 40 additions & 0 deletions gradle/verification-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<trusted-key id="E7DC75FC24FB3C8DFE8086AD3D5839A2262CBBFB" group="org.jetbrains.kotlinx"/>
<trusted-key id="E85AED155021AF8A6C6B7A4A7C7D8456294423BA" group="org.objenesis"/>
<trusted-key id="E9CC3CD1AE59E851E4DB3FA350FFD7487D34B5B9">
<trusting group="io.reactivex.rxjava3" name="rxjava" version="3.1.11"/>
<trusting group="io.reactivex.rxjava3" name="rxjava" version="3.1.8"/>
<trusting group="io.reactivex.rxjava3" name="rxjava" version="3.1.9"/>
</trusted-key>
Expand Down Expand Up @@ -10217,6 +10218,40 @@
</sha256>
</artifact>
</component>
<component group="com.github.nextcloud" name="Android-SingleSignOn" version="17df25ce03d98b9d868249b41f7300bff6c54f3e">
<artifact name="Android-SingleSignOn-17df25ce03d98b9d868249b41f7300bff6c54f3e.aar">
<sha256 value="97b62266de15af013d48af801fdd13f5328338514c3ff757122095530a66ff84" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="Android-SingleSignOn-17df25ce03d98b9d868249b41f7300bff6c54f3e.module">
<sha256 value="01e8491b4df0312fe8839af1497d4509a64a3fa73932b007421bd6857c286bb7" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="Android-SingleSignOn" version="1d31061d17">
<artifact name="Android-SingleSignOn-1d31061d17.aar">
<sha256 value="e35b753b2142d329cc800314d5d31abf9a9ece72c28c5f9c830ed57176cee0b4" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="Android-SingleSignOn-1d31061d17.module">
<sha256 value="a41c20f05f198d96fb8d0c8d33abec1b207e36650949c15de3fab45e0dcd6b2a" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="Android-SingleSignOn" version="1d31061d17e1bd88b6501fa436a753ada4273230">
<artifact name="Android-SingleSignOn-1d31061d17e1bd88b6501fa436a753ada4273230.module">
<sha256 value="7567b6eb9817a4785a900eef12dfb0231611b030db2b17721c6fc62785f6d77c" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="Android-SingleSignOn" version="ab41fe72d4">
<artifact name="Android-SingleSignOn-ab41fe72d4.aar">
<sha256 value="60cf4e8db291c411be42d725edb16a8ee8eae28ede740475a3bbbcae660b7621" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
<artifact name="Android-SingleSignOn-ab41fe72d4.module">
<sha256 value="ce809fc39073f82ac59c9a5cc38134045857ec5169acc1f24d09e2cc3421234e" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="Android-SingleSignOn" version="c8e05ec00f086e8fc464a6bc112a4b7e7cd38c4a">
<artifact name="Android-SingleSignOn-c8e05ec00f086e8fc464a6bc112a4b7e7cd38c4a.module">
<sha256 value="4d59876c3a6313d225cf0f847fc54e04eddb6e6eaf66d92587544752c02e2185" origin="Generated by Gradle" reason="Artifact is not signed"/>
</artifact>
</component>
<component group="com.github.nextcloud" name="android-common" version="0.14.0">
<artifact name="android-common-0.14.0.jar">
<sha256 value="12473a2140bdf23575f487ddce434ba8cdfc5bc28f99ddf7f6b6418c67597632" origin="Generated by Gradle" reason="Artifact is not signed"/>
Expand Down Expand Up @@ -13002,6 +13037,11 @@
<sha256 value="b25bece50483de9a3e1dfd25011c2d85330216ef8a81b86f6abebdbdf9b0f127" origin="Generated by Gradle"/>
</artifact>
</component>
<component group="io.reactivex.rxjava3" name="rxjava" version="3.1.11">
<artifact name="rxjava-3.1.11.module">
<pgp value="E9CC3CD1AE59E851E4DB3FA350FFD7487D34B5B9"/>
</artifact>
</component>
<component group="io.reactivex.rxjava3" name="rxjava" version="3.1.9">
<artifact name="rxjava-3.1.9.jar">
<sha256 value="88cba16c7f0fe78a8cc9b8c46469c8596cf166037ce22c2adfc4440cd6312e20" origin="Generated by Gradle"/>
Expand Down
Loading