-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Command line arguments and custom content support as well as changed …
…target API level to 28 to avoid warnings on newer devicees
- Loading branch information
Showing
5 changed files
with
169 additions
and
59 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 |
---|---|---|
|
@@ -7,3 +7,5 @@ APP_ABI := all | |
|
||
# Min SDK level | ||
APP_PLATFORM=android-14 | ||
|
||
APP_STL := c++_shared |
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
84 changes: 84 additions & 0 deletions
84
android/app/src/main/java/io/github/h4mu/rott94/rott94Activity.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 |
---|---|---|
@@ -1,7 +1,91 @@ | ||
/* | ||
Copyright (C) 2014-2019 Tamas Hamor | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
See the GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program; if not, write to the Free Software | ||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
*/ | ||
package io.github.h4mu.rott94; | ||
|
||
import android.database.Cursor; | ||
import android.net.Uri; | ||
import android.provider.MediaStore; | ||
|
||
import org.libsdl.app.SDLActivity; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class rott94Activity extends SDLActivity | ||
{ | ||
@Override | ||
protected String[] getArguments() { | ||
List<String> arguments = new ArrayList<>(); | ||
File filesDir = getExternalFilesDir(null); | ||
if (filesDir == null) { | ||
filesDir = getFilesDir(); | ||
} | ||
File cmdLine = new File(filesDir.getAbsolutePath() + File.separator + "arguments.txt"); | ||
if (cmdLine.canRead()) { | ||
try { | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(cmdLine))); | ||
try { | ||
String line = reader.readLine(); | ||
if (line != null) { | ||
arguments.addAll(Arrays.asList(line.split(" "))); | ||
} | ||
} finally { | ||
reader.close(); | ||
} | ||
} catch (java.io.IOException ignored) { | ||
} | ||
} | ||
Uri data = getIntent().getData(); | ||
if (data != null) { | ||
String[] projection = { MediaStore.Images.Media.DATA }; | ||
Cursor cursor = getContentResolver().query(data, projection, null, null, null); | ||
if (cursor != null) { | ||
try { | ||
int column_index = cursor.getColumnIndex(projection[0]); | ||
if (column_index != -1 && cursor.moveToFirst()) { | ||
String path = cursor.getString(column_index); | ||
if (path != null && path.length() > 4) { | ||
if (path.endsWith(".WAD")) { | ||
arguments.add("FILE"); | ||
arguments.add(path); | ||
} | ||
else if (path.endsWith(".RTL")) { | ||
arguments.add("FILERTL"); | ||
arguments.add(path); | ||
} | ||
else if (path.endsWith(".RTC")) { | ||
arguments.add("FILERTC"); | ||
arguments.add(path); | ||
} | ||
} | ||
} | ||
} finally { | ||
cursor.close(); | ||
} | ||
} | ||
} | ||
return arguments.toArray(new String[0]); | ||
} | ||
} |