diff --git a/app/build.gradle b/app/build.gradle index f18adf85d..2e7c6f73b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -83,6 +83,7 @@ dependencies { implementation project(':browse') implementation project(':search') implementation project(':viewer') + implementation project(':shareextension') implementation project(':data') implementation libs.alfresco.content @@ -103,6 +104,8 @@ dependencies { implementation libs.mavericks implementation libs.coil.core + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:2.0.4' coreLibraryDesugaring libs.android.desugar diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 4331a780d..a2fb5e620 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -7,28 +7,44 @@ android:allowBackup="false" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" + android:networkSecurityConfig="@xml/network_security_config" android:roundIcon="@mipmap/ic_launcher" android:supportsRtl="true" - android:theme="@style/Theme.Alfresco" - android:networkSecurityConfig="@xml/network_security_config"> + android:theme="@style/Theme.Alfresco"> + + + + + + + + + + + - - + + + - - - - - + @@ -42,7 +58,6 @@ android:scheme="androidacsapp" /> - diff --git a/app/src/main/java/com/alfresco/content/app/activity/ExtensionActivity.kt b/app/src/main/java/com/alfresco/content/app/activity/ExtensionActivity.kt new file mode 100644 index 000000000..acc535695 --- /dev/null +++ b/app/src/main/java/com/alfresco/content/app/activity/ExtensionActivity.kt @@ -0,0 +1,69 @@ +package com.alfresco.content.app.activity + +import android.content.Intent +import android.net.Uri +import android.os.Bundle +import android.os.Parcelable +import androidx.appcompat.app.AppCompatActivity +import androidx.navigation.findNavController +import com.airbnb.mvrx.MavericksView +import com.airbnb.mvrx.withState +import com.alfresco.content.activityViewModel +import com.alfresco.content.app.R +import com.alfresco.content.app.widget.ActionBarController + +/** + * Marked as ExtensionActivity class + */ +class ExtensionActivity : AppCompatActivity(), MavericksView { + + private val viewModel: MainActivityViewModel by activityViewModel() + private val navController by lazy { findNavController(R.id.nav_host_fragment) } + private lateinit var actionBarController: ActionBarController + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_extension) + + when (intent?.action) { + Intent.ACTION_SEND -> { + println("EXTENSION SINGLE IMAGE") + if (intent.type?.startsWith("image/") == true) { + handleSendImage(intent) + } + } + Intent.ACTION_SEND_MULTIPLE -> { + println("EXTENSION MULTIPLE IMAGE") + if (intent.type?.startsWith("image/") == true) { + handleSendMultipleImages(intent) + } + } + else -> println("EXTENSION OTHER INTENT") + } + + configure() + } + + private fun configure() = withState(viewModel) { state -> + val graph = navController.navInflater.inflate(R.navigation.nav_share_extension) + graph.startDestination = R.id.nav_extension + navController.graph = graph + + actionBarController = ActionBarController(findViewById(R.id.toolbar)) + } + + private fun handleSendImage(intent: Intent) { + (intent.getParcelableExtra(Intent.EXTRA_STREAM) as? Uri)?.let { + // Update UI to reflect image being shared + } + } + + private fun handleSendMultipleImages(intent: Intent) { + intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM)?.let { + // Update UI to reflect multiple images being shared + } + } + + override fun invalidate() = withState(viewModel) { + } +} diff --git a/app/src/main/res/layout/activity_extension.xml b/app/src/main/res/layout/activity_extension.xml new file mode 100644 index 000000000..0a34b8163 --- /dev/null +++ b/app/src/main/res/layout/activity_extension.xml @@ -0,0 +1,19 @@ + + + + + + + + diff --git a/app/src/main/res/navigation/nav_share_extension.xml b/app/src/main/res/navigation/nav_share_extension.xml new file mode 100644 index 000000000..270bd62db --- /dev/null +++ b/app/src/main/res/navigation/nav_share_extension.xml @@ -0,0 +1,13 @@ + + + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8f66f8896..02ba92784 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,6 +8,7 @@ Offline Browse Account + Share Sign out Are you sure you want to sign out? diff --git a/build.gradle b/build.gradle index 7a2072da2..a1004c1ee 100644 --- a/build.gradle +++ b/build.gradle @@ -15,6 +15,7 @@ buildscript { classpath libs.spotless classpath libs.gradleVersionsPlugin classpath libs.gradleLicensePlugin + classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30' } } diff --git a/settings.gradle b/settings.gradle index 56c53904f..7cd21ff1b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -26,3 +26,4 @@ include ':app' // Enable Gradle's version catalog support // Ref: https://docs.gradle.org/current/userguide/platforms.html enableFeaturePreview("VERSION_CATALOGS") +include ':shareextension' diff --git a/shareextension/.gitignore b/shareextension/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/shareextension/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/shareextension/build.gradle b/shareextension/build.gradle new file mode 100644 index 000000000..9d9cf4a4d --- /dev/null +++ b/shareextension/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.library' +apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' +apply plugin: 'kotlin-parcelize' + +android { + defaultConfig { + versionCode 1 + versionName "1.0" + } + + buildFeatures { + viewBinding true + } +} + +dependencies { + + implementation project(':base') + api project(':base-ui') + implementation project(':common') + implementation project(':data') + implementation project(':mimetype') + implementation project(':download') + implementation project(':capture') + implementation project(':listview') + + implementation libs.kotlin.stdlib + implementation libs.coroutines.core + + implementation libs.androidx.appcompat + implementation libs.androidx.core + implementation libs.androidx.lifecycle.viewmodel + implementation libs.androidx.lifecycle.runtime + + implementation libs.google.material + implementation libs.epoxy.core + implementation libs.mavericks + + kapt libs.epoxy.processor +} diff --git a/shareextension/proguard-rules.pro b/shareextension/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/shareextension/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/shareextension/src/main/AndroidManifest.xml b/shareextension/src/main/AndroidManifest.xml new file mode 100644 index 000000000..4fc9e2426 --- /dev/null +++ b/shareextension/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + + diff --git a/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionFragment.kt b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionFragment.kt new file mode 100644 index 000000000..fb4840596 --- /dev/null +++ b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionFragment.kt @@ -0,0 +1,30 @@ +package com.alfresco.content.shareextension + +import android.os.Parcelable +import androidx.fragment.app.Fragment +import com.airbnb.mvrx.MavericksView +import com.airbnb.mvrx.fragmentViewModel +import com.airbnb.mvrx.withState +import kotlinx.parcelize.Parcelize + +/** + * Marked as ExtensionArgs class + */ +@Parcelize +data class ExtensionArgs(val image: String) : Parcelable { + + companion object { + private const val PATH_KEY = "path" + } +} + +/** + * Marked as ExtensionFragment class + */ +class ExtensionFragment : Fragment(), MavericksView { + + private val viewModel: ExtensionViewModel by fragmentViewModel() + + override fun invalidate() = withState(viewModel) { + } +} diff --git a/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewModel.kt b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewModel.kt new file mode 100644 index 000000000..6c6f629b2 --- /dev/null +++ b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewModel.kt @@ -0,0 +1,22 @@ +package com.alfresco.content.shareextension + +import android.content.Context +import com.airbnb.mvrx.MavericksViewModel +import com.airbnb.mvrx.MavericksViewModelFactory +import com.airbnb.mvrx.ViewModelContext + +/** + * Marked as ExtensionViewModel class + */ +class ExtensionViewModel( + val context: Context, + state: ExtensionViewState +) : MavericksViewModel(state) { + + companion object : MavericksViewModelFactory { + override fun create( + viewModelContext: ViewModelContext, + state: ExtensionViewState + ) = ExtensionViewModel(viewModelContext.activity(), state) + } +} diff --git a/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewState.kt b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewState.kt new file mode 100644 index 000000000..f8df78bde --- /dev/null +++ b/shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewState.kt @@ -0,0 +1,11 @@ +package com.alfresco.content.shareextension + +import com.airbnb.mvrx.MavericksState +import com.alfresco.content.data.Entry + +/** + * Marked as ExtensionViewState class + */ +data class ExtensionViewState( + val entries: List = emptyList() +) : MavericksState diff --git a/shareextension/src/main/res/values-night/themes.xml b/shareextension/src/main/res/values-night/themes.xml new file mode 100644 index 000000000..18b97d21c --- /dev/null +++ b/shareextension/src/main/res/values-night/themes.xml @@ -0,0 +1,10 @@ + + + + diff --git a/shareextension/src/main/res/values/colors.xml b/shareextension/src/main/res/values/colors.xml new file mode 100644 index 000000000..ca1931bca --- /dev/null +++ b/shareextension/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + diff --git a/shareextension/src/main/res/values/strings.xml b/shareextension/src/main/res/values/strings.xml new file mode 100644 index 000000000..19de20c49 --- /dev/null +++ b/shareextension/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ShareExtension + diff --git a/shareextension/src/main/res/values/themes.xml b/shareextension/src/main/res/values/themes.xml new file mode 100644 index 000000000..21c2e1e28 --- /dev/null +++ b/shareextension/src/main/res/values/themes.xml @@ -0,0 +1,10 @@ + + + +