From 95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf Mon Sep 17 00:00:00 2001 From: Charles Lombardo Date: Sat, 11 Mar 2023 00:40:07 -0500 Subject: android: Convert YuzuApplication to Kotlin --- .../java/org/yuzu/yuzu_emu/YuzuApplication.java | 59 ---------------------- .../main/java/org/yuzu/yuzu_emu/YuzuApplication.kt | 56 ++++++++++++++++++++ 2 files changed, 56 insertions(+), 59 deletions(-) delete mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.java create mode 100644 src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt (limited to 'src') diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.java b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.java deleted file mode 100644 index 830d0b18c..000000000 --- a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.java +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2019 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -package org.yuzu.yuzu_emu; - -import android.app.Application; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.content.Context; -import android.os.Build; - -import org.yuzu.yuzu_emu.model.GameDatabase; -import org.yuzu.yuzu_emu.utils.DocumentsTree; -import org.yuzu.yuzu_emu.utils.DirectoryInitialization; -import org.yuzu.yuzu_emu.utils.GpuDriverHelper; - -public class YuzuApplication extends Application { - public static GameDatabase databaseHelper; - public static DocumentsTree documentsTree; - private static YuzuApplication application; - - private void createNotificationChannel() { - // Create the NotificationChannel, but only on API 26+ because - // the NotificationChannel class is new and not in the support library - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - CharSequence name = getString(R.string.app_notification_channel_name); - String description = getString(R.string.app_notification_channel_description); - NotificationChannel channel = new NotificationChannel(getString(R.string.app_notification_channel_id), name, NotificationManager.IMPORTANCE_LOW); - channel.setDescription(description); - channel.setSound(null, null); - channel.setVibrationPattern(null); - // Register the channel with the system; you can't change the importance - // or other notification behaviors after this - NotificationManager notificationManager = getSystemService(NotificationManager.class); - notificationManager.createNotificationChannel(channel); - } - } - - @Override - public void onCreate() { - super.onCreate(); - application = this; - documentsTree = new DocumentsTree(); - - DirectoryInitialization.start(getApplicationContext()); - GpuDriverHelper.initializeDriverParameters(getApplicationContext()); - NativeLibrary.LogDeviceInfo(); - - // TODO(bunnei): Disable notifications until we support app suspension. - //createNotificationChannel(); - - databaseHelper = new GameDatabase(this); - } - - public static Context getAppContext() { - return application.getApplicationContext(); - } -} diff --git a/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt new file mode 100644 index 000000000..f46ced685 --- /dev/null +++ b/src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt @@ -0,0 +1,56 @@ +package org.yuzu.yuzu_emu + +import android.app.Application +import android.app.NotificationChannel +import android.app.NotificationManager +import android.content.Context +import org.yuzu.yuzu_emu.model.GameDatabase +import org.yuzu.yuzu_emu.utils.DirectoryInitialization.start +import org.yuzu.yuzu_emu.utils.DocumentsTree +import org.yuzu.yuzu_emu.utils.GpuDriverHelper + +class YuzuApplication : Application() { + private fun createNotificationChannel() { + // Create the NotificationChannel, but only on API 26+ because + // the NotificationChannel class is new and not in the support library + val name: CharSequence = getString(R.string.app_notification_channel_name) + val description = getString(R.string.app_notification_channel_description) + val channel = NotificationChannel( + getString(R.string.app_notification_channel_id), + name, + NotificationManager.IMPORTANCE_LOW + ) + channel.description = description + channel.setSound(null, null) + channel.vibrationPattern = null + // Register the channel with the system; you can't change the importance + // or other notification behaviors after this + val notificationManager = getSystemService(NotificationManager::class.java) + notificationManager.createNotificationChannel(channel) + } + + override fun onCreate() { + super.onCreate() + application = this + documentsTree = DocumentsTree() + start(applicationContext) + GpuDriverHelper.initializeDriverParameters(applicationContext) + NativeLibrary.LogDeviceInfo() + + // TODO(bunnei): Disable notifications until we support app suspension. + //createNotificationChannel(); + databaseHelper = GameDatabase(this) + } + + companion object { + var databaseHelper: GameDatabase? = null + + @JvmField + var documentsTree: DocumentsTree? = null + private var application: YuzuApplication? = null + + @JvmStatic + val appContext: Context + get() = application!!.applicationContext + } +} -- cgit v1.2.3