~repos /only-bible-app
GIT_CONFIG_PARAMETERS="'http.version=HTTP/1.1'" git clone
https://git.pyrossh.dev/only-bible-app.git
Discussions:
https://groups.google.com/g/rust-embed-devs
The only bible app you will ever need. No ads. No in-app purchases. No distractions.
c4e7500c
—
pyrossh 1 month ago
Bring previous version settings back again
- android/app/src/main/kotlin/dev/pyrossh/onlyBible/MainActivity.kt +21 -1
- ios/Podfile.lock +1 -1
- ios/Runner/AppDelegate.swift +26 -10
- lib/env.dart +1 -1
- lib/main.dart +9 -2
- lib/services/highlighted_verses_service.dart +19 -0
android/app/src/main/kotlin/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
+
import android.content.Context
|
|
3
4
|
import io.flutter.embedding.android.FlutterActivity
|
|
5
|
+
import io.flutter.embedding.engine.FlutterEngine
|
|
6
|
+
import io.flutter.plugin.common.MethodChannel
|
|
4
7
|
|
|
5
|
-
class MainActivity : FlutterActivity()
|
|
8
|
+
class MainActivity : FlutterActivity() {
|
|
9
|
+
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
|
10
|
+
super.configureFlutterEngine(flutterEngine)
|
|
11
|
+
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, "dev.pyrossh.onlyBible/settings").setMethodCallHandler { call, result ->
|
|
12
|
+
val prefs = applicationContext.getSharedPreferences("data", Context.MODE_PRIVATE)
|
|
13
|
+
when (call.method) {
|
|
14
|
+
"getHighlightedVerses" -> {
|
|
15
|
+
result.success(prefs.getString("highlightedVerses", "{}"))
|
|
16
|
+
}
|
|
17
|
+
"deleteHighlightedVerses" -> {
|
|
18
|
+
prefs.edit().remove("highlightedVerses").apply()
|
|
19
|
+
result.success(null)
|
|
20
|
+
}
|
|
21
|
+
else -> result.notImplemented()
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
ios/Podfile.lock
CHANGED
|
@@ -17,6 +17,6 @@ SPEC CHECKSUMS:
|
|
|
17
17
|
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
|
|
18
18
|
flutter_soloud: 272cc604453b6ca135f274045fb259e7c6426122
|
|
19
19
|
|
|
20
|
-
PODFILE CHECKSUM:
|
|
20
|
+
PODFILE CHECKSUM: 251cb053df7158f337c0712f2ab29f4e0fa474ce
|
|
21
21
|
|
|
22
22
|
COCOAPODS: 1.16.2
|
ios/Runner/AppDelegate.swift
CHANGED
|
@@ -2,15 +2,31 @@ import Flutter
|
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
4
|
@main
|
|
5
|
-
@objc class AppDelegate: FlutterAppDelegate
|
|
5
|
+
@objc class AppDelegate: FlutterAppDelegate {
|
|
6
|
-
|
|
6
|
+
override func application(
|
|
7
|
-
|
|
7
|
+
_ application: UIApplication,
|
|
8
|
-
|
|
8
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
9
|
-
|
|
9
|
+
) -> Bool {
|
|
10
|
-
|
|
10
|
+
GeneratedPluginRegistrant.register(with: self)
|
|
11
|
-
}
|
|
12
11
|
|
|
13
|
-
func didInitializeImplicitFlutterEngine(_ engineBridge: FlutterImplicitEngineBridge) {
|
|
14
|
-
|
|
12
|
+
let registrar = self.registrar(forPlugin: "HighlightedVersesPlugin")!
|
|
13
|
+
let channel = FlutterMethodChannel(
|
|
14
|
+
name: "dev.pyrossh.onlyBible/settings",
|
|
15
|
+
binaryMessenger: registrar.messenger()
|
|
16
|
+
)
|
|
17
|
+
channel.setMethodCallHandler { (call: FlutterMethodCall, result: @escaping FlutterResult) in
|
|
18
|
+
switch call.method {
|
|
19
|
+
case "getHighlightedVerses":
|
|
20
|
+
let json = UserDefaults.standard.string(forKey: "highlightedVerses") ?? "{}"
|
|
21
|
+
result(json)
|
|
22
|
+
case "deleteHighlightedVerses":
|
|
23
|
+
UserDefaults.standard.removeObject(forKey: "highlightedVerses")
|
|
24
|
+
result(nil)
|
|
25
|
+
default:
|
|
26
|
+
result(FlutterMethodNotImplemented)
|
|
15
|
-
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
31
|
+
}
|
|
16
32
|
}
|
lib/env.dart
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
abstract class Env {
|
|
2
2
|
static const String ttsSubscriptionKey = String.fromEnvironment(
|
|
3
|
-
"
|
|
3
|
+
"AZURE_TTS_SUBSCRIPTION_KEY",
|
|
4
4
|
);
|
|
5
5
|
|
|
6
6
|
static const String resendApiKey = String.fromEnvironment(
|
lib/main.dart
CHANGED
|
@@ -8,8 +8,10 @@ import "package:flutter_native_splash/flutter_native_splash.dart";
|
|
|
8
8
|
import "package:async_redux/async_redux.dart";
|
|
9
9
|
import "package:only_bible_app/app.dart";
|
|
10
10
|
import "package:only_bible_app/dialog.dart";
|
|
11
|
+
import "package:only_bible_app/env.dart";
|
|
11
12
|
import "package:only_bible_app/store/app_persistor.dart";
|
|
12
13
|
import "package:only_bible_app/store/app_state.dart";
|
|
14
|
+
import "package:only_bible_app/services/highlighted_verses_service.dart";
|
|
13
15
|
import "package:only_bible_app/utils.dart";
|
|
14
16
|
|
|
15
17
|
final navigatorKey = GlobalKey<NavigatorState>();
|
|
@@ -73,7 +75,7 @@ void main() async {
|
|
|
73
75
|
};
|
|
74
76
|
await SoLoud.instance.init();
|
|
75
77
|
FlutterAzureTts.init(
|
|
76
|
-
subscriptionKey:
|
|
78
|
+
subscriptionKey: Env.ttsSubscriptionKey,
|
|
77
79
|
region: "centralindia",
|
|
78
80
|
withLogs: true,
|
|
79
81
|
);
|
|
@@ -81,7 +83,12 @@ void main() async {
|
|
|
81
83
|
final json = await persistor.readJson();
|
|
82
84
|
final bibleName = json?["bibleName"] as String? ?? "en_kjv";
|
|
83
85
|
final bible = await loadBible(bibleName);
|
|
84
|
-
|
|
86
|
+
var initialState = json != null ? AppState.fromJson(json, bible) : AppState(bible: bible);
|
|
87
|
+
final oldHighlights = await HighlightedVersesService.getHighlightedVerses();
|
|
88
|
+
if (oldHighlights.isNotEmpty) {
|
|
89
|
+
initialState = initialState.copy(highlights: {...initialState.highlights, ...oldHighlights});
|
|
90
|
+
await HighlightedVersesService.deleteHighlightedVerses();
|
|
91
|
+
}
|
|
85
92
|
final store = Store<AppState>(
|
|
86
93
|
initialState: initialState,
|
|
87
94
|
persistor: persistor,
|
lib/services/highlighted_verses_service.dart
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import "dart:convert";
|
|
2
|
+
import "package:flutter/services.dart";
|
|
3
|
+
|
|
4
|
+
class HighlightedVersesService {
|
|
5
|
+
static const _channel = MethodChannel("dev.pyrossh.onlyBible/settings");
|
|
6
|
+
|
|
7
|
+
static Future<Map<String, int>> getHighlightedVerses() async {
|
|
8
|
+
final String? jsonStr = await _channel.invokeMethod<String>("getHighlightedVerses");
|
|
9
|
+
if (jsonStr == null || jsonStr.isEmpty || jsonStr == "{}") {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
final Map<String, dynamic> decoded = json.decode(jsonStr);
|
|
13
|
+
return decoded.map((key, value) => MapEntry(key, value as int));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static Future<void> deleteHighlightedVerses() async {
|
|
17
|
+
await _channel.invokeMethod<void>("deleteHighlightedVerses");
|
|
18
|
+
}
|
|
19
|
+
}
|