diff --git a/app/build.gradle b/app/build.gradle index 4108fbdbfc..fe00f041b2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -223,6 +223,7 @@ android { dataBinding true viewBinding true aidl true + compose = true } compileOptions { @@ -246,6 +247,10 @@ android { // Adds exported schema location as test app assets. androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) } + + composeOptions { + kotlinCompilerExtensionVersion = "1.5.9" + } } dependencies { @@ -255,6 +260,12 @@ dependencies { exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version } + // Jetpack Compose + implementation(platform("androidx.compose:compose-bom:2024.02.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.material3:material3") + compileOnly 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' // remove after entire switch to lib v2 implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2 diff --git a/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt new file mode 100644 index 0000000000..e74f5d9128 --- /dev/null +++ b/app/src/main/java/com/nextcloud/client/assistant/AsssistantScreen.kt @@ -0,0 +1,43 @@ +/* + * Nextcloud Android client application + * + * @author Alper Ozturk + * Copyright (C) 2024 Alper Ozturk + * Copyright (C) 2024 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.client.assistant + +import androidx.compose.foundation.ExperimentalFoundationApi +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.lazy.LazyColumn +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier + +@OptIn(ExperimentalFoundationApi::class) +@Composable +fun AssistantScreen() { + Scaffold { + LazyColumn(modifier = Modifier.padding(it)) { + stickyHeader { + Text(text = "AssistantScreen") + } + + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeDestinations.kt b/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeDestinations.kt new file mode 100644 index 0000000000..8809b1b0c3 --- /dev/null +++ b/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeDestinations.kt @@ -0,0 +1,26 @@ +/* + * Nextcloud Android client application + * + * @author Alper Ozturk + * Copyright (C) 2024 Alper Ozturk + * Copyright (C) 2024 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.ui.composeFragment + +enum class ComposeDestinations { + AssistantScreen +} \ No newline at end of file diff --git a/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeFragment.kt b/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeFragment.kt new file mode 100644 index 0000000000..e56f66eaef --- /dev/null +++ b/app/src/main/java/com/nextcloud/ui/composeFragment/ComposeFragment.kt @@ -0,0 +1,74 @@ +/* + * Nextcloud Android client application + * + * @author Alper Ozturk + * Copyright (C) 2024 Alper Ozturk + * Copyright (C) 2024 Nextcloud GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package com.nextcloud.ui.composeFragment + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.compose.ui.platform.ViewCompositionStrategy +import androidx.fragment.app.Fragment +import com.nextcloud.client.assistant.AssistantScreen +import com.nextcloud.utils.extensions.getSerializableArgument +import com.owncloud.android.databinding.FragmentComposeViewBinding + +class ComposeFragment : Fragment() { + + private var _binding: FragmentComposeViewBinding? = null + + private val binding get() = _binding!! + private var destination: ComposeDestinations? = null + + companion object { + const val destinationKey = "destinationKey" + } + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View { + _binding = FragmentComposeViewBinding.inflate(inflater, container, false) + destination = arguments.getSerializableArgument(destinationKey, ComposeDestinations::class.java) + + binding.composeView.apply { + setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed) + setContent { + when(destination) { + ComposeDestinations.AssistantScreen -> { + AssistantScreen() + } + else -> { + + } + } + } + } + + return binding.root + } + + override fun onDestroyView() { + super.onDestroyView() + _binding = null + } +} diff --git a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java index f3b7e0ba03..f4f25e3266 100644 --- a/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java +++ b/app/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.java @@ -74,6 +74,8 @@ import com.nextcloud.client.preferences.AppPreferences; import com.nextcloud.common.NextcloudClient; import com.nextcloud.java.util.Optional; import com.nextcloud.ui.ChooseAccountDialogFragment; +import com.nextcloud.ui.composeFragment.ComposeDestinations; +import com.nextcloud.ui.composeFragment.ComposeFragment; import com.owncloud.android.MainApp; import com.owncloud.android.R; import com.owncloud.android.authentication.PassCodeManager; @@ -404,8 +406,8 @@ public abstract class DrawerActivity extends ToolbarActivity } /** - * Open app store page of specified app or search for specified string. - * Will attempt to open browser when no app store is available. + * Open app store page of specified app or search for specified string. Will attempt to open browser when no app + * store is available. * * @param string packageName or url-encoded search string * @param search false -> show app corresponding to packageName; true -> open search for string @@ -543,7 +545,18 @@ public abstract class DrawerActivity extends ToolbarActivity intent.putExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItem.getItemId()); startActivity(intent); } else if (itemId == R.id.nav_assistant) { - // TODO ADD JETPACK Compose PAGE + // FIXME Back navigation is broken, create general function to switch to Jetpack Compose + ComposeFragment composeFragment = new ComposeFragment(); + Bundle bundle = new Bundle(); + bundle.putSerializable(ComposeFragment.destinationKey, ComposeDestinations.AssistantScreen); + composeFragment.setArguments( bundle); + + getSupportFragmentManager() + .beginTransaction() + .replace(R.id.left_fragment_container, composeFragment) + .commit(); + + Log_OC.w(TAG, "ADD JETPACK Compose PAGE"); } else { if (menuItem.getItemId() >= MENU_ITEM_EXTERNAL_LINK && @@ -695,8 +708,8 @@ public abstract class DrawerActivity extends ToolbarActivity /** * Enable or disable interaction with all drawers. * - * @param lockMode The new lock mode for the given drawer. One of {@link DrawerLayout#LOCK_MODE_UNLOCKED}, {@link - * DrawerLayout#LOCK_MODE_LOCKED_CLOSED} or {@link DrawerLayout#LOCK_MODE_LOCKED_OPEN}. + * @param lockMode The new lock mode for the given drawer. One of {@link DrawerLayout#LOCK_MODE_UNLOCKED}, + * {@link DrawerLayout#LOCK_MODE_LOCKED_CLOSED} or {@link DrawerLayout#LOCK_MODE_LOCKED_OPEN}. */ public void setDrawerLockMode(int lockMode) { if (mDrawerLayout != null) { @@ -1158,7 +1171,7 @@ public abstract class DrawerActivity extends ToolbarActivity return true; } - public AppPreferences getAppPreferences(){ + public AppPreferences getAppPreferences() { return preferences; } diff --git a/app/src/main/res/layout/fragment_compose_view.xml b/app/src/main/res/layout/fragment_compose_view.xml new file mode 100644 index 0000000000..7732bd7b78 --- /dev/null +++ b/app/src/main/res/layout/fragment_compose_view.xml @@ -0,0 +1,31 @@ + + + + + + + \ No newline at end of file diff --git a/appscan/build.gradle b/appscan/build.gradle index 3e40abb952..8343eadac3 100644 --- a/appscan/build.gradle +++ b/appscan/build.gradle @@ -10,11 +10,11 @@ apply plugin: 'kotlin-android' android { namespace 'com.nextcloud.appscan' - compileSdk 33 + compileSdk 34 defaultConfig { minSdk 21 - targetSdk 33 + targetSdk 34 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a80b22ce5c..52c0aef1db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-all.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists +zipStorePath=wrapper/dists \ No newline at end of file