Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ DEADJOE
.#*
*.jar
*.zip
*.aab
*.apk
*.jks
*.keystore
bin/
gen/
bin/*
Expand All @@ -18,3 +21,13 @@ build.xml
assets/build.properties
.settings/
.settings/*
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
62 changes: 0 additions & 62 deletions AndroidManifest.xml

This file was deleted.

1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
38 changes: 38 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
plugins {
alias(libs.plugins.android.application)
}

android {
namespace 'de.onyxbits.textfiction'
compileSdk 35

defaultConfig {
applicationId "de.onyxbits.textfiction"
minSdk 24
targetSdk 33
versionCode 12
versionName "3.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
}

dependencies {

implementation libs.appcompat
implementation libs.material
testImplementation libs.junit
androidTestImplementation libs.ext.junit
androidTestImplementation libs.espresso.core
}
21 changes: 21 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
54 changes: 54 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Nemo" >
<activity
android:exported="true"
android:name=".MainActivity"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="file" />
<data android:host="*" />
<data android:pathPattern=".*\\.z3" />
<data android:pathPattern=".*\\.z5" />
<data android:pathPattern=".*\\.z8" />
<data android:pathPattern=".*\\.zblorb" />
</intent-filter>
</activity>
<activity
android:name="de.onyxbits.textfiction.GameActivity"
android:label="@string/title_activity_game"
android:parentActivityName=".MainActivity"
android:windowSoftInputMode="stateAlwaysHidden" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<activity
android:name="de.onyxbits.textfiction.SettingActivity"
android:theme="@style/AppTheme"
android:parentActivityName=".MainActivity"
android:label="@string/title_activity_setting" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
import java.util.Arrays;
import java.util.Comparator;

import android.content.ContentResolver;
import android.database.Cursor;
import android.net.Uri;
import android.os.Environment;
import android.provider.OpenableColumns;

public class FileUtil implements Comparator<File> {

Expand Down Expand Up @@ -43,7 +47,8 @@ public class FileUtil implements Comparator<File> {
* Just make sure we got all of our directories.
*/
static {
File root = Environment.getExternalStorageDirectory();
// File root = Environment.getExternalStorageDirectory();
File root = MainActivity.appContext().getExternalFilesDir(null);
library = new File(new File(root, HOMEDIR), GAMEDIR);
saves = new File(new File(root, HOMEDIR), SAVEDIR);
data = new File(new File(root, HOMEDIR), DATADIR);
Expand Down Expand Up @@ -115,11 +120,32 @@ public FileUtil() {
* @throws IOException
* if something goes wrong
*/
public static void importGame(File src) throws IOException {
public static void importGame(Uri src) throws IOException {
ensureDirs();
File dst = new File(library, src.getName());
FileInputStream fin;
File dst;
if (src != null && src.getScheme().equals(ContentResolver.SCHEME_FILE)) {
File from = new File(src.getPath());
dst = new File(library, from.getName());
fin = new FileInputStream(from);
} else if(src != null && src.getScheme().equals(ContentResolver.SCHEME_CONTENT)) {
Cursor uCursor = MainActivity.appContext().getContentResolver().query(src, null, null, null, null);
String fName = "";
if (uCursor != null && uCursor.moveToFirst()) {
int nameIndex = uCursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
int sizeIndex = uCursor.getColumnIndex(OpenableColumns.SIZE);
fName = uCursor.getString(nameIndex);
}
assert uCursor != null;
uCursor.close();
dst = new File(library, fName);
fin = new FileInputStream(MainActivity.appContext().getContentResolver().openFileDescriptor(src, "r").getFileDescriptor());
}
else {
return;
}
byte[] buf = new byte[1024];
FileInputStream fin = new FileInputStream(src);
//FileInputStream fin = new FileInputStream(from);
FileOutputStream fout = new FileOutputStream(dst);

int len;
Expand Down
Loading