Add cxyz Android project structure and initial configuration

- Introduced a new Flutter project for the cxyz Android manga/comic reader, including essential files such as pubspec.yaml, AndroidManifest.xml, and Gradle configuration.
- Added .gitignore files to exclude unnecessary files and directories for both the main project and Android-specific files.
- Implemented initial README.md with project description, features, setup instructions, and API details for ComicLand, MangaRead, and MangaTown.
- Configured analysis options and dependencies in pubspec.yaml to support Flutter development.
- Established a pnpm workspace and lockfile for dependency management.
- Included various Android resources such as icons, styles, and launch backgrounds for a complete application setup.
This commit is contained in:
2026-08-29 17:50:31 +07:00
parent 6e7f1ced35
commit a7c6058540
105 changed files with 16721 additions and 275 deletions
@@ -0,0 +1,100 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:shared_preferences/shared_preferences.dart';
/// What to attach on chapter-completed ntfy notifications.
enum NtfyAttachmentMode {
none,
cover,
firstImage,
cbz;
String get storageValue => name;
static NtfyAttachmentMode fromStorage(String? raw) {
for (final m in NtfyAttachmentMode.values) {
if (m.name == raw) return m;
}
return NtfyAttachmentMode.none;
}
String get label {
switch (this) {
case NtfyAttachmentMode.none:
return 'None';
case NtfyAttachmentMode.cover:
return 'Series cover';
case NtfyAttachmentMode.firstImage:
return 'First page';
case NtfyAttachmentMode.cbz:
return 'CBZ file';
}
}
}
class NtfySettings {
static const _kEnabled = 'ntfy_enabled';
static const _kCompletedUrl = 'ntfy_completed_url';
static const _kFailedUrl = 'ntfy_failed_url';
static const _kDrainedUrl = 'ntfy_drained_url';
static const _kAttachment = 'ntfy_attachment_mode';
static const _tokenKey = 'ntfy_auth_token';
static const _secure = FlutterSecureStorage();
final bool enabled;
final String completedUrl;
final String failedUrl;
final String drainedUrl;
final NtfyAttachmentMode attachmentMode;
final String authToken;
const NtfySettings({
required this.enabled,
required this.completedUrl,
required this.failedUrl,
required this.drainedUrl,
required this.attachmentMode,
required this.authToken,
});
String? get urlForCompleted => _nonEmpty(completedUrl);
String? get urlForFailed => _nonEmpty(failedUrl);
String? get urlForDrained => _nonEmpty(drainedUrl);
static String? _nonEmpty(String raw) {
final t = raw.trim();
return t.isEmpty ? null : t;
}
static Future<NtfySettings> load() async {
final prefs = await SharedPreferences.getInstance();
final token = await _secure.read(key: _tokenKey) ?? '';
return NtfySettings(
enabled: prefs.getBool(_kEnabled) ?? false,
completedUrl: prefs.getString(_kCompletedUrl) ?? '',
failedUrl: prefs.getString(_kFailedUrl) ?? '',
drainedUrl: prefs.getString(_kDrainedUrl) ?? '',
attachmentMode: NtfyAttachmentMode.fromStorage(
prefs.getString(_kAttachment),
),
authToken: token,
);
}
static Future<void> save({
required bool enabled,
required String completedUrl,
required String failedUrl,
required String drainedUrl,
required NtfyAttachmentMode attachmentMode,
required String authToken,
}) async {
final prefs = await SharedPreferences.getInstance();
await prefs.setBool(_kEnabled, enabled);
await prefs.setString(_kCompletedUrl, completedUrl.trim());
await prefs.setString(_kFailedUrl, failedUrl.trim());
await prefs.setString(_kDrainedUrl, drainedUrl.trim());
await prefs.setString(_kAttachment, attachmentMode.storageValue);
await _secure.write(key: _tokenKey, value: authToken);
}
}