<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <?define ProductName="APK Editor Studio" ?>
  <?define ProductVersion="$(env.VERSION)" ?>

  <Product Id="*" Name="$(var.ProductName)" Version="$(var.ProductVersion)" UpgradeCode="B889316C-C1B5-4615-8443-F1ADB1B3584D" Manufacturer="Alexander Gorishnyak" Language="1033">

    <Package InstallScope="perMachine" InstallerVersion="301" Compressed="yes" />
    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <MajorUpgrade
      Schedule="afterInstallInitialize"
      DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will now exit." />

    <UIRef Id="UI_APK_Editor_Studio" />
    <Icon Id="Icon" SourceFile="$(var.DistDir)\apk-editor-studio.exe" />
    <Property Id="ApplicationFolderName" Value="$(var.ProductName)" />
    <Property Id="ARPPRODUCTICON" Value="Icon" />

    <CustomAction Id="SetExecutablePathProperty" Property="ExecutablePath" Value="[INSTALLFOLDER]apk-editor-studio.exe" />
    <InstallExecuteSequence>
      <Custom Action="SetExecutablePathProperty" Before="InstallFiles" />
    </InstallExecuteSequence>

    <WixVariable Id="WixUIDialogBmp" Value="$(sys.SOURCEFILEDIR)\res\banner.bmp" />
    <WixVariable Id="WixUIBannerBmp" Value="$(sys.SOURCEFILEDIR)\res\header.bmp" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="$(var.ProductName)" FileSource="$(var.DistDir)">
          <Component Id="ExeComponent">
            <File Name="apk-editor-studio.exe" Id="Executable" />
          </Component>
          <Component Id="UninstallComponent">
            <Shortcut Id="UninstallShortcut" Name="Uninstall $(var.ProductName)" Description="Uninstall $(var.ProductName)" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" WorkingDirectory="SystemFolder" />
            <RegistryValue Root="HKLM" Key="Software\$(var.ProductName)" Name="Uninstaller" Type="integer" Value="1" KeyPath="yes" />
          </Component>
          <Directory Id="ToolsFolder" Name="tools">
            <Component Id="ApktoolComponent">
              <File Name="apktool.jar" />
            </Component>
            <Component Id="ApksignerComponent">
              <File Name="apksigner.jar" />
            </Component>
            <Component Id="KeystoreComponent">
              <File Name="demo.jks" />
            </Component>
            <Component Id="ZipalignComponent">
              <File Name="zipalign.exe" />
            </Component>
            <Component Id="LibWinpthreadComponent">
              <File Name="libwinpthread-1.dll" />
            </Component>
            <Component Id="AdbComponent">
              <File Name="adb.exe" />
            </Component>
            <Component Id="AdbWinApiComponent">
              <File Name="AdbWinApi.dll" />
            </Component>
            <Component Id="AdbWinUsbApiComponent">
              <File Name="AdbWinUsbApi.dll" />
            </Component>
          </Directory>
          <Directory Id="ResourcesFolder" Name="resources">
            <Directory Id="LanguagesFolder" Name="translations">
              <Component Id="AzerbaijaniComponent">
                <File Name="apk-editor-studio.az.qm" />
              </Component>
              <Component Id="ChineseSimplifiedComponent">
                <File Name="apk-editor-studio.zh_CN.qm" />
              </Component>
              <Component Id="ChineseSimplifiedQtComponent">
                <File Name="qt.zh_CN.qm" />
              </Component>
              <Component Id="CzechComponent">
                <File Name="apk-editor-studio.cs.qm" />
              </Component>
              <Component Id="CzechQtComponent">
                <File Name="qt.cs.qm" />
              </Component>
              <Component Id="EnglishBritishComponent">
                <File Name="apk-editor-studio.en_GB.qm" />
              </Component>
              <Component Id="FrenchComponent">
                <File Name="apk-editor-studio.fr.qm" />
              </Component>
              <Component Id="FrenchQtComponent">
                <File Name="qt.fr.qm" />
              </Component>
              <Component Id="GermanComponent">
                <File Name="apk-editor-studio.de.qm" />
              </Component>
              <Component Id="GermanQtComponent">
                <File Name="qt.de.qm" />
              </Component>
              <Component Id="GreekComponent">
                <File Name="apk-editor-studio.el.qm" />
              </Component>
              <Component Id="HebrewComponent">
                <File Name="apk-editor-studio.he.qm" />
              </Component>
              <Component Id="HebrewQtComponent">
                <File Name="qt.he.qm" />
              </Component>
              <Component Id="HungarianComponent">
                <File Name="apk-editor-studio.hu.qm" />
              </Component>
              <Component Id="HungarianQtComponent">
                <File Name="qt.hu.qm" />
              </Component>
              <Component Id="IndonesianComponent">
                <File Name="apk-editor-studio.id.qm" />
              </Component>
              <Component Id="ItalianComponent">
                <File Name="apk-editor-studio.it.qm" />
              </Component>
              <Component Id="ItalianQtComponent">
                <File Name="qt.it.qm" />
              </Component>
              <Component Id="JapaneseComponent">
                <File Name="apk-editor-studio.ja.qm" />
              </Component>
              <Component Id="JapaneseQtComponent">
                <File Name="qt.ja.qm" />
              </Component>
              <Component Id="KoreanComponent">
                <File Name="apk-editor-studio.ko.qm" />
              </Component>
              <Component Id="KoreanQtComponent">
                <File Name="qt.ko.qm" />
              </Component>
              <Component Id="KurdishComponent">
                <File Name="apk-editor-studio.ckb.qm" />
              </Component>
              <Component Id="PersianComponent">
                <File Name="apk-editor-studio.fa.qm" />
              </Component>
              <Component Id="PolishComponent">
                <File Name="apk-editor-studio.pl.qm" />
              </Component>
              <Component Id="PolishQtComponent">
                <File Name="qt.pl.qm" />
              </Component>
              <Component Id="PortugueseComponent">
                <File Name="apk-editor-studio.pt.qm" />
              </Component>
              <Component Id="PortugueseQtComponent">
                <File Name="qt.pt.qm" />
              </Component>
              <Component Id="RomanianComponent">
                <File Name="apk-editor-studio.ro.qm" />
              </Component>
              <Component Id="RussianComponent">
                <File Name="apk-editor-studio.ru.qm" />
              </Component>
              <Component Id="RussianQtComponent">
                <File Name="qt.ru.qm" />
              </Component>
              <Component Id="SpanishComponent">
                <File Name="apk-editor-studio.es.qm" />
              </Component>
              <Component Id="SpanishQtComponent">
                <File Name="qt.es.qm" />
              </Component>
              <Component Id="TurkishComponent">
                <File Name="apk-editor-studio.tr.qm" />
              </Component>
            </Directory>
          </Directory>
          <Directory Id="DocsFolder" Name="docs">
            <Component Id="AuthorsComponent">
              <File Name="authors.txt" />
            </Component>
            <Component Id="VersionsComponent">
              <File Name="versions.txt" />
            </Component>
            <Directory Id="LicensesFolder" Name="licenses">
              <Component Id="LicenseComponent">
                <File Name="apk-editor-studio.html" />
              </Component>
            </Directory>
          </Directory>
          <Component Id="QtCoreComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Core.dll" />
          </Component>
          <Component Id="QtGuiComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Gui.dll" />
          </Component>
          <Component Id="QtNetworkComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Network.dll" />
          </Component>
          <Component Id="QtSvgComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Svg.dll" />
          </Component>
          <Component Id="QtWidgetsComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Widgets.dll" />
          </Component>
          <Component Id="QtXmlComponent">
            <File Source="$(env.QTDIR)\bin\Qt5Xml.dll" />
          </Component>
          <Component Id="LibSslComponent">
            <File Source="$(env.OPENSSL)\libssl-1_1.dll" />
          </Component>
          <Component Id="LibCryptoComponent">
            <File Source="$(env.OPENSSL)\libcrypto-1_1.dll" />
          </Component>
          <Directory Id="ImageFormatsFolder" Name="imageformats">
            <Component Id="QtGifFormatComponent">
              <File Source="$(env.QTDIR)\plugins\imageformats\qgif.dll" />
            </Component>
            <Component Id="QtIcnsFormatComponent">
              <File Source="$(env.QTDIR)\plugins\imageformats\qicns.dll" />
            </Component>
            <Component Id="QtIcoFormatComponent">
              <File Source="$(env.QTDIR)\plugins\imageformats\qico.dll" />
            </Component>
            <Component Id="QtJpegFormatComponent">
              <File Source="$(env.QTDIR)\plugins\imageformats\qjpeg.dll" />
            </Component>
            <Component Id="QtSvgFormatComponent">
              <File Source="$(env.QTDIR)\plugins\imageformats\qsvg.dll" />
            </Component>
          </Directory>
          <Directory Id="PlatformsFolder" Name="platforms">
            <Component Id="QtPlatformComponent">
              <File Source="$(env.QTDIR)\plugins\platforms\qwindows.dll" />
            </Component>
          </Directory>
          <Directory Id="StylesFolder" Name="styles">
            <Component Id="QtVistaStyleComponent">
              <File Source="$(env.QTDIR)\plugins\styles\qwindowsvistastyle.dll" />
            </Component>
          </Directory>
        </Directory>
      </Directory>
      <Directory Id="DesktopFolder">
        <Component Id="DesktopComponent">
          <Shortcut Id="DesktopExecutableShortcut" Name="$(var.ProductName)" Description="Start $(var.ProductName)" Target="[!Executable]" WorkingDirectory="INSTALLFOLDER" />
          <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="DesktopShortcut" Type="integer" Value="1" KeyPath="yes" />
        </Component>
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="StartmenuFolder" Name="$(var.ProductName)">
          <Component Id="StartmenuComponent">
            <Shortcut Id="StartmenuExecutableShortcut" Name="$(var.ProductName)" Description="Start $(var.ProductName)" Target="[!Executable]" WorkingDirectory="INSTALLFOLDER" />
            <Shortcut Id="StartmenuUninstallShortcut" Name="Uninstall $(var.ProductName)" Description="Uninstall $(var.ProductName)" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" WorkingDirectory="SystemFolder" />
            <RemoveFolder Id="RemoveShortcutsFolder" On="uninstall" />
            <RegistryValue Root="HKCU" Key="Software\$(var.ProductName)" Name="StartmenuFolder" Type="integer" Value="1" KeyPath="yes" />
          </Component>
        </Directory>
      </Directory>
      <Component Id="AssociationComponent">
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\.apk" Value="apk-editor-studio.apk" Type="string" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\.apk\OpenWithProgIds" Name="apk-editor-studio.apk" Value="" Type="string" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk" Name="FriendlyTypeName" Value="Android Application Package" Type="string" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\DefaultIcon" Value="[ExecutablePath],0" Type="string" />
      </Component>
      <Component Id="ExplorerOpenComponent">
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Open\Command" Value="&quot;[ExecutablePath]&quot; &quot;%1&quot;" Type="string" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Open" Name="Icon" Value="[ExecutablePath]" Type="string" />
      </Component>
      <Component Id="ExplorerInstallComponent">
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Install APK\Command" Value="&quot;[ExecutablePath]&quot; --install &quot;%1&quot;" Type="string" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Install APK" Name="Icon" Value="[ExecutablePath],1" Type="string" />
      </Component>
      <Component Id="ExplorerOptimizeComponent">
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Optimize APK\Command" Value="&quot;[ExecutablePath]&quot; --optimize &quot;%1&quot;" Type="string" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Optimize APK" Name="Icon" Value="[ExecutablePath],2" Type="string" />
      </Component>
      <Component Id="ExplorerSignComponent">
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Sign APK\Command" Value="&quot;[ExecutablePath]&quot; --sign &quot;%1&quot;" Type="string" KeyPath="yes" />
        <RegistryValue Root="HKCU" Key="SOFTWARE\Classes\apk-editor-studio.apk\Shell\Sign APK" Name="Icon" Value="[ExecutablePath],3" Type="string" />
      </Component>
    </Directory>

    <ComponentGroup Id="ApplicationComponents">
      <ComponentRef Id="ExeComponent" />
      <ComponentRef Id="ApktoolComponent" />
      <ComponentRef Id="ApksignerComponent" />
      <ComponentRef Id="KeystoreComponent" />
      <ComponentGroupRef Id="QtComponents" />
      <ComponentGroupRef Id="OpenSslComponents" />
      <ComponentGroupRef Id="AdbComponents" />
      <ComponentGroupRef Id="ZipalignComponents" />
      <ComponentGroupRef Id="DocsComponents" />
      <ComponentRef Id="EnglishBritishComponent" />
      <ComponentRef Id="UninstallComponent" />
    </ComponentGroup>
    <ComponentGroup Id="QtComponents">
      <ComponentRef Id="QtCoreComponent" />
      <ComponentRef Id="QtGuiComponent" />
      <ComponentRef Id="QtNetworkComponent" />
      <ComponentRef Id="QtSvgComponent" />
      <ComponentRef Id="QtWidgetsComponent" />
      <ComponentRef Id="QtXmlComponent" />
      <ComponentRef Id="QtPlatformComponent" />
      <ComponentRef Id="QtVistaStyleComponent" />
      <ComponentGroupRef Id="QtImageFormats" />
    </ComponentGroup>
    <ComponentGroup Id="QtImageFormats">
      <ComponentRef Id="QtGifFormatComponent" />
      <ComponentRef Id="QtIcnsFormatComponent" />
      <ComponentRef Id="QtIcoFormatComponent" />
      <ComponentRef Id="QtJpegFormatComponent" />
      <ComponentRef Id="QtSvgFormatComponent" />
    </ComponentGroup>
    <ComponentGroup Id="OpenSslComponents">
      <ComponentRef Id="LibSslComponent" />
      <ComponentRef Id="LibCryptoComponent" />
    </ComponentGroup>
    <ComponentGroup Id="AdbComponents">
      <ComponentRef Id="AdbComponent" />
      <ComponentRef Id="AdbWinApiComponent" />
      <ComponentRef Id="AdbWinUsbApiComponent" />
    </ComponentGroup>
    <ComponentGroup Id="ZipalignComponents">
      <ComponentRef Id="ZipalignComponent" />
      <ComponentRef Id="LibWinpthreadComponent" />
    </ComponentGroup>
    <ComponentGroup Id="DocsComponents">
      <ComponentRef Id="AuthorsComponent" />
      <ComponentRef Id="LicenseComponent" />
      <ComponentRef Id="VersionsComponent" />
    </ComponentGroup>

		<Feature Id="ApplicationFeature" Title="$(var.ProductName)" Description="Install $(var.ProductName) application files." Absent="disallow" AllowAdvertise="no" ConfigurableDirectory="INSTALLFOLDER">
      <ComponentGroupRef Id="ApplicationComponents" />
		</Feature>
    <Feature Id="AssociationFeature" Title="File Association" Description="Register APK file association.">
      <ComponentRef Id="AssociationComponent" />
      <Feature Id="ExplorerOpenFeature" Title="Open APK Files" Description="Open APK files with $(var.ProductName).">
        <ComponentRef Id="ExplorerOpenComponent" />
      </Feature>
      <Feature Id="ExplorerIntegrationFeature" Title="Explorer Integration" Description="Add integration to Windows Explorer context menu.">
        <Feature Id="ExplorerInstallFeature" Title="Install APK Action" Description="Add Install APK action to Windows Explorer context menu.">
          <ComponentRef Id="ExplorerInstallComponent" />
        </Feature>
        <Feature Id="ExplorerOptimizeFeature" Title="Optimize APK Action" Description="Add Optimize APK action to Windows Explorer context menu.">
          <ComponentRef Id="ExplorerOptimizeComponent" />
        </Feature>
        <Feature Id="ExplorerSignFeature" Title="Sign APK Action" Description="Add Sign APK action to Windows Explorer context menu.">
          <ComponentRef Id="ExplorerSignComponent" />
        </Feature>
      </Feature>
    </Feature>
    <Feature Id="TranslationsFeature" Title="Translations" Description="Install additional translations. English is included by default.">
      <Feature Id="AzerbaijaniFeature" Title="Azerbaijani" Description="Azerbaijani translation.">
        <ComponentRef Id="AzerbaijaniComponent" />
      </Feature>
      <Feature Id="ChineseSimplifiedFeature" Title="Chinese (Simplified)" Description="Chinese (Simplified) translation.">
        <ComponentRef Id="ChineseSimplifiedComponent" />
        <ComponentRef Id="ChineseSimplifiedQtComponent" />
      </Feature>
      <Feature Id="CzechFeature" Title="Czech" Description="Czech translation.">
        <ComponentRef Id="CzechComponent" />
        <ComponentRef Id="CzechQtComponent" />
      </Feature>
      <Feature Id="FrenchFeature" Title="French" Description="French translation.">
        <ComponentRef Id="FrenchComponent" />
        <ComponentRef Id="FrenchQtComponent" />
      </Feature>
      <Feature Id="GermanFeature" Title="German" Description="German translation.">
        <ComponentRef Id="GermanComponent" />
        <ComponentRef Id="GermanQtComponent" />
      </Feature>
      <Feature Id="GreekFeature" Title="Greek" Description="Greek translation.">
        <ComponentRef Id="GreekComponent" />
      </Feature>
      <Feature Id="HebrewFeature" Title="Hebrew" Description="Hebrew translation.">
        <ComponentRef Id="HebrewComponent" />
        <ComponentRef Id="HebrewQtComponent" />
      </Feature>
      <Feature Id="HungarianFeature" Title="Hungarian" Description="Hungarian translation.">
        <ComponentRef Id="HungarianComponent" />
        <ComponentRef Id="HungarianQtComponent" />
      </Feature>
      <Feature Id="IndonesianFeature" Title="Indonesian" Description="Indonesian translation.">
        <ComponentRef Id="IndonesianComponent" />
      </Feature>
      <Feature Id="ItalianFeature" Title="Italian" Description="Italian translation.">
        <ComponentRef Id="ItalianComponent" />
        <ComponentRef Id="ItalianQtComponent" />
      </Feature>
      <Feature Id="JapaneseFeature" Title="Japanese" Description="Japanese translation.">
        <ComponentRef Id="JapaneseComponent" />
        <ComponentRef Id="JapaneseQtComponent" />
      </Feature>
      <Feature Id="KoreanFeature" Title="Korean" Description="Korean translation.">
        <ComponentRef Id="KoreanComponent" />
        <ComponentRef Id="KoreanQtComponent" />
      </Feature>
      <Feature Id="KurdishFeature" Title="Kurdish" Description="Kurdish translation.">
        <ComponentRef Id="KurdishComponent" />
      </Feature>
      <Feature Id="PersianFeature" Title="Persian" Description="Persian translation.">
        <ComponentRef Id="PersianComponent" />
      </Feature>
      <Feature Id="PolishFeature" Title="Polish" Description="Polish translation.">
        <ComponentRef Id="PolishComponent" />
        <ComponentRef Id="PolishQtComponent" />
      </Feature>
      <Feature Id="PortugueseFeature" Title="Portuguese" Description="Portuguese translation.">
        <ComponentRef Id="PortugueseComponent" />
        <ComponentRef Id="PortugueseQtComponent" />
      </Feature>
      <Feature Id="RomanianFeature" Title="Romanian" Description="Romanian translation.">
        <ComponentRef Id="RomanianComponent" />
      </Feature>
      <Feature Id="RussianFeature" Title="Russian" Description="Russian translation.">
        <ComponentRef Id="RussianComponent" />
        <ComponentRef Id="RussianQtComponent" />
      </Feature>
      <Feature Id="SpanishFeature" Title="Spanish" Description="Spanish translation.">
        <ComponentRef Id="SpanishComponent" />
        <ComponentRef Id="SpanishQtComponent" />
      </Feature>
      <Feature Id="TurkishFeature" Title="Turkish" Description="Turkish translation.">
        <ComponentRef Id="TurkishComponent" />
      </Feature>
    </Feature>
    <Feature Id="ShortcutsFeature" Title="Shortcuts" Description="Create $(var.ProductName) shortcuts.">
      <Feature Id="DesktopFeature" Title="Desktop Shortcut" Description="Add $(var.ProductName) shortcut to desktop.">
        <ComponentRef Id="DesktopComponent" />
      </Feature>
      <Feature Id="StartmenuFeature" Title="Start Menu Shortcuts" Description="Add $(var.ProductName) shortcut to start menu.">
        <ComponentRef Id="StartmenuComponent" />
      </Feature>
    </Feature>
	</Product>
</Wix>
