~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.
8463845b
—
pyrossh 2 weeks ago
remove getting highlighted verses from the previous app settings
android/app/src/main/kotlin/dev/pyrossh/onlyBible/MainActivity.kt
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
package dev.pyrossh.onlyBible
|
|
2
2
|
|
|
3
|
-
import android.content.Context
|
|
4
3
|
import io.flutter.embedding.android.FlutterActivity
|
|
5
|
-
import io.flutter.embedding.engine.FlutterEngine
|
|
6
|
-
import io.flutter.plugin.common.MethodChannel
|
|
7
4
|
|
|
8
|
-
class MainActivity : FlutterActivity()
|
|
5
|
+
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/Runner/AppDelegate.swift
CHANGED
|
@@ -8,25 +8,6 @@ import UIKit
|
|
|
8
8
|
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
9
9
|
) -> Bool {
|
|
10
10
|
GeneratedPluginRegistrant.register(with: self)
|
|
11
|
-
|
|
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)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
11
|
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
|
|
31
12
|
}
|
|
32
13
|
}
|
lib/main.dart
CHANGED
|
@@ -11,7 +11,6 @@ import "package:only_bible_app/dialog.dart";
|
|
|
11
11
|
import "package:only_bible_app/env.dart";
|
|
12
12
|
import "package:only_bible_app/store/app_persistor.dart";
|
|
13
13
|
import "package:only_bible_app/store/app_state.dart";
|
|
14
|
-
import "package:only_bible_app/services/highlighted_verses_service.dart";
|
|
15
14
|
import "package:only_bible_app/utils.dart";
|
|
16
15
|
|
|
17
16
|
final navigatorKey = GlobalKey<NavigatorState>();
|
|
@@ -83,12 +82,7 @@ void main() async {
|
|
|
83
82
|
final json = await persistor.readJson();
|
|
84
83
|
final bibleName = json?["bibleName"] as String? ?? "en_kjv";
|
|
85
84
|
final bible = await loadBible(bibleName);
|
|
86
|
-
|
|
85
|
+
final 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
|
-
}
|
|
92
86
|
final store = Store<AppState>(
|
|
93
87
|
initialState: initialState,
|
|
94
88
|
persistor: persistor,
|
lib/services/highlighted_verses_service.dart
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|