Skip to content

Commit

Permalink
Androidの通知関連修正 (#437)
Browse files Browse the repository at this point in the history
* remove: 使われていない画像を削除

* remove: 不要なXMLの削除

* fix: [Android] Desugaringを有効に

* add: Androidにおける通知チャンネル・チャンネルグループ登録実装

* fix: ProviderObserverをmain.dartから分離

* fix: introductionScreenのPadding調整

* fix: 利用していないChannelを削除

* Restyle Androidの通知関連修正 (#438)

Restyled by whitespace

Co-authored-by: Restyled.io <[email protected]>

---------

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored Dec 4, 2023
1 parent 03ba97c commit f235143
Show file tree
Hide file tree
Showing 20 changed files with 164 additions and 143 deletions.
4 changes: 4 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ android {
compileSdk 33

compileOptions {

// Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
Expand Down Expand Up @@ -100,6 +103,7 @@ dependencies {
implementation 'androidx.core:core-splashscreen:1.0.1'
implementation 'androidx.window:window:1.0.0'
implementation 'androidx.window:window-java:1.0.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.2.2'
}

apply plugin: 'com.google.firebase.crashlytics'
7 changes: 6 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
android:launchMode="singleTop"
android:theme="@style/Theme.App.Starting"
android:windowSoftInputMode="adjustResize"
android:showWhenLocked="true"
android:turnScreenOn="true"
android:directBootAware="true">

<meta-data
Expand All @@ -46,9 +48,12 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:exported="false"
android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" />

<meta-data
android:name="flutterEmbedding"
android:value="2" />
</application>

</manifest>
</manifest>
12 changes: 0 additions & 12 deletions android/app/src/main/res/drawable-v21/launch_background.xml

This file was deleted.

Binary file removed android/app/src/main/res/drawable/int0.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int1.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int2.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int3.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int4.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int5m.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int5p.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int6m.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int6p.PNG
Binary file not shown.
Binary file removed android/app/src/main/res/drawable/int7.PNG
Binary file not shown.
17 changes: 0 additions & 17 deletions android/app/src/main/res/drawable/launch_background.xml

This file was deleted.

Binary file removed android/app/src/main/res/drawable/unknown.PNG
Binary file not shown.
4 changes: 2 additions & 2 deletions android/app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<color name="light_blue_200">#FF81D4FA</color>
<color name="light_blue_600">#FF039BE5</color>
<color name="light_blue_900">#FF01579B</color>
<color name="splash_bg">#E9F5FF</color>
</resources>
<color name="splash_bg">#3A3A3A</color>
</resources>
89 changes: 49 additions & 40 deletions lib/core/fcm/channels.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,26 @@ final List<AndroidNotificationChannel> notificationChannels = [
groupId: 'fromdev',
importance: Importance.high,
),

//! EEW
const AndroidNotificationChannel(
'eew_alert',
'eew_warning',
'緊急地震速報(警報)',
groupId: 'eew',
description: '緊急地震速報(警報)通知',
ledColor: Color.fromARGB(255, 190, 0, 0),
importance: Importance.max,
),
const AndroidNotificationChannel(
'eew',
'eew_forecast',
'緊急地震速報(予報)',
groupId: 'eew',
description: '緊急地震速報(予報)通知',
ledColor: Color.fromARGB(255, 190, 0, 0),
importance: Importance.high,
),

//! 地震通知
const AndroidNotificationChannel(
'VZSE40',
groupId: 'earthquake',
'地震・津波に関するお知らせ',
description: '地震・津波の試験・訓練配信のお知らせ、自治体震度データの入電停止等のお知らせ、その他を発表',
importance: Importance.low,
),
const AndroidNotificationChannel(
'VTSE41',
groupId: 'tsunami',
'津波警報・注意報・予報',
description:
'影響をもたらす津波が到達すると予測された地域、または影響がなくなった地域に対して、津波警報・注意報・予報の発表・切替及び解除について、予報区ごとに予想の高さや津波到達時間、震源要素等を発表',
importance: Importance.max,
),
const AndroidNotificationChannel(
'VTSE51',
groupId: 'tsunami',
'津波情報',
description: '各地の満潮時刻、津波到達予想時刻に関する情報及び地上観測点における津波観測に関する情報を発表',
importance: Importance.high,
),
const AndroidNotificationChannel(
'VTSE52',
groupId: 'tsunami',
'沖合の津波情報',
description: '沖合の観測点における津波観測に関する情報を発表',
importance: Importance.high,
),
const AndroidNotificationChannel(
'WEPA60',
groupId: 'tsunami',
'国際津波関連情報(国内向け)',
description:
'北西太平洋域でM6.5以上の地震が発生した場合、北西太平洋域の各国が津波警報等の発表に資するための支援情報として発表するものを複製した国内向け配信',
importance: Importance.high,
),
const AndroidNotificationChannel(
'VXSE51',
groupId: 'earthquake',
Expand All @@ -87,6 +52,7 @@ final List<AndroidNotificationChannel> notificationChannels = [
description: '震源要素・各地の震度、海外で発生した大きな地震の震源要素等、津波の有無を通知',
importance: Importance.high,
),
/*
const AndroidNotificationChannel(
'VXSE56',
groupId: 'earthquake',
Expand All @@ -101,6 +67,7 @@ final List<AndroidNotificationChannel> notificationChannels = [
description: '顕著な地震に対して、有感地震の回数経過状況を発表',
importance: Importance.high,
),
*/
const AndroidNotificationChannel(
'VXSE61',
groupId: 'earthquake',
Expand All @@ -114,6 +81,45 @@ final List<AndroidNotificationChannel> notificationChannels = [
description: '長周期地震動階級1以上を観測した地震について、観測した要素などを地震発生後10分程度で発表',
importance: Importance.high,
),

const AndroidNotificationChannel(
'VZSE40',
groupId: 'earthquake',
'地震・津波に関するお知らせ',
description: '地震・津波の試験・訓練配信のお知らせ、自治体震度データの入電停止等のお知らせ、その他を発表',
importance: Importance.low,
),
/*
const AndroidNotificationChannel(
'VTSE41',
groupId: 'tsunami',
'津波警報・注意報・予報',
description:
'影響をもたらす津波が到達すると予測された地域、または影響がなくなった地域に対して、津波警報・注意報・予報の発表・切替及び解除について、予報区ごとに予想の高さや津波到達時間、震源要素等を発表',
importance: Importance.max,
),
const AndroidNotificationChannel(
'VTSE51',
groupId: 'tsunami',
'津波情報',
description: '各地の満潮時刻、津波到達予想時刻に関する情報及び地上観測点における津波観測に関する情報を発表',
importance: Importance.high,
),
const AndroidNotificationChannel(
'VTSE52',
groupId: 'tsunami',
'沖合の津波情報',
description: '沖合の観測点における津波観測に関する情報を発表',
importance: Importance.high,
),
const AndroidNotificationChannel(
'WEPA60',
groupId: 'tsunami',
'国際津波関連情報(国内向け)',
description:
'北西太平洋域でM6.5以上の地震が発生した場合、北西太平洋域の各国が津波警報等の発表に資するための支援情報として発表するものを複製した国内向け配信',
importance: Importance.high,
),
const AndroidNotificationChannel(
'VYSE50',
groupId: 'earthquake',
Expand All @@ -135,7 +141,7 @@ final List<AndroidNotificationChannel> notificationChannels = [
'南海トラフ地震関連解説情報(定例)',
description: '南海トラフ沿いの地震に関する評価検討会の定例会合における調査結果の発表',
importance: Importance.high,
),
),*/
];

final List<AndroidNotificationChannelGroup> notificationChannelGroups = [
Expand All @@ -146,13 +152,16 @@ final List<AndroidNotificationChannelGroup> notificationChannelGroups = [
const AndroidNotificationChannelGroup(
'earthquake',
'地震通知',
description: '緊急地震速報を除く地震に関する情報をお伝えします',
),
const AndroidNotificationChannelGroup(
'tsunami',
'津波通知',
description: '津波に関する情報をお伝えします',
),
const AndroidNotificationChannelGroup(
'fromdev',
'開発者からのお知らせ',
description: '開発者からの連絡に使用されます。',
),
];
73 changes: 73 additions & 0 deletions lib/core/provider/custom_provider_observer.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import 'dart:developer';

import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:talker_flutter/talker_flutter.dart';

class CustomProviderObserver extends ProviderObserver {
CustomProviderObserver(this.talker);

final Talker talker;

@override
void didAddProvider(
ProviderBase<Object?> provider,
Object? value,
ProviderContainer container,
) =>
switch (provider.name) {
_ when value.toString().length > 1000 => log(
'${provider.name} (${provider.runtimeType}) '
'${value?.toString().length} ',
name: 'didAddProvider',
),
_ => log(
'${provider.name} ($provider)',
name: 'didAddProvider',
),
};

@override
void didDisposeProvider(
ProviderBase<Object?> provider,
ProviderContainer container,
) =>
log('didDisposeProvider: ${provider.name}');

@override
void didUpdateProvider(
ProviderBase<Object?> provider,
Object? previousValue,
Object? newValue,
ProviderContainer container,
) =>
switch (provider.name) {
'mapViewModelProvider' || 'kmoniViewModelProvider' => null,
_
when newValue.toString().length + previousValue.toString().length >
300 =>
log(
'${provider.name} (${previousValue.runtimeType} '
'-> ${newValue.runtimeType})',
name: 'didUpdateProvider',
),
_ => log(
'${provider.name} ($previousValue -> $newValue)',
name: 'didUpdateProvider',
),
};

@override
void providerDidFail(
ProviderBase<Object?> provider,
Object error,
StackTrace stackTrace,
ProviderContainer container,
) {
talker.handle(error, stackTrace, 'providerDidFail: ${provider.name}');
log(
'${provider.name} $error',
name: 'providerDidFail',
error: error,
);
}
}
6 changes: 5 additions & 1 deletion lib/feature/setup/pages/introduction_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ class IntroductionPage extends StatelessWidget {
),
// このボタンを押して、利用規約とプライバシーポリシーに同意したものとみなします。
Card(
margin: const EdgeInsets.symmetric(horizontal: 8),
margin: const EdgeInsets.only(
left: 8,
right: 8,
bottom: 8,
),
child: Padding(
padding: const EdgeInsets.all(8),
child: Text.rich(
Expand Down
Loading

0 comments on commit f235143

Please sign in to comment.