Skip to content

Commit

Permalink
Bump to SSO 1.3.0
Browse files Browse the repository at this point in the history
To test:
add
FilesAppTypeRegistry.getInstance().init(new FilesAppType("com.nextcloud.cloud.android.client", "com.nextcloud.cloud", FilesAppType.Type.PROD));

in onCreate()

Signed-off-by: tobiasKaminsky <[email protected]>
  • Loading branch information
tobiasKaminsky committed Jul 30, 2024
1 parent 1634d57 commit 4120249
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dependencies {

// Nextcloud SSO
implementation 'com.github.nextcloud.android-common:ui:0.22.0'
implementation 'com.github.nextcloud:Android-SingleSignOn:1.2.0'
implementation 'com.github.nextcloud:Android-SingleSignOn:1.3.0'
implementation 'com.github.stefan-niedermann:android-commons:1.0.0'
implementation "com.github.stefan-niedermann.nextcloud-commons:sso-glide:$commonsVersion"
implementation "com.github.stefan-niedermann.nextcloud-commons:exception:$commonsVersion"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import android.webkit.WebView;

import androidx.appcompat.app.AppCompatDelegate;
import androidx.preference.PreferenceManager;

import it.niedermann.owncloud.notes.preferences.DarkModeSetting;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@
import androidx.core.util.Consumer;
import androidx.recyclerview.widget.RecyclerView;

import com.nextcloud.android.sso.FilesAppTypeRegistry;
import com.nextcloud.android.sso.helper.VersionCheckHelper;
import com.nextcloud.android.sso.model.FilesAppType;

import java.util.Optional;

import it.niedermann.owncloud.notes.FormattingHelpActivity;
import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.about.AboutActivity;
Expand Down Expand Up @@ -84,10 +87,12 @@ private static Intent generateTrashbinIntent(@NonNull Context context, @NonNull
// https://github.com/nextcloud/android/pull/8405#issuecomment-852966877
final int minVersionCode = 30170090;
try {
if (VersionCheckHelper.getNextcloudFilesVersionCode(context, FilesAppType.PROD) > minVersionCode) {
return generateTrashbinAppIntent(context, account, true);
} else if (VersionCheckHelper.getNextcloudFilesVersionCode(context, FilesAppType.DEV) > minVersionCode) {
return generateTrashbinAppIntent(context, account, false);
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();
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) {
return generateTrashbinAppIntent(context, account, dev.get());
} else {
// Files app is too old to be able to switch the account when launching the TrashbinActivity
return generateTrashbinWebIntent(account);
Expand All @@ -98,9 +103,9 @@ private static Intent generateTrashbinIntent(@NonNull Context context, @NonNull
}
}

private static Intent generateTrashbinAppIntent(@NonNull Context context, @NonNull Account account, boolean prod) throws PackageManager.NameNotFoundException {
private static Intent generateTrashbinAppIntent(@NonNull Context context, @NonNull Account account, FilesAppType type) throws PackageManager.NameNotFoundException {
final var packageManager = context.getPackageManager();
final String packageName = prod ? FilesAppType.PROD.packageId : FilesAppType.DEV.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

0 comments on commit 4120249

Please sign in to comment.