Skip to content

Commit

Permalink
Merge pull request #8 from mixin27/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mixin27 authored Sep 16, 2024
2 parents 497156a + e33d0e4 commit 5002886
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 96 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Android build and release

on:
push:
branches: develop

workflow_dispatch:

jobs:
version:
name: Create version number
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v1
- name: Use GitVersion
id: gitversion
uses: gittools/actions/gitversion/execute@v1
- name: Create version.txt with nuGetVersion
run: echo ${{ steps.gitversion.outputs.nuGetVersion }} > version.txt
- name: Upload version.txt
uses: actions/upload-artifact@v2
with:
name: gitversion
path: version.txt

build:
name: Create Android Release
needs: version
runs-on: ubuntu-latest
steps:
- name: 📚 Git Checkout
uses: actions/checkout@v1

- name: Git version.txt
uses: actions/download-artifact@v2
with:
name: gitversion

- name: Create new file without newline char from version.txt
run: tr -d '\n' < version.txt > version1.txt

- name: Read version
id: version
uses: juliangruber/read-file-action@v1
with:
path: version1.txt

- name: Update version in YAML
run: sed -i 's/99.99.99+99/${{ steps.version.outputs.content }}+${{ github.run_number }}/g' pubspec.yaml

- name: Download Android keystore
id: android_keystore
uses: timheuer/base64-to-file@v1.0.3
with:
fileName: upload-keystore.jks
encodedString: ${{ secrets.KEYSTORE_BASE64 }}

- name: Create key.properties
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" > android/key.properties
echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> android/key.properties
- name: Download Android keystore
id: google_play_service
uses: timheuer/base64-to-file@v1.0.3
with:
fileName: app/google-services.json
encodedString: ${{ secrets.GOOGLE_SERVICE_BASE64 }}

- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "12.x"
cache: gradle

- name: 🐦 Setup Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}

- name: 📦 Install Dependencies
run: |
flutter packages get
- name: ✨ Check Formatting
run: dart format --line-length 80 --set-exit-if-changed lib test

- name: 🏗️ Generate build_runner
run: dart run build_runner build -d

- name: 🌐 Generate Locale Keys
run: dart run easy_localization:generate -S assets/translations -O lib/src/l10n -o locale_keys.g.dart -f keys

- name: Start Android Release Build
run: apk --split-per-abi --target lib/main.dart --dart-define-from-file=.env

- name: Upload Android Release
uses: actions/upload-artifact@v2
with:
name: android-release
path: build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk
# path: build/app/outputs/bundle/release/app-release.aab
4 changes: 2 additions & 2 deletions lib/app_start_up.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:mmcalendar/firebase_options.dart';
import 'package:mmcalendar/src/shared/providers/mm_calendar_providers.dart';
import 'package:mmcalendar/src/utils/shared_prefs/preference_manager.dart';
// import 'package:mmcalendar/src/utils/onesignal/onesignal.dart';
import 'package:mmcalendar/src/utils/onesignal/onesignal.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'app_start_up.g.dart';
Expand All @@ -25,7 +25,7 @@ FutureOr<void> appStartup(AppStartupRef ref) async {
Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
),
// initOnesignal(),
initOnesignal(),

// list of providers to be warmed up
// ref.watch(onboardingRepositoryProvider.future),
Expand Down
1 change: 0 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'package:mmcalendar/src/features/app/app.dart';
import 'package:mmcalendar/src/l10n/l10n.dart';
import 'package:mmcalendar/src/shared/errors/async_error_logger.dart';
import 'package:mmcalendar/src/shared/errors/error_logger.dart';
// import 'package:mmcalendar/src/utils/onesignal/onesignal.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AppSettingsPage extends StatelessWidget {
),
body: ListView(
children: [
// const NotificationSwitchListTile(),
const NotificationSwitchListTile(),
const ThemeModeSwitchTile(),
const CalendarLanguageListTile(),
const AppLanguageListTile(),
Expand Down
50 changes: 25 additions & 25 deletions lib/src/utils/onesignal/onesignal.dart
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// import 'package:mmcalendar/src/utils/native_id.dart';
// import 'package:onesignal_flutter/onesignal_flutter.dart';
import 'package:mmcalendar/src/utils/native_id.dart';
import 'package:onesignal_flutter/onesignal_flutter.dart';

// const String onesignalAppId = String.fromEnvironment('ONESIGNAL_APP_ID');
const String onesignalAppId = String.fromEnvironment('ONESIGNAL_APP_ID');

// Future<void> initOnesignal() async {
// if (onesignalAppId.isEmpty) {
// throw AssertionError('ONESIGNAL_APP_ID is not set');
// }
Future<void> initOnesignal() async {
if (onesignalAppId.isEmpty) {
throw AssertionError('ONESIGNAL_APP_ID is not set');
}

// OneSignal.Debug.setLogLevel(OSLogLevel.verbose);
OneSignal.Debug.setLogLevel(OSLogLevel.verbose);

// OneSignal.initialize(onesignalAppId);
OneSignal.initialize(onesignalAppId);

// OneSignal.Notifications.requestPermission(true);
OneSignal.Notifications.requestPermission(true);

// final deviceId = await getNativeDeviceId();
// if (deviceId != null) {
// await OneSignal.login(deviceId);
// }
// }
final deviceId = await getNativeDeviceId();
if (deviceId != null) {
await OneSignal.login(deviceId);
}
}

// Future<void> disablePush([bool disable = true]) async {
// if (disable) {
// OneSignal.User.pushSubscription.optOut();
// } else {
// OneSignal.User.pushSubscription.optIn();
// }
// }
Future<void> disablePush([bool disable = true]) async {
if (disable) {
OneSignal.User.pushSubscription.optOut();
} else {
OneSignal.User.pushSubscription.optIn();
}
}

// bool? getPushSubsciption() {
// return OneSignal.User.pushSubscription.optedIn;
// }
bool? getPushSubsciption() {
return OneSignal.User.pushSubscription.optedIn;
}
12 changes: 6 additions & 6 deletions lib/src/widgets/settings/notification_switch_tile.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:iconly/iconly.dart';
// import 'package:mmcalendar/src/utils/onesignal/onesignal.dart';
import 'package:mmcalendar/src/utils/onesignal/onesignal.dart';

class NotificationSwitchListTile extends StatefulWidget {
const NotificationSwitchListTile({
Expand All @@ -18,10 +18,10 @@ class _NotificationSwitchListTileState

@override
void initState() {
// final flag = getPushSubsciption();
// setState(() {
// _enabled = flag ?? false;
// });
final flag = getPushSubsciption();
setState(() {
_enabled = flag ?? false;
});
super.initState();
}

Expand All @@ -33,7 +33,7 @@ class _NotificationSwitchListTileState
setState(() {
_enabled = newValue;
});
// await disablePush(!newValue);
await disablePush(!newValue);
},
secondary: const Icon(IconlyLight.notification),
title: const Text('Notification'),
Expand Down
Loading

0 comments on commit 5002886

Please sign in to comment.