Skip to content

Commit

Permalink
Replaced regular dialog with alert dialog in calendar color selection
Browse files Browse the repository at this point in the history
  • Loading branch information
dgudim committed Jan 11, 2024
1 parent b23c93c commit 209d38d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ dependencies {
implementation 'com.google.android.material:material:1.11.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

implementation "androidx.lifecycle:lifecycle-service:2.6.2"
implementation "androidx.lifecycle:lifecycle-service:2.7.0"

implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.navigation:navigation-fragment:2.7.6'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static prototype.xd.scheduler.entities.settings_entries.SettingsEntryType.CALENDAR;
import static prototype.xd.scheduler.utilities.Utilities.getPluralString;

import android.app.AlertDialog;
import android.content.res.ColorStateList;
import android.view.View;
import android.widget.GridView;
Expand All @@ -17,8 +16,9 @@
import prototype.xd.scheduler.databinding.CalendarSettingsEntryBinding;
import prototype.xd.scheduler.databinding.GridSelectionViewBinding;
import prototype.xd.scheduler.entities.SystemCalendar;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.utilities.DialogUtilities;
import prototype.xd.scheduler.utilities.Static;
import prototype.xd.scheduler.utilities.misc.ContextWrapper;
import prototype.xd.scheduler.views.settings.SystemCalendarSettings;

public class CalendarSettingsEntryConfig extends GenericCalendarSettingsEntryConfig {
Expand Down Expand Up @@ -85,19 +85,22 @@ void bind(@NonNull CalendarSettingsEntryConfig config) {

if (config.gridViewAdapter != null) {
viewBinding.colorSelectButton.setVisibility(View.VISIBLE);
viewBinding.colorSelectButton.setOnClickListener(v -> {
final AlertDialog.Builder alert = new AlertDialog.Builder(v.getContext());

GridSelectionViewBinding gridSelection = GridSelectionViewBinding.inflate(wrapper.getLayoutInflater());
GridView gridView = gridSelection.gridView;
gridView.setNumColumns(2);
gridView.setHorizontalSpacing(5);
gridView.setVerticalSpacing(5);
gridView.setAdapter(config.gridViewAdapter);

alert.setView(gridSelection.getRoot());
alert.show();
});
viewBinding.colorSelectButton.setOnClickListener(v -> DialogUtilities.displayMessageDialog(
wrapper, builder -> {
GridSelectionViewBinding gridSelection = GridSelectionViewBinding.inflate(wrapper.getLayoutInflater());
GridView gridView = gridSelection.gridView;
gridView.setNumColumns(2);
gridView.setHorizontalSpacing(5);
gridView.setVerticalSpacing(5);
gridView.setAdapter(config.gridViewAdapter);

builder.setIcon(R.drawable.ic_palette_45);
builder.setTitle(R.string.title_edit_events_with_color);
builder.setMessage(R.string.title_edit_events_with_color_description);
builder.setNegativeButton(R.string.close, null);
builder.setView(gridSelection.getRoot());
}
));
} else {
viewBinding.colorSelectButton.setVisibility(View.GONE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardBackgroundColor="?colorSurfaceContainerLow"
app:cardCornerRadius="@dimen/card_corner_radius">

<LinearLayout
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,6 @@
<string name="event_deleted_message">Event deleted</string>
<string name="settings_effects_glow">Add glow to transparency overlay</string>
<string name="settings_effects_highlight_edges">Highlight inner edges</string>
<string name="title_edit_events_with_color">Settings for specific colors</string>
<string name="title_edit_events_with_color_description">A calendar can have events with different colors, here you can set separate styles for each color</string>
</resources>

0 comments on commit 209d38d

Please sign in to comment.