-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
1 parent
ffb5501
commit c4a9765
Showing
19 changed files
with
293 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/alfresco/content/app/activity/ExtensionActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"/> |
30 changes: 30 additions & 0 deletions
30
shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionFragment.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
shareextension/src/main/kotlin/com/alfresco/content/shareextension/ExtensionViewState.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<resources> | ||
<string name="app_name">ShareExtension</string> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |