Skip to content

Commit 68ce251

Browse files
Merge pull request #38 from OctagonalStar/feat/add-noification
Feat/add-noification
2 parents 500cade + 7709dd1 commit 68ce251

File tree

20 files changed

+691
-55
lines changed

20 files changed

+691
-55
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- 添加了日志捕获 [#23](https://github.com/OctagonalStar/arabic_learning/issues/23)
88
- 添加了调试页面
99
- 添加了个性化FSRS预设页面 [#26](https://github.com/OctagonalStar/arabic_learning/issues/26)
10+
- 添加了安卓通知功能 [#24](https://github.com/OctagonalStar/arabic_learning/issues/24)
1011

1112
### Improvement
1213

@@ -18,6 +19,7 @@
1819

1920
- 修复了FSRS算法对已经过期的单词无法计数的问题
2021
- 修复了日志中FSRS信息输出错误的问题
22+
- 修复了新用户无法进入的问题
2123

2224
## v0.1.11 - 2025-11-28 - (000111)
2325

android/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ gradle-wrapper.jar
66
/local.properties
77
GeneratedPluginRegistrant.java
88
.cxx/
9+
build/
910

1011
# Remember to never publicly share your keystore.
1112
# See https://flutter.dev/to/reference-keystore

android/app/build.gradle.kts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ if (keystorePropertiesFile.exists()) {
1616

1717
android {
1818
namespace = "com.ayuban.arlearning"
19-
compileSdk = flutter.compileSdkVersion
19+
compileSdk = 36
2020
ndkVersion = flutter.ndkVersion
2121

2222
compileOptions {
23+
isCoreLibraryDesugaringEnabled = true
2324
sourceCompatibility = JavaVersion.VERSION_11
2425
targetCompatibility = JavaVersion.VERSION_11
2526
}
@@ -29,14 +30,12 @@ android {
2930
}
3031

3132
defaultConfig {
32-
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
3333
applicationId = "com.ayuban.arlearning"
34-
// You can update the following values to match your application needs.
35-
// For more information, see: https://flutter.dev/to/review-gradle-config.
3634
minSdk = flutter.minSdkVersion
3735
targetSdk = flutter.targetSdkVersion
3836
versionCode = flutter.versionCode
3937
versionName = flutter.versionName
38+
multiDexEnabled = true
4039
}
4140

4241
signingConfigs {
@@ -50,8 +49,6 @@ android {
5049

5150
buildTypes {
5251
release {
53-
// TODO: Add your own signing config for the release build.
54-
// Signing with the debug keys for now, so `flutter run --release` works.
5552
signingConfig = signingConfigs.getByName("release")
5653
}
5754
}
@@ -60,3 +57,13 @@ android {
6057
flutter {
6158
source = "../.."
6259
}
60+
61+
62+
dependencies {
63+
coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
64+
65+
implementation("androidx.window:window:1.0.0")
66+
implementation("androidx.window:window-java:1.0.0")
67+
68+
implementation("androidx.multidex:multidex:2.0.1")
69+
}

android/app/src/main/AndroidManifest.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@
2727
<category android:name="android.intent.category.LAUNCHER"/>
2828
</intent-filter>
2929
</activity>
30+
31+
<!-- 通知图标 -->
32+
<meta-data
33+
android:name="com.google.firebase.messaging.default_notification_icon"
34+
android:resource="@drawable/notification_icon" />
35+
<!-- 通知颜色 -->
36+
<meta-data
37+
android:name="com.google.firebase.messaging.default_notification_color"
38+
android:resource="@color/notification_color" />
39+
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
40+
<receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
41+
<intent-filter>
42+
<action android:name="android.intent.action.BOOT_COMPLETED"/>
43+
<action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
44+
<action android:name="android.intent.action.QUICKBOOT_POWERON" />
45+
<action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
46+
</intent-filter>
47+
</receiver>
48+
3049
<!-- Don't delete the meta-data below.
3150
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
3251
<meta-data
@@ -35,6 +54,10 @@
3554
</application>
3655
<!-- Required to fetch data from the internet. -->
3756
<uses-permission android:name="android.permission.INTERNET" />
57+
<uses-permission android:name="android.permission.VIBRATE" />
58+
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
59+
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
60+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
3861
<!-- Required to query activities that can process text, see:
3962
https://developer.android.com/training/package-visibility and
4063
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
15.6 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- 通知颜色定义 -->
4+
<color name="notification_color">#2196F3</color>
5+
<color name="notification_accent_color">#FF4081</color>
6+
</resources>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<!-- 通知颜色定义 -->
4+
<color name="notification_color">#2196F3</color>
5+
<color name="notification_accent_color">#FF4081</color>
6+
</resources>

android/build.gradle.kts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// android/build.gradle.kts
2+
3+
buildscript {
4+
repositories {
5+
google()
6+
mavenCentral()
7+
}
8+
9+
dependencies {
10+
classpath("com.android.tools.build:gradle:8.6.0")
11+
// classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10")
12+
}
13+
}
14+
115
allprojects {
216
repositories {
317
google()
@@ -15,10 +29,11 @@ subprojects {
1529
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
1630
project.layout.buildDirectory.value(newSubprojectBuildDir)
1731
}
32+
1833
subprojects {
1934
project.evaluationDependsOn(":app")
2035
}
2136

2237
tasks.register<Delete>("clean") {
2338
delete(rootProject.layout.buildDirectory)
24-
}
39+
}

ios/Runner/AppDelegate.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import UIKit
77
_ application: UIApplication,
88
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
99
) -> Bool {
10+
if #available(iOS 10.0, *) {
11+
UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
12+
}
1013
GeneratedPluginRegistrant.register(with: self)
1114
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
1215
}

lib/funcs/fsrs_func.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FSRS {
2020
if(!prefs.containsKey("fsrsData")) {
2121
logger.info("未发现FSRS配置,加载默认配置");
2222
config = FSRSConfig();
23-
prefs.setString("fsrsData", jsonEncode(config));
23+
prefs.setString("fsrsData", jsonEncode(config.toMap()));
2424
return false;
2525
} else {
2626
config = FSRSConfig.buildFromMap(jsonDecode(prefs.getString("fsrsData")!));

0 commit comments

Comments
 (0)