Skip to content

Commit

Permalink
Fixed #1180 - Dark mode for trip time picker (#1181)
Browse files Browse the repository at this point in the history
* Fixed #1180 - Supported trip time picker dark mode

Signed-off-by: Amr Hossam <amrhossam.dev@gmail.com>
  • Loading branch information
amrhossamdev authored Mar 27, 2024
1 parent aff83a1 commit 4191dc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.TypedArray;
import android.location.Location;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
Expand Down Expand Up @@ -177,6 +179,8 @@ public void onTimeSet(TimePicker view, int hour, int minute) {
}
};

Context context = new ContextThemeWrapper(getActivity(), R.style.dayNightTimePickerDialogTheme);

final DatePickerDialog.OnDateSetListener dateCallback = new DatePickerDialog.OnDateSetListener() {

@Override
Expand All @@ -196,7 +200,7 @@ public void onDateSet(DatePicker view, int year, int monthOfYear,
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
new DatePickerDialog(view.getContext(), dateCallback, mMyCalendar
new DatePickerDialog(context, dateCallback, mMyCalendar
.get(Calendar.YEAR), mMyCalendar.get(Calendar.MONTH),
mMyCalendar.get(Calendar.DAY_OF_MONTH)).show();
}
Expand All @@ -209,7 +213,7 @@ public boolean onTouch(View view, MotionEvent motionEvent) {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
new TimePickerDialog(view.getContext(), timeCallback,
new TimePickerDialog(context, timeCallback,
mMyCalendar.get(Calendar.HOUR_OF_DAY),
mMyCalendar.get(Calendar.MINUTE), false).show();
}
Expand Down
9 changes: 9 additions & 0 deletions onebusaway-android/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,14 @@
<item name="autoCompleteTextViewStyle">@style/cursorColor</item>
<!-- Allows us to force Dark Theme throughout the app -->
<item name="android:forceDarkAllowed">true</item>

</style>

<!-- Custom TimePickerDialog theme for dark mode -->
<style name="dayNightTimePickerDialogTheme" parent="Theme.MaterialComponents.DayNight.Dialog">
<item name="colorPrimary">@color/theme_primary</item>
<item name="colorPrimaryDark">@color/theme_primary_dark</item>
<item name="colorAccent">@color/theme_accent</item>
</style>

</resources>

0 comments on commit 4191dc4

Please sign in to comment.