diff options
| author | 2023-03-11 00:40:07 -0500 | |
|---|---|---|
| committer | 2023-06-03 00:05:42 -0700 | |
| commit | 95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf (patch) | |
| tree | b304cdac6cf9350c889851f5e37f5eb6fa8ba169 /src/android | |
| parent | android: Convert Action1 to Kotlin (diff) | |
| download | yuzu-95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf.tar.gz yuzu-95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf.tar.xz yuzu-95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf.zip | |
android: Convert YuzuApplication to Kotlin
Diffstat (limited to 'src/android')
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.java | 59 | ||||
| -rw-r--r-- | src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt | 56 |
2 files changed, 56 insertions, 59 deletions
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 @@ | |||
| 1 | // Copyright 2019 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | package org.yuzu.yuzu_emu; | ||
| 6 | |||
| 7 | import android.app.Application; | ||
| 8 | import android.app.NotificationChannel; | ||
| 9 | import android.app.NotificationManager; | ||
| 10 | import android.content.Context; | ||
| 11 | import android.os.Build; | ||
| 12 | |||
| 13 | import org.yuzu.yuzu_emu.model.GameDatabase; | ||
| 14 | import org.yuzu.yuzu_emu.utils.DocumentsTree; | ||
| 15 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization; | ||
| 16 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper; | ||
| 17 | |||
| 18 | public class YuzuApplication extends Application { | ||
| 19 | public static GameDatabase databaseHelper; | ||
| 20 | public static DocumentsTree documentsTree; | ||
| 21 | private static YuzuApplication application; | ||
| 22 | |||
| 23 | private void createNotificationChannel() { | ||
| 24 | // Create the NotificationChannel, but only on API 26+ because | ||
| 25 | // the NotificationChannel class is new and not in the support library | ||
| 26 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { | ||
| 27 | CharSequence name = getString(R.string.app_notification_channel_name); | ||
| 28 | String description = getString(R.string.app_notification_channel_description); | ||
| 29 | NotificationChannel channel = new NotificationChannel(getString(R.string.app_notification_channel_id), name, NotificationManager.IMPORTANCE_LOW); | ||
| 30 | channel.setDescription(description); | ||
| 31 | channel.setSound(null, null); | ||
| 32 | channel.setVibrationPattern(null); | ||
| 33 | // Register the channel with the system; you can't change the importance | ||
| 34 | // or other notification behaviors after this | ||
| 35 | NotificationManager notificationManager = getSystemService(NotificationManager.class); | ||
| 36 | notificationManager.createNotificationChannel(channel); | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | @Override | ||
| 41 | public void onCreate() { | ||
| 42 | super.onCreate(); | ||
| 43 | application = this; | ||
| 44 | documentsTree = new DocumentsTree(); | ||
| 45 | |||
| 46 | DirectoryInitialization.start(getApplicationContext()); | ||
| 47 | GpuDriverHelper.initializeDriverParameters(getApplicationContext()); | ||
| 48 | NativeLibrary.LogDeviceInfo(); | ||
| 49 | |||
| 50 | // TODO(bunnei): Disable notifications until we support app suspension. | ||
| 51 | //createNotificationChannel(); | ||
| 52 | |||
| 53 | databaseHelper = new GameDatabase(this); | ||
| 54 | } | ||
| 55 | |||
| 56 | public static Context getAppContext() { | ||
| 57 | return application.getApplicationContext(); | ||
| 58 | } | ||
| 59 | } | ||
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 @@ | |||
| 1 | package org.yuzu.yuzu_emu | ||
| 2 | |||
| 3 | import android.app.Application | ||
| 4 | import android.app.NotificationChannel | ||
| 5 | import android.app.NotificationManager | ||
| 6 | import android.content.Context | ||
| 7 | import org.yuzu.yuzu_emu.model.GameDatabase | ||
| 8 | import org.yuzu.yuzu_emu.utils.DirectoryInitialization.start | ||
| 9 | import org.yuzu.yuzu_emu.utils.DocumentsTree | ||
| 10 | import org.yuzu.yuzu_emu.utils.GpuDriverHelper | ||
| 11 | |||
| 12 | class YuzuApplication : Application() { | ||
| 13 | private fun createNotificationChannel() { | ||
| 14 | // Create the NotificationChannel, but only on API 26+ because | ||
| 15 | // the NotificationChannel class is new and not in the support library | ||
| 16 | val name: CharSequence = getString(R.string.app_notification_channel_name) | ||
| 17 | val description = getString(R.string.app_notification_channel_description) | ||
| 18 | val channel = NotificationChannel( | ||
| 19 | getString(R.string.app_notification_channel_id), | ||
| 20 | name, | ||
| 21 | NotificationManager.IMPORTANCE_LOW | ||
| 22 | ) | ||
| 23 | channel.description = description | ||
| 24 | channel.setSound(null, null) | ||
| 25 | channel.vibrationPattern = null | ||
| 26 | // Register the channel with the system; you can't change the importance | ||
| 27 | // or other notification behaviors after this | ||
| 28 | val notificationManager = getSystemService(NotificationManager::class.java) | ||
| 29 | notificationManager.createNotificationChannel(channel) | ||
| 30 | } | ||
| 31 | |||
| 32 | override fun onCreate() { | ||
| 33 | super.onCreate() | ||
| 34 | application = this | ||
| 35 | documentsTree = DocumentsTree() | ||
| 36 | start(applicationContext) | ||
| 37 | GpuDriverHelper.initializeDriverParameters(applicationContext) | ||
| 38 | NativeLibrary.LogDeviceInfo() | ||
| 39 | |||
| 40 | // TODO(bunnei): Disable notifications until we support app suspension. | ||
| 41 | //createNotificationChannel(); | ||
| 42 | databaseHelper = GameDatabase(this) | ||
| 43 | } | ||
| 44 | |||
| 45 | companion object { | ||
| 46 | var databaseHelper: GameDatabase? = null | ||
| 47 | |||
| 48 | @JvmField | ||
| 49 | var documentsTree: DocumentsTree? = null | ||
| 50 | private var application: YuzuApplication? = null | ||
| 51 | |||
| 52 | @JvmStatic | ||
| 53 | val appContext: Context | ||
| 54 | get() = application!!.applicationContext | ||
| 55 | } | ||
| 56 | } | ||