Skip to content
Open
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
65 changes: 13 additions & 52 deletions app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,72 +6,33 @@
*/
package com.nmc.android.ui

import androidx.annotation.UiThread
import androidx.test.core.app.launchActivity
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.owncloud.android.AbstractIT
import com.owncloud.android.R
import com.owncloud.android.utils.EspressoIdlingResource
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class LauncherActivityIT : AbstractIT() {

@Before
fun registerIdlingResource() {
IdlingRegistry.getInstance().register(EspressoIdlingResource.countingIdlingResource)
}

@After
fun unregisterIdlingResource() {
IdlingRegistry.getInstance().unregister(EspressoIdlingResource.countingIdlingResource)
}

@Test
@UiThread
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
launchActivity<LauncherActivity>().use { scenario ->
scenario.onActivity { _ ->
onIdleSync {
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
onView(
withId(R.id.splashScreenBold)
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
onView(
withId(R.id.splashScreenNormal)
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
}
}
}
}
@get:Rule
val activityRule = ActivityScenarioRule(LauncherActivity::class.java)

@Test
@UiThread
fun testSplashScreenWithTitlesShouldShowTitles() {
launchActivity<LauncherActivity>().use { scenario ->
scenario.onActivity {
onIdleSync {
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))

EspressoIdlingResource.increment()
it.setSplashTitles("Example", "Cloud")
EspressoIdlingResource.decrement()

val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
}
}
}
fun verifyUIElements() {
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.splashScreenBold)).check(matches(isCompletelyDisplayed()))
onView(withId(R.id.splashScreenNormal)).check(matches(isCompletelyDisplayed()))

onView(withId(R.id.splashScreenBold)).check(matches(withText("Magenta")))
onView(withId(R.id.splashScreenNormal)).check(matches(withText("CLOUD")))
shortSleep()
}
}
6 changes: 6 additions & 0 deletions app/src/debug/res/values/setup.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- webview_login_url should be empty in debug mode to show login url input screen
this will be useful in switching the environments during testing -->
<string name="webview_login_url" translatable="false" />
</resources>
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@
android:supportsRtl="true"
android:enableOnBackInvokedCallback="false"
android:theme="@style/Theme.ownCloud.Toolbar"
android:usesCleartextTraffic="true"
tools:ignore="UnusedAttribute"
tools:replace="android:allowBackup">

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/owncloud/android/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import android.os.StrictMode;
import android.text.TextUtils;
import android.view.WindowManager;
import android.webkit.WebView;

import com.google.android.material.dialog.MaterialAlertDialogBuilder;
import com.nextcloud.appReview.InAppReviewHelper;
Expand Down Expand Up @@ -384,6 +385,8 @@ public void onCreate() {
networkChangeReceiver = new NetworkChangeReceiver(this, connectivityService);
registerNetworkChangeReceiver();

configureWebViewForMultiProcess();

if (!MDMConfig.INSTANCE.sendFilesSupport(this)) {
disableDocumentsStorageProvider();
}
Expand All @@ -399,6 +402,18 @@ public void disableDocumentsStorageProvider() {
packageManager.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}

// NMC-3964 fix
// crash was happening for Xiaomi Android 15 devices
private void configureWebViewForMultiProcess(){
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
String processName = getProcessName();
if (processName != null && !processName.equals(getPackageName())) {
// this ensures each process uses a unique directory, preventing conflicts.
WebView.setDataDirectorySuffix(processName);
}
}
}

private final LifecycleEventObserver lifecycleEventObserver = ((lifecycleOwner, event) -> {
if (event == Lifecycle.Event.ON_START) {
Log_OC.d(TAG, "APP IN FOREGROUND");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@

import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;

import com.nextcloud.utils.extensions.IntentExtensionsKt;
import com.nextcloud.android.common.ui.util.extensions.WindowExtensionsKt;

import androidx.activity.EdgeToEdge;
import androidx.activity.SystemBarStyle;
import androidx.appcompat.app.AppCompatActivity;

/*
Expand Down Expand Up @@ -46,6 +51,14 @@ public final void setAccountAuthenticatorResult(Bundle result) {
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
// NMC-3936 and NMC-3813 fix
boolean isApiLevel35OrHigher = (Build.VERSION.SDK_INT >= 35);

if (isApiLevel35OrHigher) {
enableEdgeToEdge();
WindowExtensionsKt.addSystemBarPaddings(getWindow());
}

super.onCreate(savedInstanceState);

mAccountAuthenticatorResponse =
Expand All @@ -58,6 +71,11 @@ protected void onCreate(Bundle savedInstanceState) {
}
}

private void enableEdgeToEdge() {
final var style = SystemBarStyle.auto(Color.TRANSPARENT, Color.TRANSPARENT);
EdgeToEdge.enable(this, style, style);
}

/**
* Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
*/
Expand Down
Loading