Use DocumentsProvider.getContext() to get context

This must have been an oversight when implementing the documents
provider (6d714bbf0d). There is a
method on DocumentsProvider that gives us access to the context, so
trying to get it via the Application is unnecessary, and we can delete
that code. Apparently this also fixes the mysterious crashes when
opening the file manager the first few times.

Change-Id: Iab674e05104a7c895a2df2a2fcf9d0f1942f125b
This commit is contained in:
hikari_no_yume
2025-06-29 20:33:35 +02:00
parent d671600d78
commit 7aedb6c9f7
4 changed files with 5 additions and 27 deletions

View File

@@ -65,6 +65,7 @@ Usability:
- The new `--disable-analog-stick-tilt-controls` option can be used to disable the use of the game controller's analog sticks for accelerometer simulation. This is useful on devices with both an integrated game controller and an integrated accelerometer, as touchHLE by default will only use the real accelerometer if no game controller is detected. (@hikari-no-yume)
- Android builds and releases of touchHLE now have an icon and meaningful version metadata. They also now use a different package name for preview builds versus releases, which means you can install them side-by-side. (@hikari-no-yume)
- macOS builds and releases of touchHLE now come as an application bundle (`.app` directory) rather than as a bare “Unix executable” file. This should fix problems some users encountered with running touchHLE outside of a terminal, and allows putting touchHLE in the Applications folder like a normal graphical app. To support this, user data (apps, options, etc) is now stored in “Application Support” rather than the current directory, and the bundled files (fonts, dylibs, etc) are now part of the app bundle. If you prefer the old layout, you can still get it if you move all the files out of the bundle. (@hikari-no-yume)
- The “Open file manager” button on Android now works more reliably, especially the first time it is tapped. (@hikari-no-yume)
- The new `--force-composition=` option has been added, which is a workaround that may solve rendering issues in some games, at the cost of performance. For some games it is applied by the default options. (@ciciplusplus)
- touchHLE now writes log messages to a file on all platforms, not just on Android. The file has been renamed from `log.txt` to `touchHLE_log.txt`. (@hikari-no-yume)

View File

@@ -57,7 +57,6 @@
<!-- <uses-permission android:name="android.permission.RECORD_AUDIO" /> -->
<application
android:name="org.touchhle.android.touchHLEApplication"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="${icon}"

View File

@@ -23,10 +23,6 @@ import android.webkit.MimeTypeMap
//import emu.skyline.getPublicFilesDir
import java.io.*
fun getBaseDirectory() : File {
return touchHLEApplication.getContext().getExternalFilesDir(null)!!
}
class DocumentsProvider : DocumentsProvider() {
//private val baseDirectory = File(SkylineApplication.instance.getPublicFilesDir().canonicalPath)
//private val baseDirectory = Environment.getExternalStorageDirectory()
@@ -58,6 +54,10 @@ class DocumentsProvider : DocumentsProvider() {
const val ROOT_ID : String = "root"
}
private fun getBaseDirectory() : File {
return context!!.getExternalFilesDir(null)!!
}
override fun onCreate() : Boolean {
return true
}

View File

@@ -1,22 +0,0 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package org.touchhle.android;
import android.app.Application;
import android.content.Context;
public class touchHLEApplication extends Application {
private static touchHLEApplication instance;
public void onCreate() {
super.onCreate();
instance = this;
}
public static Context getContext() {
return instance.getApplicationContext();
}
}