Skip to content

Commit

Permalink
Added transparency and blur effects to the lockscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
dgudim committed Dec 7, 2023
1 parent e75f702 commit f800c87
Show file tree
Hide file tree
Showing 35 changed files with 434 additions and 114 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/prototype/xd/scheduler/IntroActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import prototype.xd.scheduler.fragments.IntroStartingFragment;
import prototype.xd.scheduler.fragments.PermissionRequestFragment;
import prototype.xd.scheduler.utilities.ColorUtilities;
import prototype.xd.scheduler.utilities.ImageUtilities;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.Utilities;

Expand All @@ -28,7 +28,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {

Static.init(this);

ColorUtilities.harmonizeColorsForActivity(this,
ImageUtilities.harmonizeColorsForActivity(this,
R.color.gray_harmonized,
R.color.green_harmonized,
R.color.yellow_harmonized,
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/prototype/xd/scheduler/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;

import prototype.xd.scheduler.utilities.ColorUtilities;
import prototype.xd.scheduler.utilities.ImageUtilities;
import prototype.xd.scheduler.utilities.PermissionUtilities;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.Utilities;
Expand All @@ -26,7 +26,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
// init theme
AppCompatDelegate.setDefaultNightMode(Static.APP_THEME.get());

ColorUtilities.harmonizeColorsForActivity(this,
ImageUtilities.harmonizeColorsForActivity(this,
R.color.gray_harmonized,
R.color.entry_settings_parameter_default,
R.color.entry_settings_parameter_group,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package prototype.xd.scheduler.adapters;

import static prototype.xd.scheduler.utilities.ColorUtilities.readBitmapFromFile;
import static prototype.xd.scheduler.utilities.ImageUtilities.readBitmapFromFile;
import static prototype.xd.scheduler.utilities.Logger.logException;
import static prototype.xd.scheduler.utilities.Utilities.getFile;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package prototype.xd.scheduler.adapters;

import static java.lang.Math.max;
import static prototype.xd.scheduler.utilities.ColorUtilities.dimColorToBg;
import static prototype.xd.scheduler.utilities.ColorUtilities.getHarmonizedFontColorWithBg;
import static prototype.xd.scheduler.utilities.ColorUtilities.getHarmonizedSecondaryFontColorWithBg;
import static prototype.xd.scheduler.utilities.DateManager.currentlySelectedDayUTC;
import static prototype.xd.scheduler.utilities.ImageUtilities.dimColorToBg;
import static prototype.xd.scheduler.utilities.ImageUtilities.getHarmonizedFontColorWithBg;
import static prototype.xd.scheduler.utilities.ImageUtilities.getHarmonizedSecondaryFontColorWithBg;
import static prototype.xd.scheduler.utilities.Static.DAY_FLAG_GLOBAL_STR;
import static prototype.xd.scheduler.utilities.Static.END_DAY_UTC;
import static prototype.xd.scheduler.utilities.Static.GLOBAL_ITEMS_LABEL_POSITION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import static androidx.core.math.MathUtils.clamp;
import static java.lang.Math.abs;
import static prototype.xd.scheduler.entities.Group.NULL_GROUP;
import static prototype.xd.scheduler.utilities.ColorUtilities.getExpiredUpcomingColor;
import static prototype.xd.scheduler.utilities.ColorUtilities.mixColorWithBg;
import static prototype.xd.scheduler.utilities.DateManager.currentDayUTC;
import static prototype.xd.scheduler.utilities.DateManager.currentTimestampUTC;
import static prototype.xd.scheduler.utilities.DateManager.msToDays;
import static prototype.xd.scheduler.utilities.DateManager.msUTCtoDaysLocal;
import static prototype.xd.scheduler.utilities.ImageUtilities.getExpiredUpcomingColor;
import static prototype.xd.scheduler.utilities.ImageUtilities.mixColorWithBg;
import static prototype.xd.scheduler.utilities.Static.TIME_RANGE_SEPARATOR;
import static prototype.xd.scheduler.utilities.Utilities.doRangesOverlap;
import static prototype.xd.scheduler.utilities.Utilities.getPluralString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void bind(@NonNull AdaptiveBackgroundSettingsEntryConfig config) {

MaterialDividerItemDecoration divider = new MaterialDividerItemDecoration(wrapper.context, LinearLayout.VERTICAL);
divider.setDividerColor(Color.TRANSPARENT);
divider.setDividerThickness(wrapper.getResources().getDimensionPixelSize(R.dimen.bg_list_item_vertical_padding));
divider.setDividerThickness(wrapper.getResources().getDimensionPixelSize(R.dimen.bg_grid_item_padding));

gridView.addItemDecoration(divider);
gridView.setHasFixedSize(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package prototype.xd.scheduler.entities.settings_entries;

import static prototype.xd.scheduler.entities.settings_entries.SettingsEntryType.CALENDAR_ACCOUNT;
import static prototype.xd.scheduler.utilities.ColorUtilities.dimColorToBg;
import static prototype.xd.scheduler.utilities.ImageUtilities.dimColorToBg;

import android.view.View;

Expand All @@ -16,8 +16,8 @@
import prototype.xd.scheduler.adapters.SettingsListViewAdapter;
import prototype.xd.scheduler.databinding.CalendarAccountSettingsEntryBinding;
import prototype.xd.scheduler.entities.SystemCalendar;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.views.settings.SystemCalendarSettings;

public class CalendarAccountSettingsEntryConfig extends GenericCalendarSettingsEntryConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import prototype.xd.scheduler.R;
import prototype.xd.scheduler.databinding.CompoundCustomizationSettingsEntryBinding;
import prototype.xd.scheduler.databinding.EntryEffectsDialogBinding;
import prototype.xd.scheduler.utilities.DialogUtilities;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.Utilities;
Expand All @@ -42,6 +43,9 @@ static class ViewHolder
@NonNull
private final AlertDialog viewSelectionDialog;

@NonNull
private final AlertDialog effectSettingsDialog;

ViewHolder(@NonNull final ContextWrapper wrapper,
@NonNull final CompoundCustomizationSettingsEntryBinding viewBinding) {
super(wrapper, viewBinding);
Expand All @@ -54,6 +58,32 @@ static class ViewHolder
viewSelectionDialogView.setOrientation(LinearLayout.VERTICAL);
viewSelectionDialogView.setPadding(padding, padding, padding, padding - itemPadding);

EntryEffectsDialogBinding effectsDialogBinding = EntryEffectsDialogBinding.inflate(wrapper.getLayoutInflater());

Utilities.setSliderChangeListener(
effectsDialogBinding.effectTransparencyDescription,
effectsDialogBinding.effectTransparencySlider,
null,
R.string.settings_effects_transparency,
Static.EFFECT_TRANSPARENCY,
false);

Utilities.setSliderChangeListener(
effectsDialogBinding.effectBlurRadiusDescription,
effectsDialogBinding.effectBlurRadiusSlider,
null,
R.string.settings_effects_blur_radius,
Static.EFFECT_BLUR_RADIUS,
false);

Utilities.setSliderChangeListener(
effectsDialogBinding.effectBlurGrainDescription,
effectsDialogBinding.effectBlurGrainSlider,
null,
R.string.settings_effects_blur_grain,
Static.EFFECT_BLUR_GRAIN,
false);

viewSelectionDialog = wrapper.attachDialogToLifecycle(
new MaterialAlertDialogBuilder(wrapper.context, R.style.DefaultAlertDialogTheme)
.setIcon(R.drawable.ic_view_carousel_24)
Expand All @@ -62,6 +92,14 @@ static class ViewHolder
.setView(viewSelectionDialogView)
.create(), null);

effectSettingsDialog = wrapper.attachDialogToLifecycle(
new MaterialAlertDialogBuilder(wrapper.context, R.style.DefaultAlertDialogTheme)
.setIcon(R.drawable.ic_effects_45)
.setTitle(R.string.settings_effects_title)
.setMessage(R.string.settings_effects_description)
.setView(effectsDialogBinding.getRoot())
.create(), null);

entryPreviewContainer = new EntryPreviewContainer(wrapper, viewBinding.previewContainer, true) {
@ColorInt
@Override
Expand Down Expand Up @@ -117,7 +155,7 @@ protected int adaptiveColorBalanceGetter() {

for (TodoItemViewType viewType : TodoItemViewType.values()) {
LockScreenTodoItemView.inflateViewByType(viewType, viewSelectionDialogView, wrapper.getLayoutInflater())
.mixAndSetBgAndTextColors(true, fontColor, bgColor)
.mixAndSetBgAndTextColors(fontColor, bgColor)
.setBorderColor(borderColor)
.setOnClickListener(v -> {
entryPreviewContainer.setTodoItemViewType(viewType);
Expand All @@ -128,6 +166,9 @@ protected int adaptiveColorBalanceGetter() {
viewBinding.previewContainer.setOnClickListener(v ->
viewSelectionDialog.show());

viewBinding.openEffectsButton.setOnClickListener(v ->
effectSettingsDialog.show());

ObjIntConsumer<Static.DefaultedInteger> colorPickerColorSelectedListener = (value, selectedColor) -> {
value.put(selectedColor);
entryPreviewContainer.notifyColorChanged(value, selectedColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
import androidx.annotation.StringRes;

import prototype.xd.scheduler.databinding.DoubleSliderSettingsEntryBinding;
import prototype.xd.scheduler.utilities.ImageUtilities;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.utilities.ColorUtilities;

public class DoubleSliderSettingsEntryConfig extends SettingsEntryConfig {

@StringRes
final int titleId;
private final int titleId;

@NonNull
protected final SliderSettingsEntryConfig leftSliderConfig;
@NonNull
protected final ColorUtilities.SliderTinter leftSliderTinter;
protected final ImageUtilities.SliderTinter leftSliderTinter;

@NonNull
protected final SliderSettingsEntryConfig rightSliderConfig;
@NonNull
protected final ColorUtilities.SliderTinter rightSliderTinter;
protected final ImageUtilities.SliderTinter rightSliderTinter;

public DoubleSliderSettingsEntryConfig(@NonNull Context context,
@StringRes int titleId,
Expand All @@ -37,8 +37,8 @@ public DoubleSliderSettingsEntryConfig(@NonNull Context context,
this.leftSliderConfig = leftSliderConfig;
this.rightSliderConfig = rightSliderConfig;

leftSliderTinter = new ColorUtilities.SliderTinter(context, leftSliderAccentColor);
rightSliderTinter = new ColorUtilities.SliderTinter(context, rightSliderAccentColor);
leftSliderTinter = new ImageUtilities.SliderTinter(context, leftSliderAccentColor);
rightSliderTinter = new ImageUtilities.SliderTinter(context, rightSliderAccentColor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import java.util.function.IntFunction;

import prototype.xd.scheduler.databinding.SliderSettingsEntryBinding;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.Utilities;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;

public class SliderSettingsEntryConfig extends SettingsEntryConfig {

Expand All @@ -30,7 +30,7 @@ public class SliderSettingsEntryConfig extends SettingsEntryConfig {
private int stringResource;

@Nullable
IntFunction<String> textFormatter;
private IntFunction<String> textFormatter;

public SliderSettingsEntryConfig(@NonNull Static.DefaultedInteger value, int seekMin, int seekMax, int stepSize, boolean zeroIsOff,
@StringRes @PluralsRes int stringResource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import static prototype.xd.scheduler.fragments.PermissionRequestFragment.PermissionsRequestChainStatus.BATTERY_PERMISSIONS;
import static prototype.xd.scheduler.fragments.PermissionRequestFragment.PermissionsRequestChainStatus.CORE_PERMISSIONS;
import static prototype.xd.scheduler.fragments.PermissionRequestFragment.PermissionsRequestChainStatus.END;
import static prototype.xd.scheduler.utilities.ColorUtilities.getOnBgColor;
import static prototype.xd.scheduler.utilities.ImageUtilities.getOnBgColor;
import static prototype.xd.scheduler.utilities.PermissionUtilities.AutoRevokeStatus;
import static prototype.xd.scheduler.utilities.PermissionUtilities.areEssentialPermissionsGranted;
import static prototype.xd.scheduler.utilities.PermissionUtilities.getAutorevokeStatus;
Expand Down Expand Up @@ -42,7 +42,7 @@

import prototype.xd.scheduler.R;
import prototype.xd.scheduler.databinding.PermissionsRequestFragmentBinding;
import prototype.xd.scheduler.utilities.ColorUtilities;
import prototype.xd.scheduler.utilities.ImageUtilities;
import prototype.xd.scheduler.utilities.Logger;


Expand Down Expand Up @@ -187,8 +187,8 @@ private static void setPermissionChipColor(boolean permissionGranted, @NonNull T
int onContainerColor = MaterialColors.getColor(permissionText, R.attr.colorOnErrorContainer, Color.RED);

if (permissionGranted) {
containerColor = ColorUtilities.swapRedAndGreenChannels(containerColor);
onContainerColor = ColorUtilities.swapRedAndGreenChannels(onContainerColor);
containerColor = ImageUtilities.swapRedAndGreenChannels(containerColor);
onContainerColor = ImageUtilities.swapRedAndGreenChannels(onContainerColor);
}

permissionText.setTextColor(onContainerColor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected void buildDialogStatic(@NonNull SettingsDialogFragmentBinding binding,

new SliderSettingsEntryConfig(Static.LOCKSCREEN_VIEW_VERTICAL_BIAS,
0, 100, 5, value -> {
String baseString = wrapper.getString(R.string.settings_event_vertical_bias, value) + "%";
String baseString = wrapper.getString(R.string.settings_event_vertical_bias, value);
if (value == 0) {
return baseString + " (" + wrapper.getString(R.string.top) + ")";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package prototype.xd.scheduler.fragments.dialogs;

import static prototype.xd.scheduler.utilities.ColorUtilities.getExpiredUpcomingColor;
import static prototype.xd.scheduler.utilities.ColorUtilities.getHarmonizedFontColorWithBg;
import static prototype.xd.scheduler.utilities.ColorUtilities.getHarmonizedSecondaryFontColorWithBg;
import static prototype.xd.scheduler.utilities.ColorUtilities.getOnBgColor;
import static prototype.xd.scheduler.utilities.ImageUtilities.getExpiredUpcomingColor;
import static prototype.xd.scheduler.utilities.ImageUtilities.getHarmonizedFontColorWithBg;
import static prototype.xd.scheduler.utilities.ImageUtilities.getHarmonizedSecondaryFontColorWithBg;
import static prototype.xd.scheduler.utilities.ImageUtilities.getOnBgColor;

import android.annotation.SuppressLint;
import android.content.res.ColorStateList;
Expand Down
Loading

0 comments on commit f800c87

Please sign in to comment.