Skip to content

Commit 5c71e2d

Browse files
Changed: Use night-mode instead of use-black-ui termux.properties property for setting DialogActivity theme as per termux/termux-app@6631599f
1 parent 2968854 commit 5c71e2d

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

app/src/main/java/com/termux/api/apis/DialogAPI.java

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
import com.termux.api.util.ResultReturner;
5050
import com.termux.api.activities.TermuxApiPermissionActivity;
5151
import 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

5356
import java.io.File;
5457
import 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

Comments
 (0)