SUMMARY="Android File Transfer"
DESCRIPTION="Reliable MTP client with minimalistic UI
Features:
* Simple Qt UI with progress dialogs.
* No file size limits.
* Automatically renames album cover to make it visible from media player.
* No extra dependencies (e.g. libptp/libmtp)."
HOMEPAGE="https://whoozle.github.io/android-file-transfer-linux/"
COPYRIGHT="2015-2019 Vladimir Menshakov"
LICENSE="GNU LGPL v2.1"
REVISION="1"
SOURCE_URI="https://github.com/whoozle/android-file-transfer-linux/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="26aa21683ae34aceaf83747fec693a15b996017a857014931ef3c5b50115971a"
SOURCE_DIR="android-file-transfer-linux-$portVersion"
PATCHES="android_file_transfer-$portVersion.patchset"
ADDITIONAL_FILES="android-file-transfer.rdef.in"

ARCHITECTURES="all !x86_gcc2"
SECONDARY_ARCHITECTURES="x86"

PROVIDES="
	android_file_transfer$secondaryArchSuffix = $portVersion
	app:AndroidFileTransfer = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libQt5Core$secondaryArchSuffix
	lib:libQt5Gui$secondaryArchSuffix
	lib:libQt5Widgets$secondaryArchSuffix
	lib:libusb_1.0$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libQt5Core$secondaryArchSuffix
	devel:libQt5Gui$secondaryArchSuffix
	devel:libQt5Widgets$secondaryArchSuffix
	devel:libusb_1.0$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:cmake
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:lrelease$secondaryArchSuffix >= 5
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

BUILD()
{
	mkdir -p build
	cd build
	cmake .. \
		-DBUILD_FUSE=OFF \
		-DBUILD_QT_UI=ON \
		-DUSB_BACKEND_LIBUSB=ON
	make $jobArgs
}

INSTALL()
{
	mkdir -p $appsDir
	cp build/qt/android-file-transfer "$appsDir/AndroidFileTransfer"

	local APP_SIGNATURE="application/x-vnd.android-file-transfer"
	local MAJOR="`echo "$portVersion" | cut -d. -f1`"
	local MIDDLE="`echo "$portVersion" | cut -d. -f2`"
	local LONG_INFO="$SUMMARY"
	sed \
		-e "s|@APP_SIGNATURE@|$APP_SIGNATURE|" \
		-e "s|@MAJOR@|$MAJOR|" \
		-e "s|@MIDDLE@|$MIDDLE|" \
		-e "s|@LONG_INFO@|$LONG_INFO|" \
		$portDir/additional-files/android-file-transfer.rdef.in > $sourceDir/android-file-transfer.rdef

	addResourcesToBinaries  $sourceDir/android-file-transfer.rdef \
		"$appsDir/AndroidFileTransfer"
	mimeset -f "$appsDir/AndroidFileTransfer"
	addAppDeskbarSymlink "$appsDir/AndroidFileTransfer" "Android File Transfer"
}
