|
707 | 707 | {#if $options.target.startsWith('zip')} |
708 | 708 | <h2>Zip</h2> |
709 | 709 | <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> |
710 | | - {/if} |
711 | | - {#if !$options.target.startsWith('zip')} |
| 710 | + {:else} |
712 | 711 | <h2>{$_('options.applicationSettings')}</h2> |
713 | 712 | <label class="option"> |
714 | 713 | {$_('options.packageName')} |
|
773 | 772 | <p class="warning">NW.js support is deprecated and may be removed in the future. Use Electron instead if possible.</p> |
774 | 773 | <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> |
775 | 774 | {/if} |
776 | | - {/if} |
777 | | - {:else if $options.target === 'android'} |
778 | | - <h2>Android</h2> |
| 775 | + {:else if $options.target === 'android'} |
| 776 | + <h2>Android</h2> |
779 | 777 |
|
780 | | - <div class="warning"> |
781 | | - 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. |
782 | | - </div> |
| 778 | + <div class="warning"> |
| 779 | + 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. |
| 780 | + </div> |
| 781 | + |
| 782 | + <p>This section assumes you have complete access to a Windows, macOS, or Linux computer.</p> |
| 783 | + |
| 784 | + <h3>Install Android Studio</h3> |
| 785 | + <p><a href="https://developer.android.com/studio/">Install Android Studio.</a></p> |
| 786 | + <p>This is quite large and may take a while.</p> |
783 | 787 |
|
784 | | - <p>This section assumes you have complete access to a Windows, macOS, or Linux computer.</p> |
785 | | - |
786 | | - <h3>Install Android Studio</h3> |
787 | | - <p><a href="https://developer.android.com/studio/">Install Android Studio.</a></p> |
788 | | - <p>This is quite large and may take a while.</p> |
789 | | - |
790 | | - <h3>Create a new project</h3> |
791 | | - <p>Create a new project in Android studio.</p> |
792 | | - <ul> |
793 | | - <li>Use the "Empty Activity" template</li> |
794 | | - <li>Set Name to your app's name, for example "<code>{$options.app.windowTitle}</code>"</li> |
795 | | - <li>Set Package name to "<code>org.turbowarp.packager.userland.{$options.app.packageName}</code>"</li> |
796 | | - <li>Choose a save location that you won't forget</li> |
797 | | - <li>Set Language to Kotlin</li> |
798 | | - <li>Set Minimum SDK to "API 21: Android 5.0 (Lollipop)"</li> |
799 | | - </ul> |
800 | | - |
801 | | - <h3>Create assets folder</h3> |
802 | | - <p>In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.</p> |
803 | | - |
804 | | - <h3>Prepare project</h3> |
805 | | - <p> |
806 | | - <Button on:click={pack} text={'Package the project as a zip'} /> |
807 | | - </p> |
808 | | - <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> |
809 | | - |
810 | | - <h3>Making the app</h3> |
811 | | - <p>In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.</p> |
812 | | - <p>Replace everything after line 2 with the following:</p> |
813 | | - <pre> |
814 | | - {[ |
815 | | - 'import android.annotation.SuppressLint', |
816 | | - 'import androidx.appcompat.app.AppCompatActivity', |
817 | | - 'import android.os.Bundle', |
818 | | - 'import android.webkit.WebView', |
819 | | - '', |
820 | | - 'class MainActivity : AppCompatActivity() {', |
821 | | - ' private lateinit var web: WebView', |
822 | | - '', |
823 | | - ' @SuppressLint("SetJavaScriptEnabled")', |
824 | | - ' override fun onCreate(savedInstanceState: Bundle?) {', |
825 | | - ' super.onCreate(savedInstanceState)', |
826 | | - ' web = WebView(this)', |
827 | | - ' web.settings.javaScriptEnabled = true', |
828 | | - ' web.loadUrl("file:///android_asset/index.html")', |
829 | | - ' setContentView(web)', |
830 | | - ' actionBar?.hide()', |
831 | | - ' supportActionBar?.hide()', |
832 | | - ' }', |
833 | | - '', |
834 | | - ' override fun onDestroy() {', |
835 | | - ' super.onDestroy()', |
836 | | - ' web.destroy()', |
837 | | - ' }', |
838 | | - '}' |
839 | | - ].join('\n')} |
840 | | - </pre> |
841 | | - <p>At this point, you now have a fully functional Android app. However, there are still a few more things you should change.</p> |
842 | | - |
843 | | - <h3>Fixing screen orientation issues</h3> |
844 | | - <p>In the sidebar on the left, open app > main > AndroidManifest.xml</p> |
845 | | - <p>Find the section that looks like this:</p> |
846 | | - <pre> |
847 | | - {[ |
848 | | - ' <activity', |
849 | | - ' android:name=".MainActivity"', |
850 | | - ' android:exported="true">', |
851 | | - ].join('\n')} |
852 | | - </pre> |
853 | | - <p>And replace it with this:</p> |
854 | | - <pre> |
855 | | - {[ |
856 | | - ' <activity', |
857 | | - ' android:configChanges="orientation|screenSize"', |
858 | | - ' android:screenOrientation="sensor"', |
859 | | - ' android:name=".MainActivity"', |
860 | | - ' android:exported="true">', |
861 | | - ].join('\n')} |
862 | | - </pre> |
863 | | - |
864 | | - <h3>Updating colors</h3> |
865 | | - <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> |
866 | | - <p>In the sidebar on the left, open app > main > res > values > color.xml.</p> |
867 | | - <p>You will see these lines:</p> |
868 | | - <pre> |
869 | | - {[ |
870 | | - ' <color name="purple_200">#FFBB86FC</color>', |
871 | | - ' <color name="purple_500">#FF6200EE</color>', |
872 | | - ' <color name="purple_700">#FF3700B3</color>', |
873 | | - ].join('\n')} |
874 | | - </pre> |
875 | | - <p>Replace those lines with:</p> |
876 | | - <pre> |
877 | | - {[ |
878 | | - ` <color name="purple_200">#FF${$options.appearance.background.substr(1)}</color>`, |
879 | | - ` <color name="purple_500">#FF${$options.appearance.background.substr(1)}</color>`, |
880 | | - ` <color name="purple_700">#FF${$options.appearance.background.substr(1)}</color>`, |
881 | | - ].join('\n')} |
882 | | - </pre> |
883 | | - <p>Do not change the other lines.</p> |
884 | | - <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> |
885 | | - <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> |
886 | | - |
887 | | - <h3>Updating the project</h3> |
888 | | - <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> |
889 | | - <ol> |
890 | | - <li>Open Android Studio and open the project</li> |
891 | | - <li>Delete everything inside the assets folder</li> |
892 | | - <li>Re-run the packager</li> |
893 | | - <li>Extract the zip and put all of its files into the assets folder</li> |
894 | | - </ol> |
| 788 | + <h3>Create a new project</h3> |
| 789 | + <p>Create a new project in Android studio.</p> |
| 790 | + <ul> |
| 791 | + <li>Use the "Empty Activity" template</li> |
| 792 | + <li>Set Name to your app's name, for example "<code>{$options.app.windowTitle}</code>"</li> |
| 793 | + <li>Set Package name to "<code>org.turbowarp.packager.userland.{$options.app.packageName}</code>"</li> |
| 794 | + <li>Choose a save location that you won't forget</li> |
| 795 | + <li>Set Language to Kotlin</li> |
| 796 | + <li>Set Minimum SDK to "API 21: Android 5.0 (Lollipop)"</li> |
| 797 | + </ul> |
| 798 | + |
| 799 | + <h3>Create assets folder</h3> |
| 800 | + <p>In the sidebar on the left, right click on "app", then select "New" > "Folder" > "Assets folder". Use the default settings.</p> |
| 801 | + |
| 802 | + <h3>Prepare project</h3> |
| 803 | + <p> |
| 804 | + <Button on:click={pack} text={'Package the project as a zip'} /> |
| 805 | + </p> |
| 806 | + <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> |
| 807 | + |
| 808 | + <h3>Making the app</h3> |
| 809 | + <p>In the sidebar on the left, navigate to app > src > main > MainActivity. This will open a short Kotlin file.</p> |
| 810 | + <p>Replace everything after line 2 with the following:</p> |
| 811 | + <pre> |
| 812 | + {[ |
| 813 | + 'import android.annotation.SuppressLint', |
| 814 | + 'import androidx.appcompat.app.AppCompatActivity', |
| 815 | + 'import android.os.Bundle', |
| 816 | + 'import android.webkit.WebView', |
| 817 | + '', |
| 818 | + 'class MainActivity : AppCompatActivity() {', |
| 819 | + ' private lateinit var web: WebView', |
| 820 | + '', |
| 821 | + ' @SuppressLint("SetJavaScriptEnabled")', |
| 822 | + ' override fun onCreate(savedInstanceState: Bundle?) {', |
| 823 | + ' super.onCreate(savedInstanceState)', |
| 824 | + ' web = WebView(this)', |
| 825 | + ' web.settings.javaScriptEnabled = true', |
| 826 | + ' web.loadUrl("file:///android_asset/index.html")', |
| 827 | + ' setContentView(web)', |
| 828 | + ' actionBar?.hide()', |
| 829 | + ' supportActionBar?.hide()', |
| 830 | + ' }', |
| 831 | + '', |
| 832 | + ' override fun onDestroy() {', |
| 833 | + ' super.onDestroy()', |
| 834 | + ' web.destroy()', |
| 835 | + ' }', |
| 836 | + '}' |
| 837 | + ].join('\n')} |
| 838 | + </pre> |
| 839 | + <p>At this point, you now have a fully functional Android app. However, there are still a few more things you should change.</p> |
| 840 | + |
| 841 | + <h3>Fixing screen orientation issues</h3> |
| 842 | + <p>In the sidebar on the left, open app > main > AndroidManifest.xml</p> |
| 843 | + <p>Find the section that looks like this:</p> |
| 844 | + <pre> |
| 845 | + {[ |
| 846 | + ' <activity', |
| 847 | + ' android:name=".MainActivity"', |
| 848 | + ' android:exported="true">', |
| 849 | + ].join('\n')} |
| 850 | + </pre> |
| 851 | + <p>And replace it with this:</p> |
| 852 | + <pre> |
| 853 | + {[ |
| 854 | + ' <activity', |
| 855 | + ' android:configChanges="orientation|screenSize"', |
| 856 | + ' android:screenOrientation="sensor"', |
| 857 | + ' android:name=".MainActivity"', |
| 858 | + ' android:exported="true">', |
| 859 | + ].join('\n')} |
| 860 | + </pre> |
| 861 | + |
| 862 | + <h3>Updating colors</h3> |
| 863 | + <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> |
| 864 | + <p>In the sidebar on the left, open app > main > res > values > color.xml.</p> |
| 865 | + <p>You will see these lines:</p> |
| 866 | + <pre> |
| 867 | + {[ |
| 868 | + ' <color name="purple_200">#FFBB86FC</color>', |
| 869 | + ' <color name="purple_500">#FF6200EE</color>', |
| 870 | + ' <color name="purple_700">#FF3700B3</color>', |
| 871 | + ].join('\n')} |
| 872 | + </pre> |
| 873 | + <p>Replace those lines with:</p> |
| 874 | + <pre> |
| 875 | + {[ |
| 876 | + ` <color name="purple_200">#FF${$options.appearance.background.substr(1)}</color>`, |
| 877 | + ` <color name="purple_500">#FF${$options.appearance.background.substr(1)}</color>`, |
| 878 | + ` <color name="purple_700">#FF${$options.appearance.background.substr(1)}</color>`, |
| 879 | + ].join('\n')} |
| 880 | + </pre> |
| 881 | + <p>Do not change the other lines.</p> |
| 882 | + <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> |
| 883 | + <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> |
| 884 | + |
| 885 | + <h3>Updating the project</h3> |
| 886 | + <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> |
| 887 | + <ol> |
| 888 | + <li>Open Android Studio and open the project</li> |
| 889 | + <li>Delete everything inside the assets folder</li> |
| 890 | + <li>Re-run the packager</li> |
| 891 | + <li>Extract the zip and put all of its files into the assets folder</li> |
| 892 | + </ol> |
| 893 | + {/if} |
895 | 894 | {/if} |
896 | 895 | </div> |
897 | 896 | </Section> |
|
0 commit comments