summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore6
-rwxr-xr-x[-rw-r--r--].vars.rc.do32
-rw-r--r--AndroidManifest.xml27
-rw-r--r--MainActivity.kt41
-rwxr-xr-xR.jar.do27
-rw-r--r--R.java.do13
-rwxr-xr-xR.zip.do24
-rw-r--r--Theme.kt67
-rwxr-xr-x[-rw-r--r--]all.do3
-rwxr-xr-xclean5
-rwxr-xr-x[-rw-r--r--]default.apk.do27
-rwxr-xr-xdefault.dex.do7
-rwxr-xr-x[-rw-r--r--]default.flat.zip.do (renamed from default.flat.do)7
-rw-r--r--default.jar.do22
-rwxr-xr-xdefault.packages.jar.do41
-rwxr-xr-x[-rw-r--r--]default.signed.apk.do10
-rwxr-xr-xdefault.signed.apk.idsig.do6
-rwxr-xr-xdefault.signed.zip.do14
-rwxr-xr-xids.rc.do6
-rw-r--r--kotlin.dex.do11
-rwxr-xr-xlog3
-rw-r--r--packages.rc67
-rwxr-xr-x[-rw-r--r--]paste.dex.do10
-rwxr-xr-xpaste.jar.do15
-rw-r--r--pkg/.gitignore1
-rwxr-xr-xpkg/default.aar.do6
-rwxr-xr-xpkg/default.flat.zip.do12
-rwxr-xr-xpkg/default.jar.do13
-rwxr-xr-xpkg/default.java.do32
-rw-r--r--pkg/get35
-rw-r--r--res/layout/activity_main.xml42
-rw-r--r--res/values/colors.xml10
-rw-r--r--res/values/strings.xml6
-rw-r--r--res/values/styles.xml6
-rw-r--r--res/values/themes.xml7
-rw-r--r--resources.rc1
-rwxr-xr-xrun5
37 files changed, 503 insertions, 164 deletions
diff --git a/.gitignore b/.gitignore
index fbc55e6..89acbdb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,13 @@
*.flat
*.idsig
*.jar
+*.zip
+.dep.*
+.depend.*
.redo/
+.target.*
.vars.rc
R.java
+all
config.rc
+ids.rc
diff --git a/.vars.rc.do b/.vars.rc.do
index f9ccc80..8cddd9e 100644..100755
--- a/.vars.rc.do
+++ b/.vars.rc.do
@@ -1,11 +1,20 @@
#!/usr/bin/env bash
set -e
-unset ANDROID_SDK ANDROID_VER BUILD_TOOLS BUILD_TOOLS_VER JAVAC KEYSTORE KEYSTORE_ARGS KEYSTORE_PASS KOTLIN KOTLINC PLATFORM verbose
+unset ANDROID_SDK BUILD_TOOLS BUILD_TOOLS_VER JAVAC KEYSTORE KEYSTORE_ARGS \
+ KEYSTORE_PASS KOTLINC MANIFEST MAVEN_REPO MIN_SDK_VER PLATFORM \
+ TARGET_SDK_VER verbose
-ANDROID_VER=android-33-ext5
+MANIFEST=AndroidManifest.xml
+redo-ifchange "$MANIFEST"
+MIN_SDK_VER=$(xmllint --xpath "string(/manifest/uses-sdk/@*[local-name()='minSdkVersion'])" "$MANIFEST")
+TARGET_SDK_VER=$(xmllint --xpath "string(/manifest/uses-sdk/@*[local-name()='targetSdkVersion'])" "$MANIFEST")
BUILD_TOOLS_VER=33.0.2
APKSIGNER_SIGN_ARGS=()
+D8_ARGS=(--min-api "$MIN_SDK_VER")
+declare -A MAVEN_REPO
+MAVEN_REPO[central]=https://repo1.maven.org/maven2
+MAVEN_REPO[google]=https://dl.google.com/dl/android/maven2
if [ -e config.rc ]; then
redo-ifchange config.rc
@@ -23,8 +32,7 @@ if [[ ! ( $BUILD_TOOLS || $PLATFORM ) && ! $ANDROID_SDK ]]; then
fi
BUILD_TOOLS=${BUILD_TOOLS-$ANDROID_SDK/build-tools/$BUILD_TOOLS_VER}
-PLATFORM=${PLATFORM-$ANDROID_SDK/platforms/$ANDROID_VER}
-KOTLIN=${KOTLIN-/usr/share/kotlin}
+PLATFORM=${PLATFORM-$ANDROID_SDK/platforms/android-$TARGET_SDK_VER}
KEYSTORE=${KEYSTORE-$HOME/.android/debug.keystore}
KEYSTORE_PASS=${KEYSTORE_PASS-pass:android}
@@ -46,8 +54,22 @@ JAVAC=$(check '$JAVAC or javac' "$JAVAC" javac) || exit
KOTLINC=$(check '$KOTLINC or kotlinc' "$KOTLINC" kotlinc) || exit
{
+ d8() (
+ set -e
+ android=$PLATFORM/android.jar d8_jar=$BUILD_TOOLS/lib/d8.jar
+ dest=$1
+ shift
+ redo-ifchange "$d8_jar" "$android"
+ tmp=$(mktemp -d)
+ trap 'rm -rf "$tmp"' EXIT
+ java -Xmx2G -cp "$d8_jar" com.android.tools.r8.D8 "${D8_ARGS[@]}" \
+ --classpath "$android" --output "$tmp" "$@"
+ mv "$tmp/classes.dex" "$dest"
+ )
printf "# generated by %s\n" "$0"
- declare -p APKSIGNER_SIGN_ARGS BUILD_TOOLS JAVAC KEYSTORE KEYSTORE_PASS KOTLIN KOTLINC PLATFORM
+ declare -p APKSIGNER_SIGN_ARGS BUILD_TOOLS D8_ARGS JAVAC KEYSTORE \
+ KEYSTORE_PASS KOTLINC MANIFEST MAVEN_REPO PLATFORM
+ declare -fp d8
} >"$3"
if [[ $verbose ]]; then
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 7f77dd9..1167b94 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -1,10 +1,28 @@
<?xml version='1.0'?>
-<manifest xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' xmlns:tools='http://schemas.android.com/tools' package='ski.kramkow.paste' android:versionCode='0' android:versionName='0'>
- <uses-sdk android:minSdkVersion="33" android:targetSdkVersion="33" />
+<manifest
+ xmlns:android='http://schemas.android.com/apk/res/android'
+ package='ski.kramkow.paste'
+ android:versionCode='0'
+ android:versionName='0.1'
+>
+ <uses-sdk
+ android:minSdkVersion="21"
+ android:targetSdkVersion="28"
+ />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <application android:label='@string/app_name' android:theme='@style/app_style'>
- <activity android:name='.MainActivity' android:exported='true'>
+ <application
+ android:appComponentFactory="androidx.core.app.CoreComponentFactory"
+ android:label="@string/app_name"
+ android:theme="@style/Theme.PasteTheme"
+ android:supportsRtl="true"
+ >
+ <activity
+ android:name='.MainActivity'
+ android:exported='true'
+ android:label="@string/app_name"
+ android:theme="@style/Theme.PasteTheme"
+ >
<intent-filter>
<category android:name='android.intent.category.LAUNCHER'/>
<action android:name='android.intent.action.MAIN'/>
@@ -12,3 +30,4 @@
</activity>
</application>
</manifest>
+
diff --git a/MainActivity.kt b/MainActivity.kt
index b11b0fc..5441527 100644
--- a/MainActivity.kt
+++ b/MainActivity.kt
@@ -1,25 +1,32 @@
package ski.kramkow.paste
-import android.app.Activity
import android.os.Bundle
-//import java.net.HttpURLConnection;
-//import java.net.URL;
-//import java.io.OutputStream;
+import androidx.activity.ComponentActivity
+import androidx.activity.compose.setContent
+import androidx.compose.foundation.layout.fillMaxSize
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Surface
+import androidx.compose.material.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.Modifier
-class MainActivity : Activity() {
+class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
- setContentView(R.layout.activity_main)
-
- //URL url = new URL("http://192.168.1.32:8000");
- //HttpURLConnection con = (HttpURLConnection)url.openConnection();
- //con.setRequestMethod("POST");
- //con.setRequestProperty("Content-Type", "text/plain");
- //con.setDoOutput(true);
- //String data = "This is a test\n";
- //try(OutputStream os = con.getOutputStream()) {
- //byte[] block = data.getBytes("utf-8");
- //os.write(block, 0, block.length);
- //}
+ setContent {
+ PasteTheme {
+ Surface(
+ modifier = Modifier.fillMaxSize(),
+ color = MaterialTheme.colors.background
+ ) {
+ Greeting("World")
+ }
+ }
+ }
}
}
+
+@Composable
+fun Greeting(name: String) {
+ Text(text = "Hello $name!")
+}
diff --git a/R.jar.do b/R.jar.do
new file mode 100755
index 0000000..ea07012
--- /dev/null
+++ b/R.jar.do
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange R.zip .vars.rc packages.rc
+. ./.vars.rc
+. ./packages.rc
+javas=()
+for package in "${!packages[@]}"; do
+ if [[ $(package_ext "$package") != "aar" ]]; then continue; fi
+ javas+=("pkg/$package.java")
+done
+android=$PLATFORM/android.jar
+redo-ifchange "$JAVAC" "$android" "${javas[@]}"
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+7z e -so R.zip R.java >"$tmp/R.java"
+sources=("$tmp/R.java")
+for f in "${javas[@]}"; do
+ if [[ ! -r $f ]]; then continue; fi
+ dir="$tmp/${#sources[@]}"
+ mkdir "$dir"
+ cp "$f" "$dir/R.java"
+ sources+=("$dir/R.java")
+done
+mkdir "$tmp/compiled"
+"$JAVAC" -source 8 -target 8 -bootclasspath "$android" -d "$tmp/compiled" "${sources[@]}"
+jar --create --no-compress --date=2000-01-01T00:00:00Z --file "$3" -C "$tmp/compiled" .
+# vim:ft=bash
diff --git a/R.java.do b/R.java.do
deleted file mode 100644
index 30389fe..0000000
--- a/R.java.do
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-set -e
-redo-ifchange .vars.rc resources.rc
-. ./.vars.rc
-. ./resources.rc
-android="$PLATFORM/android.jar"
-manifest=AndroidManifest.xml
-redo-ifchange "$BUILD_TOOLS/aapt2" "$android" "$manifest" "${resources[@]}"
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
-"$BUILD_TOOLS/aapt2" link --java "$tmp" --manifest "$manifest" -o /dev/null -I "$android" "${resources[@]}"
-find "$tmp" -name "R.java" -exec mv {} "$3" \; -quit
-# vim:ft=bash
diff --git a/R.zip.do b/R.zip.do
new file mode 100755
index 0000000..666f5f6
--- /dev/null
+++ b/R.zip.do
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+set -e
+res=(values_colors.xml.flat.zip values_strings.xml.flat.zip
+ values_themes.xml.flat.zip)
+redo-ifchange .vars.rc packages.rc
+. ./.vars.rc
+. ./packages.rc
+pkg_res=() R_args=()
+for package in "${!packages[@]}"; do
+ if [[ $(package_ext "$package") != "aar" ]]; then continue; fi
+ flat_zip="pkg/$package.flat.zip"
+ pkg_res+=("$flat_zip") R_args+=(-R "$flat_zip")
+done
+android=$PLATFORM/android.jar aapt2_bin=$BUILD_TOOLS/aapt2
+redo-ifchange "$MANIFEST" "$android" "$aapt2_bin" "${res[@]}" "${pkg_res[@]}"
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+"$aapt2_bin" link -I "$android" --manifest "$MANIFEST" --java "$tmp/src" \
+ -o "$tmp/res.apk" --output-text-symbols "$tmp/R" --auto-add-overlay \
+ "${R_args[@]}" "${res[@]}"
+R_java=$(find "$tmp/src" -name R.java -print -quit)
+7z a -tzip "$tmp/out.zip" "$R_java" "$tmp/res.apk" "$tmp/R" >/dev/null
+mv "$tmp/out.zip" "$3"
+# vim:ft=bash
diff --git a/Theme.kt b/Theme.kt
new file mode 100644
index 0000000..3097658
--- /dev/null
+++ b/Theme.kt
@@ -0,0 +1,67 @@
+package ski.kramkow.paste
+
+import androidx.compose.foundation.isSystemInDarkTheme
+import androidx.compose.foundation.shape.RoundedCornerShape
+import androidx.compose.material.MaterialTheme
+import androidx.compose.material.Shapes
+import androidx.compose.material.Typography
+import androidx.compose.material.darkColors
+import androidx.compose.material.lightColors
+import androidx.compose.runtime.Composable
+import androidx.compose.ui.graphics.Color
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.FontFamily
+import androidx.compose.ui.text.font.FontWeight
+import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+
+val Typography = Typography(
+ body1 = TextStyle(
+ fontFamily = FontFamily.Default,
+ fontWeight = FontWeight.Normal,
+ fontSize = 16.sp
+ )
+)
+
+val Shapes = Shapes(
+ small = RoundedCornerShape(4.dp),
+ medium = RoundedCornerShape(4.dp),
+ large = RoundedCornerShape(0.dp)
+)
+
+val Purple200 = Color(0xFFBB86FC)
+val Purple500 = Color(0xFF6200EE)
+val Purple700 = Color(0xFF3700B3)
+val Teal200 = Color(0xFF03DAC5)
+
+private val DarkColorPalette = darkColors(
+ primary = Purple200,
+ primaryVariant = Purple700,
+ secondary = Teal200
+)
+
+private val LightColorPalette = lightColors(
+ primary = Purple500,
+ primaryVariant = Purple700,
+ secondary = Teal200
+)
+
+@Composable
+fun PasteTheme(
+ darkTheme: Boolean = isSystemInDarkTheme(),
+ content: @Composable () -> Unit
+) {
+ val colors = if (darkTheme) {
+ DarkColorPalette
+ } else {
+ LightColorPalette
+ }
+
+ MaterialTheme(
+ colors = colors,
+ typography = Typography,
+ shapes = Shapes,
+ content = content
+ )
+}
+
diff --git a/all.do b/all.do
index 61718ed..1a4b6aa 100644..100755
--- a/all.do
+++ b/all.do
@@ -1 +1,2 @@
-redo-ifchange paste.signed.apk
+#!/usr/bin/env bash
+redo-ifchange paste.signed.apk paste.signed.apk.idsig
diff --git a/clean b/clean
index 0313ccb..b88a137 100755
--- a/clean
+++ b/clean
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
-rm -f .vars.rc R.java
-find . \( -name '*.apk' -o -name '*.dex' -o -name '*.flat' -o -name '*.idsig' -o -name '*.jar' -o -name '*.aar' \) -delete
+rm -f .vars.rc ids.rc all
+find . \( -name '*.apk' -o -name '*.dex' -o -name '*.zip' -o -name '*.idsig' -o -name '*.jar' -o -name '*.aar' \) -delete
+find pkg -name '*.java' -delete
diff --git a/default.apk.do b/default.apk.do
index e56df77..bf95e7e 100644..100755
--- a/default.apk.do
+++ b/default.apk.do
@@ -1,21 +1,20 @@
#!/usr/bin/env bash
set -e
-
-redo-ifchange .vars.rc resources.rc
-. ./.vars.rc
-. ./resources.rc
-
src=${1%.apk}.dex
-
-android="$PLATFORM/android.jar"
-manifest=AndroidManifest.xml
-
-redo-ifchange "$BUILD_TOOLS/aapt2" "$BUILD_TOOLS/zipalign" "${resources[@]}" "$src" "$manifest" "$android"
-
+redo-ifchange .vars.rc "$src" "R.zip" "R.dex" \
+ "compile.packages.dex" "runtime.packages.dex"
+. ./.vars.rc
+redo-ifchange "$BUILD_TOOLS/zipalign"
tmp=$(mktemp)
trap 'rm -f "$tmp"' EXIT
-"$BUILD_TOOLS/aapt2" link --manifest "$manifest" -o "$tmp" -I "$android" "${resources[@]}"
-7z a -tzip "$tmp" "$src"
-7z rn -tzip "$tmp" "$src" classes.dex
+add() {
+ 7z a -tzip "$tmp" "$1" >/dev/null
+ 7z rn -tzip "$tmp" "$1" "classes$2.dex" >/dev/null
+}
+7z e -so "R.zip" "res.apk" >"$tmp"
+add "$src" ''
+add "R.dex" 2
+add "compile.packages.dex" 3
+add "runtime.packages.dex" 4
"$BUILD_TOOLS/zipalign" -f 4 "$tmp" "$3"
# vim:ft=bash
diff --git a/default.dex.do b/default.dex.do
new file mode 100755
index 0000000..04a32c1
--- /dev/null
+++ b/default.dex.do
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+set -e
+src=${1%.dex}.jar
+redo-ifchange .vars.rc "$src"
+. ./.vars.rc
+d8 "$3" "$src"
+# vim:ft=bash
diff --git a/default.flat.do b/default.flat.zip.do
index e8b2558..90da780 100644..100755
--- a/default.flat.do
+++ b/default.flat.zip.do
@@ -1,14 +1,11 @@
#!/usr/bin/env bash
set -e
-src=${1%.flat}
+src=${1%.flat.zip}
dir=${src%%_*}
file=${src#*_}
src=res/$dir/$file
redo-ifchange .vars.rc
. ./.vars.rc
redo-ifchange "$BUILD_TOOLS/aapt2" "$src"
-tmp=$(mktemp)
-trap 'rm -f "$tmp"' EXIT
-"$BUILD_TOOLS/aapt2" compile -o "$tmp" "$src"
-unzip -p "$tmp" >"$3"
+"$BUILD_TOOLS/aapt2" compile -o "$3" "$src"
# vim:ft=bash
diff --git a/default.jar.do b/default.jar.do
deleted file mode 100644
index a324074..0000000
--- a/default.jar.do
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/usr/bin/env bash
-set -e
-src=${1%.jar}
-redo-ifchange .vars.rc
-. ./.vars.rc
-classpath=($PLATFORM/android.jar)
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
-if [[ $1 != R.jar ]]; then classpath+=(R.jar); fi
-for e in "${classpath[@]}"; do redo-ifchange "$e"; done
-IFS=:; classpath=${classpath[*]}
-if [[ -f "$src.kt" ]]; then
- src="$src.kt"
- redo-ifchange "$KOTLINC" "$src"
- "$KOTLINC" -jvm-target 1.8 -cp "$classpath" -d "$tmp" "$src"
-else
- src="$src.java"
- redo-ifchange "$JAVAC" "$src"
- "$JAVAC" -source 11 -target 11 -classpath "$classpath" -d "$tmp" "$src"
-fi
-jar --create --no-compress --date=2000-01-01T00:00:00Z --file "$3" -C "$tmp" .
-# vim:ft=bash
diff --git a/default.packages.jar.do b/default.packages.jar.do
new file mode 100755
index 0000000..27dedf9
--- /dev/null
+++ b/default.packages.jar.do
@@ -0,0 +1,41 @@
+#!/usr/bin/env python3
+
+import re
+from subprocess import run
+from sys import argv
+from tempfile import TemporaryDirectory
+from zipfile import ZipFile, ZipInfo
+
+variant = argv[1].removesuffix(".packages.jar")
+run(["redo-ifchange", "packages.rc"], close_fds=False).check_returncode()
+jars = []
+expr = re.compile(r"^packages_" + variant + r"\[([^]]*)\]=")
+with open("packages.rc") as f:
+ for line in f:
+ if match := expr.match(line):
+ jars.append(f"pkg/{match.group(1)}.jar")
+run(["redo-ifchange", *jars], close_fds=False).check_returncode()
+already_written = set()
+with TemporaryDirectory() as d, ZipFile(argv[3], "w") as out:
+ for jar in reversed(jars):
+ with ZipFile(jar) as z:
+ for inf in z.infolist():
+ if inf.is_dir():
+ continue
+ path = inf.filename.split("/")
+ if (
+ not path
+ or path[0] == ""
+ or ".." in path
+ or path == ["META-INF", "MANIFEST.MF"]
+ or inf.filename in already_written
+ ):
+ continue
+ already_written.add(inf.filename)
+ with z.open(inf.filename) as src:
+ out.writestr(inf, src.read())
+ out.writestr(
+ ZipInfo("META-INF/MANIFEST.MF"),
+ b"Manifest-Version: 1.0\nCreated-By: python-program\n",
+ )
+# vim:ft=python
diff --git a/default.signed.apk.do b/default.signed.apk.do
index c2c5d48..1238d49 100644..100755
--- a/default.signed.apk.do
+++ b/default.signed.apk.do
@@ -1,10 +1,6 @@
#!/usr/bin/env bash
set -e
-src=${1%.signed.apk}.apk
-redo-ifchange .vars.rc
-. ./.vars.rc
-if [[ $KEYSTORE_PASS =~ ^file: ]]; then redo-ifchange "${KEYSTORE_PASS#file:}"; fi
-redo-ifchange "$BUILD_TOOLS/apksigner" "$KEYSTORE" "$src"
-"$BUILD_TOOLS/apksigner" sign --ks "$KEYSTORE" --ks-pass "$KEYSTORE_PASS" "${APKSIGNER_SIGN_ARGS[@]}" --out "$3" "$src"
-rm "$3.idsig"
+src=${1%.apk}.zip
+redo-ifchange "$src"
+7z e -so "$src" app.apk >"$3"
# vim:ft=bash
diff --git a/default.signed.apk.idsig.do b/default.signed.apk.idsig.do
new file mode 100755
index 0000000..c298373
--- /dev/null
+++ b/default.signed.apk.idsig.do
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -e
+src=${1%.apk.idsig}.zip
+redo-ifchange "$src"
+7z e -so "$src" app.apk.idsig >"$3"
+# vim:ft=bash
diff --git a/default.signed.zip.do b/default.signed.zip.do
new file mode 100755
index 0000000..32f7c3f
--- /dev/null
+++ b/default.signed.zip.do
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+set -e
+src=${1%.signed.zip}.apk
+redo-ifchange .vars.rc "$src"
+. ./.vars.rc
+if [[ $KEYSTORE_PASS =~ ^file: ]]; then redo-ifchange "${KEYSTORE_PASS#file:}"; fi
+redo-ifchange "$BUILD_TOOLS/apksigner" "$KEYSTORE"
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+"$BUILD_TOOLS/apksigner" sign --ks "$KEYSTORE" --ks-pass "$KEYSTORE_PASS" \
+ "${APKSIGNER_SIGN_ARGS[@]}" --out "$tmp/app.apk" "$src"
+7z a -tzip "$tmp/app.zip" "$tmp/app.apk" "$tmp/app.apk.idsig" >/dev/null
+mv "$tmp/app.zip" "$3"
+# vim:ft=bash
diff --git a/ids.rc.do b/ids.rc.do
new file mode 100755
index 0000000..9c5ffd2
--- /dev/null
+++ b/ids.rc.do
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange R.zip
+printf 'declare -A ids\n' >"$3"
+7z e -so R.zip R | sed 's/^\(int[][]*\) \([^ ]*\) \([^ ]*\) \([0-9a-fA-F{},x ]*\)$/ids[\2:\3]="\1 \3 = \4"/' >>"$3"
+# vim:ft=bash
diff --git a/kotlin.dex.do b/kotlin.dex.do
deleted file mode 100644
index 5cd3eef..0000000
--- a/kotlin.dex.do
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env bash
-set -e
-redo-ifchange .vars.rc
-. ./.vars.rc
-src="$KOTLIN/lib/kotlin-stdlib.jar"
-redo-ifchange "$BUILD_TOOLS/d8" "$PLATFORM/android.jar" "$src"
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
-"$BUILD_TOOLS/d8" --intermediate "$src" --classpath "$PLATFORM/android.jar" --output "$tmp"
-mv "$tmp/classes.dex" "$3"
-# vim:ft=bash
diff --git a/log b/log
new file mode 100755
index 0000000..799f764
--- /dev/null
+++ b/log
@@ -0,0 +1,3 @@
+#!/bin/sh
+package=$(xmllint --xpath "string(/manifest/@package)" AndroidManifest.xml)
+adb logcat -d -e "$package"
diff --git a/packages.rc b/packages.rc
new file mode 100644
index 0000000..7b95934
--- /dev/null
+++ b/packages.rc
@@ -0,0 +1,67 @@
+declare -A packages_compile packages_runtime
+packages_compile[androidx.activity:activity-compose:1.3.1]=aar:google:1ca65cbf8948ef3d82dfe70fbf2b2f6805b88dbe7385c67757d601bd5068523c
+packages_compile[androidx.activity:activity-ktx:1.3.1]=aar:google:9adc905de021afe039e4107a49c0bead35661c69a8a8086af448d01ecd5d6130
+packages_compile[androidx.activity:activity:1.3.1]=aar:google:6006f41c11e6ea41e7109a70c1db361735b12a9005dd0a6f7c18c3697a9c8b34
+packages_compile[androidx.annotation:annotation-experimental:1.2.0]=aar:google:a4aead7df0f3da937960a7fd95774a53d7aa5f4e9874063a0c73a95ca293897f
+packages_compile[androidx.annotation:annotation:1.2.0]=jar:google:9029262bddce116e6d02be499e4afdba21f24c239087b76b3b57d7e98b490a36
+packages_compile[androidx.arch.core:core-common:2.1.0]=jar:google:fe1237bf029d063e7f29fe39aeaf73ef74c8b0a3658486fc29d3c54326653889
+packages_runtime[androidx.arch.core:core-runtime:2.1.0]=aar:google:dd77615bd3dd275afb11b62df25bae46b10b4a117cd37943af45bdcbf8755852
+packages_runtime[androidx.autofill:autofill:1.0.0]=aar:google:c9468f56e05006ea151a426c54957cd0799b8b83a579d2846dd22061f33e5ecd
+packages_compile[androidx.collection:collection:1.1.0]=jar:google:632a0e5407461de774409352940e292a291037724207a787820c77daf7d33b72
+packages_compile[androidx.compose.animation:animation-core:1.1.1]=aar:google:797048e2d03a9b1b98443fbe118d70f0955988e3fca56a71985ee3550be46f4e
+packages_compile[androidx.compose.animation:animation:1.1.1]=aar:google:95fca9d5bbb8da8c4f351331558e7b2f4ec04db0cf290b021852423461d76a9c
+packages_compile[androidx.compose.foundation:foundation-layout:1.2.0]=aar:google:f1143c6c62a7de22dcf42e8b1ef6a1c131e1492cddef3662efe8eb72c7fdb107
+packages_compile[androidx.compose.foundation:foundation:1.2.0]=aar:google:088ab2fff41f23ca655db48beaaf0b74ad06f452d6164863ce6735333fc9d497
+packages_compile[androidx.compose.material:material-icons-core:1.2.0]=aar:google:43c92a176e343d5db6ba316949de935748d8338ca604406da016fd135498c957
+packages_compile[androidx.compose.material:material-ripple:1.2.0]=aar:google:2d253f387801ea76b8a3086bb363887d1200b03e2723575892d13d8150296295
+packages_compile[androidx.compose.material:material:1.2.0]=aar:google:315f05e428b3faf25ad080fdeaa3074c20624255d0a323aed17072c6f07a6eae
+packages_compile[androidx.compose.runtime:runtime-saveable:1.2.0]=aar:google:15e4adbb3091b06c9f47635a558244e8c8ef3e616c3a3b3192e524aa3bbfbcf0
+packages_compile[androidx.compose.runtime:runtime:1.2.0]=aar:google:0a49a51ce083ce5d282172d4e2509d792205dddbc652ea2aff061e507e546990
+packages_compile[androidx.compose.ui:ui:1.2.0]=aar:google:499cadfff85f101632da3369d49fce148c44d6d1e39b6b1a8c73bd5083022472
+packages_compile[androidx.compose.ui:ui-geometry:1.2.0]=aar:google:4b1ac2963e19147fae4f9f116690ff64f011137607fec429e40bcaa169d83bb4
+packages_compile[androidx.compose.ui:ui-graphics:1.2.0]=aar:google:58606617a8e71e58eba56bd79410c77c6df79017bb058cf64cce1def3af463de
+packages_compile[androidx.compose.ui:ui-text:1.2.0]=aar:google:8143d7e6bb293b81e404331a35ba5b749cfa8ac1c45c07bbe260261d0a83b3b7
+packages_compile[androidx.compose.ui:ui-unit:1.2.0]=aar:google:09184bed04f3e13c73f90d0087ec3ec1f92832191b8e4494fc3c68a4b179d2a3
+packages_runtime[androidx.compose.ui:ui-util:1.2.0]=aar:google:0cfc6911f25c76388f0e8ed567cf5cb19619f7a07fe3f9d6236f0b7866263c40
+packages_runtime[androidx.concurrent:concurrent-futures:1.0.0]=jar:google:5595a40e278a7b39fa78a09490e3d7f3faa95c7b01447148bd38b5ade0605c35
+packages_compile[androidx.core:core:1.6.0]=aar:google:875dbec888c91b05521575fd180cc08824d2c4d12b10b0261b4f9d6825214ef1
+packages_compile[androidx.core:core-ktx:1.6.0]=aar:google:71ef02cee7eba1e905a7f37f313b50ba8a3bee0ec59a0f876d5a78860e1de963
+packages_runtime[androidx.customview:customview-poolingcontainer:1.0.0]=aar:google:3584102fc49bf399c56e3b7be4bfe12000c46112320cd8cf85cc0a8f93f3e752
+packages_compile[androidx.lifecycle:lifecycle-common:2.4.0]=jar:google:20ad1520f625cf455e6afd7290988306d3a9886efa993e0860fbabf4bb3f7bda
+packages_compile[androidx.lifecycle:lifecycle-livedata-core:2.3.1]=aar:google:e55d38c372460f0a03997ddc950c67227511340fd74f8634d99d29653cd81ab1
+packages_compile[androidx.lifecycle:lifecycle-runtime-ktx:2.3.1]=aar:google:7ad2987dd7f4075c0871a72cf07e9649d9cd790fc23dfab1972eca4710373873
+packages_compile[androidx.lifecycle:lifecycle-runtime:2.3.1]=aar:google:dd294f4a689c71ff877fd41f3b67a3a62f7760d44ce420e6130f1fc3569d8f00
+packages_compile[androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1]=aar:google:5fb3591b6a54eeb3e204be0125d48eb987b8ea45a5048140036865482ccf9de9
+packages_compile[androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1]=aar:google:97137a8af6a31776a14e4866ab808c7c0a791b484bdbc788bbd83e66407564c0
+packages_compile[androidx.lifecycle:lifecycle-viewmodel:2.3.1]=aar:google:b6db4c274a12ff85a4747e1e6669c7e98aefa2571ace9d1f1a6fa6be417ce838
+packages_runtime[androidx.profileinstaller:profileinstaller:1.2.0]=aar:google:0a1b2260af67962f4038d56fa84cda341315704aad56abbcf3a9b3bba6945426
+packages_compile[androidx.savedstate:savedstate-ktx:1.2.0]=aar:google:43112928d3cbb108801ee11130f303404bc4892cf78908811568195107bba7fe
+packages_compile[androidx.savedstate:savedstate:1.2.0]=aar:google:2de528d6898e95ef020d22d9ffdf9d1f77cbdd93f92d39dfaa5d5c43b0c311c8
+packages_compile[androidx.startup:startup-runtime:1.1.1]=aar:google:e0a6329a371262fe4c450372b70fdaf33b769ef6917094723787cfce896b1dd3
+packages_runtime[androidx.tracing:tracing:1.0.0]=aar:google:07b8b6139665b884a162eccf97891ca50f7f56831233bf25168ae04f7b568612
+packages_compile[androidx.versionedparcelable:versionedparcelable:1.1.1]=aar:google:57e8d93260d18d5b9007c9eed3c64ad159de90c8609ebfc74a347cbd514535a4
+packages_compile[com.google.guava:listenablefuture:1.0]=jar:central:e4ad7607e5c0477c6f890ef26a49cb8d1bb4dffb650bab4502afee64644e3069
+packages_compile[org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21]=jar:central:183bec59cd9f3a14957b190e8c879cf1194bd1f106b0a7b6e1cbb8790d242363
+packages_compile[org.jetbrains.kotlin:kotlin-stdlib:1.6.21]=jar:central:739c526672bb337573b28f63afa8306eb088b0c3a0967f56d6c89f4a3012a492
+packages_compile[org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.0]=jar:central:870d35fd266b2daf64c1080fe51824d3c368f7995384a8d7c5fc2fdc40eb7b3a
+packages_compile[org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.0]=jar:central:ab0547c495953214a5f2b28150014f4e02133678d52b77d76375ea235e443dbd
+packages_compile[org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.1]=jar:central:3a93ffd052844643c0fef950ae5578db47cccbe9e7176d681333182e232bb0f1
+packages_compile[org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1]=jar:central:961ebde8138779a299430ca325a86e28c490527a87ba518362fa45c44c7e7e95
+packages_compile[org.jetbrains:annotations:13.0]=jar:central:ace2a10dc8e2d5fd34925ecac03e4988b2c0f851650c94b8cef49ba1bd111478
+
+declare -A packages
+
+for k in "${!packages_runtime[@]}"; do
+ packages[$k]=${packages_runtime[$k]}
+done
+for k in "${!packages_compile[@]}"; do
+ packages[$k]=${packages_compile[$k]}
+done
+
+compose_compiler=org.jetbrains.compose.compiler:compiler-hosted:1.4.5
+
+packages[$compose_compiler]=jar:central:c944a75df78e787e4604bf35313c2c3d8bcb72b7fed05cf65a359796a90959d6
+
+package_ext() { printf '%s' "${packages[$1]%%:*}"; }
+package_file() { printf 'pkg/%s.%s' "$1" "$(package_ext "$1")"; }
+# vim:ft=bash
diff --git a/paste.dex.do b/paste.dex.do
index 53ec7c2..a70fb39 100644..100755
--- a/paste.dex.do
+++ b/paste.dex.do
@@ -1,12 +1,6 @@
#!/usr/bin/env bash
set -e
-jars=(R.jar MainActivity.jar)
-redo-ifchange .vars.rc
+redo-ifchange .vars.rc paste.jar
. ./.vars.rc
-android="$PLATFORM/android.jar"
-redo-ifchange "$BUILD_TOOLS/d8" "$android" kotlin.dex "${jars[@]}"
-tmp=$(mktemp -d)
-trap 'rm -rf "$tmp"' EXIT
-"$BUILD_TOOLS/d8" --classpath "$android" --output "$tmp" kotlin.dex "${jars[@]}"
-mv "$tmp/classes.dex" "$3"
+d8 "$3" paste.jar
# vim:ft=bash
diff --git a/paste.jar.do b/paste.jar.do
new file mode 100755
index 0000000..f3255e3
--- /dev/null
+++ b/paste.jar.do
@@ -0,0 +1,15 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange .vars.rc packages.rc
+. ./.vars.rc
+. ./packages.rc
+classpath=($PLATFORM/android.jar compile.packages.jar R.jar)
+plugin=$(package_file "$compose_compiler")
+sources=(MainActivity.kt Theme.kt)
+redo-ifchange "$KOTLINC" "$plugin" "$classpath" "${classpath[@]}" "${sources[@]}"
+IFS=:; classpath=${classpath[*]}
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+"$KOTLINC" -Xplugin="$plugin" -jvm-target 1.8 -cp "$classpath" -d "$tmp" "${sources[@]}"
+jar --create --no-compress --date=2000-01-01T00:00:00Z --file "$3" -C "$tmp" .
+# vim:ft=bash
diff --git a/pkg/.gitignore b/pkg/.gitignore
new file mode 100644
index 0000000..27d1535
--- /dev/null
+++ b/pkg/.gitignore
@@ -0,0 +1 @@
+*.java
diff --git a/pkg/default.aar.do b/pkg/default.aar.do
new file mode 100755
index 0000000..034d507
--- /dev/null
+++ b/pkg/default.aar.do
@@ -0,0 +1,6 @@
+#!/usr/bin/env bash
+set -e
+pkg=${1%.aar}
+redo-ifchange get
+. ./get "$pkg" "$3"
+# vim:ft=bash
diff --git a/pkg/default.flat.zip.do b/pkg/default.flat.zip.do
new file mode 100755
index 0000000..8373faf
--- /dev/null
+++ b/pkg/default.flat.zip.do
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+set -e
+src=${1%.flat.zip}.aar
+redo-ifchange ../.vars.rc "$src"
+. ../.vars.rc
+redo-ifchange "$BUILD_TOOLS/aapt2"
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+mkdir -p "$tmp/res"
+7z x -tzip -o"$tmp" "$src" res >/dev/null
+"$BUILD_TOOLS/aapt2" compile --dir "$tmp/res" -o "$3"
+# vim:ft=bash
diff --git a/pkg/default.jar.do b/pkg/default.jar.do
new file mode 100755
index 0000000..6fa7d4e
--- /dev/null
+++ b/pkg/default.jar.do
@@ -0,0 +1,13 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange ../packages.rc
+. ../packages.rc
+pkg=${1%.jar}
+if [[ $(package_ext "$pkg") == "aar" ]]; then
+ redo-ifchange "$pkg.aar"
+ 7z e -tzip -so "$pkg.aar" classes.jar >"$3"
+else
+ redo-ifchange get
+ . ./get "$pkg" "$3"
+fi
+# vim:ft=bash
diff --git a/pkg/default.java.do b/pkg/default.java.do
new file mode 100755
index 0000000..16bf440
--- /dev/null
+++ b/pkg/default.java.do
@@ -0,0 +1,32 @@
+#!/usr/bin/env bash
+set -e
+src=${1%.java}.aar
+redo-ifchange "$src" "../ids.rc"
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+7z e -tzip -o"$tmp" "$src" AndroidManifest.xml R.txt >/dev/null
+if [[ -r "$tmp/AndroidManifest.xml" ]]; then
+ package=$(xmllint --xpath 'string(/manifest/@package)' "$tmp/AndroidManifest.xml")
+fi
+if [[ ! $package ]] || [[ ! -r $tmp/R.txt ]]; then
+ printf '//\n' >"$3"
+ exit 0
+fi
+. ../ids.rc
+. <(sed -n 's/^int[^ ]* \([a-z]*\) \([A-Za-z0-9_]*\) .*$/names_\1+=(\2)/p' "$tmp/R.txt")
+mapfile -t types < <(sed -n 's/^int[^ ]* \([a-z]*\) .*/\1/p' "$tmp/R.txt" | sort -u)
+exec >"$3"
+printf '// generated by %s\n' "$0"
+printf 'package %s;\npublic final class R {\n' "$package"
+for typ in "${types[@]}"; do
+ declare -n names="names_$typ"
+ printf 'public static final class %s {\n' "$typ"
+ for name in "${names[@]}"; do
+ if [[ ${ids[$typ:$name]} ]]; then
+ printf 'public static final %s;\n' "${ids[$typ:$name]}"
+ fi
+ done
+ printf '}\n'
+done
+printf '}\n'
+# vim:ft=bash
diff --git a/pkg/get b/pkg/get
new file mode 100644
index 0000000..a26bec6
--- /dev/null
+++ b/pkg/get
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange ../packages.rc ../.vars.rc
+. ../.vars.rc
+. ../packages.rc
+
+set -f
+IFS=:; p=($1); d=(${packages[$1]})
+set +f
+group=${p[0]}
+artifact=${p[1]}
+version=${p[2]}
+packaging=${d[0]}
+repo=${d[1]}
+valid_sum=${d[2]}
+
+hash_file() { sha256sum "$1" 2>/dev/null | cut -d ' ' -f 1; }
+
+if [[ $valid_sum ]] && [[ $(hash_file "$1.$packaging") == "$valid_sum" ]]; then
+ cp "$1.$packaging" "$2"
+ exit
+fi
+
+url=${MAVEN_REPO[$repo]}/${group//.//}/$artifact/$version/$artifact-$version.$packaging
+curl --silent --show-error --fail --output "$2" "$url"
+sum=$(hash_file "$2")
+if [[ $valid_sum ]] && [[ $sum != "$valid_sum" ]]; then
+ printf '%s: checksum mismatch (got: %s)\n' "$pkg" "$sum" >&2
+ rm "$2"
+ exit 1
+fi
+if [[ ! $valid_sum ]]; then
+ printf "sed -i 's/^packages(_[a-z]*){0,1}\\[%s:%s:%s\\]=%s:%s:$/&%s/' packages.rc\n" "$group" "$artifact" "$version" "$packaging" "$repo" "$sum" >&2
+fi
+# vim:ft=bash
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
deleted file mode 100644
index 0807716..0000000
--- a/res/layout/activity_main.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:paddingLeft="16dp"
- android:paddingRight="16dp"
- android:orientation="vertical"
->
- <RadioGroup
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- >
- <RadioButton
- android:id="@+id/radio_post"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/POST"
- />
- <RadioButton
- android:id="@+id/radio_put"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/PUT"
- />
- </RadioGroup>
- <!--<Button-->
- <!--android:id="@+id/button_choose_file"-->
- <!--android:layout_width="match_parent"-->
- <!--android:layout_height="wrap_content"-->
- <!--android:text="@string/submit"-->
- <!--/>-->
- <Button
- android:id="@+id/button_submit"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:text="@string/submit"
- />
-</LinearLayout>
diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644
index 0000000..ca1931b
--- /dev/null
+++ b/res/values/colors.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <color name="purple_200">#FFBB86FC</color>
+ <color name="purple_500">#FF6200EE</color>
+ <color name="purple_700">#FF3700B3</color>
+ <color name="teal_200">#FF03DAC5</color>
+ <color name="teal_700">#FF018786</color>
+ <color name="black">#FF000000</color>
+ <color name="white">#FFFFFFFF</color>
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index c215c34..b4ac7c4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1,9 +1,3 @@
<resources>
<string name="app_name">Paste</string>
- <string name="menu_settings">Settings</string>
- <string name="title_activity_main">MainActivity</string>
- <string name="content_hint">Content</string>
- <string name="submit">Submit</string>
- <string name="PUT">PUT</string>
- <string name="POST">POST</string>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
deleted file mode 100644
index 96fe7ee..0000000
--- a/res/values/styles.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<resources>
- <style name="app_style" parent="@android:style/Theme.Light">
- <item name="android:windowActionBar">true</item>
- <item name="android:windowNoTitle">true</item>
- </style>
-</resources>
diff --git a/res/values/themes.xml b/res/values/themes.xml
new file mode 100644
index 0000000..6193b06
--- /dev/null
+++ b/res/values/themes.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <style name="Theme.PasteTheme" parent="android:Theme.Material.Light.NoActionBar">
+ <item name="android:statusBarColor">@color/purple_700</item>
+ </style>
+</resources>
diff --git a/resources.rc b/resources.rc
deleted file mode 100644
index de9db9e..0000000
--- a/resources.rc
+++ /dev/null
@@ -1 +0,0 @@
-resources=(values_strings.xml.flat values_styles.xml.flat layout_activity_main.xml.flat)
diff --git a/run b/run
new file mode 100755
index 0000000..2e01c69
--- /dev/null
+++ b/run
@@ -0,0 +1,5 @@
+#!/bin/sh
+package=$(xmllint --xpath "string(/manifest/@package)" AndroidManifest.xml)
+adb install -r -t paste.signed.apk || exit
+#todo: use xpath to find the activity
+adb shell am start -n "$package/.MainActivity"