diff --git a/Makefile b/Makefile index d5485fd2..9aa30daf 100644 --- a/Makefile +++ b/Makefile @@ -20,11 +20,11 @@ CFLAGS += \ -g LDFLAGS += -Wl,--gc-sections -ANDROID_SDK ?= /usr/lib/android-sdk -ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/29.0.3 -ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-23 -ANDROID_NDK ?= /usr/lib/android-sdk/ndk-bundle -ANDROID_NDK_API_VERSION := 30 +ANDROID_SDK ?= ~/Android/Sdk +ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/33.0.1 +ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-33 +ANDROID_NDK ?= $(ANDROID_SDK)/ndk/23.1.7779620 +ANDROID_NDK_API_VERSION := 33 ANDROID_MIN_SDK_VERSION := 26 ANDROID_ARM64_TARGETS := \ @@ -37,11 +37,9 @@ ANDROID_TARGETS := \ $(ANDROID_X86_64_TARGETS) \ $(ANDROID_ARM64_TARGETS) -$(info $(ANDROID_TARGETS)) - debug windebug $(ANDROID_TARGETS): CFLAGS += -Og debug release out/androidrelease/tildefriends out/androidrelease-x86_64/tildefriends: LDFLAGS += -rdynamic -$(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_SDK)/ndk-bundle/sysroot -fPIC +$(ANDROID_TARGETS): CFLAGS += --sysroot $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC release winrelease: CFLAGS += -DNDEBUG -O3 windebug winrelease: CC = x86_64-w64-mingw32-gcc-win32 windebug winrelease: AS = $(CC) @@ -398,22 +396,25 @@ endef $(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type)))) # Android support. -out/gen/com/unprompted/tildefriends/R.java: $(wildcard src/android/res/layout/*) src/android/AndroidManifest.xml +out/res/layout_activity_main.xml.flat: src/android/res/layout/activity_main.xml @mkdir -p $(dir $@) - @echo [aapt] R.java - @$(ANDROID_BUILD_TOOLS)/aapt package -f -m -J out/gen/ -S src/android/res/ -M src/android/AndroidManifest.xml -I $(ANDROID_PLATFORM)/android.jar + @echo [aapt2] $@ + $(ANDROID_BUILD_TOOLS)/aapt2 compile -o out/res/ src/android/res/layout/activity_main.xml + +out/res.apk out/gen/com/unprompted/tildefriends/R.java: out/res/layout_activity_main.xml.flat src/android/AndroidManifest.xml + $(ANDROID_BUILD_TOOLS)/aapt2 link -I $(ANDROID_PLATFORM)/android.jar out/res/layout_activity_main.xml.flat --manifest src/android/AndroidManifest.xml -o out/res.apk --java out/gen/ JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java) CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class))) $(CLASS_FILES) &: $(JAVA_FILES) @echo [javac] $(CLASS_FILES) - @javac --release 8 -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES) + @javac --release 8 -Xlint:deprecation -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES) out/apk/classes.dex: $(CLASS_FILES) - @mkdir -p $(dir $@) - @echo [dx] $@ - @$(ANDROID_BUILD_TOOLS)/dx --dex --min-sdk-version=$(ANDROID_MIN_SDK_VERSION) --output=$@ out/classes/ + mkdir -p $(dir $@) + echo [d8] $@ + $(ANDROID_BUILD_TOOLS)/d8 --lib $(ANDROID_PLATFORM)/android.jar --output $(dir $@) out/classes/com/unprompted/tildefriends/*.class PACKAGE_DIRS := \ apps/ \ @@ -422,19 +423,18 @@ PACKAGE_DIRS := \ deps/split/ \ deps/smoothie/ -# deps/speedscope/ \ - RAW_FILES := $(shell find $(PACKAGE_DIRS) -type f) -out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) +out/TildeFriends.unsigned.apk: out/apk/classes.dex out/androiddebug/tildefriends out/androiddebug-x86_64/tildefriends $(RAW_FILES) out/res.apk @mkdir -p $(dir $@) out/apk/lib/arm64-v8a/ out/apk/lib/x86_64/ @echo [aapt] $@ @cp out/androiddebug/tildefriends out/apk/lib/arm64-v8a/ @cp out/androiddebug-x86_64/tildefriends out/apk/lib/x86_64/ @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/arm64-v8a/tildefriends @/usr/lib/android-sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip out/apk/lib/x86_64/tildefriends - @$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/ - @zip -u $@ -q -9 -r $(PACKAGE_DIRS) + @cp out/res.apk $@ + @cd out/apk && zip -u ../../$@ -q -9 -r . && cd ../../ + @zip -u $@ -q -9 -r $(PACKAGE_DIRS) $(RAW_FILES) out/TildeFriends.apk: out/TildeFriends.unsigned.apk @echo [apksigner] $(notdir $@) diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java index 9f34b4f5..91fd4e42 100644 --- a/src/android/com/unprompted/tildefriends/MainActivity.java +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -13,6 +13,7 @@ import android.view.KeyEvent; import android.view.Window; import android.webkit.JsResult; import android.webkit.WebChromeClient; +import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; import java.lang.Process; @@ -112,12 +113,12 @@ public class MainActivity extends Activity { web_view.setWebViewClient(new WebViewClient() { @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { - if (url != null && url.startsWith("http://127.0.0.1:12345/")) { + if (request.getUrl() != null && request.getUrl().toString().startsWith("http://127.0.0.1:12345/")) { return false; } else { - view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); + view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, request.getUrl())); return true; } }