diff --git a/src/locales/en.json b/src/locales/en.json index b008d2e6..c648bec6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,7 +1,7 @@ { "p4": { "description1": { - "string": "Converts Scratch projects into HTML files, zip archives, or executable programs for Windows, macOS, and Linux." + "string": "Converts Scratch projects into HTML files, zip archives, or executable programs for Windows, macOS, Linux, and Android." }, "description2": { "string": "If you just want an easy way to embed a project into your website, you may be interested in {embedding}." @@ -408,6 +408,9 @@ "string": "{type} Linux application (64-bit only)", "context": "type will become something like 'NW.js' or 'Electron'. Do not translate 'Linux'." }, + "application-android": { + "string": "Android app (Highly experimental)" + }, "otherEnvironments": { "string": "Other environments (Click to open)", "context": "Text that can be clicked to expand list of environments to include some unrecommended ones." diff --git a/src/p4/P4.svelte b/src/p4/P4.svelte index b33461a1..3a7d55aa 100644 --- a/src/p4/P4.svelte +++ b/src/p4/P4.svelte @@ -84,7 +84,7 @@ :global([theme="dark"] .is-not-safari select:hover) { border-color: #bbb; } - :global(p), :global(h1), :global(h2), :global(h3) { + :global(p), :global(pre), :global(h1), :global(h2), :global(h3) { margin: 12px 0; } :global(summary) { diff --git a/src/p4/PackagerOptions.svelte b/src/p4/PackagerOptions.svelte index 9fe668a0..e8658115 100644 --- a/src/p4/PackagerOptions.svelte +++ b/src/p4/PackagerOptions.svelte @@ -232,8 +232,9 @@ font-weight: bold; background: yellow; color: black; - padding: 10px; - border-radius: 10px; + padding: 12px; + border-radius: 12px; + margin: 12px 0; } .buttons { display: flex; @@ -709,6 +710,13 @@ +
{$_('options.otherEnvironmentsHelp')}
@@ -843,6 +851,126 @@NW.js support is deprecated and may be removed in the future. Use Electron instead if possible.
For further help and steps, see NW.js Documentation.
{/if} + {:else if $options.target === 'android'} +This section assumes you have full access (including adminstrator/root) to a Windows, macOS, or Linux computer.
+Parts of this section may be generated by various options selected above.
+ +This is quite large and may take a while.
+ +Create a new project in Android Studio.
+{$options.app.windowTitle}
"org.turbowarp.packager.userland.{$options.app.packageName}
"In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.
+ ++ +
+Extract the zip and drag its files into "assets" folder you created. (You can directly drag and drop files over the assets folder in Android Studio)
+ +In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.
+Replace everything after line 2 with the following:
++ {[ + 'import android.annotation.SuppressLint', + 'import androidx.appcompat.app.AppCompatActivity', + 'import android.os.Bundle', + 'import android.webkit.WebView', + '', + 'class MainActivity : AppCompatActivity() {', + ' private lateinit var web: WebView', + '', + ' @SuppressLint("SetJavaScriptEnabled")', + ' override fun onCreate(savedInstanceState: Bundle?) {', + ' super.onCreate(savedInstanceState)', + ' web = WebView(this)', + ' web.settings.javaScriptEnabled = true', + ' web.loadUrl("file:///android_asset/index.html")', + ' setContentView(web)', + ' actionBar?.hide()', + ' supportActionBar?.hide()', + ' }', + '', + ' override fun onDestroy() {', + ' super.onDestroy()', + ' web.destroy()', + ' }', + '}' + ].join('\n')} ++
Make sure to leave the first line that says package ...
At this point, you have a functional Android app. However, there are still a few more things you should change.
+ +In the sidebar on the left, open app > main > AndroidManifest.xml
+Find the section that looks like this:
++ {[ + '+', + ].join('\n')} +
And replace it with this:
++ {[ + '+ +', + ].join('\n')} +
Currently the app has a purple color scheme, which may not be what you want. This can be changed.
+In the sidebar on the left, open app > main > res > values > color.xml.
+You will see these lines:
++ {[ + '+#FFBB86FC ', + '#FF6200EE ', + '#FF3700B3 ', + ].join('\n')} +
Replace those lines with: (the following snippet is generated according to your configured background color)
++ {[ + `+#FF${$options.appearance.background.substr(1)} `, + `#FF${$options.appearance.background.substr(1)} `, + `#FF${$options.appearance.background.substr(1)} `, + ].join('\n')} +
Do not change the other lines.
+For advanced users, note that these color codes are a bit unusual in that the "alpha" or "transparency" byte (typically 255
or FF
) goes first instead of last.
Ignore the bits about purple_yyy
; just leave them as is. It would typically be a good idea to rename these colors, but you will be making more work for yourself because you'll have to update some other files to reflect the new names.
It's likely that at some point you will want to update the project without redoing this entire guide. Updating a project is much simpler:
+