summaryrefslogtreecommitdiff
path: root/src/android
diff options
context:
space:
mode:
authorGravatar Charles Lombardo2023-03-11 00:40:07 -0500
committerGravatar bunnei2023-06-03 00:05:42 -0700
commit95af1b2a23a246a6ed2c2e1716e739d0ea4d0dcf (patch)
treeb304cdac6cf9350c889851f5e37f5eb6fa8ba169 /src/android
parentandroid: Convert Action1 to Kotlin (diff)
downloadyuzu-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.java59
-rw-r--r--src/android/app/src/main/java/org/yuzu/yuzu_emu/YuzuApplication.kt56
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
5package org.yuzu.yuzu_emu;
6
7import android.app.Application;
8import android.app.NotificationChannel;
9import android.app.NotificationManager;
10import android.content.Context;
11import android.os.Build;
12
13import org.yuzu.yuzu_emu.model.GameDatabase;
14import org.yuzu.yuzu_emu.utils.DocumentsTree;
15import org.yuzu.yuzu_emu.utils.DirectoryInitialization;
16import org.yuzu.yuzu_emu.utils.GpuDriverHelper;
17
18public 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 @@
1package org.yuzu.yuzu_emu
2
3import android.app.Application
4import android.app.NotificationChannel
5import android.app.NotificationManager
6import android.content.Context
7import org.yuzu.yuzu_emu.model.GameDatabase
8import org.yuzu.yuzu_emu.utils.DirectoryInitialization.start
9import org.yuzu.yuzu_emu.utils.DocumentsTree
10import org.yuzu.yuzu_emu.utils.GpuDriverHelper
11
12class 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}