From 59cfedd355f506a01b98aef2cf77f681a246126c Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 27 Jan 2023 11:06:20 +0800 Subject: [PATCH] style: use official calendar --- .../java/org/telegram/ui/ChatActivity.java | 38 +++++-------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 2418e4e37..a95b62c25 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -6866,39 +6866,19 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } AndroidUtilities.hideKeyboard(searchItem.getSearchField()); Calendar calendar = Calendar.getInstance(); + calendar.setTimeInMillis((long) floatingDateView.getCustomDate() * 1000); int year = calendar.get(Calendar.YEAR); int monthOfYear = calendar.get(Calendar.MONTH); int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); - try { - DatePickerDialog dialog = new DatePickerDialog(getParentActivity(), (view1, year1, month, dayOfMonth1) -> { - Calendar calendar1 = Calendar.getInstance(); - calendar1.clear(); - calendar1.set(year1, month, dayOfMonth1); - int date = (int) (calendar1.getTime().getTime() / 1000); - jumpToDate(date); - }, year, monthOfYear, dayOfMonth); - final DatePicker datePicker = dialog.getDatePicker(); - datePicker.setMinDate(1375315200000L); - datePicker.setMaxDate(System.currentTimeMillis()); - dialog.setButton(DialogInterface.BUTTON_POSITIVE, LocaleController.getString("JumpToDate", R.string.JumpToDate), dialog); - dialog.setButton(DialogInterface.BUTTON_NEGATIVE, LocaleController.getString("Cancel", R.string.Cancel), (dialog1, which) -> { - }); - if (Build.VERSION.SDK_INT >= 21) { - dialog.setOnShowListener(dialog12 -> { - int count = datePicker.getChildCount(); - for (int a = 0; a < count; a++) { - View child = datePicker.getChildAt(a); - ViewGroup.LayoutParams layoutParams = child.getLayoutParams(); - layoutParams.width = LayoutHelper.MATCH_PARENT; - child.setLayoutParams(layoutParams); - } - }); - } - showDialog(dialog); - } catch (Exception e) { - FileLog.e(e); - } + calendar.clear(); + calendar.set(year, monthOfYear, dayOfMonth); + Bundle bundle = new Bundle(); + bundle.putLong("dialog_id", dialog_id); + bundle.putInt("topic_id", getTopicId()); + bundle.putInt("type", CalendarActivity.TYPE_CHAT_ACTIVITY); + CalendarActivity calendarActivity = new CalendarActivity(bundle, SharedMediaLayout.FILTER_PHOTOS_AND_VIDEOS, (int) (calendar.getTime().getTime() / 1000)); + presentFragment(calendarActivity); return true; }); if (currentChat != null) {