|
180 | 180 | font-weight: bold; |
181 | 181 | background: yellow; |
182 | 182 | color: black; |
183 | | - padding: 10px; |
184 | | - border-radius: 10px; |
| 183 | + padding: 12px; |
| 184 | + border-radius: 12px; |
| 185 | + margin: 12px 0; |
185 | 186 | } |
186 | 187 | </style> |
187 | 188 |
|
|
609 | 610 | </label> |
610 | 611 | </div> |
611 | 612 |
|
| 613 | + <div class="group"> |
| 614 | + <label class="option"> |
| 615 | + <input type="radio" name="environment" bind:group={$options.target} value="android"> |
| 616 | + {$_('options.application-android')} |
| 617 | + </label> |
| 618 | + </div> |
| 619 | + |
612 | 620 | <details open={otherEnvironmentsInitiallyOpen}> |
613 | 621 | <summary>{$_('options.otherEnvironments')}</summary> |
614 | 622 | <p>{$_('options.otherEnvironmentsHelp')}</p> |
|
660 | 668 | {#if $options.target.startsWith('zip')} |
661 | 669 | <h2>Zip</h2> |
662 | 670 | <p>The zip environment is intended to be used for publishing to a website. Other uses such as sending your project to a friend over a chat app or email should use "Plain HTML" instead as zip will not work.</p> |
663 | | - {:else} |
| 671 | + {/if} |
| 672 | + {#if !$options.target.startsWith('zip')} |
664 | 673 | <h2>{$_('options.applicationSettings')}</h2> |
665 | 674 | <label class="option"> |
666 | 675 | {$_('options.packageName')} |
|
715 | 724 | <p class="warning">NW.js support is deprecated and may be removed in the future. Use Electron instead if possible.</p> |
716 | 725 | <p>For further help and steps, see <a href="https://docs.nwjs.io/en/latest/For%20Users/Package%20and%20Distribute/#linux">NW.js Documentation</a>.</p> |
717 | 726 | {/if} |
| 727 | + {:else if $options.target === 'android'} |
| 728 | + <h2>Android</h2> |
| 729 | + |
| 730 | + <div class="warning"> |
| 731 | + 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. |
| 732 | + </div> |
| 733 | + |
| 734 | + <p>This section assumes you have complete access to a Windows, macOS, or Linux computer.</p> |
| 735 | + |
| 736 | + <h3>Install Android Studio</h3> |
| 737 | + <p><a href="https://developer.android.com/studio/">Install Android Studio.</a></p> |
| 738 | + <p>This quite large and may take a while.</p> |
| 739 | + |
| 740 | + <h3>Create a new project</h3> |
| 741 | + <p>Create a new project in Android studio.</p> |
| 742 | + <ul> |
| 743 | + <li>Use the "Empty Activity" template</li> |
| 744 | + <li>Set Name to your app's name, for example "<code>{$options.app.windowTitle}</code>"</li> |
| 745 | + <li>Set Package name to "<code>org.turbowarp.packager.userland.{$options.app.packageName}</code>"</li> |
| 746 | + <li>Choose a save location that you won't forget</li> |
| 747 | + <li>Set Language to Kotlin</li> |
| 748 | + <li>Set Minimum SDK to "API 21: Android 5.0 (Lollipop)"</li> |
| 749 | + </ul> |
| 750 | + |
| 751 | + <h3>Create assets folder</h3> |
| 752 | + <p>In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.</p> |
| 753 | + |
| 754 | + <h3>Prepare project</h3> |
| 755 | + <p> |
| 756 | + <Button on:click={pack} text={'Package the project as a zip'} /> |
| 757 | + </p> |
| 758 | + <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> |
| 759 | + |
| 760 | + <h3>Making the app</h3> |
| 761 | + <p>In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.</p> |
| 762 | + <p>Replace everything after line 2 with the following:</p> |
| 763 | + <pre> |
| 764 | + {[ |
| 765 | + 'import android.annotation.SuppressLint', |
| 766 | + 'import androidx.appcompat.app.AppCompatActivity', |
| 767 | + 'import android.os.Bundle', |
| 768 | + 'import android.webkit.WebView', |
| 769 | + '', |
| 770 | + 'class MainActivity : AppCompatActivity() {', |
| 771 | + ' private lateinit var web: WebView', |
| 772 | + '', |
| 773 | + ' @SuppressLint("SetJavaScriptEnabled")', |
| 774 | + ' override fun onCreate(savedInstanceState: Bundle?) {', |
| 775 | + ' super.onCreate(savedInstanceState)', |
| 776 | + ' web = WebView(this)', |
| 777 | + ' web.settings.javaScriptEnabled = true', |
| 778 | + ' web.loadUrl("file:///android_asset/index.html")', |
| 779 | + ' setContentView(web)', |
| 780 | + ' actionBar?.hide()', |
| 781 | + ' supportActionBar?.hide()', |
| 782 | + ' }', |
| 783 | + '', |
| 784 | + ' override fun onDestroy() {', |
| 785 | + ' super.onDestroy()', |
| 786 | + ' web.destroy()', |
| 787 | + ' }', |
| 788 | + '}' |
| 789 | + ].join('\n')} |
| 790 | + </pre> |
| 791 | + <p>At this point, you now have a fully functional Android app. However, there are still a few more things you should change.</p> |
| 792 | + |
| 793 | + <h3>Fixing screen orientation issues</h3> |
| 794 | + <p>In the sidebar on the left, open app > main > AndroidManifest.xml</p> |
| 795 | + <p>Find the section that looks like this:</p> |
| 796 | + <pre> |
| 797 | + {[ |
| 798 | + ' <activity', |
| 799 | + ' android:name=".MainActivity"', |
| 800 | + ' android:exported="true">', |
| 801 | + ].join('\n')} |
| 802 | + </pre> |
| 803 | + <p>And replace it with this:</p> |
| 804 | + <pre> |
| 805 | + {[ |
| 806 | + ' <activity', |
| 807 | + ' android:configChanges="orientation|screenSize"', |
| 808 | + ' android:screenOrientation="sensor"', |
| 809 | + ' android:name=".MainActivity"', |
| 810 | + ' android:exported="true">', |
| 811 | + ].join('\n')} |
| 812 | + </pre> |
| 813 | + |
| 814 | + <h3>Updating colors</h3> |
| 815 | + <p>If you ran the app now, it would have a purple color scheme, which may not be what you want. This can be changed.</p> |
| 816 | + <p>In the sidebar on the left, open app > main > res > values > color.xml.</p> |
| 817 | + <p>You will see these lines:</p> |
| 818 | + <pre> |
| 819 | + {[ |
| 820 | + ' <color name="purple_200">#FFBB86FC</color>', |
| 821 | + ' <color name="purple_500">#FF6200EE</color>', |
| 822 | + ' <color name="purple_700">#FF3700B3</color>', |
| 823 | + ].join('\n')} |
| 824 | + </pre> |
| 825 | + <p>Replace those lines with:</p> |
| 826 | + <pre> |
| 827 | + {[ |
| 828 | + ` <color name="purple_200">#FF${$options.appearance.background.substr(1)}</color>`, |
| 829 | + ` <color name="purple_500">#FF${$options.appearance.background.substr(1)}</color>`, |
| 830 | + ` <color name="purple_700">#FF${$options.appearance.background.substr(1)}</color>`, |
| 831 | + ].join('\n')} |
| 832 | + </pre> |
| 833 | + <p>Do not change the other lines.</p> |
| 834 | + <p>The above snippet will make the status bar match your app's background color. For advanced users, note that these color codes are a bit unusual in that the "alpha" or "transparency" byte goes first instead of last.</p> |
| 835 | + <p>Ignore the bits about <code>purple_yyy</code> -- just them as is. While it would be a good idea to these colors, you will be making more work for yourself because you'll have to update some other files to reflect the new names.</p> |
| 836 | + |
| 837 | + <h3>Updating the project</h3> |
| 838 | + <p>It's likely that at some point you will want to update the project without redoing this entire guide. Updating is much simpler:</p> |
| 839 | + <ol> |
| 840 | + <li>Open Android Studio and open the project</li> |
| 841 | + <li>Delete everything inside the assets folder</li> |
| 842 | + <li>Re-run the packager</li> |
| 843 | + <li>Extract the zip and put all of its files into the assets folder</li> |
| 844 | + </ol> |
718 | 845 | {/if} |
719 | 846 | </div> |
720 | 847 | </Section> |
|
0 commit comments