11package com.vandam.echo
2+ import android.util.Log
3+ import android.provider.Settings
4+ import expo.modules.splashscreen.SplashScreenManager
5+
26import android.os.Build
37import android.os.Bundle
4- import android.provider.Settings
5- import android.util.Log
8+
69import com.facebook.react.ReactActivity
710import com.facebook.react.ReactActivityDelegate
811import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.fabricEnabled
912import com.facebook.react.defaults.DefaultReactActivityDelegate
13+
1014import expo.modules.ReactActivityDelegateWrapper
11- import expo.modules.splashscreen.SplashScreenManager
1215
1316class MainActivity : ReactActivity () {
17+ // @generated begin echo-daltonizer-fields - expo prebuild (DO NOT MODIFY) sync-cb4cee0d17ca6ae7f950d2fdcba28d175ff2ca91
1418 private var wasGrayscaleEnabled = false
1519 private var previousDaltonizerMode = 0
20+ private var didWeDisableDaltonizer = false
21+ // @generated end echo-daltonizer-fields
22+ override fun onCreate (savedInstanceState : Bundle ? ) {
23+ // Set the theme to AppTheme BEFORE onCreate to support
24+ // coloring the background, status bar, and navigation bar.
25+ // This is required for expo-splash-screen.
26+ // setTheme(R.style.AppTheme);
27+ // @generated begin expo-splashscreen - expo prebuild (DO NOT MODIFY) sync-f3ff59a738c56c9a6119210cb55f0b613eb8b6af
28+ SplashScreenManager .registerOnActivity(this )
29+ // @generated end expo-splashscreen
30+ super .onCreate(null )
31+ }
1632
17- override fun onCreate (savedInstanceState : Bundle ? ) {
18- // Set the theme to AppTheme BEFORE onCreate to support
19- // coloring the background, status bar, and navigation bar.
20- // This is required for expo-splash-screen.
21- // setTheme(R.style.AppTheme);
22- // @generated begin expo-splashscreen - expo prebuild (DO NOT MODIFY) sync-f3ff59a738c56c9a6119210cb55f0b613eb8b6af
23- SplashScreenManager .registerOnActivity(this )
24- // @generated end expo-splashscreen
25- super .onCreate(null )
26- }
27-
28- /* *
29- * Returns the name of the main component registered from JavaScript. This is used to schedule
30- * rendering of the component.
31- */
32- override fun getMainComponentName (): String = " main"
33+ /* *
34+ * Returns the name of the main component registered from JavaScript. This is used to schedule
35+ * rendering of the component.
36+ */
37+ override fun getMainComponentName (): String = " main"
3338
34- /* *
35- * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
36- * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
37- */
38- override fun createReactActivityDelegate (): ReactActivityDelegate =
39- ReactActivityDelegateWrapper (
40- this ,
41- BuildConfig .IS_NEW_ARCHITECTURE_ENABLED ,
42- object : DefaultReactActivityDelegate (
43- this ,
44- mainComponentName,
45- fabricEnabled,
46- ) {},
47- )
39+ /* *
40+ * Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
41+ * which allows you to enable New Architecture with a single boolean flags [fabricEnabled]
42+ */
43+ override fun createReactActivityDelegate (): ReactActivityDelegate {
44+ return ReactActivityDelegateWrapper (
45+ this ,
46+ BuildConfig .IS_NEW_ARCHITECTURE_ENABLED ,
47+ object : DefaultReactActivityDelegate (
48+ this ,
49+ mainComponentName,
50+ fabricEnabled
51+ ){})
52+ }
4853
49- /* *
50- * Align the back button behavior with Android S
51- * where moving root activities to background instead of finishing activities.
52- * @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
53- */
54- override fun invokeDefaultOnBackPressed () {
55- if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .R ) {
56- if (! moveTaskToBack(false )) {
57- // For non-root activities, use the default implementation to finish them.
58- super .invokeDefaultOnBackPressed()
59- }
60- return
61- }
62-
63- // Use the default back button implementation on Android S
64- // because it's doing more than [Activity.moveTaskToBack] in fact.
65- super .invokeDefaultOnBackPressed()
66- }
67-
68- private var didWeDisableDaltonizer = false
54+ /* *
55+ * Align the back button behavior with Android S
56+ * where moving root activities to background instead of finishing activities.
57+ * @see <a href="https://developer.android.com/reference/android/app/Activity#onBackPressed()">onBackPressed</a>
58+ */
59+ override fun invokeDefaultOnBackPressed () {
60+ if (Build .VERSION .SDK_INT <= Build .VERSION_CODES .R ) {
61+ if (! moveTaskToBack(false )) {
62+ // For non-root activities, use the default implementation to finish them.
63+ super .invokeDefaultOnBackPressed()
64+ }
65+ return
66+ }
6967
68+ // Use the default back button implementation on Android S
69+ // because it's doing more than [Activity.moveTaskToBack] in fact.
70+ super .invokeDefaultOnBackPressed()
71+ }
72+ // @generated begin echo-daltonizer-methods - expo prebuild (DO NOT MODIFY) sync-ab9eb474ad3398d16af28ff66243705e397a316f
7073 override fun onResume () {
7174 super .onResume()
7275 disableDaltonizer()
@@ -100,7 +103,7 @@ class MainActivity : ReactActivity() {
100103 try {
101104 Settings .Secure .putInt(contentResolver, " accessibility_display_daltonizer_enabled" , 0 )
102105 Log .d(" Daltonizer" , " Disabled (was mode: $daltonizerMode )" )
103- } catch (e : SecurityException ) {
106+ } catch (exception : SecurityException ) {
104107 Log .e(" Daltonizer" , " No permission - run: adb shell pm grant com.vandam.echo android.permission.WRITE_SECURE_SETTINGS" )
105108 }
106109 }
@@ -112,10 +115,12 @@ class MainActivity : ReactActivity() {
112115 Settings .Secure .putInt(contentResolver, " accessibility_display_daltonizer" , previousDaltonizerMode)
113116 Settings .Secure .putInt(contentResolver, " accessibility_display_daltonizer_enabled" , 1 )
114117 Log .d(" Daltonizer" , " Restored (mode: $previousDaltonizerMode )" )
115- } catch (e : SecurityException ) {
118+ } catch (exception : SecurityException ) {
116119 Log .e(" Daltonizer" , " No permission to restore" )
117120 }
121+
118122 didWeDisableDaltonizer = false
119123 }
120124 }
125+ // @generated end echo-daltonizer-methods
121126}
0 commit comments