@@ -105,6 +105,7 @@ public class CreateGroupActivity extends BaseActivity implements OnMapReadyCallb
105105 private GoogleMap map ;
106106 private LatLng chosenLatLng ;
107107 private FusedLocationProviderClient locationClient ;
108+ private boolean isDatePickerShowing = false ;
108109
109110 @ Override
110111 protected void onCreate (Bundle savedInstanceState ) {
@@ -223,6 +224,11 @@ private void initializeViews() {
223224 etPartyName = findViewById (R .id .etPartyName );
224225 groupTypeCheckBox = findViewById (R .id .cbGroupType );
225226 timePicker = findViewById (R .id .timePicker );
227+
228+ // Apply custom theme to TimePicker programmatically for better visibility
229+ if (timePicker != null && android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .M ) {
230+ timePicker .setHour (timePicker .getHour ()); // Refresh to apply theme
231+ }
226232
227233 // Floating action button
228234 chatFab = findViewById (R .id .fabChat );
@@ -502,6 +508,7 @@ private void transitionToDateTimeStep() {
502508 showViews (tvPartyDate , tvHours , tvSelectedDate , timePicker , btnAddGroup , btnBack2 );
503509
504510 hideMapAndLocationSearch ();
511+ // Automatically show date picker for better UX
505512 showDatePicker ();
506513 }
507514
@@ -934,31 +941,21 @@ public boolean onCreateOptionsMenu(Menu menu) {
934941 }
935942
936943 private void showDatePicker () {
944+ // Prevent showing multiple date pickers
945+ if (isDatePickerShowing ) {
946+ return ;
947+ }
948+
949+ isDatePickerShowing = true ;
950+
937951 DatePickerDialog datePickerDialog =
938952 new DatePickerDialog (
939953 this ,
954+ android .R .style .Theme_Material_Light_Dialog_Alert ,
940955 (view , year , month , dayOfMonth ) -> {
941- Calendar pickedDate = Calendar .getInstance ();
942- pickedDate .set (year , month , dayOfMonth );
943-
944- // Check if picked date is in the past
945- Calendar today = Calendar .getInstance ();
946- today .set (Calendar .HOUR_OF_DAY , 0 );
947- today .set (Calendar .MINUTE , 0 );
948- today .set (Calendar .SECOND , 0 );
949- today .set (Calendar .MILLISECOND , 0 );
950-
951- if (pickedDate .before (today )) {
952- Toast .makeText (
953- this ,
954- "Cannot select a date in the past. Please choose today or a future date." ,
955- Toast .LENGTH_LONG )
956- .show ();
957- return ;
958- }
959-
960956 selectedDate .set (year , month , dayOfMonth );
961957 updateSelectedDate ();
958+ isDatePickerShowing = false ;
962959 },
963960 selectedDate .get (Calendar .YEAR ),
964961 selectedDate .get (Calendar .MONTH ),
@@ -967,6 +964,22 @@ private void showDatePicker() {
967964 // Set minimum date to today to prevent past date selection
968965 Calendar today = Calendar .getInstance ();
969966 datePickerDialog .getDatePicker ().setMinDate (today .getTimeInMillis ());
967+
968+ // Fix button text color to be visible
969+ datePickerDialog .setOnShowListener (dialog -> {
970+ Button positiveButton = datePickerDialog .getButton (DatePickerDialog .BUTTON_POSITIVE );
971+ Button negativeButton = datePickerDialog .getButton (DatePickerDialog .BUTTON_NEGATIVE );
972+ if (positiveButton != null ) {
973+ positiveButton .setTextColor (ContextCompat .getColor (this , R .color .primaryBlue ));
974+ }
975+ if (negativeButton != null ) {
976+ negativeButton .setTextColor (ContextCompat .getColor (this , R .color .primaryBlue ));
977+ }
978+ });
979+
980+ // Handle dialog cancel/dismiss
981+ datePickerDialog .setOnCancelListener (dialog -> isDatePickerShowing = false );
982+ datePickerDialog .setOnDismissListener (dialog -> isDatePickerShowing = false );
970983
971984 datePickerDialog .show ();
972985 }
0 commit comments