Merge pull request #13902 from nextcloud/bugfix/first-run-activity-not-launching

Fix: Launching LauncherActivity & FirstRunActivity properly
This commit is contained in:
Tobias Kaminsky 2024-11-05 09:30:33 +01:00 committed by GitHub
commit ad8da72554
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 29 additions and 12 deletions

View file

@ -1,7 +1,7 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2023 TSI-mc
* SPDX-FileCopyrightText: 2023-2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-FileCopyrightText: 2019 Chris Narkiewicz <hello@ezaquarii.com>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
@ -19,8 +19,10 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import com.nextcloud.client.onboarding.FirstRunActivity;
import com.nextcloud.common.NextcloudClient;
import com.nextcloud.utils.extensions.AccountExtensionsKt;
import com.nmc.android.ui.LauncherActivity;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AuthenticatorActivity;
@ -398,6 +400,10 @@ public class UserAccountManagerImpl implements UserAccountManager {
@Override
public void startAccountCreation(final Activity activity) {
// skipping AuthenticatorActivity redirection when user is on Launcher or FirstRun Activity
if (activity instanceof LauncherActivity || activity instanceof FirstRunActivity) return;
Intent intent = new Intent(context, AuthenticatorActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

View file

@ -2,6 +2,7 @@
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2019 Chris Narkiewicz <hello@ezaquarii.com>
* SPDX-FileCopyrightText: 2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.nextcloud.client.onboarding
@ -42,7 +43,7 @@ internal class OnboardingServiceImpl constructor(
override val isFirstRun: Boolean
get() {
return accountProvider.currentAccount == null
return accountProvider.user.isAnonymous
}
override fun shouldShowWhatsNew(callingContext: Context): Boolean {

View file

@ -3,7 +3,7 @@
*
* SPDX-FileCopyrightText: 2023 Alper Ozturk <alper.ozturk@nextcloud.com>
* SPDX-FileCopyrightText: 2023 Andy Scherzinger <info@andy-scherzinger.de>
* SPDX-FileCopyrightText: 2023 TSI-mc
* SPDX-FileCopyrightText: 2023-2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.nmc.android.ui
@ -18,6 +18,7 @@ import androidx.annotation.VisibleForTesting
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.nextcloud.client.preferences.AppPreferences
import com.owncloud.android.R
import com.owncloud.android.authentication.AuthenticatorActivity
import com.owncloud.android.databinding.ActivitySplashBinding
import com.owncloud.android.ui.activity.BaseActivity
import com.owncloud.android.ui.activity.FileDisplayActivity
@ -65,6 +66,8 @@ class LauncherActivity : BaseActivity() {
Handler(Looper.getMainLooper()).postDelayed({
if (user.isPresent) {
startActivity(Intent(this, FileDisplayActivity::class.java))
} else {
startActivity(Intent(this, AuthenticatorActivity::class.java))
}
finish()
}, SPLASH_DURATION)

View file

@ -1,7 +1,7 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2023 TSI-mc
* SPDX-FileCopyrightText: 2023-2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-FileCopyrightText: 2019-2021 Tobias Kaminsky <tobias@kaminsky.me>
* SPDX-FileCopyrightText: 2018 Andy Scherzinger <info@andy-scherzinger>
* SPDX-FileCopyrightText: 2017 Mario Danic <mario@lovelyhq.com>
@ -1364,14 +1364,13 @@ public class AuthenticatorActivity extends AccountAuthenticatorActivity
}
private void endSuccess() {
if (onlyAdd) {
finish();
} else {
if (!onlyAdd) {
Intent i = new Intent(this, FileDisplayActivity.class);
i.setAction(FileDisplayActivity.RESTART);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
}
finish();
}
private void getUserCapabilitiesAndFinish() {

View file

@ -2,6 +2,7 @@
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.owncloud.android.ui.activity;
@ -115,8 +116,10 @@ public abstract class BaseActivity extends AppCompatActivity implements Injectab
protected void onRestart() {
Log_OC.v(TAG, "onRestart() start");
super.onRestart();
if (enableAccountHandling) {
mixinRegistry.onRestart();
}
}
private void onThemeSettingsModeChanged() {
if (paused) {

View file

@ -2,13 +2,15 @@
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2019 Chris Narkiewicz <hello@ezaquarii.com>
* SPDX-FileCopyrightText: 2024 TSI-mc <surinder.kumar@t-systems.com>
* SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
*/
package com.nextcloud.client.onboarding
import android.accounts.Account
import android.content.res.Resources
import com.nextcloud.client.account.AnonymousUser
import com.nextcloud.client.account.CurrentAccountProvider
import com.nextcloud.client.account.User
import com.nextcloud.client.preferences.AppPreferences
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@ -30,7 +32,7 @@ class OnboardingServiceTest {
private lateinit var currentAccountProvider: CurrentAccountProvider
@Mock
private lateinit var account: Account
private lateinit var user: User
private lateinit var onboardingService: OnboardingServiceImpl
@ -43,13 +45,16 @@ class OnboardingServiceTest {
@Test
fun `first run flag toggles with current current account`() {
// GIVEN
// current account is not set
// current account is anonymous
whenever(currentAccountProvider.user).thenReturn(AnonymousUser("dummy"))
// THEN
// first run flag is true
assertTrue(onboardingService.isFirstRun)
// WHEN
// current account is set
whenever(currentAccountProvider.currentAccount).thenReturn(account)
whenever(currentAccountProvider.user).thenReturn(user)
// THEN
// first run flag toggles