File size: 2,133 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from pathlib import Path

PACKAGE="com.dolor3v.app"
APP_NAME="Dolor3v"

ROOT=Path("generated_android")

def write(path,text):
    path.parent.mkdir(parents=True,exist_ok=True)
    path.write_text(text.strip()+"\n",encoding="utf-8")

def generate():

    write(
        ROOT/"AndroidManifest.xml",
        f"""
<?xml version="1.0" encoding="utf-8"?>
<manifest
    package="{PACKAGE}"
    xmlns:android="http://schemas.android.com/apk/res/android">

    <application
        android:label="{APP_NAME}"
        android:allowBackup="true"
        android:supportsRtl="true"
        android:theme="@style/Theme.App">

        <activity
            android:name=".MainActivity"
            android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>

        </activity>

    </application>

</manifest>
"""
    )

    write(
        ROOT/"res/values/strings.xml",
        """
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Dolor3v</string>
</resources>
"""
    )

    write(
        ROOT/"res/values/colors.xml",
        """
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="black">#000000</color>
<color name="white">#FFFFFF</color>
</resources>
"""
    )

    write(
        ROOT/"res/values/themes.xml",
        """
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style
    name="Theme.App"
    parent="android:Theme.Material.Light.NoActionBar"/>

</resources>
"""
    )

    java_path=ROOT/"src/com/dolor3v/app/MainActivity.java"

    write(
        java_path,
        f"""
package {PACKAGE};

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends Activity {{

    @Override
    protected void onCreate(Bundle state) {{
        super.onCreate(state);

        TextView tv=new TextView(this);
        tv.setText("Dolor3v APK Builder");
        setContentView(tv);
    }}

}}
"""
    )

    print(ROOT.resolve())

if __name__=="__main__":
    generate()