Skip to content

Commit

Permalink
feat(ui): add opt-out screen on app startup (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsutsu3 authored Dec 19, 2024
1 parent 05fd51b commit eb55a0b
Show file tree
Hide file tree
Showing 32 changed files with 583 additions and 163 deletions.
1 change: 1 addition & 0 deletions __azurite_db_queue__.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"filename":"c:\\Users\\ttm2t\\WorkSpace\\pi-hole-client\\__azurite_db_queue__.json","collections":[{"name":"$SERVICES_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{},"constraints":null,"uniqueNames":["accountName"],"transforms":{},"objType":"$SERVICES_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]},{"name":"$QUEUES_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"accountName":{"name":"accountName","dirty":false,"values":[]},"name":{"name":"name","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$QUEUES_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]},{"name":"$MESSAGES_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"accountName":{"name":"accountName","dirty":false,"values":[]},"queueName":{"name":"queueName","dirty":false,"values":[]},"messageId":{"name":"messageId","dirty":false,"values":[]},"visibleTime":{"name":"visibleTime","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$MESSAGES_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]}],"databaseVersion":1.5,"engineVersion":1.5,"autosave":true,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"persistenceMethod":"fs","autosave":true,"autosaveInterval":5000,"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}
1 change: 1 addition & 0 deletions __azurite_db_queue_extent__.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"filename":"c:\\Users\\ttm2t\\WorkSpace\\pi-hole-client\\__azurite_db_queue_extent__.json","collections":[{"name":"$EXTENTS_COLLECTION$","data":[],"idIndex":null,"binaryIndices":{"id":{"name":"id","dirty":false,"values":[]}},"constraints":null,"uniqueNames":[],"transforms":{},"objType":"$EXTENTS_COLLECTION$","dirty":false,"cachedIndex":null,"cachedBinaryIndex":null,"cachedData":null,"adaptiveBinaryIndices":true,"transactional":false,"cloneObjects":false,"cloneMethod":"parse-stringify","asyncListeners":false,"disableMeta":false,"disableChangesApi":true,"disableDeltaChangesApi":true,"autoupdate":false,"serializableIndices":true,"disableFreeze":true,"ttl":null,"maxId":0,"DynamicViews":[],"events":{"insert":[],"update":[],"pre-insert":[],"pre-update":[],"close":[],"flushbuffer":[],"error":[],"delete":[null],"warning":[null]},"changes":[],"dirtyIds":[]}],"databaseVersion":1.5,"engineVersion":1.5,"autosave":true,"autosaveInterval":5000,"autosaveHandle":null,"throttledSaves":true,"options":{"persistenceMethod":"fs","autosave":true,"autosaveInterval":5000,"serializationMethod":"normal","destructureDelimiter":"$<\n"},"persistenceMethod":"fs","persistenceAdapter":null,"verbose":false,"events":{"init":[null],"loaded":[],"flushChanges":[],"close":[],"changes":[],"warning":[]},"ENV":"NODEJS"}
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<application
android:label="PiHoleClient"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/ic_launcher"
android:enableOnBackInvokedCallback="true">
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
2 changes: 1 addition & 1 deletion lib/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class _BaseState extends State<Base> with WidgetsBindingObserver {
if (appConfigProvider.importantInfoReaden == false) {
await showDialog<String>(
context: context,
builder: (BuildContext context) => const ImportantInfoModal());
builder: (BuildContext context) => const StartInfoModal());
}
});

Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"advancedSetup": "Erweiterte Einstellungen",
"advancedSetupDescription": "Erweiterte Optionen",
"advancedStatusFiltering": "Erweiterte Statusfilterung",
"agreePrivacyPolicy": "Durch Aktivieren dieser Option stimmen Sie unseren zu",
"alias": "Alias",
"all": "Alle",
"allClientsSelected": "Alle Clients ausgewählt",
"allItemsSelected": "Alle Elemente ausgewählt",
"allStatusSelected": "Alle Status ausgewählt",
"allowCrashReport": "Absturzberichte senden erlauben?",
"allowed": "Erlaubt",
"alreadyBlacklist": "Domain existiert bereits in der Blacklist.",
"alreadyWhitelist": "Domain existiert bereits in der Whitelist.",
Expand Down Expand Up @@ -150,7 +152,10 @@
"fromOldestToLatest": "Alt nach Neu",
"fromTime": "Von",
"gettingPermission": "Berechtigungen werden geladen...",
"gettingStarted": "Erste Schritte",
"gitHub": "Code auf GitHub ansehen",
"helpUsImprove": "Helfen Sie uns, besser zu werden",
"helpUsImproveMessage": "Um die Qualität der App zu verbessern, können wir bei Problemen anonyme Absturzberichte sammeln.\nDiese Berichte enthalten keine persönlich identifizierbaren Informationen.",
"hideZeroValues": "Nullwerte ausblenden",
"hideZeroValuesDescription": "Versteckt Nullwerte aus dem Client-Diagramm",
"hits": "Treffer:",
Expand Down Expand Up @@ -237,6 +242,8 @@
"pieChartDescription": "Zeigt die Daten in einem Tortendiagramm mit einer Legende.",
"port": "Port",
"portCannotEmpty": "Port Feld darf nicht leer sein",
"privacy": "Datenschutz",
"privacyInfo": "Datenschutz und Datenverwaltung",
"privacyPolicy": "Datenschutzrichtlinie",
"privacyPolicyDescription": "Datenschutzrichtlinie ansehen",
"qrScanner": "QR-Code Scanner",
Expand Down Expand Up @@ -332,6 +339,7 @@
"version": "Version",
"versionDescription": "Wählen Sie die Version von Pi-hole, die Sie verwenden",
"visitGooglePlay": "Google Play-Seite besuchen",
"welcomeToApp": "Willkommen in der App",
"whitelist": "Zur Whitelist hinzufügen",
"writeEmail": "Schreiben Sie mir per E-Mail.",
"writeEmailDetails": "Die Email sollte im Optimalfall folgende Infos enthalten: Pi-hole und Web Interface Version, wie kann der Fehler reproduziert werden, Screenshots...\n\nFür alle Informationen sind wir sehr dankbar."
Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"advancedSetup": "Advanced settings",
"advancedSetupDescription": "Advanced options",
"advancedStatusFiltering": "Advanced status filtering",
"agreePrivacyPolicy": "By enabling this option, you agree to our",
"alias": "Alias",
"all": "All",
"allClientsSelected": "All clients selected",
"allItemsSelected": "All items selected",
"allStatusSelected": "All status selected",
"allowCrashReport": "Allow crash report submission?",
"allowed": "Allowed",
"alreadyBlacklist": "Domain is already on blacklist.",
"alreadyWhitelist": "Domain is already on whitelist.",
Expand Down Expand Up @@ -150,7 +152,10 @@
"fromOldestToLatest": "From oldest to latest",
"fromTime": "From time",
"gettingPermission": "Getting permission...",
"gettingStarted": "Getting Started",
"gitHub": "App code available on GitHub",
"helpUsImprove": "Help Us Improve",
"helpUsImproveMessage": "To improve app quality, we may collect anonymous crash reports when an issue occurs.\nThese reports do not contain any personally identifiable information. ",
"hideZeroValues": "Hide zero values",
"hideZeroValuesDescription": "Hides zero values from clients chart",
"hits": "Hits:",
Expand Down Expand Up @@ -237,6 +242,8 @@
"pieChartDescription": "Displays the data on a pie chart with the legend under it.",
"port": "Port",
"portCannotEmpty": "Port field cannot be empty",
"privacy": "Privacy",
"privacyInfo": "Privacy and Data Management",
"privacyPolicy": "Privacy Policy",
"privacyPolicyDescription": "View Privacy Policy",
"qrScanner": "QR scanner",
Expand Down Expand Up @@ -334,6 +341,7 @@
"version": "Version",
"versionDescription": "Select the version of Pi-hole you are using",
"visitGooglePlay": "Visit Google Play page",
"welcomeToApp": "Welcome to the App",
"whitelist": "Add to whitelist",
"writeEmail": "Write me by email.",
"writeEmailDetails": "Include on the body of the email all the possible details: Pi-hole and web interface version, how to reproduce the issue, screenshots...\n\nAll provided information will be very welcome."
Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_es.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"advancedSetup": "Configuración avanzada",
"advancedSetupDescription": "Opciones avanzadas",
"advancedStatusFiltering": "Filtros de estado avanzados",
"agreePrivacyPolicy": "Al habilitar esta opción, aceptas nuestra",
"alias": "Alias",
"all": "Todos",
"allClientsSelected": "Todos los clientes seleccionados",
"allItemsSelected": "Todos los items seleccionados",
"allStatusSelected": "Todos los estados seleccionados",
"allowCrashReport": "¿Permitir el envío de informes de fallos?",
"allowed": "Permitidos",
"alreadyBlacklist": "El dominio ya está en lista negra.",
"alreadyWhitelist": "El dominio ya está en lista blanca.",
Expand Down Expand Up @@ -152,7 +154,10 @@
"fromOldestToLatest": "De antiguo a nuevo",
"fromTime": "Desde",
"gettingPermission": "Obteniendo permiso...",
"gettingStarted": "Comenzando",
"gitHub": "Código de la app disponible en GitHub",
"helpUsImprove": "Ayúdanos a mejorar",
"helpUsImproveMessage": "Para mejorar la calidad de la aplicación, podemos recopilar informes de fallos anónimos cuando ocurra un problema.\nEstos informes no contienen información personal identificable. ",
"hideZeroValues": "Ocultar valores a cero",
"hideZeroValuesDescription": "Oculta los valores a cero del gráfico de clientes",
"hits": "Veces:",
Expand Down Expand Up @@ -239,6 +244,8 @@
"pieChartDescription": "Muestra los datos en un gráfico circular con la leyenda debajo.",
"port": "Puerto",
"portCannotEmpty": "Puerto no puede estar vacío",
"privacy": "Privacidad",
"privacyInfo": "Privacidad y gestión de datos",
"privacyPolicy": "Política de Privacidad",
"privacyPolicyDescription": "Ver Política de Privacidad",
"qrScanner": "Escáner QR",
Expand Down Expand Up @@ -336,6 +343,7 @@
"version": "Versión",
"versionDescription": "Seleccione la versión de Pi-hole que está utilizando",
"visitGooglePlay": "Visita la página de Google Play",
"welcomeToApp": "Bienvenido a la aplicación",
"whitelist": "Añadir a lista blanca",
"writeEmail": "Escríbeme por correo electrónico.",
"writeEmailDetails": "Incluye en el cuerpo del correo todos los detalles posibles: Pi-hole y versión de la interfaz web, cómo reproducir el problema, capturas de pantalla...\n\nToda la información proporcionada será muy bienvenida."
Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_ja.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"advancedSetup": "高度な設定",
"advancedSetupDescription": "高度なオプション",
"advancedStatusFiltering": "高度なステータスフィルタリング",
"agreePrivacyPolicy": "このオプションを有効にすると、次の内容に同意したものとみなされます",
"alias": "エイリアス",
"all": "すべて",
"allClientsSelected": "すべてのクライアントが選択されました",
"allItemsSelected": "全ての項目が選択されました",
"allStatusSelected": "全ステータスが選択されました",
"allowCrashReport": "クラッシュレポートの送信を許可しますか?",
"allowed": "許可済み",
"alreadyBlacklist": "ドメインは既にブラックリストにあります。",
"alreadyWhitelist": "ドメインは既にホワイトリストにあります。",
Expand Down Expand Up @@ -150,7 +152,10 @@
"fromOldestToLatest": "古い順",
"fromTime": "開始時刻",
"gettingPermission": "権限を取得中...",
"gettingStarted": "はじめに",
"gitHub": "アプリコードはGitHubで利用可能",
"helpUsImprove": "改善へのご協力をお願いします",
"helpUsImproveMessage": "アプリの品質向上のため、問題が発生した際に匿名のクラッシュレポートを収集することがあります。\nこれらのレポートには個人を特定できる情報は含まれません。クラッシュレポートの送信を許可しますか?",
"hideZeroValues": "ゼロ値を非表示",
"hideZeroValuesDescription": "クライアントチャートからゼロ値を非表示にします",
"hits": "ヒット:",
Expand Down Expand Up @@ -237,6 +242,8 @@
"pieChartDescription": "円グラフでデータを表示し、その下に凡例を表示します。",
"port": "ポート",
"portCannotEmpty": "ポートフィールドを空にすることはできません",
"privacy": "プライバシー",
"privacyInfo": "プライバシーとデータ管理",
"privacyPolicy": "プライバシーポリシー",
"privacyPolicyDescription": "プライバシーポリシーを見る",
"qrScanner": "QRスキャナー",
Expand Down Expand Up @@ -334,6 +341,7 @@
"version": "バージョン",
"versionDescription": "使用している Pi-hole のバージョンを選択してください",
"visitGooglePlay": "Google Playページを訪問",
"welcomeToApp": "アプリへようこそ",
"whitelist": "ホワイトリストに追加",
"writeEmail": "メールで私に書いてください。",
"writeEmailDetails": "メール本文には可能な限り詳細を記載してください:Pi-holeおよびWebインターフェースのバージョン、問題の再現方法、スクリーンショットなど。\n\n提供される情報はすべて歓迎します。"
Expand Down
8 changes: 8 additions & 0 deletions lib/l10n/app_pl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
"advancedSetup": "Ustawienia zaawansowane",
"advancedSetupDescription": "Wykresy, bezpieczenstwo i inne",
"advancedStatusFiltering": "Zaawansowane filtrowanie stanów",
"agreePrivacyPolicy": "Włączając tę opcję, zgadzasz się na nasze",
"alias": "Alias",
"all": "Wszystko",
"allClientsSelected": "Wybrano wszystkich klientów",
"allItemsSelected": "Wybrano wszystkie elementy",
"allStatusSelected": "Wybrano wszystkie stany",
"allowCrashReport": "Zezwolić na przesyłanie raportów o awariach?",
"allowed": "Dozwolone",
"alreadyBlacklist": "Domena jest już na czarnej liście.",
"alreadyWhitelist": "Domena jest już na białej liście.",
Expand Down Expand Up @@ -148,7 +150,10 @@
"fromOldestToLatest": "Od najstarszych do najnowszych",
"fromTime": "Od kiedy",
"gettingPermission": "Uzyskiwanie pozwolenia...",
"gettingStarted": "Pierwsze kroki",
"gitHub": "Kod aplikacji dostępny na GitHubie",
"helpUsImprove": "Pomóż nam ulepszyć",
"helpUsImproveMessage": "Aby poprawić jakość aplikacji, możemy zbierać anonimowe raporty o awariach w przypadku wystąpienia problemu.\nRaporty te nie zawierają żadnych danych osobowych. ",
"hideZeroValues": "Ukryj wartości zerowe",
"hideZeroValuesDescription": "Ukrywa wartości zerowe na wykresie klientów",
"hits": "Trafienia:",
Expand Down Expand Up @@ -235,6 +240,8 @@
"pieChartDescription": "Wyświetla dane na wykresie kołowym z legendą pod nimi.",
"port": "Port",
"portCannotEmpty": "Pole portu nie może być puste",
"privacy": "Prywatność",
"privacyInfo": "Prywatność i zarządzanie danymi",
"privacyPolicy": "Polityka Prywatności",
"privacyPolicyDescription": "Zobacz Politykę Prywatności",
"qrScanner": "Skaner QR",
Expand Down Expand Up @@ -330,6 +337,7 @@
"version": "Wersja",
"versionDescription": "Wybierz wersję Pi-hole, której używasz",
"visitGooglePlay": "Odwiedź stronę Google Play",
"welcomeToApp": "Witaj w aplikacji",
"whitelist": "Dodaj do białej listy",
"writeEmail": "Napisz do mnie na e-mail.",
"writeEmailDetails": "W treści e-maila umieść wszystkie możliwe szczegóły: wersję Pi-hole i interfejsu sieciowego, sposób odtworzenia problemu, zrzuty ekranu...\n\nWszystkie dostarczone informacje będą bardzo mile widziane."
Expand Down
75 changes: 44 additions & 31 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_app_lock/flutter_app_lock.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:local_auth/local_auth.dart';
import 'package:pi_hole_client/functions/logger.dart';
import 'package:pi_hole_client/repository/secure_storage.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
Expand Down Expand Up @@ -114,6 +115,47 @@ void main() async {
configProvider.setIosInfo(iosInfo);
}

Future<void> initializeSentry() async {
if (configProvider.sendCrashReports == false) {
logger.d("Send Crash Reports: OFF");
await Sentry.close();
return;
}

if ((kReleaseMode &&
(dotenv.env['SENTRY_DSN'] != null &&
dotenv.env['SENTRY_DSN'] != "")) ||
(dotenv.env['ENABLE_SENTRY'] == "true" &&
(dotenv.env['SENTRY_DSN'] != null &&
dotenv.env['SENTRY_DSN'] != ""))) {
logger.d("Send Crash Reports: ON");
SentryFlutter.init(
(options) {
options.dsn = dotenv.env['SENTRY_DSN'];
options.sendDefaultPii = false;
options.attachScreenshot =
dotenv.env['ENABLE_SENTRY_SCREENSHOTS'] == "true";
options.beforeSend = (event, hint) {
if (event.throwable is HttpException) {
return null;
}

if (event.message?.formatted.contains("Unexpected character") ??
false ||
(event.throwable != null &&
event.throwable!
.toString()
.contains("Unexpected character"))) {
return null; // Exclude this event
}

return event;
};
},
);
}
}

void startApp() => runApp(MultiProvider(
providers: [
ChangeNotifierProvider(create: ((context) => serversProvider)),
Expand Down Expand Up @@ -142,37 +184,8 @@ void main() async {
),
));

if ((kReleaseMode &&
(dotenv.env['SENTRY_DSN'] != null &&
dotenv.env['SENTRY_DSN'] != "")) ||
(dotenv.env['ENABLE_SENTRY'] == "true" &&
(dotenv.env['SENTRY_DSN'] != null &&
dotenv.env['SENTRY_DSN'] != ""))) {
SentryFlutter.init((options) {
options.dsn = dotenv.env['SENTRY_DSN'];
options.sendDefaultPii = false;
options.attachScreenshot =
dotenv.env['ENABLE_SENTRY_SCREENSHOTS'] == "true";
options.beforeSend = (event, hint) {
if (event.throwable is HttpException) {
return null;
}

if (event.message?.formatted.contains("Unexpected character") ??
false ||
(event.throwable != null &&
event.throwable!
.toString()
.contains("Unexpected character"))) {
return null; // Exclude this event
}

return event;
};
}, appRunner: () => startApp());
} else {
startApp();
}
initializeSentry();
startApp();
}

Future<PackageInfo> loadAppInfo() async {
Expand Down
Loading

0 comments on commit eb55a0b

Please sign in to comment.