From e41ac8f36700c2e439b791a185a7c2533aa7223c Mon Sep 17 00:00:00 2001 From: zhou2008 <493505110@qq.com> Date: Wed, 31 Jul 2024 19:07:32 +0800 Subject: [PATCH] add calendar support --- .../presentation/radarScreen/RadarFragment.kt | 12 +++++++++++- app/src/main/res/layout/fragment_radar.xml | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt b/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt index 45e91a34..e4e15ec0 100644 --- a/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt +++ b/app/src/main/java/com/rtbishop/look4sat/presentation/radarScreen/RadarFragment.kt @@ -17,7 +17,9 @@ */ package com.rtbishop.look4sat.presentation.radarScreen +import android.content.Intent import android.os.Bundle +import android.provider.CalendarContract import android.view.View import androidx.fragment.app.Fragment import androidx.fragment.app.viewModels @@ -106,7 +108,15 @@ class RadarFragment : Fragment(R.layout.fragment_radar) { val direction = RadarFragmentDirections.globalToMap(pass.catNum) findNavController().navigate(direction) } - radarBtnNotify.isEnabled = false + radarBtnNotify.clickWithDebounce { + val intent = Intent(Intent.ACTION_INSERT) + .setData(CalendarContract.Events.CONTENT_URI) + .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, pass.aosTime) + .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, pass.losTime) + .putExtra(CalendarContract.Events.TITLE, pass.name) + .putExtra(CalendarContract.Events.DESCRIPTION, "Look4Sat") + startActivity(intent) + } radarBtnSettings.clickWithDebounce { val direction = RadarFragmentDirections.globalToSettings() findNavController().navigate(direction) diff --git a/app/src/main/res/layout/fragment_radar.xml b/app/src/main/res/layout/fragment_radar.xml index 07faa1e5..0d6114a3 100644 --- a/app/src/main/res/layout/fragment_radar.xml +++ b/app/src/main/res/layout/fragment_radar.xml @@ -199,7 +199,6 @@ android:layout_width="0dp" android:layout_marginStart="@dimen/button_margin_side" android:text="@string/btn_notify" - android:textColor="@color/textDisabled" app:layout_constraintBottom_toBottomOf="@+id/radar_coordinator" app:layout_constraintEnd_toStartOf="@+id/radar_visibility" app:layout_constraintHorizontal_bias="0.5"