Skip to content

Commit

Permalink
Android 14. Gradle 8.1. Lot of Fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
seleuco committed Sep 4, 2023
1 parent 9ba14b0 commit cdef09c
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
apply plugin: 'com.android.application'

android {
//compileSdkVersion 33
compileSdk 33
compileSdk 34

ndkVersion "21.3.6528147"

defaultConfig {
applicationId "com.seleuco.mame4droid"
minSdkVersion 9
targetSdkVersion 33
versionCode 58
versionName '1.16.6'
targetSdkVersion 34
versionCode 59
versionName '1.16.7'
setProperty("archivesBaseName", "MAME4droid 0.139u1-$versionName")
ndk {
moduleName "mame4droid-jni"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/changelog.htm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h3>MAME4droid CHANGELOG<br>
</h3>
DEVELOPMENT:
<ul>
<li><b>2023-08-22 version 1.16</b><br/> Android 13.0 support. Added scoped storage support to read ROMs files from external storage on Android 11+. Added setting to store game states under ROMs folder.</li>
<li><b>2023-08-22 version 1.16</b><br/> Android 14.0 support. Added scoped storage support to read ROMs files from external storage on Android 11+. Added setting to store game states under ROMs folder.</li>
<li><b>2020-09-07 version 1.15</b><br/> Android 10.0 support. Added default landscape layout for ultra wide phones. Improved portrait touch controller. Improved support to open zipped roms directly from file explorers. New builds with latest NDK, clang and libc++. Some bug fixes.</li>
<li><b>2020-01-25 version 1.14</b><br/> Android 9.0. Xbox One bluetooth controller native support. Fixes.</li>
<li><b>2019-05-26 version 1.13</b><br/> Android 8.0 & 64 bits support.</li>
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/seleuco/mame4droid/MAME4droid.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ public void onCreate(Bundle savedInstanceState) {

safHelper = new SAFHelper(this);

if (getPrefsHelper().getSAF_Uri() != null) {
String uri = getPrefsHelper().getSAF_Uri();
safHelper.setURI(uri);
}

fileExplore = new FileExplorer(this);

netPlay = new NetPlay(this);
Expand Down Expand Up @@ -302,11 +307,6 @@ public void runMAME4droid() {
getMainHelper().copyFiles();
getMainHelper().removeFiles();

if (getPrefsHelper().getSAF_Uri() != null) {
String uri = getPrefsHelper().getSAF_Uri();
getSAFHelper().setURI(uri);
}

Emulator.emulate(mainHelper.getLibDir(), mainHelper.getInstallationDIR());
}

Expand Down
25 changes: 15 additions & 10 deletions app/src/main/java/com/seleuco/mame4droid/helpers/DialogHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,12 @@ public void onClick(DialogInterface dialog, int id) {
public void onClick(DialogInterface dialog, int id) {
DialogHelper.savedDialog = DIALOG_NONE;
mm.removeDialog(DIALOG_ROMs_DIR_SDK29);
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_NEW_INTERNAL);
if(mm.getMainHelper().isAndroidTV())
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_MEDIA_FOLDER);
else
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_FILES_DIR);
mm.getPrefsHelper().setROMsDIR("");
mm.getPrefsHelper().setSAF_Uri(null);
mm.getPrefsHelper().setIsNotMigrated(false);
mm.runMAME4droid();
}
Expand All @@ -190,17 +194,18 @@ public void onClick(DialogInterface dialog, int id) {
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
mm.startActivityForResult(intent, MainHelper.REQUEST_CODE_OPEN_DIRECTORY);
//throw new ActivityNotFoundException("TEST");
}
catch(ActivityNotFoundException e){
if(mm.getMainHelper().isAndroidTV() && Build.VERSION.SDK_INT <= 29 )
{
if(mm.CheckPermissions(true)) {
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_NEW_INTERNAL);
} catch (ActivityNotFoundException e) {
if (mm.getMainHelper().isAndroidTV() && Build.VERSION.SDK_INT <= 29) {
if (mm.CheckPermissions(true)) {
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_FILES_DIR);
mm.showDialog(DialogHelper.DIALOG_LOAD_FILE_EXPLORER);
}
}
else {
mm.getDialogHelper().showMessage("Your device doesn't have the native android file manager needed to authorize external storage reading ... Debloated??",
} else {
String msg = "Your device doesn't have the native android file manager needed to authorize external storage reading.";
if (mm.getMainHelper().isAndroidTV())
msg += "\n\nSome Android TV devices don't include the OS document picker which is needed to grant folder permissions for the apps on Android 11+. As an alternative, select default which use the App Media Folder which is supported on all devices and is created at Android/media/[app package name]. Move any emulator files into that folder with a file manager so the app can access them without any special permissions.";

mm.getDialogHelper().showMessage(msg,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Expand Down
21 changes: 17 additions & 4 deletions app/src/main/java/com/seleuco/mame4droid/helpers/MainHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ public class MainHelper {
final public static int DEVICE_ANDROIDTV = 5;

final public static int INSTALLATION_DIR_UNDEFINED = 1;
final public static int INSTALLATION_DIR_NEW_INTERNAL = 2;
final public static int INSTALLATION_DIR_FILES_DIR = 2;
final public static int INSTALLATION_DIR_LEGACY = 3;
final public static int INSTALLATION_DIR_MEDIA_FOLDER = 4;

protected int installationDirType = INSTALLATION_DIR_UNDEFINED;

Expand Down Expand Up @@ -167,10 +168,21 @@ public String getInstallationDIR() {
// android.os.Debug.waitForDebugger();
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
if (getInstallationDirType() == INSTALLATION_DIR_NEW_INTERNAL)
if (getInstallationDirType() == INSTALLATION_DIR_FILES_DIR)
res_dir = mm.getExternalFilesDir(null).getAbsolutePath() + "/";
else if (getInstallationDirType() == INSTALLATION_DIR_LEGACY)
res_dir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/MAME4droid/";
else if (getInstallationDirType() == INSTALLATION_DIR_MEDIA_FOLDER)
{
File[] dirs = mm.getExternalMediaDirs();
for(File d: dirs)
{
if(d != null) {
res_dir = d.getAbsolutePath() + "/";
break;
}
}
}
}
if (res_dir == null)
res_dir = mm.getFilesDir().getAbsolutePath() + "/";
Expand Down Expand Up @@ -869,7 +881,7 @@ public void activityResult(int requestCode, int resultCode, Intent intent) {
if (romsPath == null)
romsPath = "/Your_Selected_Folder";

mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_NEW_INTERNAL);
mm.getMainHelper().setInstallationDirType(MainHelper.INSTALLATION_DIR_FILES_DIR);
mm.getPrefsHelper().setROMsDIR(romsPath);
mm.getPrefsHelper().setSAF_Uri(uri.toString());
mm.getPrefsHelper().setIsNotMigrated(false);
Expand Down Expand Up @@ -1140,7 +1152,8 @@ public void restartApp() {
// System.out.println("OLD INTENT:"+oldintent.getAction());
int flags = oldintent.getFlags();

//flags |= PendingIntent.FLAG_IMMUTABLE;//67108864; //FLAG_IMMUTABLE
if(Build.VERSION.SDK_INT >= 33)//para que no saque error el UI
flags |= PendingIntent.FLAG_IMMUTABLE;//67108864; //FLAG_IMMUTABLE

PendingIntent intent = PendingIntent.getActivity(mm.getBaseContext(),
0, new Intent(oldintent), flags);
Expand Down
23 changes: 19 additions & 4 deletions app/src/main/java/com/seleuco/mame4droid/helpers/SAFHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import android.os.storage.StorageManager;
import android.os.storage.StorageVolume;
import android.provider.DocumentsContract;
import android.util.Log;

import com.seleuco.mame4droid.MAME4droid;

Expand Down Expand Up @@ -81,8 +82,14 @@ public SAFHelper(MAME4droid value) {
}

public String getNextDocumentName() {
if (fileNames == null) return null;
if (idxCurName >= fileNames.size()) return null;
if (fileNames == null)//safety
{
listUriFiles(true);
}
if (idxCurName >= fileNames.size()) {
idxCurName=0;//safety
return null;
}
String name = fileNames.get(idxCurName);
idxCurName++;
return name;
Expand All @@ -91,7 +98,10 @@ public String getNextDocumentName() {
public int openRomUriFd(String pathName, String flags) {
//System.out.println("openRomUriFd "+pathName+" "+flags);

if (fileIDs == null) return -1;
if (fileIDs == null) {//safety
//return -1;
listUriFiles(true);
}

String fileid = null;

Expand Down Expand Up @@ -173,11 +183,16 @@ private String retrieveDirId(String path) {
public boolean listUriFiles(Boolean reload) {
idxCurName = 0;

if (fileIDs != null && fileNames != null && !reload) return true;
if (fileIDs != null && fileNames != null && fileNames.size()!=0 && !reload) return true;

fileIDs = new Hashtable<String, String>();
fileNames = new ArrayList<String>();

if(uri==null){
Log.e("SAF","SAF URI NOT SET!!!");
return true;
}

String id = DocumentsContract.getTreeDocumentId(uri);
fileIDs.put("/", id);

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/seleuco/mame4droid/prefs/ListKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
int androidGamePadID = data.getIntExtra("androidGamePadID", 0);
int iKeyCodeWithDeviceId = InputHandler.makeKeyCodeWithDeviceID(androidGamePadID, androidKeyCode);

for (int i = 0; i < InputHandler.keyMapping.length; i++)
for (int i = 0; i < InputHandler.keyMapping.length; i++) {
//if (InputHandler.keyMapping[i] == androidKeyCode)
if (InputHandler.keyMapping[i] == iKeyCodeWithDeviceId)
InputHandler.keyMapping[i] = -1;
}

//InputHandler.keyMapping[(playerIndex * emulatorInputLabels.length)+ emulatorInputIndex] = androidKeyCode;
InputHandler.keyMapping[(playerIndex * emulatorInputLabels.length)+ emulatorInputIndex] = iKeyCodeWithDeviceId;
Expand Down
13 changes: 11 additions & 2 deletions app/src/main/java/com/seleuco/mame4droid/views/InputView.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,17 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightSize = 1;

if (mm.getMainHelper().getscrOrientation() == Configuration.ORIENTATION_LANDSCAPE) {
widthSize = mm.getWindowManager().getDefaultDisplay().getWidth();
heightSize = mm.getWindowManager().getDefaultDisplay().getHeight();

/*if(!mm.getPrefsHelper().isNotchUsed())
{
widthSize = mm.getWindowManager().getDefaultDisplay().getWidth();
heightSize = mm.getWindowManager().getDefaultDisplay().getHeight();
}
else {*/
widthSize = MeasureSpec.getSize(widthMeasureSpec);
heightSize = MeasureSpec.getSize(heightMeasureSpec);
//}

} else {
int w = 1;//320;
int h = 1;//240;
Expand Down
46 changes: 23 additions & 23 deletions app/src/main/res/raw-large/controller_landscape.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
1,0,0,0,1280,752 //800 //main rect
2,1,0,459,90,85 //upleft
2,2,90,447,70,96 //up
2,3,160,459,90,85 //upright
2,4,0,544,125,67 //left
2,5,125,544,125,67 //right
2,6,0,611,90,85 //downleft
2,7,90,611,70,96 //down
2,8,160,611,90,85 //downright
3,2,1170,485,125,125 //A
3,3,1075,580,125,125 //B
3,1,980,485,125,125 //C
3,0,1075,390,125,125 //D
3,4,885,580,125,125 //E
3,5,1165,295,125,125 //F
1,0,0,0,1280,800 //main rect -> 1,6 -> 5/3
2,1,0,559,90,85 //upleft
2,2,90,547,70,96 //up
2,3,160,559,90,85 //upright
2,4,0,644,125,67 //left
2,5,125,644,125,67 //right
2,6,0,711,90,85 //downleft
2,7,90,711,70,96 //down
2,8,160,711,90,85 //downright
3,2,1170,585,125,125 //A
3,3,1075,680,125,125 //B
3,1,980,585,125,125 //C
3,0,1075,490,125,125 //D
3,4,885,680,125,125 //E
3,5,1165,395,125,125 //F
3,6,0,0,117,58 //exit
3,7,1163,0,117,58 //option
3,8,0,60,117,58 //coin
3,9,1163,60,117,58 //start
4,0,10,460,230,230 //DPAD img
5,2,1175,490,115,115 //A img
5,3,1080,585,115,115 //B img
5,1,985,490,115,115 //C img
5,0,1080,395,115,115 //D img
5,4,900,585,115,115 //E img
5,5,1170,300,115,115 //F img
4,0,10,560,230,230 //DPAD img
5,2,1175,590,115,115 //A img
5,3,1080,685,115,115 //B img
5,1,985,590,115,115 //C img
5,0,1080,495,115,115 //D img
5,4,900,685,115,115 //E img
5,5,1170,400,115,115 //F img
5,6,0,0,117,58 //exit img
5,7,1163,0,117,58 //option img
5,8,0,60,117,58 //coin img
5,9,1163,60,117,58 //start img
8,0,10,460,230,230 //analog stick area
8,0,10,560,230,230 //analog stick area
7,150
3 changes: 2 additions & 1 deletion app/src/main/res/raw-large/controller_landscape_16_9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1,0,0,0,1280,672 //720 //main rect
1,0,0,0,1280,752 //main rect -> 1,7 -> 16/9
2,1,0,459,90,85 //upleft
2,2,90,447,70,96 //up
2,3,160,459,90,85 //upright
Expand Down Expand Up @@ -30,3 +30,4 @@
5,9,1163,60,117,58 //start img
8,0,10,460,230,230 //analog stick area
7,150

2 changes: 1 addition & 1 deletion app/src/main/res/raw-large/controller_landscape_19_9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1,0,0,0,1280,672 //720 //main rect
1,0,0,0,1280,672 //720 //main rect -> 1,9 -> 19/10
2,1,0,459,90,85 //upleft
2,2,90,447,70,96 //up
2,3,160,459,90,85 //upright
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/controller_landscape.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1,0,0,0,800,480 //main rect
1,0,0,0,800,480 //main rect -> 1,6 -> 5/3
2,1,0,255,75,70 //upleft
2,2,75,255,70,70 //up
2,3,145,255,140,70 //upright
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/controller_landscape_16_9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1,0,0,0,853,480 //main rect
1,0,0,0,853,480 //main rect -> 1,7 -> 16/9
2,1,0,255,75,70 //upleft
2,2,75,255,70,70 //up
2,3,145,255,140,70 //upright
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/controller_landscape_19_9.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
1,0,0,0,1013,480 //main rect
1,0,0,0,1013,480 //main rect -> 2,11 -> 19 /9
2,1,0,255,75,70 //upleft
2,2,75,255,70,70 //up
2,3,145,255,140,70 //upright
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath 'com.android.tools.build:gradle:8.1.1'
}
}

Expand Down
4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#android.bundle.enableUncompressedNativeLibs=false
android.defaults.buildfeatures.buildconfig=true
android.nonFinalResIds=false
android.nonTransitiveRClass=false
org.gradle.unsafe.configuration-cache=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit cdef09c

Please sign in to comment.