opt_out_usage
# 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 "Build debug and test APK for screenshots"
  lane :build_and_screengrab do
    build_android_app(
      task: 'assemble',
      build_type: 'Instrumented',
      properties: {
        'screenshotMode' => 'true'
      }
    )
    build_android_app(
      task: 'assemble',
      build_type: 'AndroidTest',
      properties: {
        'screenshotMode' => 'true'
      }
    )
    do_screengrab()
  end
  
  desc "Take screenshots"
  lane :do_screengrab do
    screengrab(
      output_directory: 'fastlane/screenshots',
      use_timestamp_suffix: false,
      app_package_name: 'io.github.drumber.kitsune.instrumented',
      tests_package_name: 'io.github.drumber.kitsune.instrumented.test',
      use_tests_in_packages: 'io.github.drumber.kitsune.fastlane',
      app_apk_path: 'app/build/outputs/apk/instrumented/app-instrumented.apk',
      tests_apk_path: 'app/build/outputs/apk/androidTest/instrumented/app-instrumented-androidTest.apk',
      reinstall_app: true,
      clear_previous_screenshots: true
    )
  end

  desc "Add a device frame to the screenshots and copy them to the phoneScreenshots and media folders"
  lane :process_screenshots do
    frameit(
      path: 'fastlane/screenshots'
    )
  	copy_artifacts(
      target_path: "media",
      artifacts: ["fastlane/screenshots/en-US/images/phoneScreenshots/*_framed.png"]
	  )
	  copy_artifacts(
      target_path: "fastlane/metadata/android/en-US/images/phoneScreenshots",
      artifacts: ["fastlane/screenshots/en-US/images/phoneScreenshots/*_framed.png"]
    )
  end
end
