From 980c0e5dac8907397d263c6712b0487c961ba375 Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Sat, 18 May 2019 20:47:20 +0700 Subject: [PATCH 1/6] add AutoResolutionDelay --- .../src/SettingsDialog.cs | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/source/PlayServicesResolver/src/SettingsDialog.cs b/source/PlayServicesResolver/src/SettingsDialog.cs index fabbfe11..2741ee4d 100644 --- a/source/PlayServicesResolver/src/SettingsDialog.cs +++ b/source/PlayServicesResolver/src/SettingsDialog.cs @@ -39,6 +39,7 @@ private class Settings { internal bool verboseLogging; internal bool autoResolutionDisabledWarning; internal bool promptBeforeAutoResolution; + internal int autoResolutionDelay; internal bool useProjectSettings; /// @@ -55,6 +56,7 @@ internal Settings() { verboseLogging = SettingsDialog.VerboseLogging; autoResolutionDisabledWarning = SettingsDialog.AutoResolutionDisabledWarning; promptBeforeAutoResolution = SettingsDialog.PromptBeforeAutoResolution; + autoResolutionDelay = Math.Min(Math.Max(0,SettingsDialog.AutoResolutionDelay),30); useProjectSettings = SettingsDialog.UseProjectSettings; } @@ -72,6 +74,7 @@ internal void Save() { SettingsDialog.VerboseLogging = verboseLogging; SettingsDialog.AutoResolutionDisabledWarning = autoResolutionDisabledWarning; SettingsDialog.PromptBeforeAutoResolution = promptBeforeAutoResolution; + SettingsDialog.AutoResolutionDelay = autoResolutionDelay; SettingsDialog.UseProjectSettings = useProjectSettings; } } @@ -84,10 +87,9 @@ internal void Save() { private const string ExplodeAarsKey = Namespace + "ExplodeAars"; private const string PatchAndroidManifestKey = Namespace + "PatchAndroidManifest"; private const string VerboseLoggingKey = Namespace + "VerboseLogging"; - private const string AutoResolutionDisabledWarningKey = - Namespace + "AutoResolutionDisabledWarning"; - private const string PromptBeforeAutoResolutionKey = - Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDisabledWarningKey = Namespace + "AutoResolutionDisabledWarning"; + private const string PromptBeforeAutoResolutionKey = Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDelayKey = Namespace + "AutoResolutionDelay"; private const string UseGradleDaemonKey = Namespace + "UseGradleDaemon"; // List of preference keys, used to restore default settings. @@ -177,12 +179,15 @@ internal static bool AutoResolutionDisabledWarning { /// display a prompt. /// internal static bool PromptBeforeAutoResolution { - set { - projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); - } + set { projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); } get { return projectSettings.GetBool(PromptBeforeAutoResolutionKey, true); } } + internal static int AutoResolutionDelay { + set { projectSettings.SetInt(AutoResolutionDelayKey, value); } + get { return projectSettings.GetInt(AutoResolutionDelayKey,0); } + } + internal static bool UseProjectSettings { get { return projectSettings.UseProjectSettings; } set { projectSettings.UseProjectSettings = value; } @@ -351,8 +356,12 @@ public void OnGUI() { EditorGUI.BeginDisabledGroup(!settings.enableAutoResolution); GUILayout.BeginHorizontal(); GUILayout.Label("Prompt Before Auto-Resolution", EditorStyles.boldLabel); - settings.promptBeforeAutoResolution = - EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + settings.promptBeforeAutoResolution = EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Auto Resolution Delay", EditorStyles.boldLabel); + settings.autoResolutionDelay = Math.Min(Math.Max(0,EditorGUILayout.IntField(settings.autoResolutionDelay),30)); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); From d1de42e6b21f4725034b797ec0bf24997acf60bf Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Sat, 18 May 2019 20:48:01 +0700 Subject: [PATCH 2/6] Delay auto resolve dialog --- .../src/PlayServicesResolver.cs | 95 +++++++++++++------ 1 file changed, 64 insertions(+), 31 deletions(-) diff --git a/source/PlayServicesResolver/src/PlayServicesResolver.cs b/source/PlayServicesResolver/src/PlayServicesResolver.cs index 7f13ebf9..9ffa79fb 100644 --- a/source/PlayServicesResolver/src/PlayServicesResolver.cs +++ b/source/PlayServicesResolver/src/PlayServicesResolver.cs @@ -1,4 +1,4 @@ -// +// // Copyright (C) 2015 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -149,14 +149,12 @@ public static DependencyState ReadFromFile() { return true; } else if (elementName == "package" && parentElementName == "packages") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { packages.Add(reader.ReadContentAsString()); } return true; } else if (elementName == "file" && parentElementName == "files") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { files.Add(reader.ReadContentAsString()); } return true; @@ -928,32 +926,69 @@ private static void OnPostProcessScene() { /// Defaults to 1 second. private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { lock (typeof(PlayServicesResolver)) { - if (!autoResolving) { - RunOnMainThread.Cancel(autoResolveJobId); - autoResolveJobId = RunOnMainThread.Schedule( - () => { - lock (typeof(PlayServicesResolver)) { - autoResolving = true; - } - RunOnMainThread.PollOnUpdateUntilComplete(() => { - if (EditorApplication.isCompiling) return false; - // Only run AutoResolve() if we have a valid autoResolveJobId. - // If autoResolveJobId is 0, ScheduleResolve() - // has already been run and we should not run AutoResolve() - // again. - if (autoResolveJobId != 0) { - AutoResolve(() => { - lock (typeof(PlayServicesResolver)) { - autoResolving = false; - autoResolveJobId = 0; + if (autoResolving) + return; + + RunOnMainThread.Cancel(autoResolveJobId); + autoResolveJobId = RunOnMainThread.Schedule(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = true; + } + + DateTimeOffset delay = DateTimeOffset.Now.AddSeconds(Math.Min(30,GooglePlayServices.SettingsDialog.AutoResolutionDelay)); + bool shouldResolve = true; + AlertModal alert = null; + RunOnMainThread.PollOnUpdateUntilComplete(() => { + if(delay > DateTimeOffset.Now) + { + if(alert == null) + { + alert = new AlertModal { + Title = "Resolve or Skip dependency?", + Message = "Auto Resolve Dependency in : " + (delay - DateTimeOffset.Now).TotalSeconds, + Ok = new AlertModal.LabeledAction { + Label = "Resolve", + DelegateAction = () => { + delay = DateTimeOffset.Now; + shouldResolve = true; + } + }, + Cancel = new AlertModal.LabeledAction { + Label = "Skip", + DelegateAction = () => { + delay = DateTimeOffset.Now; + shouldResolve = false; } - }); + } + }; + + alert.Display(); + } + + if(alert != null) + { + alert.Message = "Auto Resolve Dependency in : " + (delay - DateTimeOffset.Now).TotalSeconds; + return false; + } + } + + if (EditorApplication.isCompiling) return false; + // Only run AutoResolve() if we have a valid autoResolveJobId. + // If autoResolveJobId is 0, ScheduleResolve() + // has already been run and we should not run AutoResolve() + // again. + + if (shouldResolve && autoResolveJobId != 0) { + AutoResolve(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = false; + autoResolveJobId = 0; } - return true; }); - }, - delayInMilliseconds); - } + } + return true; + }); + },delayInMilliseconds); } } @@ -1397,9 +1432,7 @@ private static void ScheduleResolve(bool forceResolution, RunOnMainThread.Cancel(autoResolveJobId); autoResolveJobId = 0; // Remove any enqueued auto-resolve jobs. - resolutionJobs.RemoveAll((jobInfo) => { - return jobInfo != null && jobInfo.IsAutoResolveJob; - }); + resolutionJobs.RemoveAll((jobInfo) => jobInfo == null || jobInfo.IsAutoResolveJob); firstJob = resolutionJobs.Count == 0; resolutionJobs.Add( From b3e3c738fb4f1ce0da3866d256abd92ceac26e59 Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Wed, 22 May 2019 01:03:16 +0700 Subject: [PATCH 3/6] Update PlayServicesResolver.cs --- .../src/PlayServicesResolver.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/source/PlayServicesResolver/src/PlayServicesResolver.cs b/source/PlayServicesResolver/src/PlayServicesResolver.cs index 9ffa79fb..6c2e35cf 100644 --- a/source/PlayServicesResolver/src/PlayServicesResolver.cs +++ b/source/PlayServicesResolver/src/PlayServicesResolver.cs @@ -926,37 +926,37 @@ private static void OnPostProcessScene() { /// Defaults to 1 second. private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { lock (typeof(PlayServicesResolver)) { - if (autoResolving) - return; + if (autoResolving) { + return; + } - RunOnMainThread.Cancel(autoResolveJobId); + RunOnMainThread.Cancel(autoResolveJobId); autoResolveJobId = RunOnMainThread.Schedule(() => { lock (typeof(PlayServicesResolver)) { autoResolving = true; } - DateTimeOffset delay = DateTimeOffset.Now.AddSeconds(Math.Min(30,GooglePlayServices.SettingsDialog.AutoResolutionDelay)); + int delaySec = GooglePlayServices.SettingsDialog.AutoResolutionDelay; + DateTimeOffset resolveTime = DateTimeOffset.Now.AddSeconds(Math.Min(30,delaySec)); bool shouldResolve = true; AlertModal alert = null; RunOnMainThread.PollOnUpdateUntilComplete(() => { - if(delay > DateTimeOffset.Now) - { - if(alert == null) - { + if (resolveTime > DateTimeOffset.Now) { + if(alert == null) { alert = new AlertModal { Title = "Resolve or Skip dependency?", - Message = "Auto Resolve Dependency in : " + (delay - DateTimeOffset.Now).TotalSeconds, + Message = "Auto Resolve Dependency in : " + (resolveTime - DateTimeOffset.Now).TotalSeconds, Ok = new AlertModal.LabeledAction { Label = "Resolve", DelegateAction = () => { - delay = DateTimeOffset.Now; + resolveTime = DateTimeOffset.Now; shouldResolve = true; } }, Cancel = new AlertModal.LabeledAction { Label = "Skip", DelegateAction = () => { - delay = DateTimeOffset.Now; + resolveTime = DateTimeOffset.Now; shouldResolve = false; } } @@ -965,12 +965,12 @@ private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { alert.Display(); } - if(alert != null) - { - alert.Message = "Auto Resolve Dependency in : " + (delay - DateTimeOffset.Now).TotalSeconds; - return false; - } - } + if(alert != null) + { + alert.Message = "Auto Resolve Dependency in : " + (resolveTime - DateTimeOffset.Now).TotalSeconds; + return false; + } + } if (EditorApplication.isCompiling) return false; // Only run AutoResolve() if we have a valid autoResolveJobId. From e18f3bbb7f56284f9e91befa57ca20f7947fa688 Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Wed, 22 May 2019 01:12:15 +0700 Subject: [PATCH 4/6] Update PlayServicesResolver.cs --- .../PlayServicesResolver/src/PlayServicesResolver.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/PlayServicesResolver/src/PlayServicesResolver.cs b/source/PlayServicesResolver/src/PlayServicesResolver.cs index 6c2e35cf..63553a8b 100644 --- a/source/PlayServicesResolver/src/PlayServicesResolver.cs +++ b/source/PlayServicesResolver/src/PlayServicesResolver.cs @@ -941,11 +941,12 @@ private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { bool shouldResolve = true; AlertModal alert = null; RunOnMainThread.PollOnUpdateUntilComplete(() => { - if (resolveTime > DateTimeOffset.Now) { + int countDown = (int)(resolveTime - DateTimeOffset.Now).TotalSeconds; + if (countDown > 0) { if(alert == null) { alert = new AlertModal { Title = "Resolve or Skip dependency?", - Message = "Auto Resolve Dependency in : " + (resolveTime - DateTimeOffset.Now).TotalSeconds, + Message = "Auto Resolve Dependency in : " + countDown, Ok = new AlertModal.LabeledAction { Label = "Resolve", DelegateAction = () => { @@ -965,9 +966,8 @@ private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { alert.Display(); } - if(alert != null) - { - alert.Message = "Auto Resolve Dependency in : " + (resolveTime - DateTimeOffset.Now).TotalSeconds; + if(alert != null) { + alert.Message = "Auto Resolve Dependency in : " + countDown; return false; } } From 4f15dd772f7d2bdef30fbebbaabe8fe2d4314257 Mon Sep 17 00:00:00 2001 From: Thaina Yu Date: Sat, 18 May 2019 20:47:20 +0700 Subject: [PATCH 5/6] cleanup 30 sec maximum delay also use Resolver.AutomaticResolutionEnabled() to skip the popup Update PlayServicesResolver.cs Update PlayServicesResolver.cs Delay auto resolve dialog add AutoResolutionDelay --- .../src/PlayServicesResolver.cs | 121 +++++++++++------- .../src/SettingsDialog.cs | 28 ++-- 2 files changed, 96 insertions(+), 53 deletions(-) diff --git a/source/PlayServicesResolver/src/PlayServicesResolver.cs b/source/PlayServicesResolver/src/PlayServicesResolver.cs index 7f13ebf9..2e68b866 100644 --- a/source/PlayServicesResolver/src/PlayServicesResolver.cs +++ b/source/PlayServicesResolver/src/PlayServicesResolver.cs @@ -1,4 +1,4 @@ -// +// // Copyright (C) 2015 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -149,14 +149,12 @@ public static DependencyState ReadFromFile() { return true; } else if (elementName == "package" && parentElementName == "packages") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { packages.Add(reader.ReadContentAsString()); } return true; } else if (elementName == "file" && parentElementName == "files") { - if (isStart && reader.Read() && - reader.NodeType == XmlNodeType.Text) { + if (reader.Read() && reader.NodeType == XmlNodeType.Text) { files.Add(reader.ReadContentAsString()); } return true; @@ -928,32 +926,69 @@ private static void OnPostProcessScene() { /// Defaults to 1 second. private static void ScheduleAutoResolve(double delayInMilliseconds = 1000.0) { lock (typeof(PlayServicesResolver)) { - if (!autoResolving) { - RunOnMainThread.Cancel(autoResolveJobId); - autoResolveJobId = RunOnMainThread.Schedule( - () => { - lock (typeof(PlayServicesResolver)) { - autoResolving = true; - } - RunOnMainThread.PollOnUpdateUntilComplete(() => { - if (EditorApplication.isCompiling) return false; - // Only run AutoResolve() if we have a valid autoResolveJobId. - // If autoResolveJobId is 0, ScheduleResolve() - // has already been run and we should not run AutoResolve() - // again. - if (autoResolveJobId != 0) { - AutoResolve(() => { - lock (typeof(PlayServicesResolver)) { - autoResolving = false; - autoResolveJobId = 0; + if (autoResolving) { + return; + } + + RunOnMainThread.Cancel(autoResolveJobId); + autoResolveJobId = RunOnMainThread.Schedule(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = true; + } + + int delaySec = GooglePlayServices.SettingsDialog.AutoResolutionDelay; + DateTimeOffset resolveTime = DateTimeOffset.Now.AddSeconds(delaySec); + bool shouldResolve = true; + AlertModal alert = null; + RunOnMainThread.PollOnUpdateUntilComplete(() => { + if (resolveTime > DateTimeOffset.Now && Resolver.AutomaticResolutionEnabled()) { + int countDown = (int)(resolveTime - DateTimeOffset.Now).TotalSeconds; + if(alert == null) { + alert = new AlertModal { + Title = "Resolve or Skip dependency?", + Message = "Auto Resolve Dependency in : " + countDown, + Ok = new AlertModal.LabeledAction { + Label = "Resolve", + DelegateAction = () => { + resolveTime = DateTimeOffset.Now; + shouldResolve = true; } - }); + }, + Cancel = new AlertModal.LabeledAction { + Label = "Skip", + DelegateAction = () => { + resolveTime = DateTimeOffset.Now; + shouldResolve = false; + } + } + }; + + alert.Display(); + } + + if(alert != null) { + alert.Message = "Auto Resolve Dependency in : " + countDown; + return false; + } + } + + if (EditorApplication.isCompiling) return false; + // Only run AutoResolve() if we have a valid autoResolveJobId. + // If autoResolveJobId is 0, ScheduleResolve() + // has already been run and we should not run AutoResolve() + // again. + + if (shouldResolve && autoResolveJobId != 0) { + AutoResolve(() => { + lock (typeof(PlayServicesResolver)) { + autoResolving = false; + autoResolveJobId = 0; } - return true; }); - }, - delayInMilliseconds); - } + } + return true; + }); + },delayInMilliseconds); } } @@ -1353,19 +1388,19 @@ public static bool ResolveSync(bool forceResolution) { /// Delegate called when delete is complete. public static void DeleteResolvedLibraries(System.Action complete = null) { RunOnMainThread.Schedule(() => { - if (Resolver.AutomaticResolutionEnabled()) { - Log("Disabling auto-resolution to prevent libraries from being " + - "resolved after deletion.", level: LogLevel.Warning); - GooglePlayServices.SettingsDialog.EnableAutoResolution = false; - } - DeleteLabeledAssets(); - LocalMavenRepository.PatchPomFilesInLocalRepos( - PlayServicesSupport.GetAllDependencies().Values); - if (GradleTemplateEnabled) { - GradleTemplateResolver.InjectDependencies(new List()); - } - if (complete != null) complete(); - }, 0); + if (Resolver.AutomaticResolutionEnabled()) { + Log("Disabling auto-resolution to prevent libraries from being " + + "resolved after deletion.", level: LogLevel.Warning); + GooglePlayServices.SettingsDialog.EnableAutoResolution = false; + } + DeleteLabeledAssets(); + LocalMavenRepository.PatchPomFilesInLocalRepos( + PlayServicesSupport.GetAllDependencies().Values); + if (GradleTemplateEnabled) { + GradleTemplateResolver.InjectDependencies(new List()); + } + if (complete != null) complete(); + }, 0); } /// @@ -1397,9 +1432,7 @@ private static void ScheduleResolve(bool forceResolution, RunOnMainThread.Cancel(autoResolveJobId); autoResolveJobId = 0; // Remove any enqueued auto-resolve jobs. - resolutionJobs.RemoveAll((jobInfo) => { - return jobInfo != null && jobInfo.IsAutoResolveJob; - }); + resolutionJobs.RemoveAll((jobInfo) => jobInfo == null || jobInfo.IsAutoResolveJob); firstJob = resolutionJobs.Count == 0; resolutionJobs.Add( diff --git a/source/PlayServicesResolver/src/SettingsDialog.cs b/source/PlayServicesResolver/src/SettingsDialog.cs index fabbfe11..a4ee82a2 100644 --- a/source/PlayServicesResolver/src/SettingsDialog.cs +++ b/source/PlayServicesResolver/src/SettingsDialog.cs @@ -39,6 +39,7 @@ private class Settings { internal bool verboseLogging; internal bool autoResolutionDisabledWarning; internal bool promptBeforeAutoResolution; + internal int autoResolutionDelay; internal bool useProjectSettings; /// @@ -55,6 +56,7 @@ internal Settings() { verboseLogging = SettingsDialog.VerboseLogging; autoResolutionDisabledWarning = SettingsDialog.AutoResolutionDisabledWarning; promptBeforeAutoResolution = SettingsDialog.PromptBeforeAutoResolution; + autoResolutionDelay = SettingsDialog.AutoResolutionDelay; useProjectSettings = SettingsDialog.UseProjectSettings; } @@ -72,6 +74,7 @@ internal void Save() { SettingsDialog.VerboseLogging = verboseLogging; SettingsDialog.AutoResolutionDisabledWarning = autoResolutionDisabledWarning; SettingsDialog.PromptBeforeAutoResolution = promptBeforeAutoResolution; + SettingsDialog.AutoResolutionDelay = autoResolutionDelay; SettingsDialog.UseProjectSettings = useProjectSettings; } } @@ -84,10 +87,9 @@ internal void Save() { private const string ExplodeAarsKey = Namespace + "ExplodeAars"; private const string PatchAndroidManifestKey = Namespace + "PatchAndroidManifest"; private const string VerboseLoggingKey = Namespace + "VerboseLogging"; - private const string AutoResolutionDisabledWarningKey = - Namespace + "AutoResolutionDisabledWarning"; - private const string PromptBeforeAutoResolutionKey = - Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDisabledWarningKey = Namespace + "AutoResolutionDisabledWarning"; + private const string PromptBeforeAutoResolutionKey = Namespace + "PromptBeforeAutoResolution"; + private const string AutoResolutionDelayKey = Namespace + "AutoResolutionDelay"; private const string UseGradleDaemonKey = Namespace + "UseGradleDaemon"; // List of preference keys, used to restore default settings. @@ -177,12 +179,16 @@ internal static bool AutoResolutionDisabledWarning { /// display a prompt. /// internal static bool PromptBeforeAutoResolution { - set { - projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); - } + set { projectSettings.SetBool(PromptBeforeAutoResolutionKey, value); } get { return projectSettings.GetBool(PromptBeforeAutoResolutionKey, true); } } + const int MAXIMUM_AUTO_RESOLVE_DELAY_TIME = 30; + internal static int AutoResolutionDelay { + set { projectSettings.SetInt(AutoResolutionDelayKey,Math.Min(Math.Max(0,value),MAXIMUM_AUTO_RESOLVE_DELAY_TIME)); } + get { return Math.Min(Math.Max(0,projectSettings.GetInt(AutoResolutionDelayKey,0)),MAXIMUM_AUTO_RESOLVE_DELAY_TIME); } + } + internal static bool UseProjectSettings { get { return projectSettings.UseProjectSettings; } set { projectSettings.UseProjectSettings = value; } @@ -351,8 +357,12 @@ public void OnGUI() { EditorGUI.BeginDisabledGroup(!settings.enableAutoResolution); GUILayout.BeginHorizontal(); GUILayout.Label("Prompt Before Auto-Resolution", EditorStyles.boldLabel); - settings.promptBeforeAutoResolution = - EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + settings.promptBeforeAutoResolution = EditorGUILayout.Toggle(settings.promptBeforeAutoResolution); + GUILayout.EndHorizontal(); + + GUILayout.BeginHorizontal(); + GUILayout.Label("Auto Resolution Delay", EditorStyles.boldLabel); + settings.autoResolutionDelay = Math.Min(Math.Max(0,EditorGUILayout.IntField(settings.autoResolutionDelay),MAXIMUM_AUTO_RESOLVE_DELAY_TIME)); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); From e9820d3c4ce125b9bda656c7fd6fb72673b18a6a Mon Sep 17 00:00:00 2001 From: Thaina Date: Sun, 30 Jun 2019 20:38:02 +0700 Subject: [PATCH 6/6] fix to use progressbardialog for countdown instead --- build.gradle | 9 ++-- .../scripts/gradle-template.zip | Bin 51623 -> 51623 bytes .../src/PlayServicesResolver.cs | 51 ++++++------------ .../src/SettingsDialog.cs | 2 +- 4 files changed, 23 insertions(+), 39 deletions(-) diff --git a/build.gradle b/build.gradle index 628cef24..9004332d 100644 --- a/build.gradle +++ b/build.gradle @@ -36,7 +36,7 @@ project.ext { (OperatingSystem.WINDOWS): ["\\Program Files\\Unity\\Editor\\Unity.exe"] + (new FileNameFinder()).getFileNames( - "\\", "Program Files\\Unity\\Hub\\Editor\\*\\Editor\\Unity.exe"), + "\\Program Files\\Unity\\Hub\\Editor", "*\\Editor\\Unity.exe"), // previously don't work on windows (OperatingSystem.LINUX): ["/opt/Unity/Editor/Unity"]][operatingSystem] // Search for the Unity editor executable. @@ -61,9 +61,10 @@ project.ext { (OperatingSystem.MAC_OSX): "Unity.app/Contents/MacOS", (OperatingSystem.WINDOWS): "Editor", (OperatingSystem.LINUX): "Editor"][operatingSystem] - File unityRootDir = findFileProperty( - "UNITY_DIR", new File(unityExe.parentFile.absolutePath - - unityExeParentPath), true) + + // (string - string) will remove first occurance. We need to remove last occurance + File unityRootDir = findFileProperty("UNITY_DIR", + new File(unityExe.parentFile.absolutePath.substring(0,unityExe.parentFile.absolutePath.lastIndexOf(unityExeParentPath))), true) if (unityRootDir == null) { throw new StopActionException("Unity root directory (UNITY_DIR) not found.") } diff --git a/source/PlayServicesResolver/scripts/gradle-template.zip b/source/PlayServicesResolver/scripts/gradle-template.zip index fff63fa5a8e132371a7a92a2b86fc8edcb528935..cba424ef3e7ccef8a89092bc40e04031f18f3b86 100644 GIT binary patch delta 138 zcmZ2JnR)qSX5IjAW)?061`ZB}>CD?F@~SY~7Tud@qQea2ZA?zs4dPBdw)-}Szj?`? zN$g;T<&pc$AjV|r6GmVa0Vk}${N58jVE&yG!LmSkKlkIRR|?n}7`6#BFaRkySTfn? Lqy$(;`bh@>ZecK( delta 138 zcmZ2JnR)qSX5IjAW)?061`ZB}Jw@jx@~SXT54tqbM2A_iXXeJ_gxw(S { - if (resolveTime > DateTimeOffset.Now && Resolver.AutomaticResolutionEnabled()) { - int countDown = (int)(resolveTime - DateTimeOffset.Now).TotalSeconds; - if(alert == null) { - alert = new AlertModal { - Title = "Resolve or Skip dependency?", - Message = "Auto Resolve Dependency in : " + countDown, - Ok = new AlertModal.LabeledAction { - Label = "Resolve", - DelegateAction = () => { - resolveTime = DateTimeOffset.Now; - shouldResolve = true; - } - }, - Cancel = new AlertModal.LabeledAction { - Label = "Skip", - DelegateAction = () => { - resolveTime = DateTimeOffset.Now; - shouldResolve = false; - } - } - }; - - alert.Display(); - } - - if(alert != null) { - alert.Message = "Auto Resolve Dependency in : " + countDown; - return false; - } - } - - if (EditorApplication.isCompiling) return false; // Only run AutoResolve() if we have a valid autoResolveJobId. // If autoResolveJobId is 0, ScheduleResolve() // has already been run and we should not run AutoResolve() // again. + if(autoResolveJobId == 0) + return true; + + DateTimeOffset now = DateTimeOffset.Now; + if (resolveTime > now && PlayServicesResolver.AutomaticResolutionEnabled) { + float countDown = (float)(resolveTime - now).TotalSeconds; + if(EditorUtility.DisplayCancelableProgressBar("Skip dependency?","Auto Resolve Dependency in : " + (int)countDown,countDown / delaySec)) { + resolveTime = now; + shouldResolve = false; + } - if (shouldResolve && autoResolveJobId != 0) { + return false; + } + + EditorUtility.ClearProgressBar(); + + if (EditorApplication.isCompiling) return false; + if (shouldResolve) { AutoResolve(() => { lock (typeof(PlayServicesResolver)) { autoResolving = false; diff --git a/source/PlayServicesResolver/src/SettingsDialog.cs b/source/PlayServicesResolver/src/SettingsDialog.cs index 85cc21c7..74c0e653 100644 --- a/source/PlayServicesResolver/src/SettingsDialog.cs +++ b/source/PlayServicesResolver/src/SettingsDialog.cs @@ -386,7 +386,7 @@ public void OnGUI() { GUILayout.BeginHorizontal(); GUILayout.Label("Auto Resolution Delay", EditorStyles.boldLabel); - settings.autoResolutionDelay = Math.Min(Math.Max(0,EditorGUILayout.IntField(settings.autoResolutionDelay),MAXIMUM_AUTO_RESOLVE_DELAY_TIME)); + settings.autoResolutionDelay = Mathf.Clamp(EditorGUILayout.IntField(settings.autoResolutionDelay),0,MAXIMUM_AUTO_RESOLVE_DELAY_TIME); GUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup();