Skip to content

Commit 42edd4f

Browse files
authored
MoveTopia Update (#136)
# MoveTopia Update Changelog ## New functions - Copy the version number of the application by holding it for a more convenient bug reporting experience ## Bug fixes - Fixed issue with wrong distance at tracking workouts ## Neue Funktionen - Kopiere die Versionsnummer durch Gedrückt Halten jener, um spezifischer Fehler zu melden ## Fehlerbehebungen - Fehlerhafte Distanzberechnung beim Übertragen von Workouts behoben
2 parents 9d23a4b + b426b67 commit 42edd4f

4 files changed

Lines changed: 35 additions & 1 deletion

File tree

lib/data/repositories/base_local_health_impl.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,17 @@ interface class BaseLocalHealthRepoImpl extends BaseLocalHealthRepository {
160160
preview.activityType == ActivityType.running) {
161161
return null;
162162
}
163+
// The distance is in km, so we need to convert it to m
164+
// We multiply by 100 and round it to 2 decimal places and then divide it back to kilometers
165+
// This step is need as dart does not provide a way to round to decimal places
166+
// After that we multiply it by 1000 to convert it to meters
167+
double distance = (((preview.distance ?? 0) * 100).round() / 100) * 1000;
163168
success = await Health().writeWorkoutData(
164169
activityType: HealthWorkoutActivityType.values.firstWhere(
165170
(element) => element.name == preview.activityType?.name),
166171
start: startTime,
167172
end: endTime,
168-
totalDistance: (preview.distance ?? 0).toInt() * 1000,
173+
totalDistance: distance.toInt(),
169174
totalDistanceUnit: HealthDataUnit.METER);
170175
} catch (e) {
171176
log.info(e);

lib/l10n/app_de.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"common_theme_dark": "Dunkler Modus",
5151
"common_about": "Über",
5252
"common_version": "Version",
53+
"common_version_copied": "Version in die Zwischenablage kopiert",
5354
"common_error_version": "Fehler beim Laden der Version",
5455
"common_error": "Fehler {error}",
5556
"common_unknown": "Unbekannt",

lib/l10n/app_en.arb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
"common_theme_dark": "Dark Mode",
5353
"common_about": "About",
5454
"common_version": "Version",
55+
"common_version_copied": "Successfully copied version",
5556
"common_error_version": "Error loading version",
5657
"common_error": "Error {error}",
5758
"common_unknown": "Unknown",

lib/presentation/profile/screen/widgets/about_section.dart

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:io';
2+
3+
import 'package:device_info_plus/device_info_plus.dart';
14
import 'package:flutter/material.dart';
25
import 'package:flutter/services.dart';
36
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
@@ -240,6 +243,27 @@ class VersionInfoTile extends StatelessWidget {
240243
Widget build(BuildContext context) {
241244
final l10n = AppLocalizations.of(context)!;
242245

246+
Future<void> copyVersionToClipboard() async {
247+
final data = ClipboardData(text: packageInfo.version);
248+
await Clipboard.setData(data);
249+
if (!context.mounted) return;
250+
251+
// Determine if we should show a snackbar based on platform
252+
// Don't show on Android 12+ (API 32+) as it has its own clipboard notification
253+
if (Platform.isAndroid) {
254+
final deviceInfo = DeviceInfoPlugin();
255+
final androidInfo = await deviceInfo.androidInfo;
256+
if (androidInfo.version.sdkInt >= 32) {
257+
return; // Android 12+ has native clipboard notifications
258+
}
259+
}
260+
261+
// Show snackbar on all other platforms and older Android versions
262+
ScaffoldMessenger.of(context).showSnackBar(
263+
SnackBar(content: Text(l10n.common_version_copied)),
264+
);
265+
}
266+
243267
return InkWell(
244268
onTap: () {
245269
hiddenLogAccessNotifier.incrementClickCount();
@@ -249,6 +273,9 @@ class VersionInfoTile extends StatelessWidget {
249273
context.go('$profilePath/$profileLoggingPath');
250274
}
251275
},
276+
onLongPress: () {
277+
copyVersionToClipboard();
278+
},
252279
child: Container(
253280
width: double.infinity,
254281
padding: const EdgeInsets.symmetric(vertical: 8.0),

0 commit comments

Comments
 (0)