Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit fa46b79

Browse files
committed
Rework card, add core to disable monet theme
Fix dark terminal option is enable able while the system dark mode is active
1 parent 5541516 commit fa46b79

File tree

6 files changed

+115
-190
lines changed

6 files changed

+115
-190
lines changed

app/src/main/java/com/fox2code/mmm/MainApplication.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ public static boolean isDohEnabled() {
116116
return getSharedPreferences().getBoolean("pref_dns_over_https", true);
117117
}
118118

119+
public static boolean isMonetEnabled() {
120+
return getSharedPreferences().getBoolean("pref_enable_monet", false);
121+
}
122+
119123
public static boolean isBlurEnabled() {
120124
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M &&
121125
getSharedPreferences().getBoolean("pref_enable_blur", false);
@@ -282,7 +286,9 @@ public boolean isLightTheme() {
282286
public void onCreate() {
283287
super.onCreate();
284288
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
285-
DynamicColors.applyToActivitiesIfAvailable(this);
289+
if (MainApplication.isMonetEnabled()) {
290+
DynamicColors.applyToActivitiesIfAvailable(this);
291+
}
286292
}
287293
SharedPreferences sharedPreferences = MainApplication.getSharedPreferences();
288294
// We are only one process so it's ok to do this

app/src/main/java/com/fox2code/mmm/module/ModuleViewAdapter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import android.view.View;
1111
import android.view.ViewGroup;
1212
import android.widget.ImageButton;
13+
import android.widget.LinearLayout;
1314
import android.widget.TextView;
1415

1516
import androidx.annotation.ColorInt;
@@ -71,6 +72,7 @@ public static class ViewHolder extends RecyclerView.ViewHolder {
7172
private final TextView titleText;
7273
private final TextView creditText;
7374
private final TextView descriptionText;
75+
private final LinearLayout moduleOptionsHolder;
7476
private final TextView updateText;
7577
private final Chip[] actionsButtons;
7678
private final ArrayList<ActionButtonType> actionButtonsTypes;
@@ -87,6 +89,7 @@ public ViewHolder(@NonNull View itemView) {
8789
this.titleText = itemView.findViewById(R.id.title_text);
8890
this.creditText = itemView.findViewById(R.id.credit_text);
8991
this.descriptionText = itemView.findViewById(R.id.description_text);
92+
this.moduleOptionsHolder = itemView.findViewById(R.id.module_options_holder);
9093
this.updateText = itemView.findViewById(R.id.updated_text);
9194
this.actionsButtons = new Chip[6];
9295
this.actionsButtons[0] = itemView.findViewById(R.id.button_action1);
@@ -182,6 +185,7 @@ public boolean update(ModuleHolder moduleHolder) {
182185
this.switchMaterial.setVisibility(View.GONE);
183186
}
184187
this.creditText.setVisibility(View.VISIBLE);
188+
this.moduleOptionsHolder.setVisibility(View.VISIBLE);
185189
this.descriptionText.setVisibility(View.VISIBLE);
186190

187191
ModuleInfo moduleInfo = moduleHolder.getMainModuleInfo();

app/src/main/java/com/fox2code/mmm/settings/SettingsActivity.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.fox2code.mmm.settings;
22

3+
import android.content.res.Configuration;
34
import android.os.Build;
45
import android.os.Bundle;
56
import android.widget.Toast;
@@ -82,11 +83,12 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
8283
enableBlur.setEnabled(false);
8384
}
8485

85-
Preference disableMonet = findPreference("pref_disable_monet");
86+
Preference disableMonet = findPreference("pref_enable_monet");
8687
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
8788
disableMonet.setSummary(R.string.require_android_12);
8889
disableMonet.setEnabled(false);
8990
}
91+
9092
Preference forceEnglish = findPreference("pref_force_english");
9193
forceEnglish.setOnPreferenceChangeListener((preference, newValue) -> {
9294
CompatThemeWrapper compatThemeWrapper =
@@ -104,8 +106,18 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
104106
Http.setDoh((Boolean) v);
105107
return true;
106108
});
107-
if ("dark".equals(themePreference.getValue())) {
108-
findPreference("pref_force_dark_terminal").setEnabled(false);
109+
110+
int nightModeFlags =
111+
getContext().getResources().getConfiguration().uiMode &
112+
Configuration.UI_MODE_NIGHT_MASK;
113+
switch (nightModeFlags) {
114+
case Configuration.UI_MODE_NIGHT_YES:
115+
findPreference("pref_force_dark_terminal").setEnabled(false);
116+
break;
117+
case Configuration.UI_MODE_NIGHT_NO:
118+
case Configuration.UI_MODE_NIGHT_UNDEFINED:
119+
findPreference("pref_force_dark_terminal").setEnabled(true);
120+
break;
109121
}
110122
if (!MainApplication.isDeveloper()) {
111123
findPreference("pref_disable_low_quality_module_filter").setVisible(false);

0 commit comments

Comments
 (0)