Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes:#3868 Added Android Bundle Support #3935

Merged
merged 12 commits into from
Nov 13, 2024
7 changes: 3 additions & 4 deletions example/javalib/android/1-hello-world/app/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloworld.app">
<uses-sdk android:minSdkVersion="9"/>
<uses-sdk android:targetSdkVersion="35"/>
<application android:label="Hello World" android:debuggable="true">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloworld.app" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="35"/>
<application android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar" android:debuggable="true">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<color name="white">#FFFFFF</color>
<color name="text_green">#34A853</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<string name="app_name">HelloWorldApp</string>
<string name="hello_world">Hello, World Java!</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ protected void onCreate(Bundle savedInstanceState) {
// Create a new TextView
TextView textView = new TextView(this);

// Set the text to "Hello, World!"
textView.setText("Hello, World!");
// Set the text to the string resource
textView.setText(getString(R.string.hello_world));

// Set text size
textView.setTextSize(32);

// Center the text within the view
textView.setGravity(Gravity.CENTER);

// Set layout parameters (width and height)
// Set the layout parameters (width and height)
textView.setLayoutParams(
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

// Set the text color using a resource
textView.setTextColor(getResources().getColor(R.color.text_green));

// Set the background color using a resource
textView.setBackgroundColor(getResources().getColor(R.color.white));

// Set the content view to display the TextView
setContentView(textView);
}
Expand Down
24 changes: 24 additions & 0 deletions example/javalib/android/2-app-bundle/build.mill
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package build

import mill._
import kotlinlib._
import coursier.maven.MavenRepository
import mill.javalib.android.{AndroidSdkModule, AndroidAppBundle}

object androidSdkModule0 extends AndroidSdkModule {
def buildToolsVersion = "35.0.0"
}

object bundle extends AndroidAppBundle {
def androidSdkModule = mill.define.ModuleRef(androidSdkModule0)
}

/** Usage

> ./mill show bundle.androidBundle
".../out/bundle/androidBundle.dest/bundle.aab"

> ./mill show bundle.androidApk
".../out/bundle/androidApk.dest/universal.apk"

*/
12 changes: 12 additions & 0 deletions example/javalib/android/2-app-bundle/bundle/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloworld.app" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="35"/>
<application android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar" android:debuggable="true">
<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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<color name="white">#FFFFFF</color>
<color name="text_green">#34A853</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<string name="app_name">HelloWorldBundleApp</string>
<string name="hello_world">Hello, World Bundle!</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.helloworld.app;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.widget.TextView;

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Create a new TextView
TextView textView = new TextView(this);

// Set the text to the string resource
textView.setText(getString(R.string.hello_world));

// Set text size
textView.setTextSize(32);

// Center the text within the view
textView.setGravity(Gravity.CENTER);

// Set the layout parameters (width and height)
textView.setLayoutParams(
new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

// Set the text color using a resource
textView.setTextColor(getResources().getColor(R.color.text_green));

// Set the background color using a resource
textView.setBackgroundColor(getResources().getColor(R.color.white));

// Set the content view to display the TextView
setContentView(textView);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloworld.app">
<uses-sdk android:minSdkVersion="9"/>
<uses-sdk android:targetSdkVersion="35"/>
<application android:label="Hello World" android:debuggable="true">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.helloworld.app" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="35"/>
<application android:label="@string/app_name" android:theme="@android:style/Theme.Light.NoTitleBar" android:debuggable="true">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<color name="white">#FFFFFF</color>
<color name="text_green">#34A853</color>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<resources>
<string name="app_name">HelloWorldApp</string>
<string name="hello_world">Hello, World Kotlin!</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.helloworld.app

import android.app.Activity
import android.os.Bundle
import android.widget.TextView
import android.view.Gravity
import android.view.ViewGroup.LayoutParams
import android.widget.TextView

class MainActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -13,8 +13,8 @@ class MainActivity : Activity() {
// Create a new TextView
val textView = TextView(this)

// Set the text to "Hello, World!"
textView.text = "Hello, World Kotlin!"
// Set the text to the string resource
textView.text = getString(R.string.hello_world)

// Set text size
textView.textSize = 32f
Expand All @@ -23,10 +23,13 @@ class MainActivity : Activity() {
textView.gravity = Gravity.CENTER

// Set layout parameters (width and height)
textView.layoutParams = LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.MATCH_PARENT
)
textView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)

// Set the text color using a resource
textView.setTextColor(getColor(R.color.text_green)) // Using hex color code directly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does // Using hex color code directly mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂😂😂 actually these documentations are not updated i will update them with updation of build docs


// Set the background color using a resource
textView.setBackgroundColor(getColor(R.color.white)) // Using hex color code directly

// Set the content view to display the TextView
setContentView(textView)
Expand Down
2 changes: 1 addition & 1 deletion example/kotlinlib/android/1-hello-world/build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object androidSdkModule0 extends AndroidSdkModule {
// Actual android application
object app extends AndroidAppKotlinModule {

def kotlinVersion = "2.0.0"
def kotlinVersion = "2.0.20"
def androidSdkModule = mill.define.ModuleRef(androidSdkModule0)
}

Expand Down
Loading
Loading