Skip to content

Commit

Permalink
feature: build FOSS flavored app (#107)
Browse files Browse the repository at this point in the history
feature: load changelog from GitHub
fix: remove unnecessary permissions
  • Loading branch information
huffSamuel committed Jun 12, 2024
1 parent 70af6c6 commit 26a346f
Show file tree
Hide file tree
Showing 21 changed files with 329 additions and 232 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ jobs:
- name: Install Dependencies
run: flutter pub get

- name: Generate localizations
run: flutter gen-l10n

- name: Generate code
run: flutter pub run build_runner build --delete-conflicting-outputs

- name: Reinstall Dependencies
run: flutter pub get
- name: FOSS-ify dependencies
run: flutter pub remove --offline in_app_review

- name: Build APKs
run: flutter build apk --split-per-abi --obfuscate --split-debug-info=build/app/output/symbols
run: flutter build apk --flavor=foss -t lib/main.foss.dart --split-per-abi --obfuscate --split-debug-info=build/app/output/symbols

- name: Upload ARM_EABI assets
uses: actions/upload-release-asset@v1
Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "macos",
"request": "launch",
"type": "dart",
"program": "lib/main.dart"
},
{
"name": "google",
"request": "launch",
"type": "dart",
"program": "lib/main.google.dart",
"args": ["--flavor", "google", "-t", "lib/main.google.dart"]
},
{
"name": "foss",
"request": "launch",
"type": "dart",
"program": "lib/main.foss.dart",
"args": ["--flavor", "foss", "-t", "lib/main.foss.dart"]
}
]
}
8 changes: 0 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Miscellaneous Chores

* release 2.8.0 ([0350ff8](https://github.com/huffSamuel/upnp_explorer/commit/0350ff88990e1539557c90441913f7eaf1d71253))
* release 2.8.1 ([308bb8c](https://github.com/huffSamuel/upnp_explorer/commit/308bb8c2b5e9d7cb590f9f233f4abe739d678005))

## [2.8.0](https://github.com/huffSamuel/upnp_explorer/compare/v2.8.0...v2.8.0) (2024-02-17)


### Miscellaneous Chores

* release 2.8.0 ([0350ff8](https://github.com/huffSamuel/upnp_explorer/commit/0350ff88990e1539557c90441913f7eaf1d71253))

## [2.8.0](https://github.com/huffSamuel/upnp_explorer/compare/v2.7.0...v2.8.0) (2024-02-17)


Expand Down
19 changes: 19 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,20 @@ if (keystorePropertiesFile.exists()) {
android {
compileSdkVersion 34

flavorDimensions "store"

productFlavors {
google {
dimension "store"
resValue "string", "app_name", "UPnP Explorer"
}
foss {
dimension "store"
resValue "string", "app_name", "UPnP Explorer (FOSS)"
versionNameSuffix "-FOSS"
}
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
Expand Down Expand Up @@ -62,6 +76,11 @@ android {
'proguard-rules.pro'
}
}

dependenciesInfo {
includeInApk = false
includeInBundle = false
}
}

flutter {
Expand Down
1 change: 0 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
package="com.samueljhuf.upnp_explorer">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<queries>
<intent>
Expand Down
122 changes: 0 additions & 122 deletions assets/CHANGELOG.md

This file was deleted.

4 changes: 3 additions & 1 deletion lib/application/application.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
class Application {
static const repoUrl = 'https://github.com/huffSamuel/upnp_explorer';
static const _blob = '$repoUrl/blob/main';
static const submitBugUrl = '${repoUrl}/issues/new/choose';
static const name = 'UPnP Explorer';
static const privacyPolicyUrl = '${repoUrl}/blob/main/PRIVACY_POLICY.md';
static const privacyPolicyUrl = '$_blob/PRIVACY_POLICY.md';
static const changelogUrl = '$_blob/CHANGELOG.md';
static const appId = 'com.samueljhuf.upnp_explorer';

static const assets = const Assets();
Expand Down
37 changes: 34 additions & 3 deletions lib/application/changelog/changelog_service.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
import 'dart:io';

import 'package:flutter/services.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:injectable/injectable.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:rxdart/rxdart.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:http/http.dart' as http;
import 'package:upnp_explorer/application/application.dart';

const String lastChangelogVersion = 'lastChangelogVersion';

@lazySingleton
class ChangelogService {
final SharedPreferences prefs;
String? _changes;

ChangelogService(this.prefs);

Future<String> version() async => (await PackageInfo.fromPlatform()).version;

Future<bool> shouldDisplayChangelog() async {
final lastDisplayed = prefs.getString(lastChangelogVersion);
final currentVersion = (await PackageInfo.fromPlatform()).version;
final currentVersion = await version();

if (lastDisplayed != currentVersion) {
await prefs.setString(lastChangelogVersion, currentVersion);
Expand All @@ -23,7 +32,29 @@ class ChangelogService {
return false;
}

Future<String> changes() async {
return rootBundle.loadString('assets/CHANGELOG.md');
Stream<String> changes() => Stream.fromFuture(futureChanges());

Future<String> futureChanges() async {
if (_changes == null) {
final currentVersion = await version();

final uri =
'https://raw.githubusercontent.com/huffSamuel/upnp_explorer/v$currentVersion/CHANGELOG.md';

final data = await http.get(Uri.parse(uri));

if (data.statusCode < 200 || data.statusCode > 299) {
throw LoadFailedException();
}

_changes = data.body
.split(Platform.lineTerminator)
.skipWhile((x) => !x.startsWith('##'))
.join(Platform.lineTerminator);
}

return _changes!;
}
}

class LoadFailedException extends Error {}
13 changes: 13 additions & 0 deletions lib/application/flavors/default_features.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:upnp_explorer/application/flavors/flavor_features.dart';

class DefaultFeatures extends FlavorFeatures {
@override
Future<void> openStoreListing() {
// TODO: implement openStoreListing
throw UnimplementedError();
}

@override
bool get showRatingTile => false;

}
4 changes: 4 additions & 0 deletions lib/application/flavors/flavor_features.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
abstract class FlavorFeatures {
Future<void> openStoreListing();
bool get showRatingTile;
}
9 changes: 9 additions & 0 deletions lib/application/flavors/foss/foss_features.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import 'package:upnp_explorer/application/flavors/flavor_features.dart';

class FossFeatures extends FlavorFeatures {
@override
Future<void> openStoreListing() => Future.value();

@override
bool get showRatingTile => false;
}
12 changes: 12 additions & 0 deletions lib/application/flavors/google/google_features.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:in_app_review/in_app_review.dart';
import 'package:upnp_explorer/application/application.dart';
import 'package:upnp_explorer/application/flavors/flavor_features.dart';

class GoogleFeatures extends FlavorFeatures {
@override
Future<void> openStoreListing() => InAppReview.instance.openStoreListing(appStoreId: Application.appId);

@override
bool get showRatingTile => true;

}
1 change: 1 addition & 0 deletions lib/application/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@
"thisWillClearAllMessages": "This will clear all network message history.",
"traffic": "Traffic",
"turnOnWifi": "Turn on Wi-Fi",
"unableToLoadChangelog": "Unable to load changelog",
"unableToObtainInformation": "Unable to obtain service information",
"unableToSubmitFeedback": "Unable to submit feedback",
"unavailable": "Unavailable",
Expand Down
1 change: 1 addition & 0 deletions lib/application/l10n/intl_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"thisWillClearAllMessages": "Esto borrará todo el historial de mensajes de la red.",
"traffic": "Tráfico",
"turnOnWifi": "Activar wifi",
"unableToLoadChangelog": "No se puede cargar el registro de cambios",
"unableToObtainInformation": "No se puede obtener la información del servicio",
"unableToSubmitFeedback": "No se pueden enviar comentarios",
"unavailable": "Indisponible",
Expand Down
Loading

0 comments on commit 26a346f

Please sign in to comment.