-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch to GameActivity and gradle build
- Loading branch information
Showing
14 changed files
with
533 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
.DEFAULT_GOAL := check | ||
.PHONY: fake | ||
|
||
all: | ||
cargo check | ||
ANDROID_DIR := crates/notedeck_chrome/android | ||
|
||
check: | ||
cargo check | ||
|
||
tags: fake | ||
find . -type d -name target -prune -o -type f -name '*.rs' -print | xargs ctags | ||
|
||
.PHONY: fake | ||
jni: fake | ||
cargo ndk --target arm64-v8a -o $(ANDROID_DIR)/app/src/main/jniLibs/ build --profile release | ||
|
||
apk: jni | ||
cd $(ANDROID_DIR) && ./gradlew build | ||
|
||
android: jni | ||
cd $(ANDROID_DIR) && ./gradlew installDebug | ||
adb shell am start -n com.damus.notedeck/.MainActivity | ||
adb logcat -v color -s notedeck RustStdoutStderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
.DEFAULT_GOAL := apk | ||
.PHONY: jni apk run-on-device | ||
|
||
jni: | ||
cd rust && cargo ndk --target arm64-v8a -o ../java/app/src/main/jniLibs/ build --profile release | ||
|
||
apk: jni | ||
cd java && ./gradlew build | ||
|
||
run-on-device: jni | ||
cd java && ./gradlew installDebug | ||
adb shell am start -n local.walkers/.MainActivity | ||
adb logcat -v color -s walkers RustStdoutStderr |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
plugins { | ||
id "com.android.application" | ||
} | ||
|
||
android { | ||
namespace "com.damus.notedeck" | ||
compileSdk 31 | ||
|
||
defaultConfig { | ||
minSdk 29 | ||
targetSdk 33 | ||
versionCode 1 | ||
versionName "1" | ||
} | ||
|
||
buildTypes { | ||
debug | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation "com.google.android.material:material:1.5.0" | ||
implementation "androidx.games:games-activity:2.0.2" | ||
} |
37 changes: 37 additions & 0 deletions
37
crates/notedeck_chrome/android/app/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<application | ||
android:allowBackup="true" | ||
android:label="Notedeck" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.MaterialComponents.DayNight.NoActionBar"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="orientation|screenSize|screenLayout|keyboardHidden" | ||
android:exported="true" | ||
android:launchMode="singleTask" | ||
> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
|
||
<meta-data | ||
android:name="android.app.lib_name" | ||
android:value="main" /> | ||
</activity> | ||
</application> | ||
|
||
[[package.metadata.android.uses_feature]] | ||
name = "android.hardware.vulkan.level" | ||
required = true | ||
version = 1 | ||
|
||
<uses-feature android:name="android.hardware.vulkan.level" | ||
android:required="true" | ||
android:version="1" /> | ||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
</manifest> |
54 changes: 54 additions & 0 deletions
54
crates/notedeck_chrome/android/app/src/main/java/com/damus/notedeck/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.damus.notedeck; | ||
|
||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.MotionEvent; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
|
||
import androidx.core.graphics.Insets; | ||
import androidx.core.view.DisplayCutoutCompat; | ||
import androidx.core.view.ViewCompat; | ||
import androidx.core.view.WindowCompat; | ||
import androidx.core.view.WindowInsetsCompat; | ||
|
||
import com.google.androidgamesdk.GameActivity; | ||
|
||
public class MainActivity extends GameActivity { | ||
static { | ||
System.loadLibrary("main"); | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
// Shrink view so it does not get covered by insets. | ||
|
||
View content = getWindow().getDecorView().findViewById(android.R.id.content); | ||
ViewCompat.setOnApplyWindowInsetsListener(content, (v, windowInsets) -> { | ||
Insets insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars()); | ||
|
||
ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) v.getLayoutParams(); | ||
mlp.topMargin = insets.top; | ||
mlp.leftMargin = insets.left; | ||
mlp.bottomMargin = insets.bottom; | ||
mlp.rightMargin = insets.right; | ||
v.setLayoutParams(mlp); | ||
|
||
return WindowInsetsCompat.CONSUMED; | ||
}); | ||
|
||
WindowCompat.setDecorFitsSystemWindows(getWindow(), true); | ||
|
||
super.onCreate(savedInstanceState); | ||
} | ||
|
||
@Override | ||
public boolean onTouchEvent(MotionEvent event) { | ||
// Offset the location so it fits the view with margins caused by insets. | ||
|
||
int[] location = new int[2]; | ||
findViewById(android.R.id.content).getLocationOnScreen(location); | ||
event.offsetLocation(-location[0], -location[1]); | ||
return super.onTouchEvent(event); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
plugins { | ||
id 'com.android.application' version '8.4.1' apply false | ||
id 'com.android.library' version '8.4.1' apply false | ||
} | ||
|
||
task clean(type: Delete) { | ||
delete rootProject.buildDir | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Project-wide Gradle settings. | ||
# IDE (e.g. Android Studio) users: | ||
# Gradle settings configured through the IDE *will override* | ||
# any settings specified in this file. | ||
# For more details on how to configure your build environment visit | ||
# http://www.gradle.org/docs/current/userguide/build_environment.html | ||
# Specifies the JVM arguments used for the daemon process. | ||
# The setting is particularly useful for tweaking memory settings. | ||
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 | ||
# When configured, Gradle will run in incubating parallel mode. | ||
# This option should only be used with decoupled projects. More details, visit | ||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects | ||
# org.gradle.parallel=true | ||
# AndroidX package structure to make it clearer which packages are bundled with the | ||
# Android operating system, and which are packaged with your app"s APK | ||
# https://developer.android.com/topic/libraries/support-library/androidx-rn | ||
android.useAndroidX=true | ||
# Enables namespacing of each library's R class so that its R class includes only the | ||
# resources declared in the library itself and none from the library's dependencies, | ||
# thereby reducing the size of the R class for that library | ||
android.nonTransitiveRClass=true | ||
android.nonFinalResIds=false |
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
crates/notedeck_chrome/android/gradle/wrapper/gradle-wrapper.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.