mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
Remove getGitBaseDirectory function
Instead lets just use the path_provider. This was being used as for some reason I wanted the files to reside inside the 'files' folder and not in the 'app_flutter' directory. However, that requires maintaining a fork of path_provider, which I no longer want to do.
This commit is contained in:
@ -2,7 +2,6 @@ package io.gitjournal.gitjournal;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
@ -18,7 +17,6 @@ import io.flutter.plugin.common.MethodChannel;
|
||||
import io.flutter.plugin.common.MethodChannel.MethodCallHandler;
|
||||
import io.flutter.plugin.common.MethodChannel.Result;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
import io.flutter.util.PathUtils;
|
||||
|
||||
import io.flutter.app.FlutterActivity;
|
||||
import io.flutter.plugins.GeneratedPluginRegistrant;
|
||||
@ -38,14 +36,6 @@ public class MainActivity extends FlutterActivity implements MethodCallHandler {
|
||||
|
||||
@Override
|
||||
public void onMethodCall(MethodCall call, Result result) {
|
||||
Context context = getApplicationContext();
|
||||
final String filesDir = PathUtils.getFilesDir(context);
|
||||
|
||||
if (call.method.equals("getBaseDirectory")) {
|
||||
result.success(filesDir);
|
||||
return;
|
||||
}
|
||||
|
||||
result.notImplemented();
|
||||
}
|
||||
|
||||
|
@ -48,10 +48,7 @@ static FlutterMethodChannel* gitChannel = 0;
|
||||
NSArray *sshPrivateComponents = [NSArray arrayWithObjects:filesDir, @"ssh", @"id_rsa", nil];
|
||||
NSString *sshPrivateKeyString = [NSString pathWithComponents:sshPrivateComponents];
|
||||
|
||||
if ([@"getBaseDirectory" isEqualToString:method]) {
|
||||
result(filesDir);
|
||||
}
|
||||
else if ([@"gitClone" isEqualToString:method]) {
|
||||
if ([@"gitClone" isEqualToString:method]) {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
[self handleMethodCallAsync:call result:result];
|
||||
});
|
||||
|
@ -1,17 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
const _platform = MethodChannel('gitjournal.io/git');
|
||||
|
||||
///
|
||||
/// This gives us the directory where all the git repos will be stored
|
||||
///
|
||||
Future<Directory> getGitBaseDirectory() async {
|
||||
final String path = await _platform.invokeMethod('getBaseDirectory');
|
||||
if (path == null) {
|
||||
return null;
|
||||
}
|
||||
return Directory(path);
|
||||
}
|
@ -24,7 +24,6 @@ import 'package:dart_git/git.dart';
|
||||
import 'package:quick_actions/quick_actions.dart';
|
||||
import 'package:receive_sharing_intent/receive_sharing_intent.dart';
|
||||
|
||||
import 'package:gitjournal/apis/git.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
import 'package:gitjournal/state_container.dart';
|
||||
import 'package:gitjournal/appstate.dart';
|
||||
@ -32,6 +31,7 @@ import 'package:gitjournal/themes.dart';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:dynamic_theme/dynamic_theme.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'screens/home_screen.dart';
|
||||
import 'screens/onboarding_screens.dart';
|
||||
@ -54,7 +54,7 @@ class JournalApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
if (appState.gitBaseDirectory.isEmpty) {
|
||||
var dir = await getGitBaseDirectory();
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
appState.gitBaseDirectory = dir.path;
|
||||
appState.save(pref);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter_driver/driver_extension.dart';
|
||||
import 'package:gitjournal/apis/git.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'package:gitjournal/app.dart';
|
||||
import 'package:gitjournal/appstate.dart';
|
||||
@ -24,7 +24,7 @@ void main() async {
|
||||
|
||||
// Generate lots of notes and folders better screenshots
|
||||
Future<void> populateWithData(SharedPreferences pref) async {
|
||||
var dir = await getGitBaseDirectory();
|
||||
var dir = await getApplicationDocumentsDirectory();
|
||||
|
||||
var appState = AppState(pref);
|
||||
appState.gitBaseDirectory = dir.path;
|
||||
|
Reference in New Issue
Block a user