Skip to content

Commit

Permalink
v 0.7.9
Browse files Browse the repository at this point in the history
- Fixes Crashes on Most of Devices.
- Bug Fixes & Code Improvements.
  • Loading branch information
canewsin committed Dec 26, 2020
1 parent 64f998c commit 400908c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 108 deletions.
4 changes: 2 additions & 2 deletions android/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
flutter.versionName=v 0.7.8 - patch
flutter.versionCode=35
flutter.versionName=v 0.7.9
flutter.versionCode=40
12 changes: 6 additions & 6 deletions lib/mobx/varstore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ abstract class _VarStore with Store {
zeroNetAppbarStatus = status;
}

// @observable
// String zeroNetStatus = 'Not Running';
@observable
String zeroNetStatus = 'Not Running';

// @action
// void setZeroNetStatus(String status) {
// zeroNetStatus = status;
// }
@action
void setZeroNetStatus(String status) {
zeroNetStatus = status;
}

@observable
bool zeroNetInstalled = false;
Expand Down
81 changes: 1 addition & 80 deletions lib/native.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
import 'dart:convert';
import 'dart:io';

import 'package:device_info/device_info.dart';
import 'package:flutter/services.dart';
import 'package:flutter_absolute_path/flutter_absolute_path.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:zeronet/common.dart';
import 'package:zeronet/mobx/varstore.dart';
import 'package:zeronet/utils.dart';

import 'common.dart';
import 'constants.dart';
import 'imports.dart';

const MethodChannel _channel = const MethodChannel('in.canews.zeronet');
const EventChannel _events_channel =
Expand Down Expand Up @@ -111,70 +99,3 @@ getArch() async {
arch = 'x86_64';
else if (archL.contains('x86')) arch = 'x86';
}

initNotifications() {
flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();
final initializationSettingsAndroid =
AndroidInitializationSettings('app_icon');
final initializationSettingsIOS = IOSInitializationSettings();
final initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
// final categories = [
// NotificationCategory(
// notificationCategory,
// [
// NotificationAction("Stop", "ACTION_CLOSE"),
// NotificationAction("Exit App", "ACTION_CLOSEAPP"),
// ],
// ),
// ];
flutterLocalNotificationsPlugin.initialize(
initializationSettings,
onSelectNotification: onSelectNotification,
// onSelectNotificationAction: onSelectNotificationAction,
// categories: categories,
);
}

Future<void> onSelectNotification(String payload) async {
if (payload != null) {
printOut('notification payload: ' + payload);
}
}

// Future<void> onSelectNotificationAction(NotificationActionData data) async {
// printOut('notification action data: $data');
// if (data.actionIdentifier == "ACTION_CLOSE") {
// shutDownZeronet();
// } else {
// shutDownZeronet();
// exit(0);
// }
// }

Future<void> showZeroNetRunningNotification({
bool enableVibration = true,
}) async {
var androidDetails = AndroidNotificationDetails(
zeroNetNotiId,
zeroNetChannelName,
zeroNetChannelDes,
ongoing: true,
playSound: false,
autoCancel: false,
enableVibration: enableVibration,
);
var iosDetails = IOSNotificationDetails();
var details = NotificationDetails(
androidDetails,
iosDetails,
);
await flutterLocalNotificationsPlugin.show(
0,
'ZeroNet Mobile is Running',
'Click on Stop, to Stop ZeroNet or Click Here to Open App',
details,
// categoryIdentifier: notificationCategory,
// payload: 'zeronet',
);
}
19 changes: 1 addition & 18 deletions lib/utils.dart
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:isolate';
import 'dart:ui';

import 'package:archive/archive.dart';
import 'package:crypto/crypto.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:package_info/package_info.dart';
import 'package:random_string/random_string.dart';
import 'package:zeronet/native.dart';
import 'package:zeronet_ws/zeronet_ws.dart';

import 'common.dart';
import 'extensions.dart';
import 'constants.dart';
import 'mobx/varstore.dart';
import 'models.dart';
import 'imports.dart';

debugTime(Function func) {
var start = DateTime.now();
Expand Down Expand Up @@ -521,7 +505,6 @@ shutDownZeronet() {
}
zeroNetUrl = '';
varStore.setZeroNetStatus('Not Running');
flutterLocalNotificationsPlugin.cancelAll();
}
}

Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ dependencies:
random_string: 2.1.0
share: 0.6.5+3
url_launcher: 5.7.6
flutter_background_service: 0.0.1+18
flutter_background_service: 0.0.1+21
# path: ../flutter_background_service
# git:
# url: https://github.com/canewsin/flutter_background_service
# ref: auto-start-pref
# ref: zeronet
flutter_webview_plugin: #0.3.11
git:
url: https://github.com/canewsin/flutter_webview_plugin
Expand Down

0 comments on commit 400908c

Please sign in to comment.