From 8f560f0f615090047eadbf7f3aac600ae8a2990f Mon Sep 17 00:00:00 2001 From: Alexander Mahr Date: Mon, 7 Oct 2024 16:37:21 +0200 Subject: [PATCH] add example app source, adjust Docker/Makefile --- Dockerfile | 1 + Makefile | 4 + apk/Makefile | 5 +- apk/src/de/alexmahr/app1/App1.java | 117 ++++++++++++++++++++++++++ apk/src/de/alexmahr/app1/App1.kt | 47 +++++++++++ apk/src/de/alexmahr/app1/App1.kt.back | 93 ++++++++++++++++++++ apk/src/de/alexmahr/app1/R.java | 22 +++++ apk/src/main | Bin 0 -> 4192 bytes apk/src/main.c | 6 ++ compose.yml | 2 + 10 files changed, 293 insertions(+), 4 deletions(-) create mode 100644 apk/src/de/alexmahr/app1/App1.java create mode 100644 apk/src/de/alexmahr/app1/App1.kt create mode 100644 apk/src/de/alexmahr/app1/App1.kt.back create mode 100644 apk/src/de/alexmahr/app1/R.java create mode 100755 apk/src/main create mode 100644 apk/src/main.c diff --git a/Dockerfile b/Dockerfile index 235606a..a9dccc9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,3 +28,4 @@ RUN chown 0:0 /entrypoint.sh RUN chmod 0700 /entrypoint.sh WORKDIR /apk ENTRYPOINT ["/entrypoint.sh"] +RUN echo "$YESACCEPT" | tee yesaccept diff --git a/Makefile b/Makefile index 0433371..00165ce 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ +all: build install + build: docker-compose run compile +install: + adb install -r ./apk/bin/app1.apk clean: rm docker-compose-build.log || true diff --git a/apk/Makefile b/apk/Makefile index f84db2f..bab07e4 100644 --- a/apk/Makefile +++ b/apk/Makefile @@ -8,15 +8,12 @@ CXX_FLAGS = -march=armv8-a --sysroot=$(TOOLCHAIN)/sysroot -all: build deploy +all: build .PHONY : build .PHONY : deploy .PHONY : clean -deploy : - adb install -r ./bin/hellojni.apk - build : ./bin/app1.apk diff --git a/apk/src/de/alexmahr/app1/App1.java b/apk/src/de/alexmahr/app1/App1.java new file mode 100644 index 0000000..990f3ae --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.java @@ -0,0 +1,117 @@ +package de.alexmahr.app1; + +import android.util.Log; +import android.widget.TextView; +import android.app.Activity; +import android.os.Bundle; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.lang.Thread; +import java.util.concurrent.TimeUnit; +import android.text.method.ScrollingMovementMethod; + +class Threads1 implements Runnable { + + public String result = "alex"; + + public void run(){ + try{ + result = result.concat("step 2\n"); + URL url = new URL("https://alexmahr.de/word"); + result = result.concat("step 3\n"); + HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + result = result.concat("step 4\n"); + BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); + result = result.concat("step 5\n"); + String inputLine; + StringBuffer response = new StringBuffer(); + result = result.concat("step 6\n"); + + while ((inputLine = in.readLine()) != null) { + result = result.concat("step 7\n"); + response.append(inputLine); + } + result = result.concat("step 8\n"); + in.close(); + result = result.concat("step 9\n"); + result = result.concat( "OK".concat(response.toString())); + urlConnection.disconnect(); + } catch (Exception e){ +// throw new RuntimeException(e); + } + } +} + + +public class App1 extends Activity +{ + + @Override + public void onCreate(Bundle savedInstanceState) + { + try + { + super.onCreate(savedInstanceState); + //volatile String result = "initial"; + String result = "initial"; + TextView tv = new TextView(this); + tv.setMovementMethod(new ScrollingMovementMethod()); + Threads1 threads1 = new Threads1(); + Thread thread = new Thread(threads1); + thread.start(); + thread.join(); + + // Thread thread = new Thread(new Runnable() { + + // @Override + // public void run() { + // try { + // result = result.concat("step 2\n"); + // URL url = new URL("https://alexmahr.de/word"); + // result = result.concat("step 3\n"); + // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); + // result = result.concat("step 4\n"); + // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); + // result = result.concat("step 5\n"); + // String inputLine; + // StringBuffer response = new StringBuffer(); + // result = result.concat("step 6\n"); + + // while ((inputLine = in.readLine()) != null) { + // result = result.concat("step 7\n"); + // response.append(inputLine); + // } + // result = result.concat("step 8\n"); + // in.close(); + // result = result.concat("step 9\n"); + // result = result.concat( "OK".concat(response.toString())); + // urlConnection.disconnect(); + + + // } catch (Exception e) { + // e.printStackTrace(); + // } + // } + // }); + // thread.start(); + // thread.join(); + tv.setText( result); + setContentView(tv); + try{ + // TimeUnit.SECONDS.sleep(1); + } catch (Exception e){ +// throw new RuntimeException(e); + } + tv.setText(result.concat(threads1.result)); + } catch (Exception e) { + throw new RuntimeException(e); + } + + } + + +} diff --git a/apk/src/de/alexmahr/app1/App1.kt b/apk/src/de/alexmahr/app1/App1.kt new file mode 100644 index 0000000..49a9b70 --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.kt @@ -0,0 +1,47 @@ +import android.os.Bundle +import android.view.Menu +import android.view.MenuItem +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity + +class MainActivity : AppCompatActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + // calling this activity's function to + // use ActionBar utility methods + val actionBar = supportActionBar + + // providing title for the ActionBar + actionBar!!.title = " GfG | Action Bar" + + // providing subtitle for the ActionBar + actionBar.subtitle = " Design a custom Action Bar" + + // adding icon in the ActionBar + actionBar.setIcon(R.drawable.app_logo) + + // methods to display the icon in the ActionBar + actionBar.setDisplayUseLogoEnabled(true) + actionBar.setDisplayShowHomeEnabled(true) + } + + // method to inflate the options menu when + // the user opens the menu for the first time + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.main, menu) + return super.onCreateOptionsMenu(menu) + } + + // methods to control the operations that will + // happen when user clicks on the action buttons + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.search -> Toast.makeText(this, "Search Clicked", Toast.LENGTH_SHORT).show() + R.id.refresh -> Toast.makeText(this, "Refresh Clicked", Toast.LENGTH_SHORT).show() + R.id.copy -> Toast.makeText(this, "Copy Clicked", Toast.LENGTH_SHORT).show() + } + return super.onOptionsItemSelected(item) + } +} diff --git a/apk/src/de/alexmahr/app1/App1.kt.back b/apk/src/de/alexmahr/app1/App1.kt.back new file mode 100644 index 0000000..a62120a --- /dev/null +++ b/apk/src/de/alexmahr/app1/App1.kt.back @@ -0,0 +1,93 @@ +package de.alexmahr.app1; + +//#import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import android.util.Log; +import android.widget.TextView; +import android.app.Activity; +//import java.io.BufferedReader; +//import java.io.IOException; +//import java.io.InputStreamReader; +//import java.io.OutputStream; +//import java.net.HttpURLConnection; +//import java.net.URL; +//import java.lang.Thread; +//import java.util.concurrent.TimeUnit; +//import android.text.method.ScrollingMovementMethod; + +public class App1 extends Activity{ +{ + override fun onCreate(savedInstanceState: Bundle?) { + + super.onCreate(savedInstanceState); + val tv = TextView(this); + tv.setText( "result"); + setContentView(tv); + + } +} +// @Override +// public void onCreate(Bundle savedInstanceState) +// { +// try +// { +// super.onCreate(savedInstanceState); +// //volatile String result = "initial"; +// String result = "initial"; +// TextView tv = new TextView(this); +// tv.setMovementMethod(new ScrollingMovementMethod()); +// Threads1 threads1 = new Threads1(); +// Thread thread = new Thread(threads1); +// thread.start(); +// thread.join(); +// +// // Thread thread = new Thread(new Runnable() { +// +// // @Override +// // public void run() { +// // try { +// // result = result.concat("step 2\n"); +// // URL url = new URL("https://alexmahr.de/word"); +// // result = result.concat("step 3\n"); +// // HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); +// // result = result.concat("step 4\n"); +// // BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); +// // result = result.concat("step 5\n"); +// // String inputLine; +// // StringBuffer response = new StringBuffer(); +// // result = result.concat("step 6\n"); +// +// // while ((inputLine = in.readLine()) != null) { +// // result = result.concat("step 7\n"); +// // response.append(inputLine); +// // } +// // result = result.concat("step 8\n"); +// // in.close(); +// // result = result.concat("step 9\n"); +// // result = result.concat( "OK".concat(response.toString())); +// // urlConnection.disconnect(); +// +// +// // } catch (Exception e) { +// // e.printStackTrace(); +// // } +// // } +// // }); +// // thread.start(); +// // thread.join(); +// tv.setText( result); +// setContentView(tv); +// try{ +// // TimeUnit.SECONDS.sleep(1); +// } catch (Exception e){ +//// throw new RuntimeException(e); +// } +// tv.setText(result.concat(threads1.result)); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// +// } +// +// +//} diff --git a/apk/src/de/alexmahr/app1/R.java b/apk/src/de/alexmahr/app1/R.java new file mode 100644 index 0000000..4725840 --- /dev/null +++ b/apk/src/de/alexmahr/app1/R.java @@ -0,0 +1,22 @@ +/* AUTO-GENERATED FILE. DO NOT MODIFY. + * + * This class was automatically generated by the + * aapt tool from the resource data it found. It + * should not be modified by hand. + */ + +package de.alexmahr.app1; + +public final class R { + public static final class attr { + } + public static final class drawable { + public static final int ic_launcher=0x7f020000; + } + public static final class layout { + public static final int main=0x7f030000; + } + public static final class string { + public static final int app_name=0x7f040000; + } +} diff --git a/apk/src/main b/apk/src/main new file mode 100755 index 0000000000000000000000000000000000000000..e85433850d91273f6da780b595d4bf27c43067c1 GIT binary patch literal 4192 zcmbVPU2GIp6h6CMq{5;L{_vyXU@9p@W_P>&17E0s(pU^uA0#muW_PCT%64ZnJ4Kop zCE|lIB0lO<`=E&r#?-_IV^DcA#%RI=F_`eMEiP0{6e1d;#P$2`%&o(!F?u#<&iT$c z_jk^md-sJsBM&DM3DMLc-9j{Xn@BHYcN&kREbA3R((v6S>*Xex=+k@@4ah0j$Q|Gh zfHk8lA=3x5Vu&Sr4-LrlOD6Qs0do%I92$|A#rzEfH@ZUZf{)C3>GmmrRDZ}cvv2KR z4n5wUeiCC0a1wkC;2QcTH-O1(&zR9>;KbW=Y-45UgDQ{15AhdLOxRcppxtgt%tA|`)q!a#^!nQJ0b$qYv$VOnlr>6+)kzsR9eLhNy>u}=2)~)#`_h^ zDjl&cJ8+Mb1At1oShC7hrTgx98Jp|FJLdU^q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{#`Ql$Sfc6`@e3fQ}bpRcn@b>{2r|1_-&Bx0rTu+9BUGJ zKXkTbUyNg2VNK*2$T*&hfx+cC0 z(lIdOI^b9T({u-Pf(-Q(RomGH!!5;e-kNl?H(}s^1;(+KF2eD5ac{$aYZS*CeEA>Z z-bW1A!2Z<#Jj6AiGY?3Bs{fB5)jA+~*FU=~%r`(qj3a#t)^WW5Eh3J0HBCD1a~L>p zj;qd0OhWq@tM#v-v%egTApW1_{{l@^$zOxfS54bDU;$e-fYePcKxgi0+Ksqb7Px# literal 0 HcmV?d00001 diff --git a/apk/src/main.c b/apk/src/main.c new file mode 100644 index 0000000..4ccc8aa --- /dev/null +++ b/apk/src/main.c @@ -0,0 +1,6 @@ +#include + +int main(){ + printf("hallo"); + return 0; +} diff --git a/compose.yml b/compose.yml index 1cd0c5a..e036ee2 100644 --- a/compose.yml +++ b/compose.yml @@ -2,6 +2,8 @@ services: compile: build: context: . + args: + YESACCEPT: ${YESACCEPT} stop_grace_period: 1s volumes: - ./apk:/apk