Skip to content

Commit

Permalink
Mobileapps 1074 (#55)
Browse files Browse the repository at this point in the history
* app extension for other apps added (#77)

* merged community code and resolved conflicts

Co-authored-by: AnniNygren <[email protected]>
Co-authored-by: Gloria Camino <[email protected]>
Co-authored-by: Lovekesh Saxena <[email protected]>
  • Loading branch information
4 people authored Feb 11, 2022
1 parent ffb5501 commit c4a9765
Show file tree
Hide file tree
Showing 19 changed files with 293 additions and 10 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ dependencies {
implementation project(':browse')
implementation project(':search')
implementation project(':viewer')
implementation project(':shareextension')

implementation project(':data')
implementation libs.alfresco.content
Expand All @@ -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

Expand Down
35 changes: 25 additions & 10 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<activity
android:name=".activity.ExtensionActivity"
android:configChanges="locale|keyboardHidden|orientation|screenSize"
android:exported="true"
android:icon="@drawable/ic_launcher_foreground"
android:launchMode="singleInstance"
android:logo="@drawable/ic_launcher_foreground"
android:theme="@style/Theme.Alfresco"
android:windowSoftInputMode="adjustResize">

<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />

<category android:name="android.intent.category.DEFAULT" />

<data android:mimeType="*/*" />
</intent-filter>

</activity>
<activity
android:name=".activity.SplashActivity"
android:theme="@style/Theme.Alfresco.Splash">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity
android:name=".activity.MainActivity"
android:windowSoftInputMode="adjustNothing" />

<activity android:name=".activity.LoginActivity" />

<activity android:name=".activity.SettingsActivity"/>

<activity android:name=".activity.SettingsActivity" />
<activity android:name="com.alfresco.auth.pkce.RedirectUriReceiverActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
Expand All @@ -42,7 +58,6 @@
android:scheme="androidacsapp" />
</intent-filter>
</activity>

</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -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<Parcelable>(Intent.EXTRA_STREAM) as? Uri)?.let {
// Update UI to reflect image being shared
}
}

private fun handleSendMultipleImages(intent: Intent) {
intent.getParcelableArrayListExtra<Parcelable>(Intent.EXTRA_STREAM)?.let {
// Update UI to reflect multiple images being shared
}
}

override fun invalidate() = withState(viewModel) {
}
}
19 changes: 19 additions & 0 deletions app/src/main/res/layout/activity_extension.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.ExtensionActivity">

<include layout="@layout/layout_toolbar" />

<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:defaultNavHost="true"/>

</LinearLayout>
13 changes: 13 additions & 0 deletions app/src/main/res/navigation/nav_share_extension.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_share_extension"
app:startDestination="@id/nav_extension">

<fragment
android:id="@+id/nav_extension"
android:name="com.alfresco.content.shareextension.ExtensionFragment"
android:label="@string/nav_title_share">
</fragment>

</navigation>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<string name="nav_title_offline">Offline</string>
<string name="nav_title_browse">Browse</string>
<string name="nav_title_settings">Account</string>
<string name="nav_title_share">Share</string>

<string name="sign_out_confirmation_title">Sign out</string>
<string name="sign_out_confirmation_message">Are you sure you want to sign out?</string>
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ buildscript {
classpath libs.spotless
classpath libs.gradleVersionsPlugin
classpath libs.gradleLicensePlugin
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30'
}
}

Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
1 change: 1 addition & 0 deletions shareextension/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
41 changes: 41 additions & 0 deletions shareextension/build.gradle
Original file line number Diff line number Diff line change
@@ -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
}
21 changes: 21 additions & 0 deletions shareextension/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions shareextension/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.alfresco.content.shareextension"/>
Original file line number Diff line number Diff line change
@@ -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) {
}
}
Original file line number Diff line number Diff line change
@@ -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<ExtensionViewState>(state) {

companion object : MavericksViewModelFactory<ExtensionViewModel, ExtensionViewState> {
override fun create(
viewModelContext: ViewModelContext,
state: ExtensionViewState
) = ExtensionViewModel(viewModelContext.activity(), state)
}
}
Original file line number Diff line number Diff line change
@@ -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<Entry> = emptyList()
) : MavericksState
10 changes: 10 additions & 0 deletions shareextension/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Alfrescomobileworkspaceandroid" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Customize your theme here. -->
</style>
</resources>
10 changes: 10 additions & 0 deletions shareextension/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>
3 changes: 3 additions & 0 deletions shareextension/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">ShareExtension</string>
</resources>
10 changes: 10 additions & 0 deletions shareextension/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.Alfrescomobileworkspaceandroid" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryDark">@color/purple_700</item>
<item name="colorAccent">@color/teal_200</item>
<!-- Customize your theme here. -->
</style>
</resources>

0 comments on commit c4a9765

Please sign in to comment.