Skip to content

Commit bbf63fa

Browse files
committed
NMC-3250 -> opening login flow in internal webview instead of external browser.
NMC-1885: Splash screen customized NMC-3680: sometimes app crash during launch fix
1 parent 9ea94cb commit bbf63fa

File tree

8 files changed

+103
-306
lines changed

8 files changed

+103
-306
lines changed

app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,33 @@
66
*/
77
package com.nmc.android.ui
88

9-
import androidx.annotation.UiThread
10-
import androidx.test.core.app.launchActivity
119
import androidx.test.espresso.Espresso.onView
12-
import androidx.test.espresso.IdlingRegistry
1310
import androidx.test.espresso.assertion.ViewAssertions.matches
14-
import androidx.test.espresso.matcher.ViewMatchers
1511
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
16-
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
1712
import androidx.test.espresso.matcher.ViewMatchers.withId
13+
import androidx.test.espresso.matcher.ViewMatchers.withText
14+
import androidx.test.ext.junit.rules.ActivityScenarioRule
1815
import androidx.test.ext.junit.runners.AndroidJUnit4
1916
import com.owncloud.android.AbstractIT
2017
import com.owncloud.android.R
21-
import com.owncloud.android.utils.EspressoIdlingResource
22-
import org.junit.After
23-
import org.junit.Before
18+
import org.junit.Rule
2419
import org.junit.Test
2520
import org.junit.runner.RunWith
2621

2722
@RunWith(AndroidJUnit4::class)
2823
class LauncherActivityIT : AbstractIT() {
2924

30-
@Before
31-
fun registerIdlingResource() {
32-
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
33-
}
34-
35-
@After
36-
fun unregisterIdlingResource() {
37-
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
38-
}
39-
40-
@Test
41-
@UiThread
42-
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
43-
launchActivity<LauncherActivity>().use { scenario ->
44-
scenario.onActivity { _ ->
45-
onIdleSync {
46-
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
47-
onView(
48-
withId(R.id.splashScreenBold)
49-
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
50-
onView(
51-
withId(R.id.splashScreenNormal)
52-
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
53-
}
54-
}
55-
}
56-
}
25+
@get:Rule
26+
val activityRule = ActivityScenarioRule(LauncherActivity::class.java)
5727

5828
@Test
59-
@UiThread
60-
fun testSplashScreenWithTitlesShouldShowTitles() {
61-
launchActivity<LauncherActivity>().use { scenario ->
62-
scenario.onActivity {
63-
onIdleSync {
64-
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
65-
66-
EspressoIdlingResource.increment()
67-
it.setSplashTitles("Example", "Cloud")
68-
EspressoIdlingResource.decrement()
69-
70-
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
71-
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
72-
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
73-
}
74-
}
75-
}
29+
fun verifyUIElements() {
30+
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
31+
onView(withId(R.id.splashScreenBold)).check(matches(isCompletelyDisplayed()))
32+
onView(withId(R.id.splashScreenNormal)).check(matches(isCompletelyDisplayed()))
33+
34+
onView(withId(R.id.splashScreenBold)).check(matches(withText("Magenta")))
35+
onView(withId(R.id.splashScreenNormal)).check(matches(withText("CLOUD")))
36+
shortSleep()
7637
}
7738
}

app/src/main/java/com/nextcloud/client/account/UserAccountManagerImpl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import android.content.SharedPreferences;
1919
import android.preference.PreferenceManager;
2020
import android.text.TextUtils;
21+
import android.util.Log;
2122

2223
import com.nextcloud.client.onboarding.FirstRunActivity;
2324
import com.nextcloud.common.NextcloudClient;
@@ -117,12 +118,22 @@ public boolean exists(Account account) {
117118

118119
if (account != null && account.name != null) {
119120
int lastAtPos = account.name.lastIndexOf('@');
121+
// NMC-3680 fix
122+
if (lastAtPos == -1) {
123+
Log_OC.e(TAG, "Invalid account name: " + account.name);
124+
return false;
125+
}
120126
String hostAndPort = account.name.substring(lastAtPos + 1);
121127
String username = account.name.substring(0, lastAtPos);
122128
String otherHostAndPort;
123129
String otherUsername;
124130
for (Account otherAccount : nextcloudAccounts) {
125131
lastAtPos = otherAccount.name.lastIndexOf('@');
132+
// NMC-3680 fix
133+
if (lastAtPos == -1) {
134+
// Skip invalid account names
135+
continue;
136+
}
126137
otherHostAndPort = otherAccount.name.substring(lastAtPos + 1);
127138
otherUsername = otherAccount.name.substring(0, lastAtPos);
128139
if (otherHostAndPort.equals(hostAndPort) &&

0 commit comments

Comments
 (0)