Skip to content

Commit

Permalink
Upversion everything, fix various flutter issues/workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
kmac committed May 8, 2022
1 parent e5c0c94 commit 04deb7c
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 153 deletions.
6 changes: 4 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 30
// compileSdkVersion 31
compileSdkVersion flutter.compileSdkVersion

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -45,7 +46,8 @@ android {
defaultConfig {
applicationId "com.kmac5dev.mindfulnotifier"
minSdkVersion 21
targetSdkVersion 30
// targetSdkVersion 31
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand Down
18 changes: 1 addition & 17 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kmac5dev.mindfulnotifier">
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.
In most cases you can leave this as-is, but you if you want to provide
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:name="${applicationName}"
android:label="Mindful Notifier"
android:icon="@mipmap/ic_launcher">
<activity
Expand All @@ -24,17 +19,6 @@
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<!--
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
-->
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.4'
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand Down
3 changes: 1 addition & 2 deletions android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionSha256Sum=abc10bcedb58806e8654210f96031db541bcd2d6fc3161e81cb0572d6a15e821
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
4 changes: 2 additions & 2 deletions lib/components/datastore.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:convert';
import 'dart:math';
import 'package:flutter/foundation.dart';
import 'package:hive/hive.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down Expand Up @@ -250,7 +249,8 @@ abstract class ScheduleDataStoreBase {
static const int defaultQuietHoursEndHour = 9;
static const int defaultQuietHoursEndMinute = 0;
static const bool defaultNotifyQuietHours = false;
static const String defaultReminderMessage = constants.reminderMessageDisabled;
static const String defaultReminderMessage =
constants.reminderMessageDisabled;
static const String defaultInfoMessage = constants.infoMessageDisabled;
static const String defaultControlMessage = '';
static const String defaultTheme = 'Default';
Expand Down
10 changes: 9 additions & 1 deletion lib/components/scheduler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path_provider_android/path_provider_android.dart';
import 'package:shared_preferences_android/shared_preferences_android.dart';

import 'package:mindfulnotifier/components/alarmservice.dart';
import 'package:mindfulnotifier/components/constants.dart' as constants;
Expand Down Expand Up @@ -78,14 +80,19 @@ class Scheduler {
Future<void> init() async {
logger.i("Initializing scheduler ${getCurrentIsolate()}");

// TEMPORARY: fix eof SharedPreferences and PathProvider
// https://github.com/flutter/flutter/issues/99155#issuecomment-1052023743:
// This will be replaced with 'DartPluginRegistrant.ensureInitialized()'
SharedPreferencesAndroid.registerWith();
PathProviderAndroid.registerWith();
try {
PackageInfo info = await PackageInfo.fromPlatform();
Get.put(info);
} catch (e) {
// throws during testing
}

ds = await ScheduleDataStore.getInstance();
ds ??= await ScheduleDataStore.getInstance();
Get.delete<ScheduleDataStore>();
Get.put(ds, permanent: true);

Expand Down Expand Up @@ -191,6 +198,7 @@ class Scheduler {
}

Future<void> sendDataStoreUpdate() async {
ds ??= await ScheduleDataStore.getInstance();
sendValueToUI('syncDataStore', ds.getInMemoryInstance());
}

Expand Down
2 changes: 0 additions & 2 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:device_info_plus/device_info_plus.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mindfulnotifier/components/utils.dart';
Expand All @@ -12,7 +11,6 @@ import 'package:mindfulnotifier/components/router.dart' as router;
import 'package:mindfulnotifier/components/alarmservice.dart';
import 'package:mindfulnotifier/theme/themes.dart';


void main() async {
// needed if you intend to initialize in the `main` function
WidgetsFlutterBinding.ensureInitialized();
Expand Down
12 changes: 3 additions & 9 deletions lib/screens/about.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:mindfulnotifier/components/constants.dart';
Expand Down Expand Up @@ -87,13 +85,9 @@ This project is licensed under the terms of the [GNU General Public License v3.0
""";

Future<void> launchInBrowser(String url) async {
if (await canLaunch(url)) {
await launch(
url,
forceSafariVC: false,
forceWebView: false,
headers: <String, String>{'my_header_key': 'my_header_value'},
);
Uri uri = Uri.parse(url);
if (await canLaunchUrl(uri)) {
await launchUrl(uri, mode: LaunchMode.platformDefault);
} else {
throw 'Could not launch $url';
}
Expand Down
11 changes: 4 additions & 7 deletions lib/screens/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ import 'dart:io';
import 'dart:convert';
import 'dart:typed_data';

import 'package:battery_optimization/battery_optimization.dart';
import 'package:optimization_battery/optimization_battery.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:share_plus/share_plus.dart';
Expand Down Expand Up @@ -104,8 +102,7 @@ class GeneralWidgetController extends GetxController {
InMemoryScheduleDataStore mds = Get.find();

// update alarm service with new memory store
Get.find<MindfulNotifierWidgetController>()
.updatePermanentDataStore(mds);
Get.find<MindfulNotifierWidgetController>().updatePermanentDataStore(mds);

scheduleDirty.value = false;
}
Expand Down Expand Up @@ -273,7 +270,7 @@ class GeneralWidget extends StatelessWidget {
}

void _checkBatteryOptimization(var context) {
BatteryOptimization.isIgnoringBatteryOptimizations().then((onValue) {
OptimizationBattery.isIgnoringBatteryOptimizations().then((onValue) {
if (onValue) {
// Ignoring Battery Optimization
utils.showInfoAlert(
Expand All @@ -295,7 +292,7 @@ class GeneralWidget extends StatelessWidget {
buttons: [
DialogButton(
onPressed: () {
BatteryOptimization.openBatteryOptimizationSettings();
OptimizationBattery.openBatteryOptimizationSettings();
Navigator.pop(context);
},
child: Text(
Expand Down
1 change: 0 additions & 1 deletion lib/screens/mindfulnotifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:ui';
import 'dart:isolate';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:minimize_app/minimize_app.dart';
Expand Down
5 changes: 0 additions & 5 deletions lib/screens/reminderview.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import 'dart:ui';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';
import 'package:mindfulnotifier/components/datastore.dart';
import 'package:dropdown_search/dropdown_search.dart';
Expand Down
3 changes: 0 additions & 3 deletions lib/screens/schedulesview.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import 'dart:ui';
import 'dart:async';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:get/get.dart';

import 'package:mindfulnotifier/components/datastore.dart';
Expand Down
5 changes: 1 addition & 4 deletions lib/screens/sound.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:file_picker/file_picker.dart';
import 'package:rflutter_alert/rflutter_alert.dart';
import 'package:get/get.dart';
Expand Down Expand Up @@ -112,8 +110,7 @@ class SoundWidgetController extends GetxController {

void _updateAlarmService(InMemoryScheduleDataStore mds) {
// update alarm service with new memory store
Get.find<MindfulNotifierWidgetController>()
.updatePermanentDataStore(mds);
Get.find<MindfulNotifierWidgetController>().updatePermanentDataStore(mds);
}
}

Expand Down
Loading

0 comments on commit 04deb7c

Please sign in to comment.