# This is the minimum version number required.
fastlane_version "2.58.0"

lane :screenshotsPhone do
    build_for_screengrab()

    screengrab(
        device_type: "phone",
        app_apk_path: APK_LOCATION,
        tests_apk_path: TEST_APK_LOCATION
    )
end

lane :screenshotsTablet do
    build_for_screengrab()

    screengrab(
    device_type: "sevenInch",
    app_apk_path: APK_LOCATION,
    tests_apk_path: TEST_APK_LOCATION
    )
end

desc "Build debug and test APK for screenshots"
private_lane :build_for_screengrab do
    build_android_app(
      task: 'assemble',
      flavor: 'Generic',
      build_type: 'Debug'
    )
    APK_LOCATION = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].select{ |i| i[/00/] }[0]

    build_android_app(
      task: 'assemble',
      flavor: 'Generic',
      build_type: 'DebugAndroidTest'
    )
    TEST_APK_LOCATION = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].select{ |i| i[/androidTest/] }[0]
end
