-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #804 from Catrobat/release-v2.5.3
Release v2.5.3
- Loading branch information
Showing
150 changed files
with
4,195 additions
and
1,531 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
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 }} |
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,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 }} |
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 @@ | ||
output=none |
141 changes: 141 additions & 0 deletions
141
...oidTest/java/org/catrobat/paintroid/test/espresso/FileFromOtherSourceIntegrationTest.java
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,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; | ||
} | ||
} |
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
Oops, something went wrong.