diff --git a/app/build.gradle b/app/build.gradle index 84fab080f645646c8e260939dc6c10c31c850815..18799c3726eeb9e64f69a0b07e3d9f960d415944 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -7,8 +7,8 @@ def buildDate = { -> def appMajor = 3 def appMinor = 7 -def appPatch = 2 -def appVersionCode = 3007002 +def appPatch = 3 +def appVersionCode = 3007003 android { compileSdkVersion 33 diff --git a/app/src/main/java/it/niedermann/owncloud/notes/importaccount/ImportAccountActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/importaccount/ImportAccountActivity.java index 50676b9d23b0cfad9833e29156305f1ed918ad6a..0ab3fd9bf5c4da89dc08d5fe52dfee0cdb9f0c38 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/importaccount/ImportAccountActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/importaccount/ImportAccountActivity.java @@ -39,6 +39,7 @@ import it.niedermann.owncloud.notes.shared.account.ImportMurenaAccountViewModel; import it.niedermann.owncloud.notes.shared.account.LocalAccountBundle; import it.niedermann.owncloud.notes.shared.account.LocalAccountViewModel; import it.niedermann.owncloud.notes.shared.model.IResponseCallback; +import it.niedermann.owncloud.notes.shared.util.AccountSyncUtil; import trikita.log.Log; public class ImportAccountActivity extends AppCompatActivity { @@ -138,7 +139,7 @@ public class ImportAccountActivity extends AppCompatActivity { runOnUiThread(() -> { Log.i(TAG, capabilities.toString()); BrandingUtil.saveBrandColors(ImportAccountActivity.this, capabilities.getColor(), capabilities.getTextColor()); - finishActivity(); + finishActivity(false); }); SyncWorker.update(ImportAccountActivity.this, PreferenceManager.getDefaultSharedPreferences(ImportAccountActivity.this) .getBoolean(getString(R.string.pref_key_background_sync), true)); @@ -191,10 +192,11 @@ public class ImportAccountActivity extends AppCompatActivity { } } - private void finishActivity() { + private void finishActivity(boolean isLocal) { setResult(RESULT_OK); Intent intent = new Intent(ImportAccountActivity.this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); + intent.putExtra(AccountSyncUtil.LOCAL, isLocal); startActivity(intent); finish(); } @@ -272,7 +274,7 @@ public class ImportAccountActivity extends AppCompatActivity { SingleAccountHelper.setCurrentAccount(getApplicationContext(), result.getSingleSignOnAccount().name); BrandingUtil.saveBrandColors(ImportAccountActivity.this, result.getCapabilities().getColor(), result.getCapabilities().getTextColor()); - finishActivity(); + finishActivity(true); }); } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java index c7b40e31ac9111b6134e17294e36bb42e3922be6..ccad6f2c67bb4fddacfb2dae5efd98657493eb02 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java @@ -94,6 +94,7 @@ import it.niedermann.owncloud.notes.shared.model.CategorySortingMethod; import it.niedermann.owncloud.notes.shared.model.IResponseCallback; import it.niedermann.owncloud.notes.shared.model.NavigationCategory; import it.niedermann.owncloud.notes.shared.model.NoteClickListener; +import it.niedermann.owncloud.notes.shared.util.AccountSyncUtil; import it.niedermann.owncloud.notes.shared.util.CustomAppGlideModule; import it.niedermann.owncloud.notes.shared.util.DisplayUtils; import it.niedermann.owncloud.notes.shared.util.NoteUtil; @@ -164,7 +165,16 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A setupNotesList(); mainViewModel.getAccounts$().observe(this, (accounts) -> { - if (accounts.isEmpty() || importMurenaAccountViewModel.shouldLoadMurenaAccount(accounts)) { + Intent mainIntent = getIntent(); + boolean isLocalAccount = mainIntent != null && + mainIntent.getBooleanExtra(AccountSyncUtil.LOCAL, false); + + // Import the Murena account depending on what the user pressed in ImportAccountActivity. + // If the user wants a local account, then avoid the loop of adding the account again. + boolean importMurenaAccount = !isLocalAccount && + importMurenaAccountViewModel.shouldLoadMurenaAccount(accounts); + + if (accounts.isEmpty() || importMurenaAccount) { Intent intent = new Intent(this, ImportAccountActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java index 34b58463ce6be17cb06ab3b46bb59041855fb2ce..6abcbcce2493b7020063ddf020e90f3e69d1e180 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/shared/util/AccountSyncUtil.java @@ -40,6 +40,8 @@ public final class AccountSyncUtil { private static final String TAG = AccountSyncUtil.class.getSimpleName(); + public static final String LOCAL = "Local"; + private AccountSyncUtil() { throw new UnsupportedOperationException("Do not instantiate this util class."); }