Skip to content

Commit

Permalink
Merge pull request #1071 from Catrobat/hotfix-release-v2.8.2
Browse files Browse the repository at this point in the history
Hotfix release v2.8.2
  • Loading branch information
wslany authored Apr 15, 2022
2 parents 3566774 + 09d96c8 commit 5cce665
Show file tree
Hide file tree
Showing 23 changed files with 448 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ public void testTabsAreSelectable() {
}

@Test
public void dontShowAlphaSliderFromCatrobat() {
public void dontShowAlphaRelatedStuffFromCatroidFormulaEditor() {
launchActivityRule.getActivity().model.setOpenedFromCatroid(true);
launchActivityRule.getActivity().model.setOpenedFromFormulaEditorInCatroid(true);

onColorPickerView()
.performOpenColorPicker();
Expand All @@ -161,10 +162,52 @@ public void dontShowAlphaSliderFromCatrobat() {

onView(withId(R.id.color_alpha_slider))
.check(matches(not(isDisplayed())));

onColorPickerView()
.onPositiveButton()
.perform(click());

int currentSelectColor = toolReference.getTool().getDrawPaint().getColor();

onColorPickerView()
.performOpenColorPicker();

onView(allOf(withId(R.id.color_picker_tab_icon), withBackground(R.drawable.ic_color_picker_tab_rgba))).perform(click());

onView(withId(R.id.color_picker_base_layout))
.perform(swipeUp());

onView(withId(R.id.color_picker_alpha_row))
.check(matches(not(isDisplayed())));

onView(withId(R.id.color_picker_color_rgb_hex))
.check(matches(withText(String.format("#%02X%02X%02X", Color.red(currentSelectColor), Color.green(currentSelectColor), Color.blue(currentSelectColor)))));
}

@Test
public void showAlphaSliderIfNotCatrobatFlagSet() {
public void showAlphaSliderFromCatroid() {
launchActivityRule.getActivity().model.setOpenedFromCatroid(true);

onColorPickerView()
.performOpenColorPicker();

onView(withId(R.id.color_picker_base_layout))
.perform(swipeUp());

onView(withId(R.id.color_alpha_slider))
.check(matches(isDisplayed()));

onView(allOf(withId(R.id.color_picker_tab_icon), withBackground(R.drawable.ic_color_picker_tab_hsv))).perform(click());

onView(withId(R.id.color_picker_base_layout))
.perform(swipeUp());

onView(withId(R.id.color_alpha_slider))
.check(matches(isDisplayed()));
}

@Test
public void showAlphaSliderIfNotCatroidFlagSet() {
onColorPickerView()
.performOpenColorPicker();

Expand Down Expand Up @@ -682,6 +725,9 @@ public void alphaValueIsSetInSliderWhenChangedInSeekBar() {
// set color to value #7F000000, alpha seekbar 49%
onView(withId(R.id.color_picker_color_rgb_seekbar_alpha)).perform(touchCenterMiddle());
onView(allOf(withId(R.id.color_picker_tab_icon), withBackground(R.drawable.ic_color_picker_tab_preset))).perform(scrollTo(), click());
onColorPickerView()
.onPositiveButton()
.perform(click());
onToolProperties()
.checkMatchesColor(Color.parseColor("#7F000000"));
}
Expand Down
13 changes: 11 additions & 2 deletions Paintroid/src/main/java/org/catrobat/paintroid/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Paintroid: An image manipulation application for Android.
* Copyright (C) 2010-2021 The Catrobat Team
* Copyright (C) 2010-2022 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -134,6 +134,8 @@ class MainActivity : AppCompatActivity(), MainView, CommandListener {
private const val IS_FULLSCREEN_KEY = "isFullscreen"
private const val IS_SAVED_KEY = "isSaved"
private const val IS_OPENED_FROM_CATROID_KEY = "isOpenedFromCatroid"
private const val IS_OPENED_FROM_FORMULA_EDITOR_IN_CATROID_KEY =
"isOpenedFromFormulaEditorInCatroid"
private const val WAS_INITIAL_ANIMATION_PLAYED = "wasInitialAnimationPlayed"
private const val SAVED_PICTURE_URI_KEY = "savedPictureUri"
private const val CAMERA_IMAGE_URI_KEY = "cameraImageUri"
Expand Down Expand Up @@ -261,12 +263,15 @@ class MainActivity : AppCompatActivity(), MainView, CommandListener {
val isSaved = savedInstanceState.getBoolean(IS_SAVED_KEY, false)
val isOpenedFromCatroid =
savedInstanceState.getBoolean(IS_OPENED_FROM_CATROID_KEY, false)
val isOpenedFromFormulaEditorInCatroid = savedInstanceState.getBoolean(
IS_OPENED_FROM_FORMULA_EDITOR_IN_CATROID_KEY, false
)
val wasInitialAnimationPlayed =
savedInstanceState.getBoolean(WAS_INITIAL_ANIMATION_PLAYED, false)
val savedPictureUri = savedInstanceState.getParcelable<Uri>(SAVED_PICTURE_URI_KEY)
val cameraImageUri = savedInstanceState.getParcelable<Uri>(CAMERA_IMAGE_URI_KEY)
presenterMain.restoreState(
isFullscreen, isSaved, isOpenedFromCatroid,
isFullscreen, isSaved, isOpenedFromCatroid, isOpenedFromFormulaEditorInCatroid,
wasInitialAnimationPlayed, savedPictureUri, cameraImageUri
)
}
Expand Down Expand Up @@ -522,6 +527,10 @@ class MainActivity : AppCompatActivity(), MainView, CommandListener {
putBoolean(IS_FULLSCREEN_KEY, model.isFullscreen)
putBoolean(IS_SAVED_KEY, model.isSaved)
putBoolean(IS_OPENED_FROM_CATROID_KEY, model.isOpenedFromCatroid)
putBoolean(
IS_OPENED_FROM_FORMULA_EDITOR_IN_CATROID_KEY,
model.isOpenedFromFormulaEditorInCatroid
)
putBoolean(WAS_INITIAL_ANIMATION_PLAYED, model.wasInitialAnimationPlayed())
putParcelable(SAVED_PICTURE_URI_KEY, model.savedPictureUri)
putParcelable(CAMERA_IMAGE_URI_KEY, model.cameraImageUri)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ interface LayerContracts {

fun setMergable()

fun isSelected(): Boolean

fun setCheckBox(setTo: Boolean)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Paintroid: An image manipulation application for Android.
* Copyright (C) 2010-2021 The Catrobat Team
* Copyright (C) 2010-2022 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -178,6 +178,7 @@ interface MainActivityContracts {
isFullscreen: Boolean,
isSaved: Boolean,
isOpenedFromCatroid: Boolean,
isOpenedFromFormulaEditorInCatroid: Boolean,
wasInitialAnimationPlayed: Boolean,
savedPictureUri: Uri?,
cameraImageUri: Uri?
Expand Down Expand Up @@ -298,6 +299,7 @@ interface MainActivityContracts {
var isSaved: Boolean
var isFullscreen: Boolean
var isOpenedFromCatroid: Boolean
var isOpenedFromFormulaEditorInCatroid: Boolean

fun wasInitialAnimationPlayed(): Boolean

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Paintroid: An image manipulation application for Android.
* Copyright (C) 2010-2021 The Catrobat Team
* Copyright (C) 2010-2022 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -24,6 +24,7 @@ import org.catrobat.paintroid.contract.MainActivityContracts
class MainActivityModel : MainActivityContracts.Model {
private var wasInitialAnimationPlayed = false
override var isOpenedFromCatroid = false
override var isOpenedFromFormulaEditorInCatroid = false
override var isFullscreen = false
override var isSaved = false
override var savedPictureUri: Uri? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,14 @@ class LayerPresenter(
adapter?.notifyDataSetChanged()
listItemLongClickHandler.stopDragging()
}

fun resetMergeColor(layerPosition: Int) {
if (adapter != null && adapter?.getViewHolderAt(layerPosition) != null) {
if (adapter?.getViewHolderAt(layerPosition)!!.isSelected()) {
adapter?.getViewHolderAt(layerPosition)?.setSelected()
} else {
adapter?.getViewHolderAt(layerPosition)?.setDeselected()
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,9 @@ open class MainActivityPresenter(
override fun initializeFromCleanState(extraPicturePath: String?, extraPictureName: String?) {
model.isOpenedFromCatroid = extraPicturePath != null
FileIO.wasImageLoaded = false
if (extraPictureName != null) {
val imageFile = extraPicturePath?.let { File(it) }
if (imageFile != null && imageFile.exists()) {
if (extraPicturePath != null) {
val imageFile = File(extraPicturePath)
if (imageFile.exists()) {
model.savedPictureUri = view.getUriFromFile(imageFile)
interactor.loadFile(
this,
Expand All @@ -589,7 +589,7 @@ open class MainActivityPresenter(
false,
workspace
)
} else {
} else if (extraPictureName != null) {
interactor.createFile(
this,
CREATE_FILE_DEFAULT,
Expand Down Expand Up @@ -648,13 +648,15 @@ open class MainActivityPresenter(
isFullscreen: Boolean,
isSaved: Boolean,
isOpenedFromCatroid: Boolean,
isOpenedFromFormulaEditorInCatroid: Boolean,
wasInitialAnimationPlayed: Boolean,
savedPictureUri: Uri?,
cameraImageUri: Uri?
) {
model.isFullscreen = isFullscreen
model.isSaved = isSaved
model.isOpenedFromCatroid = isOpenedFromCatroid
model.isOpenedFromFormulaEditorInCatroid = isOpenedFromFormulaEditorInCatroid
model.setInitialAnimationPlayed(wasInitialAnimationPlayed)
model.savedPictureUri = savedPictureUri
model.cameraImageUri = cameraImageUri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class LayerAdapter(val presenter: LayerContracts.Presenter) : BaseAdapter(), Lay
private val imageView: ImageView = itemView.findViewById(R.id.pocketpaint_item_layer_image)
private var currentBitmap: Bitmap? = null
private val checkBox: CheckBox = itemView.findViewById(R.id.pocketpaint_checkbox_layer)
private var isSelected = false

companion object {
private const val RESIZE_LENGTH = 400f
Expand All @@ -107,16 +108,21 @@ class LayerAdapter(val presenter: LayerContracts.Presenter) : BaseAdapter(), Lay
bottomNavigationViewHolder?.showCurrentTool(ToolType.HAND)
}
layerBackground.setBackgroundColor(Color.BLUE)
isSelected = true
}

override fun setSelected() {
layerBackground.setBackgroundColor(Color.BLUE)
isSelected = true
}

override fun setDeselected() {
layerBackground.setBackgroundColor(Color.TRANSPARENT)
isSelected = false
}

override fun isSelected() = isSelected

override fun updateImageView(bitmap: Bitmap?, isDrawerLayoutOpen: Boolean) {
if (isDrawerLayoutOpen) {
runBlocking {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Paintroid: An image manipulation application for Android.
* Copyright (C) 2010-2021 The Catrobat Team
* Copyright (C) 2010-2022 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -28,7 +28,6 @@ import android.graphics.Bitmap
import android.net.Uri
import android.os.Build
import android.provider.OpenableColumns
import android.view.Gravity
import android.widget.Toast
import androidx.appcompat.app.AppCompatDialogFragment
import androidx.core.app.ActivityCompat
Expand Down Expand Up @@ -197,7 +196,8 @@ class MainActivityNavigator(
toolReference.tool?.let {
val dialog = ColorPickerDialog.newInstance(
it.drawPaint.color,
mainActivity.model.isOpenedFromCatroid
mainActivity.model.isOpenedFromCatroid,
mainActivity.model.isOpenedFromFormulaEditorInCatroid
)
setupColorPickerDialogListeners(dialog)
showDialogFragmentSafely(dialog, COLOR_PICKER_DIALOG_TAG)
Expand Down Expand Up @@ -485,11 +485,9 @@ class MainActivityNavigator(
override fun showToolChangeToast(offset: Int, idRes: Int) {
var offset = offset
val toolNameToast = ToastFactory.makeText(mainActivity, idRes, Toast.LENGTH_SHORT)
val gravity = Gravity.TOP or Gravity.CENTER
if (mainActivity.resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
offset = 0
}
toolNameToast.setGravity(gravity, 0, offset)
toolNameToast.show()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import android.view.View
import android.widget.AdapterView.OnItemClickListener
import android.widget.AdapterView.OnItemLongClickListener
import android.widget.ListView
import org.catrobat.paintroid.presenter.LayerPresenter
import kotlin.math.max
import kotlin.math.min

Expand Down Expand Up @@ -109,6 +110,9 @@ class DragAndDropListView : ListView, ListItemLongClickHandler {

override fun stopDragging() {
hoveringListItem ?: return
if (presenter is LayerPresenter) {
(presenter as LayerPresenter).resetMergeColor(mergePosition)
}
mergePosition = -1
view?.visibility = VISIBLE
view = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:padding="?dialogPreferredPadding">

<LinearLayout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/pocketpaint_antialiasing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:orientation="vertical"
android:padding="10dp"
style="@style/AlertDialogTheme">
android:layout_height="match_parent"
android:checked="true"
android:text="@string/dialog_antialiasing"
android:textColor="@color/design_default_color_on_secondary"
android:theme="@style/CustomSwitchTheme" />

<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true"
android:text="@string/dialog_antialiasing"
android:id="@+id/pocketpaint_antialiasing"
android:textColor="@color/design_default_color_on_secondary"/>
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_height="16dp" />

<LinearLayout
<com.google.android.material.switchmaterial.SwitchMaterial
android:id="@+id/pocketpaint_smoothing"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:orientation="vertical"
android:padding="10dp"
style="@style/AlertDialogTheme">

<com.google.android.material.switchmaterial.SwitchMaterial
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:checked="true"
android:text="@string/dialog_smoothing"
android:id="@+id/pocketpaint_smoothing"
android:textColor="@color/design_default_color_on_secondary"/>
</LinearLayout>
android:layout_height="match_parent"
android:checked="true"
android:text="@string/dialog_smoothing"
android:textColor="@color/design_default_color_on_secondary"
android:theme="@style/CustomSwitchTheme" />

</LinearLayout>
2 changes: 1 addition & 1 deletion Paintroid/src/main/res/values-hu-rHU/string.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<string name="enjoy_pocket_paint">You are all set. Enjoy Pocket Paint.</string>
<string name="intro_get_started">Get started and create a new masterpiece.</string>
<string name="lets_go">Let\'s go</string>
<string name="next">Next</string>
<string name="next">Következő</string>
<string name="skip">Átugrás</string>
<string name="pocketpaint_about_title">About</string>
<string name="pocketpaint_about_content">Pocket Paint is a picture editing library that is part of the Catrobat project.\n\nCatrobat is a visual programming language and set of creativity tools for smartphones.\n\nThe source code of Pocket Paint is mainly licensed under the %s.\nFor precise details of the license see the link below.</string>
Expand Down
Loading

0 comments on commit 5cce665

Please sign in to comment.