Skip to content

Commit 1eb4ee0

Browse files
committed
r: Cleanup
1 parent aa78fe3 commit 1eb4ee0

File tree

11 files changed

+35
-702
lines changed

11 files changed

+35
-702
lines changed

.gitignore

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@ obj/
3535
ehthumbs.db
3636
Thumbs.db
3737

38-
# ============ #
39-
# IDEA generated #
40-
# ============ #
41-
# /.idea
42-
43-
4438
# ============ #
4539
# Visual Studio Code generated #
4640
# ============ #
@@ -50,7 +44,10 @@ TestBuilds/
5044
Assets/AirConsole/airconsole.prefs*
5145

5246
Assets/WebGLTemplates/**/airconsole-settings.js
53-
\# IntellJ Code Style
47+
48+
# ============ #
49+
# IntellJ Code Style
50+
# ============ #
5451

5552
!/.idea/
5653
/.idea/*
-569 KB
Binary file not shown.

Assets/AirConsole/airconsole-code.unitypackage.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

Assets/AirConsole/scripts/Runtime/AirConsole.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public class AirConsole : MonoBehaviour {
129129
/// <summary>
130130
/// Device ID of the screen
131131
/// </summary>
132+
// ReSharper disable once InconsistentNaming
132133
public const int SCREEN = 0;
133134

134135
/// <summary>

Assets/AirConsole/scripts/Runtime/Plugin/Android/PluginManager.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ internal PluginManager(AirConsole airConsole) {
4646
AirConsoleLogger.LogDevelopment(() => $"Audio focus event received: {focusEvent}");
4747

4848
OnAudioFocusChange?.Invoke(focusEvent);
49-
50-
// Handle audio focus change if needed
5149
});
5250

5351
UnityPluginExecutionCallback reloadCallback = new(() => { OnReloadWebview?.Invoke(); });
@@ -110,18 +108,6 @@ internal void InitializeOfflineCheck() {
110108
_service.Call("initializeOfflineCheck");
111109
}
112110

113-
private void OnPause() {
114-
AirConsoleLogger.LogDevelopment(() => "OnPause called.");
115-
116-
_service.Call("onPause");
117-
}
118-
119-
private void OnResume() {
120-
AirConsoleLogger.LogDevelopment(() => "OnResume called.");
121-
122-
_service.Call("onResume");
123-
}
124-
125111
private void OnDestroy() {
126112
_airConsole.UnityDestroy -= OnDestroy;
127113
AirConsoleLogger.LogDevelopment(() => "OnDestroy called.");
@@ -149,4 +135,4 @@ internal static void SendPlatformMessage(string type) {
149135
}
150136
}
151137
}
152-
}
138+
}

Assets/AirConsole/unity-webview/Editor/UnityWebViewPostprocessBuild.cs

Lines changed: 22 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ public void OnPostGenerateGradleAndroidProject(string basePath) {
5050
var changed = false;
5151
var androidManifest = new AndroidManifest(GetManifestPath(basePath));
5252

53-
AddWebkitPermissions(ref changed, androidManifest, basePath);
54-
55-
if (!nofragment) {
56-
AddCorePermissions(ref changed, androidManifest, basePath);
57-
}
53+
AddAndroidXDependencies(ref changed, androidManifest, basePath, !nofragment);
5854

5955
changed = (androidManifest.SetExported(true) || changed);
6056
changed = (androidManifest.SetWindowSoftInputMode("adjustPan") || changed);
@@ -75,78 +71,39 @@ public void OnPostGenerateGradleAndroidProject(string basePath) {
7571
}
7672
}
7773

78-
private void AddCorePermissions(ref bool changed, AndroidManifest androidManifest, string basePath) {
74+
private void AddAndroidXDependencies(ref bool changed, AndroidManifest androidManifest, string basePath, bool includeCoreDependency) {
7975
changed = androidManifest.AddFileProvider(basePath) || changed;
8076
{
8177
string path = GetBuildGradlePath(basePath);
8278
string[] lines0 = File.ReadAllText(path).Replace("\r\n", "\n").Replace("\r", "\n").Split(new[] { '\n' });
8379
{
8480
List<string> lines = new();
85-
bool independencies = false;
81+
bool inDependencies = false;
82+
bool hasWebkit = false;
83+
bool hasCore = false;
8684
foreach (string line in lines0) {
8785
if (line == "dependencies {") {
88-
independencies = true;
89-
} else if (independencies && line == "}") {
90-
independencies = false;
91-
lines.Add(" implementation 'androidx.core:core:1.6.0'");
92-
} else if (independencies) {
93-
if (line.Contains("implementation(name: 'core")
94-
|| line.Contains("implementation(name: 'androidx.core.core")
95-
|| line.Contains("implementation 'androidx.core:core")) {
96-
break;
86+
inDependencies = true;
87+
} else if (inDependencies && line == "}") {
88+
if (!hasWebkit) {
89+
lines.Add(" implementation 'androidx.webkit:webkit:1.12.0'");
90+
hasWebkit = true;
9791
}
98-
}
99-
100-
lines.Add(line);
101-
}
102-
103-
if (lines.Count > lines0.Length) {
104-
File.WriteAllText(path, string.Join("\n", lines) + "\n");
105-
}
106-
}
107-
}
108-
{
109-
string path = GetGradlePropertiesPath(basePath);
110-
string lines0 = "";
111-
string lines = "";
112-
if (File.Exists(path)) {
113-
lines0 = File.ReadAllText(path).Replace("\r\n", "\n").Replace("\r", "\n") + "\n";
114-
lines = lines0;
115-
}
116-
117-
if (!lines.Contains("android.useAndroidX=true")) {
118-
lines += "android.useAndroidX=true\n";
119-
}
120-
121-
if (!lines.Contains("android.enableJetifier=true")) {
122-
lines += "android.enableJetifier=true\n";
123-
}
124-
125-
if (lines != lines0) {
126-
File.WriteAllText(path, lines);
127-
}
128-
}
129-
}
130-
131-
private void AddWebkitPermissions(ref bool changed, AndroidManifest androidManifest, string basePath) {
132-
changed = androidManifest.AddFileProvider(basePath) || changed;
133-
{
134-
string path = GetBuildGradlePath(basePath);
135-
string[] lines0 = File.ReadAllText(path).Replace("\r\n", "\n").Replace("\r", "\n").Split(new[] { '\n' });
136-
{
137-
List<string> lines = new();
138-
bool independencies = false;
139-
foreach (string line in lines0) {
140-
if (line == "dependencies {") {
141-
independencies = true;
142-
} else if (independencies && line == "}") {
143-
independencies = false;
144-
lines.Add(" implementation 'androidx.webkit:webkit:1.12.0'");
145-
} else if (independencies) {
92+
if (includeCoreDependency && !hasCore) {
93+
lines.Add(" implementation 'androidx.core:core:1.6.0'");
94+
hasCore = true;
95+
}
96+
inDependencies = false;
97+
} else if (inDependencies) {
14698
if (line.Contains("implementation(name: 'webkit")
14799
|| line.Contains("implementation(name: 'androidx.webkit.webkit")
148100
|| line.Contains("implementation 'androidx.webkit:webkit")) {
149-
break;
101+
hasWebkit = true;
102+
}
103+
if (line.Contains("implementation(name: 'core")
104+
|| line.Contains("implementation(name: 'androidx.core.core")
105+
|| line.Contains("implementation 'androidx.core:core")) {
106+
hasCore = true;
150107
}
151108
}
152109

Assets/AirConsole/unity-webview/Plugins/Editor.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)