use correct folder on android platform

This commit is contained in:
lukas-heiligenbrunner 2022-09-28 11:56:51 +02:00
parent a80b547656
commit 2ba9fb3fbd

View File

@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:gallery/data_provider/data_provider.dart';
import 'package:gallery/image_grid.dart';
@ -20,23 +22,28 @@ enum Page { local, remote }
class _MyHomePageState extends State<MyHomePage> {
Page page = Page.local;
final DataProvider localProvider = LocalDataProvider(getApplicationDocumentsDirectory());
Future<Directory> _getLocalDir() async {
Directory dir;
if (Theme.of(context).platform == TargetPlatform.android) {
dir = Directory("/storage/emulated/0/DCIM/");
} else {
dir = (await getDownloadsDirectory())?.parent ??
await getApplicationDocumentsDirectory();
}
return dir;
}
Widget _buildPage() {
DataProvider provider;
switch (page) {
case Page.local:
provider = localProvider;
provider = LocalDataProvider(_getLocalDir());
break;
case Page.remote:
// todo do not generate a new provider on each tab switch
provider = SSHDataProvider(
initialPath: "/",
host: "",
password: "",
port: 0,
username: "");
initialPath: "/", host: "", password: "", port: 0, username: "");
break;
}
return ImageGrid(dProvider: provider);