Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: sketching prototype pt1 - module (WPB-6243) #2811

Merged
merged 29 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
78193da
chore: add base for isolated sketch module
yamilmedina Feb 20, 2024
7b31e49
chore: add base for isolated sketch module
yamilmedina Feb 20, 2024
b63008b
chore: add base template
yamilmedina Feb 20, 2024
a0caa83
chore: add base template script
yamilmedina Feb 20, 2024
3bc4b15
chore: add base template script
yamilmedina Feb 20, 2024
a84c26b
chore: add as is classes
yamilmedina Feb 20, 2024
0521a30
chore: porting more classes
yamilmedina Feb 21, 2024
ca2f76c
chore: more
yamilmedina Feb 21, 2024
d22d306
chore: more
yamilmedina Feb 21, 2024
42b649d
chore: more
yamilmedina Feb 21, 2024
90e34bc
chore: more
yamilmedina Feb 21, 2024
74394c2
chore: more
yamilmedina Feb 21, 2024
93b84e5
Merge branch 'develop' into feat/poc-sketch
yamilmedina Mar 1, 2024
356445f
chore: merge developr
yamilmedina Mar 1, 2024
f96ce6e
Merge branch 'develop' into feat/poc-sketch
yamilmedina Mar 11, 2024
599ea26
chore: add script to init new modules
yamilmedina Mar 11, 2024
f306a86
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Mar 22, 2024
70f839d
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Mar 25, 2024
b42c574
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Mar 26, 2024
d662764
chore: cleanup
yamilmedina Mar 27, 2024
801951d
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Mar 28, 2024
aaa8fa5
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Mar 28, 2024
8edeb50
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Apr 2, 2024
663f8e1
chore: pr comments
yamilmedina Apr 2, 2024
e66914a
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Apr 3, 2024
1db7a57
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Apr 4, 2024
00f8833
Merge branch 'develop' into feat/sketching-proto-pt1
yamilmedina Apr 5, 2024
add503c
feat: sketching prototype pt2 - drawing on canvas (WPB-6960) (#2812)
yamilmedina Apr 5, 2024
925af74
feat: adjustments
yamilmedina Apr 5, 2024
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
5 changes: 5 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ dependencies {
implementation("com.wire.kalium:kalium-logic")
implementation("com.wire.kalium:kalium-util")

// features
implementation(project(":features:sketch"))

// Application dependencies
implementation(libs.androidx.appcompat)
implementation(libs.androidx.core)
Expand Down Expand Up @@ -114,6 +117,7 @@ dependencies {
implementation(libs.androidx.lifecycle.liveData)
implementation(libs.androidx.lifecycle.runtime)
implementation(libs.androidx.lifecycle.viewModelSavedState)
implementation("androidx.fragment:fragment-ktx:1.4.1")
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved

// Compose
val composeBom = platform(libs.compose.bom)
Expand All @@ -130,6 +134,7 @@ dependencies {
implementation(libs.compose.material.icons)
implementation(libs.compose.material.ripple)
implementation(libs.compose.ui.preview)
implementation(libs.compose.ui.viewbinding)
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
implementation(libs.compose.activity)
implementation(libs.compose.navigation)
implementation(libs.compose.constraintLayout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,39 @@
package com.wire.android.ui.home.messagecomposer

import android.net.Uri
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.material3.Divider
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.viewinterop.AndroidView
import androidx.compose.ui.viewinterop.AndroidViewBinding
import androidx.fragment.app.FragmentContainerView
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import androidx.fragment.app.commit
import androidx.fragment.app.findFragment
import androidx.viewbinding.ViewBinding
import com.wire.android.feature.sketch.DrawingFragment
import com.wire.android.feature.sketch.databinding.FragmentContainerBinding
import com.wire.android.feature.sketch.databinding.FragmentDrawingBinding
import com.wire.android.ui.common.colorsScheme
import com.wire.android.ui.common.scaffold.WireScaffold
import com.wire.android.ui.common.topappbar.NavigationIconType
import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar
import com.wire.android.ui.home.conversations.model.UriAsset
import com.wire.android.ui.home.messagecomposer.location.GeoLocatedAddress
import com.wire.android.ui.home.messagecomposer.location.LocationPickerComponent
import com.wire.android.ui.home.messagecomposer.recordaudio.RecordAudioComponent
import com.wire.android.ui.home.messagecomposer.state.AdditionalOptionMenuState
import com.wire.android.ui.home.messagecomposer.state.AdditionalOptionSelectItem
Expand Down Expand Up @@ -127,9 +148,16 @@ fun AdditionalOptionSubMenu(
}

AdditionalOptionSubMenuState.Location -> {
LocationPickerComponent(
onLocationPicked = onLocationPicked,
onLocationClosed = onCloseAdditionalAttachment
FragmentHolderScreen(
androidViewBindingFactory = FragmentContainerBinding::inflate,
androidViewBindingUpdate = {
with(fragmentContainerView.findFragment<DrawingFragment>()) {
// Reference of AnalyticsEventsFragment is available here
}
},
onBackPress = {

},
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
)
}
// non functional for now
Expand Down Expand Up @@ -172,3 +200,51 @@ fun AttachmentAndAdditionalOptionsMenuItems(
)
}
}

@Composable
fun FragmentContainer(
modifier: Modifier = Modifier,
fragmentManager: FragmentManager,
commit: FragmentTransaction.(containerId: Int) -> Unit
) {
val containerId by rememberSaveable { mutableStateOf(View.generateViewId()) }

AndroidView(
modifier = modifier,
factory = { context ->
fragmentManager.findFragmentById(containerId)?.view
?.also { (it.parent as? ViewGroup)?.removeView(it) }
?: FragmentContainerView(context)
.apply { id = containerId }
.also {
fragmentManager.commit { commit(it.id) }
}
},
update = {}
)
}

@Composable
fun <T : ViewBinding> FragmentHolderScreen(
androidViewBindingFactory: (inflater: LayoutInflater, parent: ViewGroup, attachToParent: Boolean) -> T,
onBackPress: () -> Unit = {},
androidViewBindingUpdate: T.() -> Unit = {},
) {
WireScaffold(topBar = {
WireCenterAlignedTopAppBar(
elevation = 0.dp,
title = "",
navigationIconType = NavigationIconType.Close,
onNavigationPressed = onBackPress
)
// } else {
// Spacer(modifier = Modifier.height(MaterialTheme.wireDimensions.welcomeVerticalPadding))
// }
}) { paddingValues ->
AndroidViewBinding(
factory = androidViewBindingFactory,
modifier = Modifier.padding(paddingValues),
update = androidViewBindingUpdate,
)
}
}
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions features/sketch/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
22 changes: 22 additions & 0 deletions features/sketch/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id(libs.plugins.wire.android.library.get().pluginId)
id("org.jetbrains.kotlin.android")
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
alias(libs.plugins.ksp)
}

android {
namespace = "com.wire.android.feature.sketch"
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
implementation(libs.androidx.core)
implementation(libs.androidx.appcompat)
implementation(libs.material)

val composeBom = platform(libs.compose.bom)
implementation(composeBom)

testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.test.extJunit)
androidTestImplementation(libs.androidx.espresso.core)
yamilmedina marked this conversation as resolved.
Show resolved Hide resolved
}
Empty file.
21 changes: 21 additions & 0 deletions features/sketch/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.wire.android

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.wire.android.test", appContext.packageName)
}
}
20 changes: 20 additions & 0 deletions features/sketch/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Wire
~ Copyright (C) 2024 Wire Swiss GmbH
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU 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 General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<manifest>

</manifest>
20 changes: 20 additions & 0 deletions features/sketch/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Wire
~ Copyright (C) 2024 Wire Swiss GmbH
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU 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 General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<resources>
<string name="module_name">Sketch module</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.wire.android.feature.sketch

import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}
1 change: 1 addition & 0 deletions features/template/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
22 changes: 22 additions & 0 deletions features/template/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
id(libs.plugins.wire.android.library.get().pluginId)
id("org.jetbrains.kotlin.android")
alias(libs.plugins.ksp)
}

android {
namespace = "com.wire.android.feature.template"
}

dependencies {
implementation(libs.androidx.core)
implementation(libs.androidx.appcompat)
implementation(libs.material)
val composeBom = platform(libs.compose.bom)
implementation(composeBom)
implementation(libs.compose.runtime.liveData)

testImplementation(libs.junit4)
androidTestImplementation(libs.androidx.test.extJunit)
androidTestImplementation(libs.androidx.espresso.core)
}
Empty file.
21 changes: 21 additions & 0 deletions features/template/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.wire.android

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.wire.android.test", appContext.packageName)
}
}
20 changes: 20 additions & 0 deletions features/template/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ Wire
~ Copyright (C) 2024 Wire Swiss GmbH
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU 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 General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see http://www.gnu.org/licenses/.
-->
<manifest>

</manifest>
Loading
Loading