mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
cmd/gogio: include Android themes in .aar outputs
Not strictly necessary, but makes embedding a Gio Android Activity easier; adding <activity android:name="org.gioui.GioActivity" android:theme="@style/Theme.GioApp" android:configChanges="orientation|keyboardHidden" android:windowSoftInputMode="adjustResize"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> should be enough. Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+20
-14
@@ -52,6 +52,22 @@ type manifestData struct {
|
|||||||
AppName string
|
AppName string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
themes = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.GioApp" parent="android:style/Theme.NoTitleBar">
|
||||||
|
</style>
|
||||||
|
</resources>`
|
||||||
|
themesV21 = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.GioApp" parent="android:style/Theme.NoTitleBar">
|
||||||
|
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||||
|
<item name="android:navigationBarColor">#40000000</item>
|
||||||
|
<item name="android:statusBarColor">#40000000</item>
|
||||||
|
</style>
|
||||||
|
</resources>`
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
exeSuffix = ".exe"
|
exeSuffix = ".exe"
|
||||||
@@ -250,7 +266,10 @@ func archiveAndroid(tmpDir string, bi *buildInfo, perms []string) (err error) {
|
|||||||
aarw := newZipWriter(aar)
|
aarw := newZipWriter(aar)
|
||||||
defer aarw.Close()
|
defer aarw.Close()
|
||||||
aarw.Create("R.txt")
|
aarw.Create("R.txt")
|
||||||
aarw.Create("res/")
|
themesXML := aarw.Create("res/values/themes.xml")
|
||||||
|
themesXML.Write([]byte(themes))
|
||||||
|
themesXML21 := aarw.Create("res/values-v21/themes.xml")
|
||||||
|
themesXML21.Write([]byte(themesV21))
|
||||||
permissions, features := getPermissions(perms)
|
permissions, features := getPermissions(perms)
|
||||||
manifest := aarw.Create("AndroidManifest.xml")
|
manifest := aarw.Create("AndroidManifest.xml")
|
||||||
manifestSrc := manifestData{
|
manifestSrc := manifestData{
|
||||||
@@ -341,23 +360,10 @@ func exeAndroid(tmpDir string, tools *androidTools, bi *buildInfo, extraJars, pe
|
|||||||
}
|
}
|
||||||
iconSnip = `android:icon="@mipmap/ic_launcher"`
|
iconSnip = `android:icon="@mipmap/ic_launcher"`
|
||||||
}
|
}
|
||||||
themes := `<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<style name="Theme.GioApp" parent="android:style/Theme.NoTitleBar">
|
|
||||||
</style>
|
|
||||||
</resources>`
|
|
||||||
err = ioutil.WriteFile(filepath.Join(valDir, "themes.xml"), []byte(themes), 0660)
|
err = ioutil.WriteFile(filepath.Join(valDir, "themes.xml"), []byte(themes), 0660)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
themesV21 := `<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<style name="Theme.GioApp" parent="android:style/Theme.NoTitleBar">
|
|
||||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
|
||||||
<item name="android:navigationBarColor">#40000000</item>
|
|
||||||
<item name="android:statusBarColor">#40000000</item>
|
|
||||||
</style>
|
|
||||||
</resources>`
|
|
||||||
err = ioutil.WriteFile(filepath.Join(v21Dir, "themes.xml"), []byte(themesV21), 0660)
|
err = ioutil.WriteFile(filepath.Join(v21Dir, "themes.xml"), []byte(themesV21), 0660)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user