-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<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"> | ||
<Style src="project://database/Packages/com.dreamcode.mobile.android-keystore/Editor/Assets/Styles/KeystoreWindow.uss?fileID=7433441132597879392&guid=4c0697299499c2746bd838d8d7bc9c29&type=3#KeystoreWindow" /> | ||
<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;"> | ||
<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;" /> | ||
<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;" /> | ||
<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;" /> | ||
<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;" /> | ||
<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;" /> | ||
<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;" /> | ||
<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;" /> | ||
</ui:VisualElement> | ||
</ui:UXML> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.save-button { | ||
background-color: rgb(26, 115, 232); | ||
color: rgb(255, 255, 255); | ||
margin-right: 20%; | ||
margin-left: 20%; | ||
margin-bottom: 0; | ||
margin-top: 4%; | ||
height: 12%; | ||
border-top-left-radius: 16px; | ||
border-bottom-left-radius: 16px; | ||
border-top-right-radius: 16px; | ||
border-bottom-right-radius: 16px; | ||
font-size: 18px; | ||
} | ||
|
||
.save-button:hover { | ||
background-color: rgb(73, 153, 231); | ||
} | ||
|
||
.keystore-text-field { | ||
flex-direction: column; | ||
flex-wrap: nowrap; | ||
justify-content: flex-start; | ||
font-size: 14px; | ||
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: 20px; | ||
} | ||
|
||
.keystore-text-field > .unity-base-field__label { | ||
color: rgb(118, 118, 118); | ||
} | ||
|
||
.keystore-text-field > .unity-base-field__input { | ||
background-color: rgb(232, 232, 232); | ||
color: rgb(32, 33, 36); | ||
border-left-color: rgb(204, 204, 204); | ||
border-right-color: rgb(204, 204, 204); | ||
border-top-color: rgb(204, 204, 204); | ||
border-bottom-color: rgb(204, 204, 204); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "DreamCode.AutoKeystore.Editor", | ||
"rootNamespace": "", | ||
"references": [], | ||
"includePlatforms": [ | ||
"Editor" | ||
], | ||
"excludePlatforms": [], | ||
"allowUnsafeCode": false, | ||
"overrideReferences": false, | ||
"precompiledReferences": [], | ||
"autoReferenced": true, | ||
"defineConstraints": [], | ||
"versionDefines": [], | ||
"noEngineReferences": false | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using UnityEditor.Build; | ||
using UnityEditor.Build.Reporting; | ||
|
||
namespace DreamCode.AutoKeystore.Editor.Configuration | ||
{ | ||
internal class KeystorePreprocess : IPreprocessBuildWithReport | ||
{ | ||
public int callbackOrder => 0; | ||
|
||
public void OnPreprocessBuild(BuildReport report) | ||
{ | ||
KeystoreSettings.Load(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace DreamCode.AutoKeystore.Editor | ||
{ | ||
internal static class KeystoreSettings | ||
{ | ||
public static string Name; | ||
public static string Password; | ||
public static string AliasName; | ||
public static string AliasPassword; | ||
private const string KeystoreExt = ".keystore"; | ||
|
||
public static void Load() | ||
{ | ||
Name = EditorPrefs.GetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Name)}"); | ||
Password = EditorPrefs.GetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Password)}"); | ||
AliasName = EditorPrefs.GetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasName)}"); | ||
AliasPassword = | ||
EditorPrefs.GetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasPassword)}"); | ||
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) | ||
return; | ||
PlayerSettings.Android.keystoreName = Name + KeystoreExt; | ||
PlayerSettings.Android.keystorePass = Password; | ||
PlayerSettings.Android.keyaliasName = AliasName; | ||
PlayerSettings.Android.keyaliasPass = AliasPassword; | ||
} | ||
|
||
public static void Save(string name, string password, string aliasName, string aliasPassword) | ||
{ | ||
EditorPrefs.SetString($"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Name)}", | ||
name); | ||
EditorPrefs.SetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(Password)}", password); | ||
EditorPrefs.SetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasName)}", aliasName); | ||
EditorPrefs.SetString( | ||
$"{PlayerSettings.applicationIdentifier}-{nameof(KeystoreSettings)}-{nameof(AliasPassword)}", | ||
aliasPassword); | ||
if (EditorUserBuildSettings.activeBuildTarget != BuildTarget.Android) | ||
return; | ||
PlayerSettings.Android.keystoreName = name + KeystoreExt; | ||
PlayerSettings.Android.keystorePass = password; | ||
PlayerSettings.Android.keyaliasName = aliasName; | ||
PlayerSettings.Android.keyaliasPass = aliasPassword; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
using UnityEditor; | ||
using UnityEngine; | ||
using UnityEngine.UIElements; | ||
|
||
namespace DreamCode.AutoKeystore.Editor.UI | ||
{ | ||
internal class KeystoreEditorWindow : EditorWindow | ||
{ | ||
private static readonly Vector2 s_windowMinSize = new(200, 380); | ||
private const string PackagePath = "Packages/com.dreamcode.mobile.android-keystore"; | ||
private const string AssetsPath = PackagePath + "/Editor/Assets"; | ||
private const string LayoutsPath = AssetsPath + "/Layouts"; | ||
private const string StylesPath = AssetsPath + "/Styles"; | ||
private const string WindowLayoutPath = LayoutsPath + "/KeystoreWindow.uxml"; | ||
private TextField _keystoreName; | ||
private TextField _keystorePass; | ||
private TextField _keyaliasName; | ||
private TextField _keyaliasPass; | ||
|
||
[MenuItem("DreamCode/Android/AutoKeystore")] | ||
internal static void ShowWindow() | ||
{ | ||
var window = GetWindow<KeystoreEditorWindow>(); | ||
window.titleContent.text = nameof(AutoKeystore); | ||
window.minSize = s_windowMinSize; | ||
} | ||
|
||
private void CreateGUI() | ||
{ | ||
var visualTree = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(WindowLayoutPath); | ||
visualTree.CloneTree(rootVisualElement); | ||
SetupWindowLayout(); | ||
LoadSettings(); | ||
RegisterListeners(); | ||
} | ||
|
||
private void OnDisable() | ||
{ | ||
RemoveListeners(); | ||
} | ||
|
||
private void RegisterListeners() | ||
{ | ||
rootVisualElement.Q<Button>("SaveBtn").clicked += OnSaveBtnClicked; | ||
_keystorePass.RegisterCallback<FocusInEvent>(OnKeystorePassFocusIn); | ||
_keystorePass.RegisterCallback<FocusOutEvent>(OnKeystorePassFocusOut); | ||
_keyaliasPass.RegisterCallback<FocusInEvent>(OnKeyaliasPassFocusIn); | ||
_keyaliasPass.RegisterCallback<FocusOutEvent>(OnKeyaliasPassFocusOut); | ||
} | ||
|
||
private void RemoveListeners() | ||
{ | ||
rootVisualElement.Q<Button>("SaveBtn").clicked -= OnSaveBtnClicked; | ||
_keystorePass.UnregisterCallback<FocusInEvent>(OnKeystorePassFocusIn); | ||
_keystorePass.UnregisterCallback<FocusOutEvent>(OnKeystorePassFocusOut); | ||
_keyaliasPass.UnregisterCallback<FocusInEvent>(OnKeyaliasPassFocusIn); | ||
_keyaliasPass.UnregisterCallback<FocusOutEvent>(OnKeyaliasPassFocusOut); | ||
} | ||
|
||
private void OnSaveBtnClicked() | ||
{ | ||
SaveSettings(); | ||
Close(); | ||
} | ||
|
||
private void OnKeystorePassFocusIn(FocusInEvent e) | ||
{ | ||
_keystorePass.isPasswordField = false; | ||
} | ||
|
||
private void OnKeystorePassFocusOut(FocusOutEvent evt) | ||
{ | ||
_keystorePass.isPasswordField = true; | ||
} | ||
|
||
private void OnKeyaliasPassFocusIn(FocusInEvent evt) | ||
{ | ||
_keyaliasPass.isPasswordField = false; | ||
} | ||
|
||
private void OnKeyaliasPassFocusOut(FocusOutEvent evt) | ||
{ | ||
_keyaliasPass.isPasswordField = true; | ||
} | ||
|
||
private void SetupWindowLayout() | ||
{ | ||
_keystoreName = rootVisualElement.Q<TextField>("KeystorePath"); | ||
_keystorePass = rootVisualElement.Q<TextField>("KeystorePass"); | ||
_keystorePass.isPasswordField = true; | ||
_keyaliasName = rootVisualElement.Q<TextField>("KeyaliasName"); | ||
_keyaliasPass = rootVisualElement.Q<TextField>("KeyaliasPass"); | ||
_keyaliasPass.isPasswordField = true; | ||
} | ||
|
||
private void LoadSettings() | ||
{ | ||
KeystoreSettings.Load(); | ||
_keystoreName.value = KeystoreSettings.Name; | ||
_keystorePass.value = KeystoreSettings.Password; | ||
_keyaliasName.value = KeystoreSettings.AliasName; | ||
_keyaliasPass.value = KeystoreSettings.AliasPassword; | ||
} | ||
|
||
private void SaveSettings() | ||
{ | ||
var keystoreName = _keystoreName.value; | ||
var keystorePass = _keystorePass.value; | ||
var keyaliasName = _keyaliasName.value; | ||
var keyaliasPass = _keyaliasPass.value; | ||
KeystoreSettings.Save(keystoreName, keystorePass, keyaliasName, keyaliasPass); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.