4949import com .termux .api .util .ResultReturner ;
5050import com .termux .api .activities .TermuxApiPermissionActivity ;
5151import com .termux .shared .logger .Logger ;
52+ import com .termux .shared .termux .theme .TermuxThemeUtils ;
53+ import com .termux .shared .theme .NightMode ;
54+ import com .termux .shared .theme .ThemeUtils ;
5255
5356import java .io .File ;
5457import java .io .FileInputStream ;
@@ -83,31 +86,6 @@ public static class DialogActivity extends AppCompatActivity {
8386
8487 private boolean resultReturned = false ;
8588
86- protected boolean getBlackUI () {
87- File propsFile = new File (TERMUX_PROPERTIES_PRIMARY_FILE_PATH );
88-
89- if (!propsFile .exists ())
90- propsFile = new File (TERMUX_PROPERTIES_SECONDARY_FILE_PATH );
91-
92- boolean mUseBlackUi = false ;
93-
94- if (propsFile .exists ()) {
95- Properties props = new Properties ();
96- try {
97- if (propsFile .isFile () && propsFile .canRead ()) {
98- try (FileInputStream in = new FileInputStream (propsFile )) {
99- props .load (new InputStreamReader (in , StandardCharsets .UTF_8 ));
100- }
101- }
102- mUseBlackUi = props .getProperty ("use-black-ui" ).equals ("true" );
103- } catch (Exception e ) {
104- Logger .logStackTraceWithMessage (LOG_TAG , "Error loading props" , e );
105- }
106- }
107-
108- return mUseBlackUi ;
109- }
110-
11189 @ Override
11290 protected void onCreate (Bundle savedInstanceState ) {
11391 Logger .logDebug (LOG_TAG , "onCreate" );
@@ -119,7 +97,10 @@ protected void onCreate(Bundle savedInstanceState) {
11997
12098 String methodType = intent .hasExtra ("input_method" ) ? intent .getStringExtra ("input_method" ) : "" ;
12199
122- if (getBlackUI ())
100+ // Set NightMode.APP_NIGHT_MODE
101+ TermuxThemeUtils .setAppNightMode (context );
102+ boolean shouldEnableDarkTheme = ThemeUtils .shouldEnableDarkTheme (this , NightMode .getAppNightMode ().getName ());
103+ if (shouldEnableDarkTheme )
123104 this .setTheme (R .style .DialogTheme_Dark );
124105
125106 InputMethod method = InputMethodFactory .get (methodType , this );
0 commit comments