fix: replace download flow with manual transfer instructions; rename app package
The Gemma model requires Kaggle login/licence so direct HTTP download is not possible. Replaces the download screen with adb transfer instructions, a Scan button that checks the file on disk, and a Continue without AI bypass. Also renames the Android package from com.example.dailyou to net.stefwill.dailyou (build.gradle.kts, MainActivity.kt path + declaration) and adds *.bin to .gitignore to keep model files out of the repo.
This commit is contained in:
@@ -39,6 +39,9 @@ app.*.symbols
|
|||||||
# Obfuscation related
|
# Obfuscation related
|
||||||
app.*.map.json
|
app.*.map.json
|
||||||
|
|
||||||
|
# LLM model files
|
||||||
|
*.bin
|
||||||
|
|
||||||
# Android Studio will place build artifacts here
|
# Android Studio will place build artifacts here
|
||||||
/android/app/debug
|
/android/app/debug
|
||||||
/android/app/profile
|
/android/app/profile
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.example.dailyou"
|
namespace = "net.stefwill.dailyou"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
ndkVersion = flutter.ndkVersion
|
ndkVersion = flutter.ndkVersion
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ android {
|
|||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId = "com.example.dailyou"
|
applicationId = "net.stefwill.dailyou"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
// For more information, see: https://flutter.dev/to/review-gradle-config.
|
||||||
minSdk = flutter.minSdkVersion
|
minSdk = flutter.minSdkVersion
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package com.example.dailyou
|
package net.stefwill.dailyou
|
||||||
|
|
||||||
import io.flutter.embedding.android.FlutterActivity
|
import io.flutter.embedding.android.FlutterActivity
|
||||||
|
|
||||||
+11
-8
@@ -9,6 +9,7 @@ class App extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
final skipped = ref.watch(modelSkippedProvider);
|
||||||
final modelPresentAsync = ref.watch(modelPresentProvider);
|
final modelPresentAsync = ref.watch(modelPresentProvider);
|
||||||
|
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
@@ -17,14 +18,16 @@ class App extends ConsumerWidget {
|
|||||||
theme: _lightTheme(),
|
theme: _lightTheme(),
|
||||||
darkTheme: _darkTheme(),
|
darkTheme: _darkTheme(),
|
||||||
themeMode: ThemeMode.system,
|
themeMode: ThemeMode.system,
|
||||||
home: modelPresentAsync.when(
|
home: skipped
|
||||||
data: (present) =>
|
? const AppShell()
|
||||||
present ? const AppShell() : const ModelDownloadScreen(),
|
: modelPresentAsync.when(
|
||||||
loading: () => const Scaffold(
|
data: (present) =>
|
||||||
body: Center(child: CircularProgressIndicator()),
|
present ? const AppShell() : const ModelDownloadScreen(),
|
||||||
),
|
loading: () => const Scaffold(
|
||||||
error: (_, __) => const ModelDownloadScreen(),
|
body: Center(child: CircularProgressIndicator()),
|
||||||
),
|
),
|
||||||
|
error: (_, __) => const ModelDownloadScreen(),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,31 +8,46 @@ final modelPresentProvider = FutureProvider<bool>((ref) {
|
|||||||
return ModelDownloadService().isModelPresent();
|
return ModelDownloadService().isModelPresent();
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── Download notifier — streams progress and marks completion ─────────────────
|
// ── Has the user chosen to skip the model requirement? ───────────────────────
|
||||||
|
|
||||||
class ModelDownloadNotifier extends Notifier<AsyncValue<double>> {
|
class _SkipNotifier extends Notifier<bool> {
|
||||||
@override
|
@override
|
||||||
AsyncValue<double> build() => const AsyncData(0.0);
|
bool build() => false;
|
||||||
|
void skip() => state = true;
|
||||||
Future<void> startDownload() async {
|
|
||||||
state = const AsyncData(0.0);
|
|
||||||
try {
|
|
||||||
await for (final progress in ModelDownloadService().download()) {
|
|
||||||
if (!ref.mounted) return;
|
|
||||||
state = AsyncData(progress);
|
|
||||||
}
|
|
||||||
if (!ref.mounted) return;
|
|
||||||
await ref.read(settingsNotifierProvider.notifier).markModelDownloaded();
|
|
||||||
ref.invalidate(modelPresentProvider);
|
|
||||||
} catch (e, st) {
|
|
||||||
if (!ref.mounted) return;
|
|
||||||
state = AsyncError(e, st);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset() => state = const AsyncData(0.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final modelDownloadNotifierProvider =
|
final modelSkippedProvider =
|
||||||
NotifierProvider<ModelDownloadNotifier, AsyncValue<double>>(
|
NotifierProvider<_SkipNotifier, bool>(_SkipNotifier.new);
|
||||||
ModelDownloadNotifier.new);
|
|
||||||
|
// ── Scan notifier — checks for the model on demand ────────────────��──────────
|
||||||
|
|
||||||
|
class ModelScanNotifier extends Notifier<AsyncValue<bool>> {
|
||||||
|
@override
|
||||||
|
AsyncValue<bool> build() => const AsyncData(false);
|
||||||
|
|
||||||
|
Future<void> scan() async {
|
||||||
|
state = const AsyncLoading();
|
||||||
|
final next = await AsyncValue.guard(
|
||||||
|
() => ModelDownloadService().isModelPresent(),
|
||||||
|
);
|
||||||
|
if (!ref.mounted) return;
|
||||||
|
next.whenData((present) async {
|
||||||
|
if (present) {
|
||||||
|
await ref.read(settingsNotifierProvider.notifier).markModelDownloaded();
|
||||||
|
ref.invalidate(modelPresentProvider);
|
||||||
|
} else {
|
||||||
|
state = AsyncError(
|
||||||
|
Exception('Model file not found at expected path'),
|
||||||
|
StackTrace.current,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (next is AsyncError) state = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
void skipToApp() => ref.read(modelSkippedProvider.notifier).skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
final modelScanProvider =
|
||||||
|
NotifierProvider.autoDispose<ModelScanNotifier, AsyncValue<bool>>(
|
||||||
|
ModelScanNotifier.new);
|
||||||
|
|||||||
@@ -7,27 +7,68 @@ class ModelDownloadScreen extends ConsumerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final downloadState = ref.watch(modelDownloadNotifierProvider);
|
final scanState = ref.watch(modelScanProvider);
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
body: SafeArea(
|
body: SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(32),
|
padding: const EdgeInsets.all(32),
|
||||||
child: downloadState.when(
|
child: Column(
|
||||||
data: (progress) => progress == 0.0
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
? _IdleView(
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
onDownload: () => ref
|
children: [
|
||||||
.read(modelDownloadNotifierProvider.notifier)
|
Icon(
|
||||||
.startDownload(),
|
Icons.auto_awesome,
|
||||||
)
|
size: 64,
|
||||||
: _DownloadingView(progress: progress),
|
color: Theme.of(context).colorScheme.primary,
|
||||||
loading: () => const Center(child: CircularProgressIndicator()),
|
),
|
||||||
error: (e, _) => _ErrorView(
|
const SizedBox(height: 24),
|
||||||
error: e.toString(),
|
Text(
|
||||||
onRetry: () {
|
'On-device AI',
|
||||||
ref.read(modelDownloadNotifierProvider.notifier).reset();
|
style: Theme.of(context).textTheme.headlineSmall,
|
||||||
},
|
textAlign: TextAlign.center,
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
Text(
|
||||||
|
'DailyYou uses an on-device AI model to spot patterns in your '
|
||||||
|
'moods and behaviour. Your data never leaves your phone.',
|
||||||
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
const SizedBox(height: 32),
|
||||||
|
_InstructionCard(),
|
||||||
|
const SizedBox(height: 24),
|
||||||
|
if (scanState is AsyncLoading)
|
||||||
|
const Center(child: CircularProgressIndicator())
|
||||||
|
else ...[
|
||||||
|
if (scanState is AsyncError)
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
|
child: Text(
|
||||||
|
'Model not found at expected path.',
|
||||||
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||||
|
color: Theme.of(context).colorScheme.error,
|
||||||
|
),
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
FilledButton.icon(
|
||||||
|
onPressed: () =>
|
||||||
|
ref.read(modelScanProvider.notifier).scan(),
|
||||||
|
icon: const Icon(Icons.search),
|
||||||
|
label: const Text('Scan for model'),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 12),
|
||||||
|
OutlinedButton(
|
||||||
|
onPressed: () => ref
|
||||||
|
.read(modelScanProvider.notifier)
|
||||||
|
.skipToApp(),
|
||||||
|
child: const Text('Continue without AI'),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -35,133 +76,77 @@ class ModelDownloadScreen extends ConsumerWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _IdleView extends StatelessWidget {
|
class _InstructionCard extends StatelessWidget {
|
||||||
const _IdleView({required this.onDownload});
|
|
||||||
|
|
||||||
final VoidCallback onDownload;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
final cs = Theme.of(context).colorScheme;
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
return Card(
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
child: Padding(
|
||||||
children: [
|
padding: const EdgeInsets.all(16),
|
||||||
Icon(
|
child: Column(
|
||||||
Icons.auto_awesome,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
size: 64,
|
children: [
|
||||||
color: Theme.of(context).colorScheme.primary,
|
Text('How to get the model',
|
||||||
|
style: Theme.of(context).textTheme.titleSmall),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
_Step(
|
||||||
|
n: '1',
|
||||||
|
text: 'Download gemma-2b-it-cpu-int4.bin from Kaggle '
|
||||||
|
'(requires a free Google account and licence acceptance).',
|
||||||
|
),
|
||||||
|
_Step(
|
||||||
|
n: '2',
|
||||||
|
text: 'Transfer the file to the device using adb:\n'
|
||||||
|
'adb push gemma-2b-it-cpu-int4.bin '
|
||||||
|
r'$(adb shell run-as net.stefwill.dailyou '
|
||||||
|
r'printenv DATA_DIR)/files/',
|
||||||
|
),
|
||||||
|
_Step(
|
||||||
|
n: '3',
|
||||||
|
text: 'Tap "Scan for model" once the transfer is complete.',
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
Text(
|
||||||
|
'The model is ~1.3 GB and only needs to be transferred once.',
|
||||||
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
|
color: cs.outline,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
),
|
||||||
Text(
|
|
||||||
'On-device AI',
|
|
||||||
style: Theme.of(context).textTheme.headlineSmall,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Text(
|
|
||||||
'DailyYou uses an on-device AI model to spot patterns in your moods '
|
|
||||||
'and behaviour. Your data never leaves your phone.',
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'The model is ~1.1 GB and only needs to be downloaded once.',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
FilledButton.icon(
|
|
||||||
onPressed: onDownload,
|
|
||||||
icon: const Icon(Icons.download),
|
|
||||||
label: const Text('Download model'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DownloadingView extends StatelessWidget {
|
class _Step extends StatelessWidget {
|
||||||
const _DownloadingView({required this.progress});
|
const _Step({required this.n, required this.text});
|
||||||
|
final String n;
|
||||||
final double progress;
|
final String text;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final pct = (progress * 100).toStringAsFixed(0);
|
return Padding(
|
||||||
final done = progress >= 1.0;
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: Row(
|
||||||
return Column(
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
children: [
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
CircleAvatar(
|
||||||
children: [
|
radius: 10,
|
||||||
Icon(
|
backgroundColor: Theme.of(context).colorScheme.primaryContainer,
|
||||||
done ? Icons.check_circle : Icons.downloading,
|
child: Text(n,
|
||||||
size: 64,
|
style: Theme.of(context).textTheme.labelSmall?.copyWith(
|
||||||
color: done
|
color:
|
||||||
? Theme.of(context).colorScheme.primary
|
Theme.of(context).colorScheme.onPrimaryContainer,
|
||||||
: Theme.of(context).colorScheme.secondary,
|
)),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(width: 10),
|
||||||
Text(
|
Expanded(
|
||||||
done ? 'Ready!' : 'Downloading…',
|
child: Text(text,
|
||||||
style: Theme.of(context).textTheme.headlineSmall,
|
style: Theme.of(context).textTheme.bodySmall),
|
||||||
textAlign: TextAlign.center,
|
),
|
||||||
),
|
],
|
||||||
const SizedBox(height: 24),
|
),
|
||||||
LinearProgressIndicator(value: progress),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
done ? 'Model downloaded successfully.' : '$pct% — keep the app open',
|
|
||||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.outline,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _ErrorView extends StatelessWidget {
|
|
||||||
const _ErrorView({required this.error, required this.onRetry});
|
|
||||||
|
|
||||||
final String error;
|
|
||||||
final VoidCallback onRetry;
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
||||||
children: [
|
|
||||||
Icon(Icons.error_outline,
|
|
||||||
size: 64, color: Theme.of(context).colorScheme.error),
|
|
||||||
const SizedBox(height: 24),
|
|
||||||
Text(
|
|
||||||
'Download failed',
|
|
||||||
style: Theme.of(context).textTheme.headlineSmall,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'Check your connection and try again.',
|
|
||||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
||||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
||||||
),
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
|
||||||
FilledButton.icon(
|
|
||||||
onPressed: onRetry,
|
|
||||||
icon: const Icon(Icons.refresh),
|
|
||||||
label: const Text('Try again'),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user