Skip to content

Commit

Permalink
Release v1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Voklen committed Aug 5, 2023
2 parents 174b157 + 7f1d2f0 commit 8b3fc44
Show file tree
Hide file tree
Showing 27 changed files with 829 additions and 485 deletions.
28 changes: 14 additions & 14 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
# This file should be version controlled.

version:
revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
channel: beta
revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
channel: stable

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: android
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: ios
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: linux
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: macos
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
- platform: windows
create_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
base_revision: 75927305ff855f76a9ef704f9b4a86fa2fce7292
create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8

# User provided section

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# Daily Diary


<img src="https://img.shields.io/f-droid/v/com.voklen.daily_diary.svg?logo=F-Droid"
alt="F-droid version">
<img src="https://img.shields.io/github/v/release/Voklen/daily-diary.svg?logo=github"
alt="Github version">
[![Github version](https://img.shields.io/github/v/release/Voklen/daily-diary.svg?logo=github)](https://github.com/Voklen/Daily-Diary/releases/latest)
[![F-droid version](https://img.shields.io/f-droid/v/com.voklen.daily_diary.svg?logo=F-Droid)](https://f-droid.org/packages/com.voklen.daily_diary/)

Jot down whatever you want throughout the day and the app will reset the next morning. All previous days are stored in plaintext files which can be exported and moved to a different device.

Expand Down
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
namespace "com.voklen.daily_diary"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion

Expand Down
3 changes: 1 addition & 2 deletions android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.voklen.daily_diary">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
5 changes: 2 additions & 3 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.voklen.daily_diary">
<application
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:label="Daily Diary"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
Expand Down
3 changes: 1 addition & 2 deletions android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.voklen.daily_diary">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The INTERNET permission is required for development. Specifically,
the Flutter tool needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
Expand Down
6 changes: 3 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.7.10'
ext.kotlin_version = '1.9.0'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
12 changes: 12 additions & 0 deletions ios/RunnerTests/RunnerTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Flutter
import UIKit
import XCTest

class RunnerTests: XCTestCase {

func testExample() {
// If you add code to the Runner application, consider adding tests here.
// See https://developer.apple.com/documentation/xctest for more information about using XCTest.
}

}
86 changes: 86 additions & 0 deletions lib/backend_classes/filenames.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import 'package:daily_diary/main.dart';

class Filename {
static String dateToFilename(DateTime date, {String? dateFormat}) {
String filename = dateFormat ?? App.settingsNotifier.value.dateFormat;
filename = filename.replaceAll('%Y', _twoDigits(date.year));
filename = filename.replaceAll('%M', _twoDigits(date.month));
filename = filename.replaceAll('%D', _twoDigits(date.day));
return filename;
}

static String _twoDigits(int n) {
if (n >= 10) return "$n";
return "0$n";
}

static DateTime? filenameToDate(String filename) {
String dateFormat = App.settingsNotifier.value.dateFormat;
_Order order = _Order(dateFormat);

String regexString = dateFormat
.replaceFirst('%Y', r'(\d+)')
.replaceFirst('%M', r'(\d+)')
.replaceFirst('%D', r'(\d+)');
RegExp regex = RegExp(regexString);

// Find all matches of the pattern in the expression
final RegExpMatch? matches = regex.firstMatch(filename);
if (matches == null) return null;

// The groups cannot be null because the regex has 3 groups and so all must exist
int year = int.parse(matches.group(order.year)!);
int month = int.parse(matches.group(order.month)!);
int day = int.parse(matches.group(order.day)!);
return DateTime(year, month, day);
}
}

class _Order {
late int year;
late int month;
late int day;

_Order(String dateFormat) {
int yearLocation = dateFormat.indexOf('%Y');
int monthLocation = dateFormat.indexOf('%M');
int dayLocation = dateFormat.indexOf('%D');

if (yearLocation < monthLocation && monthLocation < dayLocation) {
year = 1;
month = 2;
day = 3;
return;
}
if (yearLocation < dayLocation && dayLocation < monthLocation) {
year = 1;
day = 2;
month = 3;
return;
}
if (monthLocation < yearLocation && yearLocation < dayLocation) {
month = 1;
year = 2;
day = 3;
return;
}
if (monthLocation < dayLocation && dayLocation < yearLocation) {
month = 1;
day = 2;
year = 3;
return;
}
if (dayLocation < yearLocation && yearLocation < monthLocation) {
day = 1;
year = 2;
month = 3;
return;
}
if (dayLocation < monthLocation && monthLocation < yearLocation) {
day = 1;
month = 2;
year = 3;
return;
}
}
}
10 changes: 5 additions & 5 deletions lib/path.dart → lib/backend_classes/path.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:flutter/material.dart';

import 'package:daily_diary/main.dart';

import 'package:path_provider/path_provider.dart';
import 'package:shared_storage/saf.dart';
import 'package:path_provider/path_provider.dart' as path_prov;
import 'package:shared_storage/shared_storage.dart';

class SavePath {
// Due to the constructors only one can ever be null at any time
Expand Down Expand Up @@ -54,7 +54,7 @@ class SavePath {
return file;
}
DocumentFile? createdFile =
await createFile(uri!, mimeType: 'text/plain', displayName: filename);
await createFile(uri!, mimeType: '', displayName: filename);
return createdFile!;
}
}
Expand Down Expand Up @@ -98,12 +98,12 @@ Future<String> get _defaultPath async {
Future<Directory> get _directory async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
final directory = await getExternalStorageDirectory();
final directory = await path_prov.getExternalStorageDirectory();
if (directory != null) {
return directory;
}
}

final directory = await getApplicationDocumentsDirectory();
final directory = await path_prov.getApplicationDocumentsDirectory();
return directory;
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import 'package:flutter/material.dart';

import 'package:daily_diary/path.dart';
import 'package:daily_diary/storage.dart';
import 'package:daily_diary/backend_classes/path.dart';
import 'package:daily_diary/backend_classes/storage.dart';

class Settings {
ThemeMode theme = ThemeMode.system;
double fontSize = 16;
Color colorScheme = const Color.fromARGB(255, 152, 85, 211);
bool checkSpelling = true;
String dateFormat = '%Y-%M-%D.txt';
}

class SettingsNotifier extends ValueNotifier<Settings> {
Expand All @@ -33,6 +34,10 @@ class SettingsNotifier extends ValueNotifier<Settings> {
await setCheckSpelling(await storage.getCheckSpelling());
}

Future<void> setDateFormatFromFile() async {
await setDateFormat(await storage.getDateFormat());
}

Future<void> setThemeToDefault() async {
await setTheme(Settings().theme);
}
Expand All @@ -49,6 +54,10 @@ class SettingsNotifier extends ValueNotifier<Settings> {
await setCheckSpelling(Settings().checkSpelling);
}

Future<void> setDateFormatToDefault() async {
await setDateFormat(Settings().dateFormat);
}

Future<void> setTheme(ThemeMode? theme) async {
if (theme == null) {
return;
Expand Down Expand Up @@ -78,10 +87,19 @@ class SettingsNotifier extends ValueNotifier<Settings> {

Future<void> setCheckSpelling(bool? checkSpelling) async {
if (checkSpelling == null) {
return Future(() => null);
return;
}
value.checkSpelling = checkSpelling;
await storage.setCheckSpelling(checkSpelling);
notifyListeners();
}

Future<void> setDateFormat(String? dateFormat) async {
if (dateFormat == null) {
return;
}
value.dateFormat = dateFormat;
await storage.setDateFormat(dateFormat);
notifyListeners();
}
}
Loading

0 comments on commit 8b3fc44

Please sign in to comment.