| | |
| | | package com.example.firstapp.ui.notifications |
| | | |
| | | import android.content.ClipData |
| | | import android.content.ClipboardManager |
| | | import android.content.Context |
| | | import android.content.Intent |
| | | import android.net.Uri |
| | | import android.os.Bundle |
| | | import android.view.LayoutInflater |
| | | import android.view.View |
| | | import android.view.ViewGroup |
| | | import android.widget.TextView |
| | | import android.widget.EditText |
| | | import android.widget.Toast |
| | | import androidx.fragment.app.Fragment |
| | | import androidx.lifecycle.ViewModelProvider |
| | | import androidx.navigation.fragment.findNavController |
| | | import com.google.android.material.dialog.MaterialAlertDialogBuilder |
| | | import com.example.firstapp.R |
| | | import com.example.firstapp.databinding.FragmentNotificationsBinding |
| | | |
| | | class NotificationsFragment : Fragment() { |
| | |
| | | container: ViewGroup?, |
| | | savedInstanceState: Bundle? |
| | | ): View { |
| | | val notificationsViewModel = |
| | | ViewModelProvider(this).get(NotificationsViewModel::class.java) |
| | | |
| | | _binding = FragmentNotificationsBinding.inflate(inflater, container, false) |
| | | val root: View = binding.root |
| | | |
| | | val textView: TextView = binding.textNotifications |
| | | notificationsViewModel.text.observe(viewLifecycleOwner) { |
| | | textView.text = it |
| | | setupClickListeners() |
| | | |
| | | return binding.root |
| | | } |
| | | return root |
| | | |
| | | private fun setupClickListeners() { |
| | | // 设置提醒 |
| | | binding.settingsReminder.setOnClickListener { |
| | | // 跳转到设置提醒页面 |
| | | findNavController().navigate(R.id.action_navigation_notifications_to_reminderSettingsFragment) |
| | | } |
| | | |
| | | // 关于小红书 |
| | | binding.aboutApp.setOnClickListener { |
| | | // 跳转到小红书账号页面 |
| | | val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://www.xiaohongshu.com/user/profile/64978d5c000000001001ee26")) |
| | | startActivity(intent) |
| | | } |
| | | |
| | | // 邮件联系 |
| | | binding.emailContact.setOnClickListener { |
| | | showEmailDialog() |
| | | } |
| | | |
| | | // 意见与反馈 |
| | | binding.feedback.setOnClickListener { |
| | | showFeedbackDialog() |
| | | } |
| | | |
| | | // 分享给好友 |
| | | binding.shareToFriends.setOnClickListener { |
| | | shareToWechat() |
| | | } |
| | | } |
| | | |
| | | private fun showEmailDialog() { |
| | | val email = "support@example.com" |
| | | MaterialAlertDialogBuilder(requireContext()) |
| | | .setTitle("联系邮箱") |
| | | .setMessage(email) |
| | | .setPositiveButton("复制") { _, _ -> |
| | | val clipboard = requireContext().getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager |
| | | val clip = ClipData.newPlainText("email", email) |
| | | clipboard.setPrimaryClip(clip) |
| | | Toast.makeText(context, "邮箱已复制", Toast.LENGTH_SHORT).show() |
| | | } |
| | | .setNegativeButton("取消", null) |
| | | .show() |
| | | } |
| | | |
| | | private fun showFeedbackDialog() { |
| | | val dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_feedback, null) |
| | | val editText = dialogView.findViewById<EditText>(R.id.feedback_edit_text) |
| | | |
| | | MaterialAlertDialogBuilder(requireContext()) |
| | | .setTitle("意见反馈") |
| | | .setView(dialogView) |
| | | .setPositiveButton("提交") { _, _ -> |
| | | val feedback = editText.text.toString() |
| | | if (feedback.isNotEmpty()) { |
| | | // TODO: 提交反馈到服务器 |
| | | Toast.makeText(context, "感谢您的反馈", Toast.LENGTH_SHORT).show() |
| | | } |
| | | } |
| | | .setNegativeButton("取消", null) |
| | | .show() |
| | | } |
| | | |
| | | private fun shareToWechat() { |
| | | try { |
| | | val intent = Intent() |
| | | intent.setPackage("com.tencent.mm") |
| | | intent.action = Intent.ACTION_SEND |
| | | intent.type = "text/plain" |
| | | intent.putExtra(Intent.EXTRA_TEXT, "推荐一个很棒的应用给你!") |
| | | startActivity(Intent.createChooser(intent, "分享到微信")) |
| | | } catch (e: Exception) { |
| | | Toast.makeText(context, "请先安装微信", Toast.LENGTH_SHORT).show() |
| | | } |
| | | } |
| | | |
| | | override fun onDestroyView() { |
对比新文件 |
| | |
| | | package com.example.firstapp.ui.reminder |
| | | |
| | | import android.os.Bundle |
| | | import android.view.LayoutInflater |
| | | import android.view.View |
| | | import android.view.ViewGroup |
| | | import android.widget.Toast |
| | | import androidx.fragment.app.Fragment |
| | | import androidx.navigation.fragment.findNavController |
| | | import com.example.firstapp.databinding.FragmentReminderSettingsBinding |
| | | |
| | | class ReminderSettingsFragment : Fragment() { |
| | | |
| | | private var _binding: FragmentReminderSettingsBinding? = null |
| | | private val binding get() = _binding!! |
| | | |
| | | override fun onCreateView( |
| | | inflater: LayoutInflater, |
| | | container: ViewGroup?, |
| | | savedInstanceState: Bundle? |
| | | ): View { |
| | | _binding = FragmentReminderSettingsBinding.inflate(inflater, container, false) |
| | | return binding.root |
| | | } |
| | | |
| | | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { |
| | | super.onViewCreated(view, savedInstanceState) |
| | | |
| | | // 返回按钮点击事件 |
| | | binding.btnBack.setOnClickListener { |
| | | findNavController().navigateUp() |
| | | } |
| | | |
| | | // 添加提醒按钮点击事件 |
| | | binding.btnAddReminder.setOnClickListener { |
| | | val reminderText = binding.editQuickReminder.text.toString() |
| | | if (reminderText.isNotEmpty()) { |
| | | // TODO: 保存提醒到数据库 |
| | | Toast.makeText(context, "提醒已添加", Toast.LENGTH_SHORT).show() |
| | | binding.editQuickReminder.text.clear() |
| | | } else { |
| | | Toast.makeText(context, "请输入提醒内容", Toast.LENGTH_SHORT).show() |
| | | } |
| | | } |
| | | } |
| | | |
| | | override fun onDestroyView() { |
| | | super.onDestroyView() |
| | | _binding = null |
| | | } |
| | | } |
对比新文件 |
| | |
| | | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:width="200dp" |
| | | android:height="200dp" |
| | | android:viewportWidth="1024" |
| | | android:viewportHeight="1024"> |
| | | <path |
| | | android:pathData="M833.4,62L190.6,62C120.8,62 62,133.3 62,203.3L62,835.6C62,905.4 118.6,962 188.4,962L835.6,962c69.8,0 126.4,-56.6 126.4,-126.4L962,203.3c0,-70 -58.8,-141.3 -128.6,-141.3zM897.7,833.4c0,34.9 -29.4,64.3 -64.3,64.3l-321.4,0.5 -321.4,-0.5c-34.9,0 -64.3,-29.4 -64.3,-64.3L126.3,190.6c0,-34.9 29.4,-64.3 64.3,-64.3h642.8c34.9,0 64.3,29.4 64.3,64.3v642.8z" |
| | | android:fillColor="#707070"/> |
| | | <path |
| | | android:pathData="M409.2,586.1h53.5v242.7h-53.5zM244.6,664.2h53.5v164.6h-53.5zM767.1,433.8h49.4v394.9h-49.4zM697.1,285.7L524.3,437.9l-86.4,-65.8L187,594.3l37,28.8 213.9,-189.3 86.4,65.9 209.9,-185.2L800,368l37,-172.8 -201.6,41.2zM594.3,524.3h53.5v304.4h-53.5z" |
| | | android:fillColor="#707070"/> |
| | | </vector> |
对比新文件 |
| | |
| | | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:width="200dp" |
| | | android:height="200dp" |
| | | android:viewportWidth="1024" |
| | | android:viewportHeight="1024"> |
| | | <path |
| | | android:pathData="M998.7,503.1a22.9,22.9 0,0 1,-16.4 -6.7L543.8,58.9a47.4,47.4 0,0 0,-65.5 0L41.9,496.4a23.3,23.3 0,0 1,-32.8 0.1,23 23,0 0,1 0,-32.8L445.5,26.2c34.9,-35 96.1,-34.9 130.9,0l438.5,437.4a23.2,23.2 0,0 1,0.1 32.8,23.4 23.4,0 0,1 -16.3,6.7z" |
| | | android:fillColor="#707070"/> |
| | | <path |
| | | android:pathData="M755.3,966.5H268.8c-40.8,0 -88.1,-20.8 -120.4,-53.2 -32.4,-32.6 -53.3,-79.9 -53.3,-120.6V410.4a23.2,23.2 0,0 1,46.3 0v382.3c0,28.6 16,63.9 39.7,87.7 23.4,23.4 59.5,39.7 87.7,39.7h486.5c25,0 49.1,-12.5 76,-39.7 23.4,-23.4 28.1,-60.6 28.1,-87.7V410.4c0,-12.7 10.3,-23.1 23.2,-23.1 12.8,0 23.2,10.3 23.2,23.1v382.3c0,36 -7.1,86 -41.6,120.6 -36.3,36.2 -70.9,53.2 -108.9,53.2z" |
| | | android:fillColor="#707070"/> |
| | | <path |
| | | android:pathData="M674.2,966.5L349.9,966.5v-312.8A162.4,162.4 0,0 1,512.1 491.5a162.4,162.4 0,0 1,162.2 162.2v312.8zM396.2,920.1h231.7v-266.4c0,-63.9 -52,-115.9 -115.8,-115.9s-115.9,52 -115.9,115.9v266.4z" |
| | | android:fillColor="#707070"/> |
| | | </vector> |
对比新文件 |
| | |
| | | <vector xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:width="217.6dp" |
| | | android:height="200dp" |
| | | android:viewportWidth="1114" |
| | | android:viewportHeight="1024"> |
| | | <path |
| | | android:pathData="M1081,394.7l-162.5,-278.6c-41.8,-72 -118.4,-116.1 -199.7,-116.1L393.7,-0c-81.3,0 -160.2,44.1 -199.7,116.1l-162.5,278.6c-41.8,72 -41.8,162.5 0,234.5l162.5,278.6c41.8,72 118.4,116.1 199.7,116.1h325.1c81.3,0 160.2,-44.1 199.7,-116.1l162.5,-278.6c41.8,-74.3 41.8,-162.5 0,-234.5zM1002,580.5l-162.5,278.6c-25.5,41.8 -72,69.7 -120.7,69.7L393.7,928.8c-48.8,0 -95.2,-25.5 -120.7,-69.7l-162.5,-278.6c-25.5,-44.1 -25.5,-97.5 0,-139.3l162.5,-278.6c25.5,-41.8 72,-69.7 120.7,-69.7h325.1c48.8,0 95.2,25.5 120.7,69.7l162.5,278.6c25.5,41.8 25.5,97.5 0,139.3z" |
| | | android:fillColor="#707070"/> |
| | | <path |
| | | android:pathData="M556.2,301.9c-116.1,0 -209,92.9 -209,209s92.9,209 209,209 209,-92.9 209,-209 -92.9,-209 -209,-209zM556.2,626.9c-65,0 -116.1,-51.1 -116.1,-116.1s51.1,-116.1 116.1,-116.1 116.1,51.1 116.1,116.1 -51.1,116.1 -116.1,116.1z" |
| | | android:fillColor="#707070"/> |
| | | </vector> |
| | |
| | | xmlns:app="http://schemas.android.com/apk/res-auto" |
| | | android:id="@+id/container" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:paddingTop="?attr/actionBarSize"> |
| | | android:layout_height="match_parent" > |
| | | <!-- android:paddingTop="?attr/actionBarSize"--> |
| | | |
| | | |
| | | <com.google.android.material.bottomnavigation.BottomNavigationView |
| | | android:id="@+id/nav_view" |
| | |
| | | android:layout_width="48dp" |
| | | android:layout_height="48dp" |
| | | android:background="?attr/selectableItemBackgroundBorderless" |
| | | android:src="@drawable/left_forward2" |
| | | android:src="@drawable/left_forward" |
| | | android:padding="12dp" /> |
| | | |
| | | <TextView |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:orientation="vertical" |
| | | android:padding="16dp"> |
| | | |
| | | <EditText |
| | | android:id="@+id/feedback_edit_text" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:minHeight="120dp" |
| | | android:gravity="top" |
| | | android:hint="请输入您的意见或建议" |
| | | android:padding="8dp" |
| | | android:background="@android:drawable/edit_text" /> |
| | | |
| | | </LinearLayout> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:padding="8dp" |
| | | android:text="功能" |
| | | android:textStyle="bold" |
| | | android:textSize="14sp" /> |
| | | |
| | | <!-- 设置选项 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 取录与反馈 --> |
| | | <!-- 联系与反馈 --> |
| | | <TextView |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:padding="8dp" |
| | | android:text="取录与反馈" |
| | | android:text="联系与反馈" |
| | | android:textStyle="bold" |
| | | android:textSize="14sp" /> |
| | | |
| | | <!-- 关于小红书 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 邮件联系 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 意见与反馈 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 分享给好友 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 其他区域标题 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:padding="8dp" |
| | | android:text="其他" |
| | | android:textStyle="bold" |
| | | android:textSize="14sp" /> |
| | | |
| | | <!-- 隐私协议 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 如何使用 --> |
| | |
| | | android:layout_height="wrap_content" |
| | | android:layout_alignParentEnd="true" |
| | | android:layout_centerVertical="true" |
| | | android:src="@android:drawable/ic_menu_more" /> |
| | | android:src="@drawable/right_forward" /> |
| | | </RelativeLayout> |
| | | |
| | | </LinearLayout> |
对比新文件 |
| | |
| | | <?xml version="1.0" encoding="utf-8"?> |
| | | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="match_parent" |
| | | android:orientation="vertical"> |
| | | |
| | | <!-- 标题栏 --> |
| | | <RelativeLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="?attr/actionBarSize" |
| | | android:background="#FFFFFF" |
| | | android:elevation="4dp"> |
| | | |
| | | <!-- 返回按钮 --> |
| | | <ImageButton |
| | | android:id="@+id/btn_back" |
| | | android:layout_width="48dp" |
| | | android:layout_height="48dp" |
| | | android:layout_centerVertical="true" |
| | | android:background="?attr/selectableItemBackgroundBorderless" |
| | | android:src="@android:drawable/ic_menu_close_clear_cancel" |
| | | android:contentDescription="返回" /> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:layout_centerInParent="true" |
| | | android:text="标题" |
| | | android:textSize="18sp" |
| | | android:textColor="#000000" /> |
| | | </RelativeLayout> |
| | | |
| | | <!-- 快速提醒输入框 --> |
| | | <EditText |
| | | android:id="@+id/edit_quick_reminder" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_margin="16dp" |
| | | android:background="@android:drawable/edit_text" |
| | | android:hint="快速提醒" |
| | | android:padding="12dp" /> |
| | | |
| | | <!-- 添加提醒按钮 --> |
| | | <Button |
| | | android:id="@+id/btn_add_reminder" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginHorizontal="16dp" |
| | | android:layout_marginTop="16dp" |
| | | android:backgroundTint="#03A9F4" |
| | | android:text="添加到提醒" |
| | | android:textColor="#FFFFFF" /> |
| | | |
| | | </LinearLayout> |
| | |
| | | |
| | | <item |
| | | android:id="@+id/navigation_home" |
| | | android:icon="@drawable/ic_home_black_24dp" |
| | | android:icon="@drawable/home" |
| | | android:title="@string/title_home" /> |
| | | |
| | | <item |
| | | android:id="@+id/navigation_dashboard" |
| | | android:icon="@drawable/ic_dashboard_black_24dp" |
| | | android:icon="@drawable/data" |
| | | android:title="@string/title_dashboard" /> |
| | | |
| | | <item |
| | | android:id="@+id/navigation_notifications" |
| | | android:icon="@drawable/ic_notifications_black_24dp" |
| | | android:icon="@drawable/set" |
| | | android:title="@string/title_notifications" /> |
| | | |
| | | </menu> |
| | |
| | | android:id="@+id/navigation_notifications" |
| | | android:name="com.example.firstapp.ui.notifications.NotificationsFragment" |
| | | android:label="@string/title_notifications" |
| | | tools:layout="@layout/fragment_notifications" /> |
| | | tools:layout="@layout/fragment_notifications" > |
| | | <action |
| | | android:id="@+id/action_navigation_notifications_to_reminderSettingsFragment" |
| | | app:destination="@id/reminderSettingsFragment" |
| | | app:enterAnim="@anim/nav_default_enter_anim" |
| | | app:exitAnim="@anim/nav_default_exit_anim" |
| | | app:popEnterAnim="@anim/nav_default_pop_enter_anim" |
| | | app:popExitAnim="@anim/nav_default_pop_exit_anim" /> |
| | | </fragment> |
| | | |
| | | <fragment |
| | | android:id="@+id/reminderSettingsFragment" |
| | | android:name="com.example.firstapp.ui.reminder.ReminderSettingsFragment" |
| | | android:label="设置提醒" |
| | | tools:layout="@layout/fragment_reminder_settings" /> |
| | | </navigation> |
| | |
| | | <resources> |
| | | <string name="app_name">FirstApp</string> |
| | | <string name="title_home">Home</string> |
| | | <string name="title_dashboard">Dashboard</string> |
| | | <string name="title_notifications">Notifications</string> |
| | | <string name="app_name">智信管家</string> |
| | | <string name="title_home">首页</string> |
| | | <string name="title_dashboard">数据统计</string> |
| | | <string name="title_notifications">设置</string> |
| | | |
| | | |
| | | <string name="notification_content">短信监听小程序</string> |
| | | <string name="notification_content">智信管家APP</string> |
| | | |
| | | </resources> |
| | |
| | | <resources> |
| | | <style name="SettingsItem"> |
| | | <item name="android:layout_width">match_parent</item> |
| | | <item name="android:layout_height">wrap_content</item> |
| | |
| | | <item name="android:clickable">true</item> |
| | | <item name="android:focusable">true</item> |
| | | </style> |
| | | </resources> |
| | |
| | | <resources xmlns:tools="http://schemas.android.com/tools"> |
| | | <!-- Base application theme. --> |
| | | <!-- <style name="Theme.FirstApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">--> |
| | | <style name="Theme.FirstApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar"> |
| | | <!-- Primary brand color. --> |
| | | <item name="colorPrimary">@color/purple_500</item> |