Пример #1
0
 public static bool CleanUp(string apk_location, string theme_name)
 {
     ColorPrint.WriteLine("Cleaning up");
     try
     {
         EnvHelper.CleanWorkEnvironment(theme_name);
         string apk_folder = new FileInfo(apk_location).DirectoryName;
         try
         {
             if (Directory.Exists(Path.Combine(apk_folder, theme_name + ".theme")))
             {
                 ColorPrint.WriteLine("\tREMOVING: {0}..", Path.Combine(apk_folder, theme_name + ".theme"));
                 Directory.Delete(Path.Combine(apk_folder, theme_name + ".theme"), true);
             }
         }
         catch { }
         ColorPrint.WriteLine("\tMOVING: {0}..", Path.Combine(Globals.WorkingDirectory, theme_name + ".theme"));
         Directory.Move(Path.Combine(Globals.WorkingDirectory, theme_name + ".theme"), Path.Combine(String.IsNullOrEmpty(Globals.OutputDirectory) ? apk_folder : Globals.OutputDirectory, theme_name + ".theme"));
         ColorPrint.WriteLine("\nSuccessfully cleaned up\n", ConsoleColor.Green);
         return(true);
     } catch (Exception ex)
     {
         ColorPrint.WriteLine("\nFailed cleaning up\n", ConsoleColor.Red);
         return(false);
     }
 }
Пример #2
0
        static void Main(string[] args)
        {
            // Display our pretty little header message. ;)
            PrintBannerMessage();

            List <string[]> icon_list = new List <string[]>();

            // Get our icon filter list. We check for a local file first, then fallback to the online database.
            if (!GetFilterList(icon_list))
            {
                return;
            }

            // Check to make sure we provided at least one APK file for the converter to use.
            RunArgsCheck(ref args);

            // A simple for loop to handle any/all files thrown at the converter.
            foreach (string apk in args)
            {
                // Read some file information about our APK file.
                FileInfo apk_info = new FileInfo(apk);

                // Get a basic name of the APK file (without any .apk or .zip extensions)
                string apk_name = new FileInfo(apk).Name.Replace(".apk", "").Replace(".zip", "");

                // Set up our temporary work environment. This basically just clears and creates a directory in APPDATA for us to move files around in.
                EnvHelper.SetupWorkEnvironment();

                // Check to see if the given file is a valid APK. We do this by attempting to extract one icon; if we fail, it can't be a valid icon pack.
                if (!CheckPackage(apk, apk_info))
                {
                    continue;
                }

                // Extract apk's icon folder. These will be extracted to our working directory that we created earlier.
                if (!ExtractIcons(apk))
                {
                    continue;
                }

                // Rename all icons according to our filter. Rename and move all of the icons found in the filter list.
                if (!RenameIcons(icon_list))
                {
                    continue;
                }

                // Clean up after all of the copying. Move some folders around to clean up and delete any unused android icons.
                if (!CleanUp(apk, apk_name))
                {
                    continue;
                }

                ColorPrint.WriteLine("Conversion successful!", ConsoleColor.Green);
                Globals.ConvertedIcons = 0;
                Globals.ConvertedThemes++;
            }

            ColorPrint.WriteLine("\nConverted {0} themes!", Globals.ConvertedThemes);
        }