mirror of
https://github.com/DrBeef/QuakeQuest.git
synced 2024-11-21 11:40:59 +00:00
Proper External SDCARD access
No need to use scoped storage
This commit is contained in:
parent
cf5f737f53
commit
c9922b1d94
4 changed files with 32 additions and 71 deletions
|
@ -1,8 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.drbeef.quakequest"
|
package="com.drbeef.quakequest"
|
||||||
android:versionCode="25"
|
android:versionCode="26"
|
||||||
android:versionName="1.5.6"
|
android:versionName="1.5.7"
|
||||||
android:installLocation="auto" >
|
android:installLocation="auto" >
|
||||||
|
|
||||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||||
|
@ -14,7 +14,7 @@
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
|
|
@ -33,7 +33,9 @@ android {
|
||||||
abiFilters 'arm64-v8a'
|
abiFilters 'arm64-v8a'
|
||||||
}
|
}
|
||||||
ndkBuild {
|
ndkBuild {
|
||||||
abiFilters 'arm64-v8a'
|
def numProcs = Runtime.runtime.availableProcessors()
|
||||||
|
arguments "V=0", "-j$numProcs", "-C$project.buildDir.parent", "APP_PLATFORM=android-29", "NDK_TOOLCHAIN_VERSION=clang", "APP_STL=c++_static"
|
||||||
|
abiFilters 'arm64-v8a'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3597,7 +3597,7 @@ static void M_Credits_Draw (void)
|
||||||
" QQQQQQQQ QQQQQQQQ ",
|
" QQQQQQQQ QQQQQQQQ ",
|
||||||
" QQQ QQQ ",
|
" QQQ QQQ ",
|
||||||
" Q Q ",
|
" Q Q ",
|
||||||
" Q Q v1.5.6");
|
" Q Q v1.5.7");
|
||||||
|
|
||||||
int i, l, linelength, firstline, lastline, lines;
|
int i, l, linelength, firstline, lastline, lines;
|
||||||
for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_credits_message[i];i++)
|
for (i = 0, linelength = 0, firstline = 9999, lastline = -1;m_credits_message[i];i++)
|
||||||
|
|
|
@ -16,11 +16,15 @@ import java.util.Locale;
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
|
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Environment;
|
||||||
|
import android.provider.Settings;
|
||||||
import android.system.ErrnoException;
|
import android.system.ErrnoException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
@ -57,31 +61,25 @@ import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
private static final String TAG = "QuakeQuest";
|
private static final String TAG = "QuakeQuest";
|
||||||
|
|
||||||
private int permissionCount = 0;
|
|
||||||
private static final int READ_EXTERNAL_STORAGE_PERMISSION_ID = 1;
|
|
||||||
private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_ID = 2;
|
|
||||||
|
|
||||||
String commandLineParams;
|
String commandLineParams;
|
||||||
|
|
||||||
private SurfaceView mView;
|
private SurfaceHolder mSurfaceHolder;
|
||||||
private SurfaceHolder mSurfaceHolder;
|
|
||||||
private long mNativeHandle;
|
private long mNativeHandle;
|
||||||
|
|
||||||
String dir;
|
String dir;
|
||||||
|
|
||||||
private final boolean m_asynchronousTracking = false;
|
|
||||||
|
|
||||||
@Override protected void onCreate( Bundle icicle )
|
@Override protected void onCreate( Bundle icicle )
|
||||||
{
|
{
|
||||||
Log.v( TAG, "----------------------------------------------------------------" );
|
Log.v( TAG, "----------------------------------------------------------------" );
|
||||||
Log.v( TAG, "GLES3JNIActivity::onCreate()" );
|
Log.v( TAG, "GLES3JNIActivity::onCreate()" );
|
||||||
super.onCreate( icicle );
|
super.onCreate( icicle );
|
||||||
|
|
||||||
mView = new SurfaceView( this );
|
SurfaceView mView = new SurfaceView(this);
|
||||||
setContentView( mView );
|
setContentView(mView);
|
||||||
mView.getHolder().addCallback( this );
|
mView.getHolder().addCallback( this );
|
||||||
|
|
||||||
dir = getBaseContext().getExternalFilesDir(null).getAbsolutePath();
|
dir = "/sdcard/QuakeQuest";
|
||||||
|
//dir = getBaseContext().getExternalFilesDir(null).getAbsolutePath();
|
||||||
|
|
||||||
// Force the screen to stay on, rather than letting it dim and shut off
|
// Force the screen to stay on, rather than letting it dim and shut off
|
||||||
// while the user is watching a movie.
|
// while the user is watching a movie.
|
||||||
|
@ -97,76 +95,37 @@ import android.support.v4.content.ContextCompat;
|
||||||
|
|
||||||
/** Initializes the Activity only if the permission has been granted. */
|
/** Initializes the Activity only if the permission has been granted. */
|
||||||
private void checkPermissionsAndInitialize() {
|
private void checkPermissionsAndInitialize() {
|
||||||
// Boilerplate for checking runtime permissions in Android.
|
if (!Environment.isExternalStorageManager()) {
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
//request for the permission
|
||||||
!= PackageManager.PERMISSION_GRANTED){
|
Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION);
|
||||||
ActivityCompat.requestPermissions(
|
Uri uri = Uri.fromParts("package", getPackageName(), null);
|
||||||
GLES3JNIActivity.this,
|
intent.setData(uri);
|
||||||
new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
|
startActivityForResult(intent, 1);
|
||||||
WRITE_EXTERNAL_STORAGE_PERMISSION_ID);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
permissionCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED)
|
|
||||||
{
|
|
||||||
ActivityCompat.requestPermissions(
|
|
||||||
GLES3JNIActivity.this,
|
|
||||||
new String[] {Manifest.permission.READ_EXTERNAL_STORAGE},
|
|
||||||
READ_EXTERNAL_STORAGE_PERMISSION_ID);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
permissionCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (permissionCount == 2) {
|
|
||||||
// Permissions have already been granted.
|
// Permissions have already been granted.
|
||||||
try {
|
create();
|
||||||
create();
|
|
||||||
} catch (Exception ignored)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Handles the user accepting the permission. */
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] results) {
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
if (requestCode == READ_EXTERNAL_STORAGE_PERMISSION_ID) {
|
create();
|
||||||
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
permissionCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (requestCode == WRITE_EXTERNAL_STORAGE_PERMISSION_ID) {
|
|
||||||
if (results.length > 0 && results[0] == PackageManager.PERMISSION_GRANTED) {
|
|
||||||
permissionCount++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkPermissionsAndInitialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void create() throws ErrnoException {
|
public void create() {
|
||||||
//This will copy the shareware version of quake if user doesn't have anything installed
|
//This will copy the shareware version of quake if user doesn't have anything installed
|
||||||
copy_asset(dir + "/id1", "pak0.pak");
|
copy_asset(dir + "/id1", "pak0.pak");
|
||||||
copy_asset(dir + "/id1", "config.cfg");
|
copy_asset(dir + "/id1", "config.cfg");
|
||||||
copy_asset(dir, "commandline.txt");
|
copy_asset(dir, "commandline.txt");
|
||||||
|
|
||||||
setenv("QUAKEQUEST_DIR", dir, true);
|
try {
|
||||||
|
setenv("QUAKEQUEST_DIR", dir, true);
|
||||||
|
} catch (Exception ignored)
|
||||||
|
{
|
||||||
|
System.exit(-9);;
|
||||||
|
}
|
||||||
|
|
||||||
//Read these from a file and pass through
|
//Read these from a file and pass through
|
||||||
commandLineParams = new String("quake");
|
commandLineParams = new String("quake");
|
||||||
|
|
Loading…
Reference in a new issue