Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "interactive"
}
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pipeline {
stage('Build Debug-APK') {
steps {
sh "./gradlew -Pindependent='#$env.BUILD_NUMBER $env.BRANCH_NAME' assembleDebug"
archiveArtifacts 'app/build/outputs/apk/debug/paintroid-debug*.apk'
archiveArtifacts artifacts: 'app/build/outputs/apk/debug/paintroid-debug*.apk', allowEmptyArchive: true
plot csvFileName: 'dexcount.csv', csvSeries: [[displayTableFlag: false, exclusionValues: '', file: 'Paintroid/build/outputs/dexcount/*.csv', inclusionFlag: 'OFF', url: '']], group: 'APK Stats', numBuilds: '180', style: 'line', title: 'dexcount'
}
}
Expand All @@ -76,9 +76,9 @@ pipeline {
}
renameApks("${env.BRANCH_NAME}-${env.BUILD_NUMBER}")
dir('Catroid') {
archiveArtifacts "catroid/src/main/libs/*.aar"
archiveArtifacts artifacts: "catroid/src/main/libs/*.aar", allowEmptyArchive: true
sh "./gradlew assembleCatroidDebug"
archiveArtifacts 'catroid/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk'
archiveArtifacts artifacts: 'catroid/build/outputs/apk/catroid/debug/catroid-catroid-debug.apk', allowEmptyArchive: true
}
}
}
Expand Down Expand Up @@ -123,7 +123,7 @@ pipeline {
sh '/home/user/android/sdk/platform-tools/adb logcat -d > logcat.txt'
sh './gradlew stopEmulator'
junitAndCoverage "$reports/coverage/debug/report.xml", 'device', javaSrc
archiveArtifacts 'logcat.txt'
archiveArtifacts artifacts: 'logcat.txt', allowEmptyArchive: true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@ class ShapeToolOptionsViewInteraction private constructor() :

fun performSelectShape(shape: DrawableShape): ShapeToolOptionsViewInteraction {
Espresso.onView(ViewMatchers.withId(getButtonIdFromBaseShape(shape)))
.check(androidx.test.espresso.assertion.ViewAssertions.matches(ViewMatchers.isDisplayed()))
.perform(ViewActions.click())
return this
}

fun performSelectShapeDrawType(shapeDrawType: DrawableStyle): ShapeToolOptionsViewInteraction {
Espresso.onView(ViewMatchers.withId(getButtonIdFromShapeDrawType(shapeDrawType)))
.check(androidx.test.espresso.assertion.ViewAssertions.matches(ViewMatchers.isDisplayed()))
.perform(ViewActions.click())
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,41 @@ class ClipboardToolTest {
Assert.assertEquals(tool!!.toolPosition.x, initialToolPositionX + 9, 0f)
Assert.assertEquals(tool!!.toolPosition.y, initialToolPositionY + 9, 0f)
}

@Test
fun testClearButtonEnabledAfterCopy() {
Mockito.`when`(workspace!!.bitmapOfCurrentLayer).thenReturn(
Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)
)
tool!!.copyBoxContent()
Mockito.verify(clipboardToolOptionsView)!!.enableClear(true)
}

@Test
fun testClearButtonEnabledAfterCut() {
Mockito.`when`(workspace!!.bitmapOfCurrentLayer).thenReturn(
Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)
)
tool!!.copyBoxContent()
Mockito.verify(clipboardToolOptionsView)!!.enableClear(true)
}

@Test
fun testClearDisablesPasteAndClearButtons() {
Mockito.`when`(workspace!!.bitmapOfCurrentLayer).thenReturn(
Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)
)
// First copy to enable buttons
tool!!.copyBoxContent()
Mockito.verify(clipboardToolOptionsView)!!.enablePaste(true)
Mockito.verify(clipboardToolOptionsView)!!.enableClear(true)
// Now clear and verify both buttons are disabled
Mockito.clearInvocations(clipboardToolOptionsView)
// Simulate clear button click by getting the callback and calling clearClicked
val callbackCaptor = org.mockito.ArgumentCaptor.forClass(ClipboardToolOptionsView.Callback::class.java)
Mockito.verify(clipboardToolOptionsView, Mockito.atLeastOnce())!!.setCallback(callbackCaptor.capture())
callbackCaptor.value.clearClicked()
Mockito.verify(clipboardToolOptionsView)!!.enablePaste(false)
Mockito.verify(clipboardToolOptionsView)!!.enableClear(false)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,29 @@ class ClipboardTool(
highlightBox()
copyBoxContent()
this@ClipboardTool.clipboardToolOptionsView.enablePaste(true)
this@ClipboardTool.clipboardToolOptionsView.enableClear(true)
}

override fun cutClicked() {
highlightBox()
copyBoxContent()
cutBoxContent()
this@ClipboardTool.clipboardToolOptionsView.enablePaste(true)
this@ClipboardTool.clipboardToolOptionsView.enableClear(true)
}

override fun pasteClicked() {
highlightBox()
pasteBoxContent()
}

override fun clearClicked() {
highlightBox()
drawingBitmap = null
readyForPaste = false
this@ClipboardTool.clipboardToolOptionsView.enablePaste(false)
this@ClipboardTool.clipboardToolOptionsView.enableClear(false)
}
}
clipboardToolOptionsView.setCallback(callback)
toolOptionsViewController.showDelayed()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ interface ClipboardToolOptionsView {

fun enablePaste(enable: Boolean)

fun enableClear(enable: Boolean)

fun setShapeSizeText(shapeSize: String)

fun toggleShapeSizeVisibility(isVisible: Boolean)
Expand All @@ -37,5 +39,7 @@ interface ClipboardToolOptionsView {
fun cutClicked()

fun pasteClicked()

fun clearClicked()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DefaultClipboardToolOptionsView(rootView: ViewGroup) : ClipboardToolOption
private val pasteChip: Chip
private val copyChip: Chip
private val cutChip: Chip
private val clearChip: Chip
private val shapeSizeChip: Chip
private val changeSizeShapeSizeChip: Chip
private val clipboardToolOptionsView: View
Expand All @@ -49,6 +50,10 @@ class DefaultClipboardToolOptionsView(rootView: ViewGroup) : ClipboardToolOption
pasteChip.setOnClickListener {
callback?.pasteClicked()
}

clearChip.setOnClickListener {
callback?.clearClicked()
}
}

override fun setCallback(callback: ClipboardToolOptionsView.Callback) {
Expand All @@ -59,6 +64,10 @@ class DefaultClipboardToolOptionsView(rootView: ViewGroup) : ClipboardToolOption
pasteChip.isEnabled = enable
}

override fun enableClear(enable: Boolean) {
clearChip.isEnabled = enable
}

override fun toggleShapeSizeVisibility(isVisible: Boolean) {
if (isVisible && !changeSizeShapeSizeChipVisible && clipboardToolOptionsView.visibility == View.INVISIBLE) {
changeSizeShapeSizeChip.visibility = View.VISIBLE
Expand All @@ -83,6 +92,7 @@ class DefaultClipboardToolOptionsView(rootView: ViewGroup) : ClipboardToolOption
copyChip = stampToolOptionsView.findViewById(R.id.action_copy)
pasteChip = stampToolOptionsView.findViewById(R.id.action_paste)
cutChip = stampToolOptionsView.findViewById(R.id.action_cut)
clearChip = stampToolOptionsView.findViewById(R.id.action_clear)
enablePaste(false)
initializeListeners()
stampToolOptionsView.run {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,23 @@
app:chipIcon="@drawable/ic_pocketpaint_paste_chip_icon_selector"
app:chipStartPadding="8dp" />

<Space
android:id="@+id/space_three"
style="@style/PocketPaintToolHorizontalSpace"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/action_paste" />

<com.google.android.material.chip.Chip
android:id="@+id/action_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toEndOf="@+id/space_three"
android:text="@string/clipboard_tool_clear"
android:theme="@style/Theme.MaterialComponents.Light"
app:chipIcon="@drawable/ic_pocketpaint_layers_delete"
app:chipStartPadding="8dp" />

</RelativeLayout>

<RelativeLayout
Expand Down
1 change: 1 addition & 0 deletions Paintroid/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<string name="clipboard_tool_paste">Paste</string>
<string name="clipboard_tool_copy">Copy</string>
<string name="clipboard_tool_cut">Cut</string>
<string name="clipboard_tool_clear">Clear</string>

<string name="stickers">Stickers</string>
<string name="dialog_import_image_title" translatable="false">@string/button_import_image</string>
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-XX:MaxPermSize=1024m -Xmx4096m
android.disableAutomaticComponentCreation=true
org.gradle.jvmargs=-Xmx4096m
android.disableAutomaticComponentCreation=true