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

WIP: Android kotlin #488

Draft
wants to merge 84 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ce4cdef
init some credits goes to citra for colors and themes,et…
Ishan09811 Dec 10, 2024
f519d2f
Update deploy_android_kotlin.yml
Ishan09811 Dec 10, 2024
43b5a9b
deploy_android_kotlin: fix
Ishan09811 Dec 10, 2024
95fbb61
Update build.gradle.kts
Ishan09811 Dec 10, 2024
3b3a4b7
Update and rename settings.gradle to settings.gradle.kts
Ishan09811 Dec 10, 2024
3e189e2
build.gradle.kts: add namespace
Ishan09811 Dec 10, 2024
d080ead
Create material_switch.xml
Ishan09811 Dec 10, 2024
95af1a8
fix sdk
Ishan09811 Dec 10, 2024
99b1327
Update AndroidManifest.xml
Ishan09811 Dec 10, 2024
590706b
Create menu_navigation.xml
Ishan09811 Dec 10, 2024
b44214d
Add icons
Ishan09811 Dec 10, 2024
7400ff9
fix jvm version conflict
Ishan09811 Dec 11, 2024
90b85a9
build.gradle.kts: enable binding
Ishan09811 Dec 11, 2024
5bc5867
Implement SkyEmuApplication
Ishan09811 Dec 11, 2024
7f8440d
AndroidManifest: use custom ``SkyEmuApplication``
Ishan09811 Dec 11, 2024
16026ed
Create fragment_games.xml
Ishan09811 Dec 11, 2024
502c44a
Create GameUtils.kt
Ishan09811 Dec 11, 2024
d9ae597
Create FileUtil.kt
Ishan09811 Dec 11, 2024
d41c0e7
Update GamesFragment.kt
Ishan09811 Dec 11, 2024
dfb5a3a
fragment_games: Add fab to add games
Ishan09811 Dec 11, 2024
e126089
Fix
Ishan09811 Dec 11, 2024
6e7a59a
Update deploy_android_kotlin.yml
Ishan09811 Dec 11, 2024
1c7608f
Add icons
Ishan09811 Dec 11, 2024
f7331b8
Create dimens.xml
Ishan09811 Dec 11, 2024
136c39f
EmulationActivity: fix missing import
Ishan09811 Dec 11, 2024
991f3b0
Fix
Ishan09811 Dec 11, 2024
b240a8d
Update GamesFragment.kt
Ishan09811 Dec 11, 2024
b89b789
Fix
Ishan09811 Dec 11, 2024
8834fa9
Update FileUtil.kt
Ishan09811 Dec 11, 2024
133dc90
EmulationActivity: add todo
Ishan09811 Dec 11, 2024
af0ca5c
Update GameAdapter.kt
Ishan09811 Dec 11, 2024
5b701a9
FileUtil: fix errors
Ishan09811 Dec 11, 2024
a921bbf
Typo
Ishan09811 Dec 11, 2024
ddaaf68
Update GamesFragment.kt
Ishan09811 Dec 11, 2024
129897d
Fix
Ishan09811 Dec 11, 2024
32edd1d
Update GameAdapter.kt
Ishan09811 Dec 11, 2024
ec3cbe9
Update GamesFragment.kt
Ishan09811 Dec 11, 2024
6b53008
Update MainActivity.kt
Ishan09811 Dec 11, 2024
568c3c0
Missing import
Ishan09811 Dec 11, 2024
b471bf9
Update fragment_games.xml
Ishan09811 Dec 11, 2024
38ef06b
GameUtils: fix crashes
Ishan09811 Dec 12, 2024
736c9f7
Update GameUtils.kt
Ishan09811 Dec 12, 2024
e1b73e8
GamesFragment: fix insets
Ishan09811 Dec 12, 2024
c141528
Create GamesViewModel.kt
Ishan09811 Dec 12, 2024
7f7ff4a
GamesFragment: use custom viewmodel
Ishan09811 Dec 12, 2024
81809be
EmulationActivity: catch unsatisfied link errors
Ishan09811 Dec 12, 2024
a6ebace
deploy_android_kotlin: implement caching
Ishan09811 Dec 12, 2024
7c8260e
Fix
Ishan09811 Dec 12, 2024
79505bd
try to fix native crashes
Ishan09811 Dec 12, 2024
49d31af
refix native crashes
Ishan09811 Dec 12, 2024
9d193d3
Update main.cpp
Ishan09811 Dec 12, 2024
a7e8639
EmulationActivity: Implement missing functions
Ishan09811 Dec 12, 2024
c07b1d9
fix
Ishan09811 Dec 12, 2024
2eb0367
Update EmulationActivity.kt
Ishan09811 Dec 12, 2024
12946d8
another fix
Ishan09811 Dec 12, 2024
c6ef4d7
Update EmulationActivity.kt
Ishan09811 Dec 12, 2024
d5f54ae
Update EmulationActivity.kt
Ishan09811 Dec 12, 2024
e00cbf2
Update main.cpp
Ishan09811 Dec 12, 2024
eb9da66
Update main.cpp
Ishan09811 Dec 12, 2024
9490fc3
Update and rename EmulationActivity.kt to EnhancedNativeActivity.kt
Ishan09811 Dec 13, 2024
2856b84
Update home_navigation.xml
Ishan09811 Dec 13, 2024
4c92ca6
Update Game.kt
Ishan09811 Dec 13, 2024
372c330
Update AndroidManifest.xml
Ishan09811 Dec 13, 2024
c1cfc00
Update and rename EnhancedNativeActivity.kt to EnhancedNativeActivity…
Ishan09811 Dec 13, 2024
e11475b
Update EnhancedNativeActivity.java
Ishan09811 Dec 13, 2024
4bda311
missing import
Ishan09811 Dec 13, 2024
7714370
java moment
Ishan09811 Dec 13, 2024
e1fcf3c
EnhancedNativeActivity: fix permission
Ishan09811 Dec 13, 2024
b5177a2
fix
Ishan09811 Dec 13, 2024
a25de3e
Update Game.kt
Ishan09811 Dec 13, 2024
4feaa0e
Update GameUtils.kt
Ishan09811 Dec 13, 2024
1492ad1
Update EnhancedNativeActivity.java
Ishan09811 Dec 13, 2024
311b7ca
Update EnhancedNativeActivity.java
Ishan09811 Dec 13, 2024
4613f29
Update Game.kt
Ishan09811 Dec 13, 2024
79ae637
Update GameUtils.kt
Ishan09811 Dec 13, 2024
00ab552
Update GamesFragment.kt
Ishan09811 Dec 13, 2024
3556b50
correct save_file, etc file path for android
Ishan09811 Dec 14, 2024
0b4f430
Add default games icon
Ishan09811 Dec 18, 2024
85db4a7
Update app_item.xml
Ishan09811 Dec 18, 2024
b42550d
Update EnhancedNativeActivity.java
Ishan09811 Dec 18, 2024
3ff39f4
Fix
Ishan09811 Dec 18, 2024
6574f65
Update EnhancedNativeActivity.java
Ishan09811 Dec 19, 2024
ef7e1f3
Update main.c
Ishan09811 Dec 19, 2024
115c426
Update main.c
Ishan09811 Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/deploy_android_kotlin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Android Kotlin
on: [push,pull_request,workflow_dispatch]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@master

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'

- name: Set up cache
uses: actions/[email protected]
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
${{ github.workspace }}/.ccache
key: ${{ runner.os }}-android-${{ github.sha }}
restore-keys: |
${{ runner.os }}-android-

- name: Build Release apk
run: |
sudo apt-get install ccache
export NDK_CCACHE=$(which ccache)
cd tools/android_project_kotlin/
chmod +x ./gradlew && ./gradlew assembleRelease
ls app/build/outputs/apk/release/
ccache -s -v

- name: GH Release 🚀
# You may pin to the exact commit or the version.
uses: actions/upload-artifact@v4
with:
name: AndroidRelease
path: tools/android_project_kotlin/app/build/outputs/apk/release/com.sky.SkyEmu-*-release.apk


9 changes: 9 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,14 @@ void se_load_search_paths(){
char settings_path[SB_FILE_PATH_SIZE];
snprintf(settings_path,SB_FILE_PATH_SIZE,"%ssearch_paths.bin",se_get_pref_path());
if(!sb_load_file_data_into_buffer(settings_path,(void*)&gui_state.paths,sizeof(gui_state.paths)))memset(&gui_state.paths,0,sizeof(gui_state.paths));

#ifdef PLATFORM_ANDROID
const char *android_private_path = "/data/data/com.sky.SkyEmu/files/";
snprintf(gui_state.paths.save, SB_FILE_PATH_SIZE, "%s/save/", android_private_path);
snprintf(gui_state.paths.bios, SB_FILE_PATH_SIZE, "%s/bios/", android_private_path);
snprintf(gui_state.paths.cheat_codes, SB_FILE_PATH_SIZE, "%s/cheat_codes/", android_private_path);
#endif

char * paths[]={
gui_state.paths.save,
gui_state.paths.bios,
Expand Down Expand Up @@ -8367,6 +8375,7 @@ static void headless_mode(){
void Java_com_sky_SkyEmu_EnhancedNativeActivity_se_1android_1load_1rom(JNIEnv *env, jobject thiz, jstring filePath) {
const char *nativeFilePath = (*env)->GetStringUTFChars(env, filePath, 0);
gui_state.ran_from_launcher=true;
gui_state.settings.save_to_path = true;
se_load_rom(nativeFilePath);
(*env)->ReleaseStringUTFChars(env, filePath, nativeFilePath);
}
Expand Down
52 changes: 52 additions & 0 deletions tools/android_project_kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
Native Activity
===============
Native Activity is an Android sample that initializes a GLES 2.0 context and reads accelerometer data from C code using [Native Activity](http://developer.android.com/reference/android/app/NativeActivity.html).

This sample uses the new [Android Studio CMake plugin](http://tools.android.com/tech-docs/external-c-builds) with C++ support.

Pre-requisites
--------------
- Android Studio 2.2+ with [NDK](https://developer.android.com/ndk/) bundle.

Getting Started
---------------
1. [Download Android Studio](http://developer.android.com/sdk/index.html)
1. Launch Android Studio.
1. Open the sample directory.
1. Open *File/Project Structure...*
- Click *Download* or *Select NDK location*.
1. Click *Tools/Android/Sync Project with Gradle Files*.
1. Click *Run/Run 'app'*.

Screenshots
-----------
![screenshot](screenshot.png)

Support
-------
If you've found an error in these samples, please [file an issue](https://github.com/googlesamples/android-ndk/issues/new).

Patches are encouraged, and may be submitted by [forking this project](https://github.com/googlesamples/android-ndk/fork) and
submitting a pull request through GitHub. Please see [CONTRIBUTING.md](../CONTRIBUTING.md) for more details.

- [Stack Overflow](http://stackoverflow.com/questions/tagged/android-ndk)
- [Android Tools Feedbacks](http://tools.android.com/feedback)

License
-------
Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
93 changes: 93 additions & 0 deletions tools/android_project_kotlin/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("kotlin-parcelize")
kotlin("plugin.serialization") version "2.1.0"
id("androidx.navigation.safeargs.kotlin")
}

android {
signingConfigs {
create("release") {
storePassword = "skyemu-super-secure-password"
keyAlias = "skyemu-open-code-certificate"
keyPassword = "skyemu-super-secure-password"
storeFile = file("../skyemu-open-signing-store")
}
}
namespace = "com.sky.SkyEmu"
compileSdk = 34
ndkVersion = "22.1.7171670"

defaultConfig {
signingConfig = signingConfigs.getByName("release")
applicationId = "com.sky.SkyEmu"
minSdk = 28
targetSdk = 34
versionCode = 32
versionName = "v3.2"
setProperty("archivesBaseName", "$applicationId-v$versionCode")
externalNativeBuild {
cmake {
arguments += listOf(
"-DANDROID_STL=c++_static",
"-DANDROID=1",
"-DNDK_DEBUG=0",
"-DCMAKE_BUILD_TYPE=RELWITHDEBINFO",
"-DANDROID_ARM_NEON=TRUE"
)
targets += "SkyEmu"
}
}
ndk {
abiFilters += listOf("arm64-v8a")
}
}

buildTypes {
getByName("release") {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android.txt"),
"proguard-rules.pro"
)
}
}

externalNativeBuild {
cmake {
version = "3.18.1"
path = file("../../../CMakeLists.txt")
}
}

buildFeatures {
viewBinding = true
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}
}

dependencies {
implementation(fileTree("libs") { include("*.jar") })
implementation("androidx.activity:activity-ktx:1.9.3")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("androidx.documentfile:documentfile:1.0.1")
implementation("androidx.fragment:fragment-ktx:1.8.5")
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.8.7")
implementation("androidx.navigation:navigation-fragment-ktx:2.8.4")
implementation("androidx.navigation:navigation-ui-ktx:2.8.4")
implementation("androidx.preference:preference-ktx:1.2.1")
implementation("androidx.recyclerview:recyclerview:1.3.2")
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.browser:browser:1.5.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
}
18 changes: 18 additions & 0 deletions tools/android_project_kotlin/app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"version": 2,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "com.sky.SkyEmu",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"versionCode": 0,
"versionName": "",
"outputFile": "app-release.apk"
}
]
}
120 changes: 120 additions & 0 deletions tools/android_project_kotlin/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.sky.SkyEmu">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature android:glEsVersion="0x00030000" android:required="true" />

<application
android:name="com.sky.SkyEmu.SkyEmuApplication"
android:requestLegacyExternalStorage="true"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:roundIcon="@mipmap/ic_launcher_round"
android:label="@string/app_name"
android:supportsRtl="true"
tools:targetApi="34"
android:theme="@style/Theme.SkyEmu.Main">
<!-- Declare your content provider -->
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>
<activity
android:name="com.sky.SkyEmu.MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.sky.SkyEmu.EnhancedNativeActivity"
android:exported="true"
android:label="@string/app_name"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout"
android:windowSoftInputMode="stateHidden|adjustPan|adjustNothing"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="skyemu" android:host="oauth" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.OPENABLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="*/*" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.gba" />
<data android:pathPattern=".*\\..*\\.gba" />
<data android:pathPattern=".*\\..*\\..*\\.gba" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gba" />
<data android:pathPattern=".*\\.gbc" />
<data android:pathPattern=".*\\..*\\.gbc" />
<data android:pathPattern=".*\\..*\\..*\\.gbc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gbc" />
<data android:pathPattern=".*\\.gb" />
<data android:pathPattern=".*\\..*\\.gb" />
<data android:pathPattern=".*\\..*\\..*\\.gb" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gb" />

<data android:pathPattern=".*\\.nds" />
<data android:pathPattern=".*\\..*\\.nds" />
<data android:pathPattern=".*\\..*\\..*\\.nds" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.nds" />

<data android:pathPattern=".*\\.zip" />
<data android:pathPattern=".*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.zip" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.OPENABLE" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="*/*" />
<data android:host="*" />
<data android:scheme="content" />
<data android:pathPattern=".*\\.gba" />
<data android:pathPattern=".*\\..*\\.gba" />
<data android:pathPattern=".*\\..*\\..*\\.gba" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gba" />
<data android:pathPattern=".*\\.gbc" />
<data android:pathPattern=".*\\..*\\.gbc" />
<data android:pathPattern=".*\\..*\\..*\\.gbc" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gbc" />
<data android:pathPattern=".*\\.gb" />
<data android:pathPattern=".*\\..*\\.gb" />
<data android:pathPattern=".*\\..*\\..*\\.gb" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.gb" />

<data android:pathPattern=".*\\.nds" />
<data android:pathPattern=".*\\..*\\.nds" />
<data android:pathPattern=".*\\..*\\..*\\.nds" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.nds" />

<data android:pathPattern=".*\\.zip" />
<data android:pathPattern=".*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\.zip" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.zip" />
</intent-filter>



<meta-data
android:name="android.app.lib_name"
android:value="SkyEmu" />
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.sky.SkyEmu;
import android.content.Context;
import android.view.inputmethod.InputMethodManager;
public class EnhancedNativeActivity extends android.app.NativeActivity {
private static final String TAG = "EnhancedNativeActivity";
public void print_hello(){
android.util.Log.v(TAG, "Hello World\n");
}
public void showKeyboard() {
InputMethodManager imm = ( InputMethodManager )getSystemService( Context.INPUT_METHOD_SERVICE );
imm.showSoftInput( this.getWindow().getDecorView(), InputMethodManager.SHOW_FORCED );
}
public void hideKeyboard(){
InputMethodManager imm = ( InputMethodManager )getSystemService( Context.INPUT_METHOD_SERVICE );
imm.hideSoftInputFromWindow( this.getWindow().getDecorView().getWindowToken(), 0 );
}
}
Loading