Skip to content

Commit

Permalink
#129 の解消
Browse files Browse the repository at this point in the history
- talkerライブラリの追加(ログ)
- flutter3.3.8へアップデート
- EEWUIの`程度以上`の文字色が震度部分と異なる問題を修正
  • Loading branch information
YumNumm authored Nov 20, 2022
2 parents a85fd06 + 27757b3 commit 0ffa368
Show file tree
Hide file tree
Showing 55 changed files with 1,253 additions and 1,219 deletions.
480 changes: 252 additions & 228 deletions .dart_tool/package_config.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.3.7",
"flutterSdkVersion": "3.3.8",
"flavors": {}
}
10 changes: 9 additions & 1 deletion .github/workflows/android-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Flutter build Android(r)

on:
push:
branches: [main,android,without-firebase]
branches: [main, android, without-firebase]
workflow_dispatch:

jobs:
Expand All @@ -13,6 +13,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: pocket-apps/action-setup-firebase@v2
with:
firebase-token: ${{ secrets.FIREBASE_TOKEN }}

# https://github.com/kuhnroyal/flutter-fvm-config-action
- name: Fetch flutter config
uses: kuhnroyal/flutter-fvm-config-action@v1
Expand Down Expand Up @@ -87,6 +91,10 @@ jobs:
name: release-apk
path: build/app/outputs/flutter-apk/app-release.apk

- name: Upload obfuscate
run: |
firebase crashlytics:symbols:upload --app=1:179553945248:android:31d2c3e4dcc608f66fabc5 obfuscate/android
# - uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
Expand Down
10 changes: 7 additions & 3 deletions lib/api/dio_firebase_performance.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
// ignore_for_file: avoid_dynamic_calls

import 'package:dio/dio.dart';
import 'package:eqmonitor/utils/talker_log/log_types.dart';
import 'package:firebase_performance/firebase_performance.dart';
import 'package:logger/logger.dart';
import 'package:talker_flutter/talker_flutter.dart';

class DioFirebasePerformanceInterceptor extends Interceptor {
DioFirebasePerformanceInterceptor({
DioFirebasePerformanceInterceptor(
this.talker, {
this.requestContentLengthMethod = defaultRequestContentLength,
this.responseContentLengthMethod = defaultResponseContentLength,
});
final Talker talker;

/// key: requestKey hash code, value: ongoing metric
final _map = <int, HttpMetric>{};
Expand All @@ -31,7 +34,8 @@ class DioFirebasePerformanceInterceptor extends Interceptor {
try {
await metric.start();
} on Exception catch (e) {
Logger().e(e);
talker.logTyped(FirebasePerformanceLog(e.toString()),
logLevel: LogLevel.error);
}
if (requestContentLength != null) {
metric.requestPayloadSize = requestContentLength;
Expand Down
2 changes: 0 additions & 2 deletions lib/api/remote/kmoni.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class KyoshinMonitorApi {
//);
;

// final _logger = Logger();

/// 強震モニタ サーバ側の最新時刻を取得します
Future<DateTime> getLatestDateTime() async {
final res = await dio.get<List<int>>(
Expand Down
11 changes: 4 additions & 7 deletions lib/api/remote/kmoni/kmoni_image_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,17 @@ import 'dart:math';

import 'package:flutter/cupertino.dart';
import 'package:image/image.dart' as image_lib;
import 'package:logger/logger.dart';
import 'package:talker_flutter/talker_flutter.dart';

import '../../../model/analyzed_kyoshin_kansokuten.dart';
import '../../../schema/local/kyoshin_kansokuten.dart';
import '../../../ui/theme/jma_intensity.dart';
import 'real_time_data_type.dart';

class KyoshinImageParser {
final Logger logger = Logger(
printer: PrettyPrinter(
methodCount: 1,
printTime: true,
),
);
KyoshinImageParser(this.talker);

final Talker talker;

List<AnalyzedKoshinKansokuten> imageParse({
required List<int> picture,
Expand Down
22 changes: 14 additions & 8 deletions lib/api/remote/supabase/dio_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ import 'package:dio/dio.dart' hide Response;
import 'package:dio_http2_adapter/dio_http2_adapter.dart';
import 'package:eqmonitor/api/dio_firebase_performance.dart';
import 'package:http/http.dart';
import 'package:talker_flutter/talker_flutter.dart';

class SupabaseHttpsClientWithDioAndFirebase implements Client {
final Dio dio = Dio()
..options.connectTimeout = 5000
..interceptors.add(DioFirebasePerformanceInterceptor())
..httpClientAdapter = Http2Adapter(
ConnectionManager(
onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
),
);
SupabaseHttpsClientWithDioAndFirebase(this.talker) : super() {
dio = Dio()
..options.connectTimeout = 5000
..interceptors.add(DioFirebasePerformanceInterceptor(talker))
..httpClientAdapter = Http2Adapter(
ConnectionManager(
onClientCreate: (_, config) => config.onBadCertificate = (_) => true,
),
);
}

final Talker talker;
late Dio dio;

@override
void close() {}
Expand Down
41 changes: 22 additions & 19 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore_for_file: avoid_Logger().wtf
// ignore_for_file: avoid_talker.wdebugtf

import 'dart:async';
import 'dart:convert';
Expand All @@ -18,13 +18,15 @@ import 'package:eqmonitor/provider/init/map_area_tsunami_forecast.dart';
import 'package:eqmonitor/provider/init/parameter_earthquake.dart';
import 'package:eqmonitor/provider/init/secure_storage.dart';
import 'package:eqmonitor/provider/init/shared_preferences.dart';
import 'package:eqmonitor/provider/init/talker.dart';
import 'package:eqmonitor/provider/init/travel_time.dart';
import 'package:eqmonitor/provider/setting/crash_log_share.dart';
import 'package:eqmonitor/schema/local/kyoshin_kansokuten.dart';
import 'package:eqmonitor/schema/local/prefecture/map_polygon.dart';
import 'package:eqmonitor/schema/remote/dmdata/parameter-earthquake/parameter-earthquake.dart';
import 'package:eqmonitor/ui/app.dart';
import 'package:eqmonitor/utils/fcm/firebase_notification_controller.dart';
import 'package:eqmonitor/utils/talker_log/log_types.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:flutter/foundation.dart';
Expand All @@ -34,10 +36,10 @@ import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:intl/intl.dart' hide TextDirection;
import 'package:logger/logger.dart';
import 'package:path_provider/path_provider.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:supabase_flutter/supabase_flutter.dart';
import 'package:talker_flutter/talker_flutter.dart';

import 'firebase_options.dart';

Expand All @@ -52,27 +54,22 @@ Future<void> main() async {
statusBarColor: Colors.transparent, // transparent status bar
),
);
final talker = Talker();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);

Intl.defaultLocale = 'ja_JP';
final crashlytics = FirebaseCrashlytics.instance;
final deviceInfo = await DeviceInfoPlugin().androidInfo;
final prefs = await SharedPreferences.getInstance();
// final appInfo = await PackageInfo.fromPlatform();
// クラッシュレポートの初期化
final isCrashLogShareAllowed =
await CrashLogShareProvider(prefs).loadSettingsFromSharedPrefrences();
await crashlytics.setUserIdentifier(
deviceInfo.fingerprint,
);
await crashlytics.setCrashlyticsCollectionEnabled(
isCrashLogShareAllowed && kReleaseMode,
);

// ログ出力の初期化

// ファイル等の読み込み
late List<KyoshinKansokuten> kansokuten;
late List<MapPolygon> mapAreaForecastLocalE;
Expand All @@ -87,18 +84,19 @@ Future<void> main() async {
ParameterEarthquake? parameterEarthquake;

final futures = <Future<dynamic>>[
loadKyoshinKansokuten().then((e) => kansokuten = e),
loadMapAreaTsunamiForecast().then((e) => mapAreaTsunamiForecast = e),
loadMapAreaForecastLocalE().then((e) => mapAreaForecastLocalE = e),
loadMapAreaForecastLocalEew().then((e) => mapAreaForecastLocalEew = e),
loadMapAreaInformationCityQuake()
loadKyoshinKansokuten(talker).then((e) => kansokuten = e),
loadMapAreaTsunamiForecast(talker).then((e) => mapAreaTsunamiForecast = e),
loadMapAreaForecastLocalE(talker).then((e) => mapAreaForecastLocalE = e),
loadMapAreaForecastLocalEew(talker)
.then((e) => mapAreaForecastLocalEew = e),
loadMapAreaInformationCityQuake(talker)
.then((e) => mapAreaInformationCityQuake = e),
loadTravelTimeTable().then((e) => travelTimeTable = e),
loadTravelTimeTable(talker).then((e) => travelTimeTable = e),
getApplicationSupportDirectory().then((e) => dir = e),
Supabase.initialize(
url: Env.supabaseS1Url,
anonKey: Env.supabaseS1AnonKey,
debug: false,
debug: kDebugMode,
),
initFirebaseCloudMessaging(),
crashlytics.sendUnsentReports(),
Expand All @@ -119,12 +117,16 @@ Future<void> main() async {

//isar = await Isar.open([], directory: dir.path);
FlutterNativeSplash.remove();
Logger().d('全ての初期化が完了: ${(stopwatch..stop()).elapsedMicroseconds / 1000}ms');
talker.logTyped(
InitializationEventLog(
'全ての初期化が完了: ${(stopwatch..stop()).elapsedMicroseconds / 1000}ms',
),
);
FlutterError.onError = onFlutterError;
DartPluginRegistrant.ensureInitialized();

PlatformDispatcher.instance.onError = (error, stackTrace) {
Logger().e(error, stackTrace);
talker.handle(error, stackTrace, 'Uncaught App Exception');
if (kReleaseMode) {
crashlytics.recordError(error, stackTrace);
}
Expand Down Expand Up @@ -160,6 +162,7 @@ Future<void> main() async {
iOSDeviceInfoProvider.overrideWithValue(iosDeviceInfo),
// if (kDebugMode)
// changeLogProvider.overrideWithProvider(changeLogMockProvider),
talkerProvider.overrideWithValue(talker),
],
observers: const [
//if (kDebugMode) ProvidersLogger(),
Expand All @@ -171,7 +174,7 @@ Future<void> main() async {
}

Future<void> onFlutterError(FlutterErrorDetails details) async {
Logger().wtf('Error: ${details.exception}');
Logger().wtf('Stack: ${details.stack}');
Talker()
.handle(details.exception, details.stack, 'Uncaught Flutter Exception');
await FirebaseCrashlytics.instance.recordFlutterError(details);
}
38 changes: 0 additions & 38 deletions lib/provider/earthquake/earthquake_controller.dart

This file was deleted.

Loading

0 comments on commit 0ffa368

Please sign in to comment.