Skip to content

Commit b2cc90b

Browse files
Added: Add Day/Night theme support for EditConfigurationActivity based on night-mode termux.properties value
The stdin `TextIOActivity` will always use light theme since it doesn't currently support dark mode. Support will be added in future when `termux-shared` is updated with media viewer support.
1 parent 2bdab10 commit b2cc90b

File tree

7 files changed

+369
-367
lines changed

7 files changed

+369
-367
lines changed

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
android:name=".TermuxTaskerApplication"
1010
android:label="@string/application_name"
1111
android:icon="@drawable/ic_launcher"
12-
android:theme="@style/AppTheme"
1312
android:allowBackup="true"
1413
android:fullBackupOnly="false"
1514
android:supportsRtl="true">
@@ -27,6 +26,7 @@
2726
android:exported="true"
2827
android:icon="@drawable/ic_launcher"
2928
android:label="@string/plugin_name"
29+
android:theme="@style/Theme.BaseActivity.DayNight.NoActionBar"
3030
android:windowSoftInputMode="stateHidden"
3131
android:uiOptions="splitActionBarWhenNarrow">
3232
<!-- this Intent filter allows the plug-in to be discovered by Locale -->
@@ -39,7 +39,8 @@
3939
Android Studio linter is broken and correct package name will be used at build time." -->
4040
<activity
4141
android:name="${TERMUX_PACKAGE_NAME}.shared.activities.TextIOActivity"
42-
android:theme="@style/Theme.MediaViewActivity.DayNight"
42+
android:exported="false"
43+
android:theme="@style/Theme.BaseActivity.Light.NoActionBar"
4344
tools:ignore="MissingClass" />
4445

4546
<!--

app/src/main/java/com/termux/tasker/EditConfigurationActivity.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.google.android.material.textfield.TextInputEditText;
88
import com.google.android.material.textfield.TextInputLayout;
99
import com.termux.shared.activities.TextIOActivity;
10+
import com.termux.shared.activity.media.AppCompatActivityUtils;
1011
import com.termux.shared.data.DataUtils;
1112
import com.termux.shared.errors.Error;
1213
import com.termux.shared.logger.Logger;
@@ -16,15 +17,14 @@
1617
import com.termux.shared.file.FileUtils;
1718
import com.termux.shared.termux.TermuxUtils;
1819
import com.termux.shared.termux.file.TermuxFileUtils;
20+
import com.termux.shared.termux.theme.TermuxThemeUtils;
21+
import com.termux.shared.theme.NightMode;
1922
import com.termux.tasker.utils.LoggerUtils;
2023
import com.termux.tasker.utils.PluginUtils;
2124
import com.termux.tasker.utils.TaskerPlugin;
2225

23-
import androidx.activity.result.ActivityResult;
24-
import androidx.activity.result.ActivityResultCallback;
2526
import androidx.activity.result.ActivityResultLauncher;
2627
import androidx.activity.result.contract.ActivityResultContracts;
27-
import androidx.appcompat.app.ActionBar;
2828

2929
import android.text.Editable;
3030
import android.text.TextWatcher;
@@ -90,13 +90,16 @@ public final class EditConfigurationActivity extends AbstractPluginActivity {
9090
protected void onCreate(final Bundle savedInstanceState) {
9191
super.onCreate(savedInstanceState);
9292

93-
ActionBar actionBar = getSupportActionBar();
94-
if (actionBar != null) {
95-
actionBar.setTitle(R.string.application_name);
96-
actionBar.setDisplayHomeAsUpEnabled(true);
97-
}
93+
// Set NightMode.APP_NIGHT_MODE
94+
TermuxThemeUtils.setAppNightMode(this);
95+
AppCompatActivityUtils.setNightMode(this, NightMode.getAppNightMode().getName(), true);
96+
97+
setContentView(R.layout.activity_edit_configuration);
98+
99+
AppCompatActivityUtils.setToolbar(this, R.id.toolbar);
100+
AppCompatActivityUtils.setToolbarTitle(this, R.id.toolbar, TermuxConstants.TERMUX_TASKER_APP_NAME, 0);
101+
AppCompatActivityUtils.setShowBackButtonInActionBar(this, true);
98102

99-
setContentView(R.layout.edit_activity);
100103
setStartTextIOActivityForResult();
101104

102105
final Intent intent = getIntent();
@@ -189,7 +192,7 @@ protected void onResume() {
189192
@Override
190193
public boolean onCreateOptionsMenu(Menu menu) {
191194
super.onCreateOptionsMenu(menu);
192-
getMenuInflater().inflate(R.menu.edit_activity, menu);
195+
getMenuInflater().inflate(R.menu.activity_edit_configuration, menu);
193196
return true;
194197
}
195198

0 commit comments

Comments
 (0)