Skip to content

Commit

Permalink
Merge pull request #130 from osociety/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
git-elliot authored Mar 17, 2024
2 parents af3c4ba + d2f5ae6 commit 992df16
Show file tree
Hide file tree
Showing 26 changed files with 416 additions and 233 deletions.
22 changes: 9 additions & 13 deletions .github/workflows/flutter_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
runs-on: ubuntu-latest
env:
LINUX_ZIP: Vernet-${{github.ref_name}}-linux.zip
ANDROID_APK_ARM_V7A: app-armeabi-v7a-dev-debug.apk
ANDROID_APK_ARM_V8A: app-arm64-v8a-dev-debug.apk
ANDROID_APK_x86_64: app-x86_64-dev-debug.apk
ANDROID_APK_ARM_V7A: app-armeabi-v7a-dev-release.apk
ANDROID_APK_ARM_V8A: app-arm64-v8a-dev-release.apk
ANDROID_APK_x86_64: app-x86_64-dev-release.apk

steps:
- name: Checkout
Expand Down Expand Up @@ -50,15 +50,11 @@ jobs:
encodedString: '${{ secrets.ANDROID_KEYSTORE_BASE64 }}'

- name: Create key.properties
run: >
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" >
android/key.properties
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >>
android/key.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >>
android/key.properties
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >>
android/key.properties
run: |
echo "storeFile=${{ steps.android_keystore.outputs.filePath }}" >> android/key.properties
echo "storePassword=${{ secrets.ANDROID_KEYSTORE_PASSWORD }}" >> android/key.properties
echo "keyPassword=${{ secrets.ANDROID_KEY_PASSWORD }}" >> android/key.properties
echo "keyAlias=${{ secrets.ANDROID_KEY_ALIAS }}" >> android/key.properties
- name: Create artifacts directory
run: mkdir -p artifacts
Expand All @@ -69,7 +65,7 @@ jobs:
- name: Build Android App and Linux Bundle
# Use signing keys for release instead of debug
run: |
flutter build apk --debug --split-per-abi --flavor dev
flutter build apk --split-per-abi --flavor dev
flutter build linux --release
- name: Rename ANDROID APKs
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Note: macOS build hasn't been notarized yet.
### Instructions for Linux

1. Star this repository.
2. Download vernet-linux.zip from [releases](https://github.com/git-elliot/vernet/releases/latest)
3. Extract downloaded zip file.
4. Go to bundle folder and double click vernet file.
2. Install `net-tools` package for `arp` command, otherwise app will not run.
3. Download vernet-linux.zip from [releases](https://github.com/git-elliot/vernet/releases/latest)
4. Extract downloaded zip file.
5. Go to bundle folder and double click vernet file.

## Contributors Required

Expand Down
6 changes: 3 additions & 3 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (keystorePropertiesFile.exists()) {
}

android {
compileSdkVersion 33
compileSdkVersion 34

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
Expand All @@ -41,7 +41,7 @@ android {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "org.fsociety.vernet"
minSdkVersion 19
targetSdkVersion 33
targetSdkVersion 34
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -67,7 +67,7 @@ android {
productFlavors {
dev {
dimension "deploy"
signingConfig signingConfigs.debug
signingConfig signingConfigs.release
}
fdroid {
dimension "deploy"
Expand Down
4 changes: 4 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
<package android:name="org.fdroid.fdroid" />
</queries>
<application
android:label="Vernet"
Expand Down Expand Up @@ -42,7 +43,10 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

</activity>
<!-- Don't delete the meta-data below.
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
Expand Down
2 changes: 1 addition & 1 deletion fastlane/metadata/android/en-US/changelogs/18.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Follow system theme added and bug fixes
Follow system theme added and bug fixes
1 change: 1 addition & 0 deletions fastlane/metadata/android/en-US/changelogs/19.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Many improvements and bug fixes
32 changes: 28 additions & 4 deletions lib/api/update_checker.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'dart:convert';
import 'dart:io';

import 'package:external_app_launcher/external_app_launcher.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:package_info_plus/package_info_plus.dart';
import 'package:vernet/helper/utils_helper.dart';

import 'package:vernet/main.dart';

Future<bool> _checkUpdates(String v) async {
final Uri url = Uri.parse(
'https://api.github.com/repos/git-elliot/vernet/tags?per_page=1',
Expand Down Expand Up @@ -37,7 +40,10 @@ Future<void> checkForUpdates(
try {
final info = await PackageInfo.fromPlatform();
final String v = '${info.version}+${info.buildNumber}';
final bool available = await compute(_checkUpdates, v);
bool available = false;
if (appSettings.inAppInternet) {
available = await compute(_checkUpdates, v);
}
ScaffoldMessenger.of(context).clearSnackBars();
Widget? content;
SnackBarAction? action;
Expand All @@ -46,12 +52,16 @@ Future<void> checkForUpdates(
action = SnackBarAction(
label: 'Update',
onPressed: () {
_navigateToStore();
_navigateToStore(context);
},
);
} else {
if (showIfNoUpdate) {
content = const Text('No updates found');
if (!appSettings.inAppInternet) {
content =
const Text('Please turn on In-App Internet to check updates.');
}
}
}
if (ScaffoldMessenger.of(context).mounted && content != null) {
Expand All @@ -67,14 +77,28 @@ Future<void> checkForUpdates(
}
}

Future<void> _navigateToStore() async {
Future<void> _navigateToStore(BuildContext context) async {
String url = 'https://github.com/git-elliot/vernet/releases/latest';

if (Platform.isAndroid) {
final isFdroidInstalled = await LaunchApp.isAppInstalled(
androidPackageName: 'org.fdroid.fdroid',
iosUrlScheme: 'fdroid://',
);

if ((await PackageInfo.fromPlatform()).version.contains('store')) {
//Goto playstore
url =
'https://play.google.com/store/apps/details?id=org.fsociety.vernet.store';
} else if (isFdroidInstalled == true) {
await LaunchApp.openApp(
androidPackageName: 'org.fdroid.fdroid',
iosUrlScheme: 'fdroid://',
appStoreLink: 'itms-apps://itunes.apple.com/',
openStore: false,
);
return;
}
}
launchURL(url);
launchURLWithWarning(context, url);
}
34 changes: 33 additions & 1 deletion lib/helper/app_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ class AppSettings {
static const String _firstSubnetKey = 'AppSettings-FIRST_SUBNET';
static const String _socketTimeoutKey = 'AppSettings-SOCKET_TIMEOUT';
static const String _pingCountKey = 'AppSettings-PING_COUNT';
static const String _inAppInternetKey = 'AppSettings-IN-APP-INTERNET';
static const String _customSubnetKey = 'AppSettings-CUSTOM-SUBNET';
int _firstSubnet = 1;
int _lastSubnet = 254;
int _socketTimeout = 500;
int _pingCount = 5;
bool _inAppInternet = false;
String _customSubnet = '';

static final AppSettings _instance = AppSettings._();

Expand All @@ -20,6 +24,11 @@ class AppSettings {
int get lastSubnet => _lastSubnet;
int get socketTimeout => _socketTimeout;
int get pingCount => _pingCount;
bool get inAppInternet => _inAppInternet;
String get customSubnet => _customSubnet;
String get gatewayIP => _customSubnet.isNotEmpty
? _customSubnet.substring(0, _customSubnet.lastIndexOf('.'))
: _customSubnet;

Future<bool> setFirstSubnet(int firstSubnet) async {
_firstSubnet = firstSubnet;
Expand All @@ -45,12 +54,25 @@ class AppSettings {
.setInt(_pingCountKey, _pingCount);
}

Future<bool> setInAppInternet(bool inAppInternet) async {
_inAppInternet = inAppInternet;
return (await SharedPreferences.getInstance())
.setBool(_inAppInternetKey, _inAppInternet);
}

Future<bool> setCustomSubnet(String customSubnet) async {
_customSubnet = customSubnet;
return (await SharedPreferences.getInstance())
.setString(_customSubnetKey, _customSubnet);
}

Future<void> load() async {
debugPrint("Fetching all app settings");
_firstSubnet =
(await SharedPreferences.getInstance()).getInt(_firstSubnetKey) ??
_firstSubnet;
debugPrint("First subnet : $_firstSubnet");

_lastSubnet =
(await SharedPreferences.getInstance()).getInt(_lastSubnetKey) ??
_lastSubnet;
Expand All @@ -60,10 +82,20 @@ class AppSettings {
(await SharedPreferences.getInstance()).getInt(_socketTimeoutKey) ??
_socketTimeout;
debugPrint("Socket timeout : $_socketTimeout");

_pingCount =
(await SharedPreferences.getInstance()).getInt(_pingCountKey) ??
_pingCount;
debugPrint("Ping count : $_pingCount");

_inAppInternet =
(await SharedPreferences.getInstance()).getBool(_inAppInternetKey) ??
_inAppInternet;
debugPrint("In-App Internet : $_inAppInternet");

debugPrint("Ping count : $_socketTimeout");
_customSubnet =
(await SharedPreferences.getInstance()).getString(_customSubnetKey) ??
_customSubnet;
debugPrint("Custom Subnet : $_customSubnet");
}
}
11 changes: 11 additions & 0 deletions lib/helper/utils_helper.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:vernet/ui/external_link_dialog.dart';

Future<void> launchURL(String url) async => await canLaunchUrlString(url)
? await launchUrlString(url)
: throw 'Could not launch $url';

Future<void> launchURLWithWarning(BuildContext context, String url) {
return showDialog(
context: context,
builder: (context) => ExternalLinkWarningDialog(
link: url,
),
);
}
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Future<void> main() async {
configureDependencies(Env.prod);
WidgetsFlutterBinding.ensureInitialized();
final appDocDirectory = await getApplicationDocumentsDirectory();
await configureNetworkTools(appDocDirectory.path);
await configureNetworkToolsFlutter(appDocDirectory.path);
final bool allowed = await ConsentLoader.isConsentPageShown();

// load app settings
Expand Down
16 changes: 15 additions & 1 deletion lib/models/wifi_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ class WifiInfo {
final String? _name;
bool unknown;
String get ip => _ip ?? 'x.x.x.x';
String get name => _name ?? 'Wi-Fi';

static const String noWifiName = 'Wi-Fi';

String get name {
if (_name == null || _name!.isEmpty) return noWifiName;
if (_name!.startsWith('"') && _name!.endsWith('"')) {
final array = _name!.split('"');
if (array.length > 1) {
final wifiName = array[1];
return wifiName.isEmpty ? noWifiName : wifiName;
}
}
return _name!;
}

String get bssid => _bssid ?? defaultBSSID.first;
}
Loading

0 comments on commit 992df16

Please sign in to comment.