Skip to content

Commit

Permalink
Merge pull request #804 from Catrobat/release-v2.5.3
Browse files Browse the repository at this point in the history
Release v2.5.3
  • Loading branch information
wslany authored Dec 18, 2020
2 parents 4177505 + 305a2e3 commit 54680a6
Show file tree
Hide file tree
Showing 150 changed files with 4,195 additions and 1,531 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/sync_crowdin_Paintroid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ** Synchronize Crowdin translation **
#
# Crowdin is a platform to manage the translation process in the Catroweb project:
#
# 1. We upload our english (base) translation files
# 2. Users worldwide translate our provided strings
# 3. We download the translations (In case translations are missing english is the fallback)
#
# This GitHub Action uses the official action from Crowdin to automate step 1 and 2.
# A pull request is created/updated automatically containing all new translations.
#
# - Secrets required!
#
name: Synchronize Crowdin

#
# New base strings could be uploaded on the merge of a new feature.
# However, the translation download process is independent from a pull request.
# Hence, keeping a consistent schedule once a day is more than enough.
#
# In case, an additional run is required, a manual dispatch trigger is also enabled.
#
on:
#schedule:
# - cron: '0 0 * * *'
workflow_dispatch:

jobs:

#
# - Two-way synchronization:
# -- In case of new strings in the repo, they are uploaded to Crowdin
# -- In case of new translation, a pull request containing all changes will be created or updated
#
# - The crowdin configuration is in `crowdin.yml`. However, without credentials!
#
# - The credentials are provided as secrets to the action as environment variables.
# In case they must be updated, talk to a product owner.
#
synchronize-with-crowdin:
# Only should run on the main repo. (Running without the secrets would result in a fail anyway!)
if: github.repository == 'Catrobat/Paintroid'

name: Synchronize Crowdin Translations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: crowdin/[email protected]
with:
upload_translations: true
download_translations: true
config: 'crowdin_Paintroid.yml'
env:
GITHUB_TOKEN: ${{ secrets.TEST_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
58 changes: 58 additions & 0 deletions .github/workflows/sync_crowdin_colorpicker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ** Synchronize Crowdin translation **
#
# Crowdin is a platform to manage the translation process in the Catroweb project:
#
# 1. We upload our english (base) translation files
# 2. Users worldwide translate our provided strings
# 3. We download the translations (In case translations are missing english is the fallback)
#
# This GitHub Action uses the official action from Crowdin to automate step 1 and 2.
# A pull request is created/updated automatically containing all new translations.
#
# - Secrets required!
#
name: Synchronize Crowdin

#
# New base strings could be uploaded on the merge of a new feature.
# However, the translation download process is independent from a pull request.
# Hence, keeping a consistent schedule once a day is more than enough.
#
# In case, an additional run is required, a manual dispatch trigger is also enabled.
#
on:
#schedule:
# - cron: '0 0 * * *'
workflow_dispatch:

jobs:

#
# - Two-way synchronization:
# -- In case of new strings in the repo, they are uploaded to Crowdin
# -- In case of new translation, a pull request containing all changes will be created or updated
#
# - The crowdin configuration is in `crowdin.yml`. However, without credentials!
#
# - The credentials are provided as secrets to the action as environment variables.
# In case they must be updated, talk to a product owner.
#
synchronize-with-crowdin:
# Only should run on the main repo. (Running without the secrets would result in a fail anyway!)
if: github.repository == 'Catrobat/Paintroid'

name: Synchronize Crowdin Translations
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: crowdin/[email protected]
with:
upload_translations: true
download_translations: true
config: 'crowdin_colorpicker.yml'
env:
GITHUB_TOKEN: ${{ secrets.TEST_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
13 changes: 11 additions & 2 deletions Paintroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'kotlin-android'

apply from: 'gradle/adb_tasks.gradle'
apply from: 'gradle/code_quality_tasks.gradle'
Expand All @@ -56,7 +57,7 @@ check.dependsOn 'checkstyle'
check.dependsOn 'pmd'

jacoco {
toolVersion = "0.8.1"
toolVersion = "0.8.5"
}

jacocoAndroidUnitTestReport {
Expand Down Expand Up @@ -103,17 +104,24 @@ android {
xmlOutput file("build/reports/lint-report.xml")
htmlOutput file("build/reports/lint-report.html")
}

testOptions {
unitTests.returnDefaultValues = true
}
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation project(':colorpicker')

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.core:core-ktx:1.3.2'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"

debugImplementation 'androidx.multidex:multidex:2.0.0'

implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.18.3'

Expand All @@ -124,6 +132,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'
androidTestImplementation "androidx.test.uiautomator:uiautomator:2.2.0"

pmd 'net.sourceforge.pmd:pmd-core:5.8.1'
pmd 'net.sourceforge.pmd:pmd-java:5.8.1'
Expand Down
1 change: 1 addition & 0 deletions Paintroid/src/androidTest/jacoco-agent.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
output=none
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package org.catrobat.paintroid.test.espresso;

import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;

import org.catrobat.paintroid.FileIO;
import org.catrobat.paintroid.MainActivity;
import org.catrobat.paintroid.test.espresso.util.EspressoUtils;
import org.catrobat.paintroid.tools.ToolType;
import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Objects;

import androidx.test.rule.ActivityTestRule;
import androidx.test.rule.GrantPermissionRule;

import static org.catrobat.paintroid.test.espresso.util.wrappers.ToolBarViewInteraction.onToolBarView;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class FileFromOtherSourceIntegrationTest {

private static ArrayList<File> deletionFileList = null;

@Rule
public ActivityTestRule<MainActivity> launchActivityRule = new ActivityTestRule<>(MainActivity.class);

@ClassRule
public static GrantPermissionRule grantPermissionRule = EspressoUtils.grantPermissionRulesVersionCheck();

private ContentResolver resolver;

@Before
public void setUp() {
onToolBarView().performSelectTool(ToolType.BRUSH);
deletionFileList = new ArrayList<>();
resolver = launchActivityRule.getActivity().getContentResolver();
}

@Test
public void testGetSharedPictureFromOtherApp() {
Intent intent = new Intent();
Uri receivedUri = createTestImageFile();
Bitmap receivedBitmap = null;

try {
receivedBitmap = FileIO.getBitmapFromUri(resolver, receivedUri);
} catch (Exception e) {
Log.e("Can't read", "Can't get Bitmap from File");
}

Objects.requireNonNull(receivedBitmap);
intent.setData(receivedUri);
intent.setType("image/png");
intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, receivedUri);

launchActivityRule.launchActivity(intent);
Intent mainActivityIntent = launchActivityRule.getActivity().getIntent();

String intentAction = intent.getAction();
String intentType = intent.getType();
Bundle intentBundle = intent.getExtras();
Objects.requireNonNull(intentBundle);
Uri intentUri = (Uri) intentBundle.get(Intent.EXTRA_STREAM);

String mainActivityIntentAction = mainActivityIntent.getAction();
String mainActivityIntentType = mainActivityIntent.getType();
Bundle mainActivityIntentBundle = mainActivityIntent.getExtras();
Objects.requireNonNull(mainActivityIntentBundle);
Uri mainActivityIntentUri = (Uri) mainActivityIntentBundle.get(Intent.EXTRA_STREAM);
Bitmap mainActivityIntentBitmap = null;
Objects.requireNonNull(mainActivityIntentUri);

try {
mainActivityIntentBitmap = FileIO.getBitmapFromUri(resolver, mainActivityIntentUri);
} catch (Exception e) {
Log.e("Can't read", "Can't get Bitmap from File");
}

Objects.requireNonNull(mainActivityIntentBitmap);

assertEquals(intentAction, mainActivityIntentAction);
assertEquals(intentType, mainActivityIntentType);
assertEquals(intentUri, mainActivityIntentUri);
assertEquals(receivedBitmap.getWidth(), mainActivityIntentBitmap.getWidth());
assertEquals(receivedBitmap.getHeight(), mainActivityIntentBitmap.getHeight());
}

@After
public void tearDown() {
for (File file : deletionFileList) {
if (file != null && file.exists()) {
assertTrue(file.delete());
}
}
}

private Uri createTestImageFile() {
Bitmap bitmap = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);

ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Images.Media.DISPLAY_NAME, "testfile.jpg");
contentValues.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
contentValues.put(MediaStore.Images.Media.RELATIVE_PATH, Environment.DIRECTORY_PICTURES);
}

Uri imageUri = resolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);

try {
OutputStream fos = resolver.openOutputStream(Objects.requireNonNull(imageUri));
assertTrue(bitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos));
assert fos != null;
fos.close();
} catch (IOException e) {
throw new AssertionError("Picture file could not be created.", e);
}

File imageFile = new File(imageUri.getPath(), "testfile.jpg");
deletionFileList.add(imageFile);

return imageUri;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public void testOpenColorPickerDialogChooseColorInLandscape() {
.performClickColorPickerPresetSelectorButton(i);

if (colors[i] != Color.TRANSPARENT) {
onView(withId(R.id.color_picker_button_ok))
onView(withId(R.id.color_picker_new_color_view))
.perform(scrollTo())
.check(matches(withBackgroundColor(colors[i])));
}
Expand All @@ -208,7 +208,7 @@ public void testOpenColorPickerDialogApplyColorInLandscape() {
.performClickColorPickerPresetSelectorButton(i);

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

Expand All @@ -229,20 +229,20 @@ public void testColorPickerCancelButtonKeepsColorInLandscape() {
.performClickColorPickerPresetSelectorButton(2);

onColorPickerView()
.checkCancelButtonColor(initialColor);
.checkCurrentViewColor(initialColor);

setOrientation(SCREEN_ORIENTATION_LANDSCAPE);

onColorPickerView()
.checkCancelButtonColor(initialColor);
.checkCurrentViewColor(initialColor);
}

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

onView(withId(R.id.color_picker_button_ok))
onView(withText(R.string.color_picker_apply))
.perform(scrollTo());
}

Expand Down
Loading

0 comments on commit 54680a6

Please sign in to comment.