Browse Source

added fastlane screengrab support for android

pull/9/head
Khoren Markosyan 3 years ago
parent
commit
b447da6f73
  1. 4
      .vscode/settings.json
  2. 4
      android/build.gradle
  3. 7
      example/pubspec.lock
  4. 7
      lib/src/ui/reader_widget.dart
  5. 1
      pubspec.yaml
  6. 5
      zxscanner/android/.gitignore
  7. 34
      zxscanner/android/Gemfile.lock
  8. 12
      zxscanner/android/app/build.gradle
  9. 48
      zxscanner/android/app/src/androidTest/java/com/markosyan/zxscanner/JUnit4StyleTests.kt
  10. 17
      zxscanner/android/app/src/debug/AndroidManifest.xml
  11. 11
      zxscanner/android/app/src/test/java/com/markosyan/zxscanner/ExampleTest.kt
  12. 2
      zxscanner/android/fastlane/Appfile
  13. 52
      zxscanner/android/fastlane/Fastfile
  14. 56
      zxscanner/android/fastlane/README.md
  15. 15
      zxscanner/android/fastlane/Screengrabfile
  16. BIN
      zxscanner/android/fastlane/metadata/android/background.jpg
  17. 5
      zxscanner/android/fastlane/metadata/android/en-US/full_description.txt
  18. 3
      zxscanner/android/fastlane/metadata/android/en-US/keyword.strings
  19. 1
      zxscanner/android/fastlane/metadata/android/en-US/short_description.txt
  20. 3
      zxscanner/android/fastlane/metadata/android/en-US/title.strings
  21. 1
      zxscanner/android/fastlane/metadata/android/en-US/title.txt
  22. 0
      zxscanner/android/fastlane/metadata/android/en-US/video.txt
  23. 35
      zxscanner/android/fastlane/metadata/android/framefile.json
  24. 6
      zxscanner/android/gradle/wrapper/gradle-wrapper.properties
  25. 13
      zxscanner/pubspec.lock
  26. 18
      zxscanner/pubspec.yaml

4
.vscode/settings.json vendored

@ -2,6 +2,8 @@
"cmake.sourceDirectory": "${workspaceFolder}/ios/Classes/src",
"files.associations": {
"__config": "cpp",
"__nullptr": "cpp"
"__nullptr": "cpp",
"codecvt": "cpp",
"cmath": "cpp"
}
}

4
android/build.gradle

@ -2,14 +2,14 @@ group 'com.markosyan.flutter_zxing'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.6.10'
ext.kotlin_version = '1.7.0'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

7
example/pubspec.lock

@ -104,13 +104,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_beep:
dependency: transitive
description:
name: flutter_beep
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_lints:
dependency: "direct dev"
description:

7
lib/src/ui/reader_widget.dart

@ -5,7 +5,7 @@ import 'dart:math';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_beep/flutter_beep.dart';
// import 'package:flutter_beep/flutter_beep.dart';
import '../../generated_bindings.dart';
import '../logic/zxing.dart';
@ -19,7 +19,6 @@ class ReaderWidget extends StatefulWidget {
required this.onScan,
this.onControllerCreated,
this.codeFormat = Format.Any,
this.beep = true,
this.showCroppingRect = true,
this.scannerOverlay,
this.showFlashlight = true,
@ -32,7 +31,6 @@ class ReaderWidget extends StatefulWidget {
final Function(CodeResult) onScan;
final Function(CameraController?)? onControllerCreated;
final int codeFormat;
final bool beep;
final bool showCroppingRect;
final ScannerOverlay? scannerOverlay;
final bool showFlashlight;
@ -163,9 +161,6 @@ class _ReaderWidgetState extends State<ReaderWidget>
cropPercent: widget.cropPercent,
);
if (result.isValidBool) {
if (widget.beep) {
FlutterBeep.beep();
}
widget.onScan(result);
setState(() {});
await Future<void>.delayed(const Duration(seconds: 1));

1
pubspec.yaml

@ -12,7 +12,6 @@ dependencies:
ffi: ^2.0.0
flutter:
sdk: flutter
flutter_beep: ^1.0.0
image: ^3.2.0
dev_dependencies:

5
zxscanner/android/.gitignore vendored

@ -11,3 +11,8 @@ GeneratedPluginRegistrant.java
key.properties
**/*.keystore
**/*.jks
/fastlane/report.xml
/fastlane/private
/fastlane/**/*.png
fastlane/metadata/android/screenshots.html

34
zxscanner/android/Gemfile.lock

@ -8,8 +8,8 @@ GEM
artifactory (3.0.15)
atomos (0.1.3)
aws-eventstream (1.2.0)
aws-partitions (1.600.0)
aws-sdk-core (3.131.1)
aws-partitions (1.602.0)
aws-sdk-core (3.131.2)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
@ -66,7 +66,7 @@ GEM
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.206.2)
fastlane (2.207.0)
CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0)
artifactory (~> 3.0)
@ -106,9 +106,9 @@ GEM
xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3)
gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.22.0)
google-apis-core (>= 0.5, < 2.a)
google-apis-core (0.6.0)
google-apis-androidpublisher_v3 (0.23.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-core (0.7.0)
addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a)
httpclient (>= 2.8.1, < 3.a)
@ -117,19 +117,19 @@ GEM
retriable (>= 2.0, < 4.a)
rexml
webrick
google-apis-iamcredentials_v1 (0.11.0)
google-apis-core (>= 0.5, < 2.a)
google-apis-playcustomapp_v1 (0.8.0)
google-apis-core (>= 0.5, < 2.a)
google-apis-storage_v1 (0.15.0)
google-apis-core (>= 0.5, < 2.a)
google-apis-iamcredentials_v1 (0.12.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-playcustomapp_v1 (0.9.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-storage_v1 (0.16.0)
google-apis-core (>= 0.6, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.2)
google-cloud-storage (1.37.0)
addressable (~> 2.8)
digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1)
@ -137,7 +137,7 @@ GEM
google-cloud-core (~> 1.6)
googleauth (>= 0.16.2, < 2.a)
mini_mime (~> 1.0)
googleauth (1.1.3)
googleauth (1.2.0)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0)
memoist (~> 0.16)
@ -173,9 +173,9 @@ GEM
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
security (0.1.3)
signet (0.16.1)
signet (0.17.0)
addressable (~> 2.8)
faraday (>= 0.17.5, < 3.0)
faraday (>= 0.17.5, < 3.a)
jwt (>= 1.5, < 3.0)
multi_json (~> 1.10)
simctl (1.6.8)
@ -196,7 +196,7 @@ GEM
unicode-display_width (1.8.0)
webrick (1.7.0)
word_wrap (1.0.0)
xcodeproj (1.21.0)
xcodeproj (1.22.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)

12
zxscanner/android/app/build.gradle

@ -57,6 +57,8 @@ android {
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
signingConfigs {
@ -81,4 +83,14 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// Used tests to automatically generate screenshots using Fastlane Screengrab
// implementation 'androidx.test:core:1.4.0'
testImplementation 'junit:junit:4.13.2'
// testImplementation "com.google.truth:truth:1.0"
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'tools.fastlane:screengrab:2.1.1'
}

48
zxscanner/android/app/src/androidTest/java/com/markosyan/zxscanner/JUnit4StyleTests.kt

@ -0,0 +1,48 @@
package com.markosyan.zxscanner
import androidx.test.ext.junit.rules.ActivityScenarioRule
import org.junit.*
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
import tools.fastlane.screengrab.Screengrab
import tools.fastlane.screengrab.UiAutomatorScreenshotStrategy
import tools.fastlane.screengrab.cleanstatusbar.BluetoothState
import tools.fastlane.screengrab.cleanstatusbar.CleanStatusBar
import tools.fastlane.screengrab.cleanstatusbar.MobileDataType
import tools.fastlane.screengrab.locale.LocaleTestRule
@RunWith(JUnit4::class)
class JUnit4StyleTests {
companion object {
@JvmStatic
@BeforeClass
fun beforeAll() {
Screengrab.setDefaultScreenshotStrategy(UiAutomatorScreenshotStrategy())
CleanStatusBar()
.setMobileNetworkDataType(MobileDataType.LTE)
.setBluetoothState(BluetoothState.DISCONNECTED)
.enable()
}
@JvmStatic
@AfterClass
fun afterAll() {
CleanStatusBar.disable()
}
}
@get:Rule
var activityRule = ActivityScenarioRule(MainActivity::class.java)
@Rule @JvmField
val localeTestRule = LocaleTestRule()
@Test
fun testTakeScannerScreenshot() {
Thread.sleep(3000)
Screengrab.screenshot("01_scanner_screen")
Thread.sleep(3000)
Assert.assertTrue(true)
}
}

17
zxscanner/android/app/src/debug/AndroidManifest.xml

@ -5,4 +5,21 @@
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.DUMP"/>
<!-- Allows unlocking your device and activating its screen so UI tests can succeed -->
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<!-- Allows for storing and retrieving screenshots -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!-- Allows changing locales -->
<uses-permission android:name="android.permission.CHANGE_CONFIGURATION" />
<!-- <application android:usesCleartextTraffic="true">-->
<!-- -->
<!-- </application>-->
</manifest>

11
zxscanner/android/app/src/test/java/com/markosyan/zxscanner/ExampleTest.kt

@ -0,0 +1,11 @@
package com.markosyan.zxscanner
import org.junit.Assert
import org.junit.Test
class ExampleTest {
@Test
fun addition_isCorrect() {
Assert.assertEquals(4, 2 + 2)
}
}

2
zxscanner/android/fastlane/Appfile

@ -0,0 +1,2 @@
json_key_file("fastlane/private/pc-api-8902372433309418312-948-1346a3d81bee.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.markosyan.zxscanner") # e.g. com.krausefx.app

52
zxscanner/android/fastlane/Fastfile

@ -0,0 +1,52 @@
# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
# https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
# https://docs.fastlane.tools/plugins/available-plugins
#
# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Submit a new Beta Build to Crashlytics Beta"
lane :beta do
gradle(task: "clean assembleRelease")
crashlytics
# sh "your_script.sh"
# You can also use other beta testing services here
end
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(task: "clean assembleRelease")
upload_to_play_store
end
desc "Build debug and test APK for screenshots"
lane :screenshots do
# build_android_app(
# task: 'assemble',
# build_type: 'Debug'
# )
# build_android_app(
# task: 'assemble',
# build_type: 'AndroidTest'
# )
# screengrab()
frameit
end
end

56
zxscanner/android/fastlane/README.md

@ -0,0 +1,56 @@
fastlane documentation
----
# Installation
Make sure you have the latest version of the Xcode command line tools installed:
```sh
xcode-select --install
```
For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
# Available Actions
## Android
### android test
```sh
[bundle exec] fastlane android test
```
Runs all the tests
### android beta
```sh
[bundle exec] fastlane android beta
```
Submit a new Beta Build to Crashlytics Beta
### android deploy
```sh
[bundle exec] fastlane android deploy
```
Deploy a new version to the Google Play
### android screenshots
```sh
[bundle exec] fastlane android screenshots
```
Build debug and test APK for screenshots
----
This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).

15
zxscanner/android/fastlane/Screengrabfile

@ -0,0 +1,15 @@
# remove the leading '#' to uncomment lines
app_package_name('com.markosyan.zxscanner')
# use_tests_in_packages(['your.screenshot.tests.package'])
app_apk_path('/Users/khorenmarkosyan/Documents/Projects/flutter_zxing/zxscanner/build/app/outputs/apk/debug/app-debug.apk')
tests_apk_path('/Users/khorenmarkosyan/Documents/Projects/flutter_zxing/zxscanner/build/app/outputs/apk/androidTest/debug/app-debug-androidTest.apk')
locales(['en-US'])
# clear all previously generated screenshots in your local output directory before creating new ones
clear_previous_screenshots(true)
# For more information about all available options run
# fastlane screengrab --help

BIN
zxscanner/android/fastlane/metadata/android/background.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

5
zxscanner/android/fastlane/metadata/android/en-US/full_description.txt

@ -0,0 +1,5 @@
Barcode and QR code scanner that supports more than 15 types of codes.
- Scan barcode from camera stream
- Scan barcode from image path
- Create barcode from text
- Flashlight and pinch to zoom support

3
zxscanner/android/fastlane/metadata/android/en-US/keyword.strings

@ -0,0 +1,3 @@
"01_scanner_screen" = "SCAN";
"02_creator_screen" = "CREATE";
"03_help_screen" = "HELP";

1
zxscanner/android/fastlane/metadata/android/en-US/short_description.txt

@ -0,0 +1 @@
Barcode and QR Code Scanner

3
zxscanner/android/fastlane/metadata/android/en-US/title.strings

@ -0,0 +1,3 @@
"01_scanner_screen" = "Scan Barcodes";
"02_creator_screen" = "Create Your Barcodes";
"03_help_screen" = "Introduction To Barcodes";

1
zxscanner/android/fastlane/metadata/android/en-US/title.txt

@ -0,0 +1 @@
ZXScanner

0
zxscanner/android/fastlane/metadata/android/en-US/video.txt

35
zxscanner/android/fastlane/metadata/android/framefile.json

@ -0,0 +1,35 @@
{
"device_frame_version": "latest",
"default": {
"title": {
"color": "#545454"
},
"background": "./background.jpg",
"padding": 30,
"show_complete_frame": false,
"stack_title" : true,
"title_below_image": false,
"frame": "BLACK"
},
"data": [
{
"filter": "01_scanner_screen",
"keyword": {
"color": "#BF382A"
}
},
{
"filter": "02_creator_screen",
"keyword": {
"color": "#26AD5E"
}
},
{
"filter": "03_help_screen",
"keyword": {
"color": "#394C82"
}
}
]
}

6
zxscanner/android/gradle/wrapper/gradle-wrapper.properties vendored

@ -1,6 +1,6 @@
#Fri Jun 23 08:50:38 CEST 2017
#Thu Jul 07 11:06:28 AMT 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME

13
zxscanner/pubspec.lock

@ -21,7 +21,7 @@ packages:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
version: "3.1.11"
args:
dependency: transitive
description:
@ -203,7 +203,7 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.2"
version: "3.0.1"
cupertino_icons:
dependency: "direct main"
description:
@ -258,13 +258,6 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_beep:
dependency: transitive
description:
name: flutter_beep
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
flutter_lints:
dependency: "direct dev"
description:
@ -851,7 +844,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
version: "1.3.0"
universal_io:
dependency: transitive
description:

18
zxscanner/pubspec.yaml

@ -1,6 +1,6 @@
name: zxscanner
description: A barcode scanner application.
publish_to: 'none'
publish_to: "none"
version: 1.0.0+4
@ -37,15 +37,17 @@ flutter_intl:
dev_dependencies:
build_runner: ^2.1.11
# espresso: ^0.2.0+2
flutter_lints: ^2.0.1
flutter_native_splash: ^2.2.4 # flutter pub run flutter_native_splash:create
flutter_test:
sdk: flutter
hive_generator:
icons_launcher: ^1.1.9 # flutter pub run icons_launcher:create
# integration_test:
# sdk: flutter
mobx_codegen:
flutter:
uses-material-design: true
@ -54,8 +56,8 @@ flutter_native_splash:
color_dark: "#131d25"
image: assets/images/app_logo.png
info_plist_files:
- 'ios/Runner/Info-Debug.plist'
- 'ios/Runner/Info-Release.plist'
- "ios/Runner/Info-Debug.plist"
- "ios/Runner/Info-Release.plist"
flutter_icons:
android: true
@ -65,7 +67,7 @@ flutter_icons:
web: false
remove_alpha_ios: true
image_path: "assets/images/app_icon_border.png"
image_path_ios: 'assets/images/app_icon.png'
adaptive_icon_background: '#4C9BBA'
adaptive_icon_foreground: 'assets/images/app_icon_adaptive.png'
adaptive_icon_round: 'assets/images/app_icon_round.png'
image_path_ios: "assets/images/app_icon.png"
adaptive_icon_background: "#4C9BBA"
adaptive_icon_foreground: "assets/images/app_icon_adaptive.png"
adaptive_icon_round: "assets/images/app_icon_round.png"

Loading…
Cancel
Save