Skip to content

Commit e902adb

Browse files
author
yapetrichka
committed
style: MS coding style
1 parent 5e0512b commit e902adb

16 files changed

+348
-0
lines changed

Editor/Assets.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Assets/Layouts.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
2+
<Style src="project://database/Packages/com.dreamcode.mobile.android-keystore/Editor/Assets/Styles/KeystoreWindow.uss?fileID=7433441132597879392&amp;guid=4c0697299499c2746bd838d8d7bc9c29&amp;type=3#KeystoreWindow" />
3+
<ui:VisualElement name="Container" style="height: 100%; color: rgb(255, 255, 255); background-color: rgb(255, 255, 255); justify-content: space-around; flex-grow: 0; align-items: stretch;">
4+
<ui:Label text="Project Keystore" display-tooltip-when-elided="true" name="KeystoreLabel" style="color: rgb(118, 118, 118); -unity-font-style: bold; -unity-text-align: upper-center; font-size: 24px; padding-right: 0; padding-left: 0; padding-top: 0; width: auto; white-space: normal;" />
5+
<ui:TextField picking-mode="Ignore" label="Path .keystore" text="path.keystore" multiline="false" name="KeystorePath" class="keystore-text-field" style="padding-top: 0; font-size: 18px;" />
6+
<ui:TextField picking-mode="Ignore" label="Password" text="password" multiline="false" name="KeystorePass" class="keystore-text-field" style="flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; font-size: 18px; color: rgb(255, 255, 255); background-color: rgb(255, 255, 255); -unity-font-style: bold; -unity-text-align: upper-left; width: auto; padding-left: 10%; padding-right: 10%; padding-top: 0;" />
7+
<ui:Label text="Project Key" display-tooltip-when-elided="true" name="KeyLabel" style="color: rgb(118, 118, 118); -unity-font-style: bold; -unity-text-align: upper-center; font-size: 24px; padding-right: 0; padding-left: 0; padding-top: 0; white-space: normal;" />
8+
<ui:TextField picking-mode="Ignore" label="Alias" text="alias" multiline="false" name="KeyaliasName" class="keystore-text-field" style="flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; font-size: 18px; color: rgb(255, 255, 255); background-color: rgb(255, 255, 255); -unity-font-style: bold; -unity-text-align: upper-left; width: auto; padding-left: 10%; padding-right: 10%; padding-top: 0;" />
9+
<ui:TextField picking-mode="Ignore" label="Password" text="password" multiline="false" name="KeyaliasPass" class="keystore-text-field" style="flex-direction: column; flex-wrap: nowrap; justify-content: flex-start; font-size: 18px; color: rgb(255, 255, 255); background-color: rgb(255, 255, 255); -unity-font-style: bold; -unity-text-align: upper-left; width: auto; padding-left: 10%; padding-right: 10%; padding-top: 0;" />
10+
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveBtn" class="save save-button" style="border-left-width: 0; border-right-width: 0; border-top-width: 0; border-bottom-width: 0; margin-top: 0; margin-bottom: 0; -unity-font-style: bold; bottom: auto; top: auto; flex-shrink: 0; flex-grow: 0;" />
11+
</ui:VisualElement>
12+
</ui:UXML>

Editor/Assets/Layouts/KeystoreWindow.uxml.meta

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Assets/Styles.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.save-button {
2+
background-color: rgb(26, 115, 232);
3+
color: rgb(255, 255, 255);
4+
margin-right: 20%;
5+
margin-left: 20%;
6+
margin-bottom: 0;
7+
margin-top: 4%;
8+
height: 12%;
9+
border-top-left-radius: 16px;
10+
border-bottom-left-radius: 16px;
11+
border-top-right-radius: 16px;
12+
border-bottom-right-radius: 16px;
13+
font-size: 18px;
14+
}
15+
16+
.save-button:hover {
17+
background-color: rgb(73, 153, 231);
18+
}
19+
20+
.keystore-text-field {
21+
flex-direction: column;
22+
flex-wrap: nowrap;
23+
justify-content: flex-start;
24+
font-size: 14px;
25+
color: rgb(255, 255, 255);
26+
background-color: rgb(255, 255, 255);
27+
-unity-font-style: bold;
28+
-unity-text-align: upper-left;
29+
width: auto;
30+
padding-left: 10%;
31+
padding-right: 10%;
32+
padding-top: 20px;
33+
}
34+
35+
.keystore-text-field > .unity-base-field__label {
36+
color: rgb(118, 118, 118);
37+
}
38+
39+
.keystore-text-field > .unity-base-field__input {
40+
background-color: rgb(232, 232, 232);
41+
color: rgb(32, 33, 36);
42+
border-left-color: rgb(204, 204, 204);
43+
border-right-color: rgb(204, 204, 204);
44+
border-top-color: rgb(204, 204, 204);
45+
border-bottom-color: rgb(204, 204, 204);
46+
}

Editor/Assets/Styles/KeystoreWindow.uss.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/AutoKeystore.Editor.asmdef

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "DreamCode.AutoKeystore.Editor",
3+
"rootNamespace": "",
4+
"references": [],
5+
"includePlatforms": [
6+
"Editor"
7+
],
8+
"excludePlatforms": [],
9+
"allowUnsafeCode": false,
10+
"overrideReferences": false,
11+
"precompiledReferences": [],
12+
"autoReferenced": true,
13+
"defineConstraints": [],
14+
"versionDefines": [],
15+
"noEngineReferences": false
16+
}

Editor/AutoKeystore.Editor.asmdef.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Configuration.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using UnityEditor.Build;
2+
using UnityEditor.Build.Reporting;
3+
4+
namespace DreamCode.AutoKeystore.Editor.Configuration
5+
{
6+
internal class KeystorePreprocess : IPreprocessBuildWithReport
7+
{
8+
public int callbackOrder => 0;
9+
10+
public void OnPreprocessBuild(BuildReport report)
11+
{
12+
KeystoreSettings.Load();
13+
}
14+
}
15+
}

Editor/Configuration/KeystorePreprocess.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/KeystoreSettings.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
4+
namespace DreamCode.AutoKeystore.Editor
5+
{
6+
internal static class KeystoreSettings
7+
{
8+
public static string Name;
9+
public static string Password;
10+
public static string AliasName;
11+
public static string AliasPassword;
12+
private const string KeystoreExt = ".keystore";
13+
14+
public static void Load()
15+
{
16+
Name = EditorPrefs.GetString(
17+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Name)}");
18+
Password = EditorPrefs.GetString(
19+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Password)}");
20+
AliasName = EditorPrefs.GetString(
21+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasName)}");
22+
AliasPassword =
23+
EditorPrefs.GetString(
24+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasPassword)}");
25+
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
26+
return;
27+
PlayerSettings.Android.keystoreName = Name + KeystoreExt;
28+
PlayerSettings.Android.keystorePass = Password;
29+
PlayerSettings.Android.keyaliasName = AliasName;
30+
PlayerSettings.Android.keyaliasPass = AliasPassword;
31+
}
32+
33+
public static void Save(string name, string password, string aliasName, string aliasPassword)
34+
{
35+
EditorPrefs.SetString($"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Name)}",
36+
name);
37+
EditorPrefs.SetString(
38+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Password)}", password);
39+
EditorPrefs.SetString(
40+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasName)}", aliasName);
41+
EditorPrefs.SetString(
42+
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasPassword)}",
43+
aliasPassword);
44+
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android)
45+
return;
46+
PlayerSettings.Android.keystoreName = name + KeystoreExt;
47+
PlayerSettings.Android.keystorePass = password;
48+
PlayerSettings.Android.keyaliasName = aliasName;
49+
PlayerSettings.Android.keyaliasPass = aliasPassword;
50+
}
51+
}
52+
}

Editor/KeystoreSettings.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/UI/KeystoreEditorWindow.cs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using UnityEditor;
2+
using UnityEngine;
3+
using UnityEngine.UIElements;
4+
5+
namespace DreamCode.AutoKeystore.Editor.UI
6+
{
7+
internal class KeystoreEditorWindow : EditorWindow
8+
{
9+
private static readonly Vector2 s_windowMinSize = new(200, 380);
10+
private const string PackagePath = "Packages/com.dreamcode.mobile.android-keystore";
11+
private const string AssetsPath = PackagePath + "/Editor/Assets";
12+
private const string LayoutsPath = AssetsPath + "/Layouts";
13+
private const string StylesPath = AssetsPath + "/Styles";
14+
private const string WindowLayoutPath = LayoutsPath + "/KeystoreWindow.uxml";
15+
private TextField _keystoreName;
16+
private TextField _keystorePass;
17+
private TextField _keyaliasName;
18+
private TextField _keyaliasPass;
19+
20+
[MenuItem("DreamCode/Android/AutoKeystore")]
21+
internal static void ShowWindow()
22+
{
23+
var window = GetWindow<KeystoreEditorWindow>();
24+
window.titleContent.text = nameof(AutoKeystore);
25+
window.minSize = s_windowMinSize;
26+
}
27+
28+
private void CreateGUI()
29+
{
30+
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(WindowLayoutPath);
31+
visualTree.CloneTree(rootVisualElement);
32+
SetupWindowLayout();
33+
LoadSettings();
34+
RegisterListeners();
35+
}
36+
37+
private void OnDisable()
38+
{
39+
RemoveListeners();
40+
}
41+
42+
private void RegisterListeners()
43+
{
44+
rootVisualElement.Q<Button>("SaveBtn").clicked += OnSaveBtnClicked;
45+
_keystorePass.RegisterCallback<FocusInEvent>(OnKeystorePassFocusIn);
46+
_keystorePass.RegisterCallback<FocusOutEvent>(OnKeystorePassFocusOut);
47+
_keyaliasPass.RegisterCallback<FocusInEvent>(OnKeyaliasPassFocusIn);
48+
_keyaliasPass.RegisterCallback<FocusOutEvent>(OnKeyaliasPassFocusOut);
49+
}
50+
51+
private void RemoveListeners()
52+
{
53+
rootVisualElement.Q<Button>("SaveBtn").clicked -= OnSaveBtnClicked;
54+
_keystorePass.UnregisterCallback<FocusInEvent>(OnKeystorePassFocusIn);
55+
_keystorePass.UnregisterCallback<FocusOutEvent>(OnKeystorePassFocusOut);
56+
_keyaliasPass.UnregisterCallback<FocusInEvent>(OnKeyaliasPassFocusIn);
57+
_keyaliasPass.UnregisterCallback<FocusOutEvent>(OnKeyaliasPassFocusOut);
58+
}
59+
60+
private void OnSaveBtnClicked()
61+
{
62+
SaveSettings();
63+
Close();
64+
}
65+
66+
private void OnKeystorePassFocusIn(FocusInEvent e)
67+
{
68+
_keystorePass.isPasswordField = false;
69+
}
70+
71+
private void OnKeystorePassFocusOut(FocusOutEvent evt)
72+
{
73+
_keystorePass.isPasswordField = true;
74+
}
75+
76+
private void OnKeyaliasPassFocusIn(FocusInEvent evt)
77+
{
78+
_keyaliasPass.isPasswordField = false;
79+
}
80+
81+
private void OnKeyaliasPassFocusOut(FocusOutEvent evt)
82+
{
83+
_keyaliasPass.isPasswordField = true;
84+
}
85+
86+
private void SetupWindowLayout()
87+
{
88+
_keystoreName = rootVisualElement.Q<TextField>("KeystorePath");
89+
_keystorePass = rootVisualElement.Q<TextField>("KeystorePass");
90+
_keystorePass.isPasswordField = true;
91+
_keyaliasName = rootVisualElement.Q<TextField>("KeyaliasName");
92+
_keyaliasPass = rootVisualElement.Q<TextField>("KeyaliasPass");
93+
_keyaliasPass.isPasswordField = true;
94+
}
95+
96+
private void LoadSettings()
97+
{
98+
KeystoreSettings.Load();
99+
_keystoreName.value = KeystoreSettings.Name;
100+
_keystorePass.value = KeystoreSettings.Password;
101+
_keyaliasName.value = KeystoreSettings.AliasName;
102+
_keyaliasPass.value = KeystoreSettings.AliasPassword;
103+
}
104+
105+
private void SaveSettings()
106+
{
107+
var keystoreName = _keystoreName.value;
108+
var keystorePass = _keystorePass.value;
109+
var keyaliasName = _keyaliasName.value;
110+
var keyaliasPass = _keyaliasPass.value;
111+
KeystoreSettings.Save(keystoreName, keystorePass, keyaliasName, keyaliasPass);
112+
}
113+
}
114+
}

Editor/UI/KeystoreEditorWindow.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)