Skip to content

Commit

Permalink
Disable effects on unsupported devices
Browse files Browse the repository at this point in the history
  • Loading branch information
dgudim committed Dec 8, 2023
1 parent a9b8895 commit f302b99
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static prototype.xd.scheduler.entities.settings_entries.SettingsEntryType.COMPOUND_CUSTOMIZATION;

import android.graphics.Color;
import android.os.Build;
import android.widget.LinearLayout;

import androidx.annotation.ColorInt;
Expand Down Expand Up @@ -84,8 +85,14 @@ static class ViewHolder
Static.EFFECT_BLUR_GRAIN,
false);

Utilities.setSwitchChangeListener(effectsDialogBinding.glowSwitch, Static.EFFECT_GLOW, null);
Utilities.setSwitchChangeListener(effectsDialogBinding.highlightEdgesSwitch, Static.EFFECT_HIGHLIGHT_EDGE, null);
if (Build.VERSION.SDK_INT >= 31) {
Utilities.setSwitchChangeListener(effectsDialogBinding.glowSwitch, Static.EFFECT_GLOW, null);
Utilities.setSwitchChangeListener(effectsDialogBinding.highlightEdgesSwitch, Static.EFFECT_HIGHLIGHT_EDGE, null);
} else {
effectsDialogBinding.glowSwitch.freezeState(false);
effectsDialogBinding.highlightEdgesSwitch.freezeState(false);
}


viewSelectionDialog = wrapper.attachDialogToLifecycle(
new MaterialAlertDialogBuilder(wrapper.context, R.style.DefaultAlertDialogTheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ public void handleOnBackPressed() {
bnd.shareLogcatView.setOnClickListener(v1 -> Logger.shareLog(wrapper.context));

if (BuildConfig.DEBUG) {
bnd.debugLoggingSwitch.setCheckedSilent(true);
bnd.debugLoggingSwitch.setClickable(false);
bnd.debugLoggingSwitch.setAlpha(0.5F);
bnd.debugLoggingSwitch.freezeState(true);
} else {
setSwitchChangeListener(bnd.debugLoggingSwitch, Static.DEBUG_LOGGING, (switchView, isChecked) -> Logger.setDebugEnabled(isChecked));
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/java/prototype/xd/scheduler/views/Switch.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public void setCheckedSilent(boolean checked) {
}
}

public void freezeState(boolean state) {
setCheckedSilent(state);
setAlpha(0.5F);
setClickable(false);
}

@FunctionalInterface
public interface OnSilentCheckedChangeListener {
void onCheckedChanged(@NonNull CompoundButton buttonView, boolean isChecked, boolean fromUser);
Expand Down

0 comments on commit f302b99

Please sign in to comment.