-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtwandroid.html
More file actions
234 lines (214 loc) · 7.55 KB
/
twandroid.html
File metadata and controls
234 lines (214 loc) · 7.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html>
<head>
<style>
:root {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
[theme="dark"] {
background: #111;
color: #eee;
color-scheme: dark;
}
a {
color: blue;
}
[theme="dark"] a {
color: #56b2ff;
}
a:active {
color: red;
}
input[type="text"],
input[type="number"],
textarea {
padding: 2px;
}
input[type="text"],
input[type="number"],
textarea,
.is-not-safari select {
background-color: white;
color: black;
border: 1px solid rgb(160, 160, 160);
border-radius: 2px;
}
.is-not-safari select:hover {
border-color: rgb(30, 30, 30);
}
[theme="dark"] input[type="text"],
[theme="dark"] input[type="number"],
[theme="dark"] textarea,
[theme="dark"] .is-not-safari select {
background-color: #333;
color: white;
border-color: #888;
}
[theme="dark"] .is-not-safari select:hover {
border-color: #bbb;
}
p, pre, h1, h2, h3 {
margin: 12px 0;
}
summary {
cursor: pointer;
}
input {
font-size: 0.8em;
}
main {
padding-bottom: 10px;
}
footer {
text-align: center;
}
footer > div {
margin-top: 12px;
}
.footer-spacer {
margin: 0 3px;
}
.disclaimer {
font-style: italic;
}
.group {
margin: 12px 0;
}
p {
margin: 8px 0;
}
.warning {
font-weight: bold;
background: yellow;
color: black;
padding: 12px;
border-radius: 12px;
margin: 12px 0;
}
pre {
background-color: #eee;
padding: 0.25em 0.25em;
border: solid 1px #0005;
}
body {
max-width: 625px;
margin: auto;
margin-top: auto;
margin-bottom: auto;
border-radius: 0.3em;
background-color: #fff;
padding: 1em;
margin-top: 1em;
margin-bottom: 1em;
box-shadow: 0 2px 0.5em 0.1em rgba(0, 0, 0, 0.2);
border-top: 6px solid #639bff;
}
hr {
margin: 1em 0;
color: #bbb;
}
</style>
<title>Packaging TurboWarp projects to APK</title>
</head>
<body>
<h1>Packaging TurboWarp projects to APK</h1>
<p>This page (everything below that divider line) was mostly written by GarboMuffin (who is also the TurboWarp Packager's creator) in <a href="https://github.com/TurboWarp/packager/pull/224">a packager pull request</a>, credit goes to him.</p>
<p>The styles are also taken from the packager's <a href="https://github.com/TurboWarp/packager">source code</a>, which is licensed under Apache-2.0.</p>
<p>I just put this on its own webpage, with some modifications to account for this not being part of the packager (and thus not being able to generate some parts), for convienience so an easily readable version can be linked to.</p>
<p>-CST1229</p>
<hr>
<div class="warning">
Unlike the other environments, Android support is not fully automated. You must manually create an app. This section will try to guide you through the process.
</div>
<p>This section assumes you have full access (including adminstrator/root) to a Windows, macOS, or Linux computer.</p>
<!-- <p>Parts of this section would have been generated by various options selected above.</p> -->
<h3>Install Android Studio</h3>
<p><a href="https://developer.android.com/studio/">Install Android Studio.</a></p>
<p>This is quite large and may take a while.</p>
<h3>Create a new project</h3>
<p>Create a new project in Android Studio.</p>
<ul>
<li>Use the "Empty Activity" template</li>
<li>Set Name to your app's name, for example "<code>My Project</code>"</li>
<li>Set Package name to "<code>org.turbowarp.packager.userland.PACKAGENAME</code>" (replace PACKAGENAME with your project's package name; it should be a unique name used only by your application)</li>
<li>Choose a save location that you won't forget</li>
<li>Set Language to "Kotlin"</li>
<li>Set Minimum SDK to "API 21: Android 5.0 (Lollipop)"</li>
</ul>
<h3>Create assets folder</h3>
<p>In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.</p>
<h3>Prepare project</h3>
<p>Package the project as a zip normally.</p>
<p>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)</p>
<h3>Making the app</h3>
<p>In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.</p>
<p>Replace everything after line 2 with the following:</p>
<pre>
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()
}
}
</pre>
<p>Make sure to leave the first line that says <code>package ...</code></p>
<p>At this point, you have a functional Android app. However, there are still a few more things you should change.</p>
<h3>Fixing screen orientation issues</h3>
<p>In the sidebar on the left, open app > main > AndroidManifest.xml</p>
<p>Find the section that looks like this:</p>
<pre>
<activity
android:name=".MainActivity"
android:exported="true">
</pre>
<p>And replace it with this:</p>
<pre>
<activity
android:configChanges="orientation|screenSize"
android:screenOrientation="sensor"
android:name=".MainActivity"
android:exported="true">
</pre>
<h3>Updating colors</h3>
<p>Currently the app has a purple color scheme, which may not be what you want. This can be changed.</p>
<p>In the sidebar on the left, open app > main > res > values > color.xml.</p>
<p>You will see these lines:</p>
<pre>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
</pre>
<p>Replace the colors (the parts after #FF) with your background hex color, for example:</p>
<pre>
<color name="purple_200">#FF4D97FF</color>
<color name="purple_500">#FF4D97FF</color>
<color name="purple_700">#FF4D97FF</color>
</pre>
<p>Do not change the other lines.</p>
<p>For advanced users, note that these color codes are a bit unusual in that the "alpha" or "transparency" byte (typically <code>255</code> or <code>FF</code>) goes first instead of last.</p>
<p>Ignore the bits about <code>purple_yyy</code>; 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.</p>
<h3>Updating the project</h3>
<p>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:</p>
<ol>
<li>Open Android Studio and open the project</li>
<li>Delete everything inside the assets folder</li>
<li>Re-run the packager</li>
<li>Extract the zip and put all of its files into the assets folder</li>
</ol>
</body>
</html>