Skip to content

Commit

Permalink
Fixed Local Extensions on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
K3vinb5 committed Oct 8, 2024
1 parent 2f5e331 commit 610051d
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
3 changes: 0 additions & 3 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ Future<void> main() async {
Locale('it'),
Locale('pt'),
Locale('ru'),
// Locale('po'),
// Locale('zh-cn'),
// Locale('zh-hk')
],
useOnlyLangCode: true,
path: 'assets/languages',
Expand Down
6 changes: 3 additions & 3 deletions lib/models/media_content_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ class MediaContentModel {
if (response.statusCode != 200){
if (attempt < 5){

}
}
}
Map<String, dynamic> jsonResponse = json.decode(response.body);
Map<String, dynamic> episodes = jsonResponse["episodes"];
imageUrls = episodes.values.map((e) => e["image"] as String?).toList();
titles = episodes.values.map((e) => e["title"]["en"] as String?).toList();
fanart = jsonResponse["images"][2]["url"];
banner = jsonResponse["images"][0]["url"];
fanart = jsonResponse["images"]?[2]["url"];
banner = jsonResponse["images"]?[0]["url"];
// if (titles != null){
// titles!.addAll(List.filled(10, null));
// }
Expand Down
1 change: 1 addition & 0 deletions lib/models/preferences_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class PreferencesModel {
}
String? version = sharedPreferences.getString("version");
if(version == null || version != currentVersion){
print("New version, updating api");
processManager.downloadNewCore();
}
sharedPreferences.setString("version", currentVersion);
Expand Down
5 changes: 3 additions & 2 deletions lib/screens/local_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,10 @@ class _LocalExtensionsScreenState extends State<LocalExtensionsScreen> {
List<String> updatedinstalledExtensions = await animeExtensionsDir
.list()
.map((fileSystemEntity) => fileSystemEntity.path
.substring(fileSystemEntity.path.lastIndexOf("/") + 1)
.substring(fileSystemEntity.path.lastIndexOf(Platform.isWindows ? "\\" : "/") + 1)
.replaceFirst(".jar", ""))
.toList();
print(updatedinstalledExtensions);
setState(() {
installedAnimeExtensions = updatedinstalledExtensions;
});
Expand All @@ -215,7 +216,7 @@ class _LocalExtensionsScreenState extends State<LocalExtensionsScreen> {
List<String> updatedinstalledExtensions = await mangaExtensionsDir
.list()
.map((fileSystemEntity) => fileSystemEntity.path
.substring(fileSystemEntity.path.lastIndexOf("/") + 1)
.substring(fileSystemEntity.path.lastIndexOf(Platform.isWindows ? "\\" :"/") + 1)
.replaceFirst(".jar", ""))
.toList();
setState(() {
Expand Down
17 changes: 4 additions & 13 deletions lib/util/processes/process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,17 @@ class ProcessManager {

Future<void> _extractJar({bool ignore = false}) async {
supportDirectoryPath = await getApplicationSupportDirectory();
final jarFile = File(p.join(supportDirectoryPath.path,
"extensions.jar")); /*Platform.isWindows
? File('${supportDirectoryPath.path}\\extensions.jar')
: File('${supportDirectoryPath.path}//extensions.jar');*/
final jarFile = File(p.join(supportDirectoryPath.path, "extensions.jar"));

if (await jarFile.exists() && !ignore) {
_jarPath = jarFile.path;
return;
}

final byteData = await rootBundle.load(p.join("assets",
"extensions.jar") /*Platform.isWindows
? 'assets\\extensions.jar'
: 'assets//extensions.jar'*/
);
// NOTE, even for windows, the slash must be forawd on this one
final byteData = await rootBundle.load("assets/extensions.jar");
final buffer = byteData.buffer;
final file = File(p.join(supportDirectoryPath.path,
"extensions.jar")); /*Platform.isWindows
? File('${supportDirectoryPath.path}\\extensions.jar')
: File('${supportDirectoryPath.path}//extensions.jar');*/
final file = File(p.join(supportDirectoryPath.path, "extensions.jar"));
await file.writeAsBytes(
buffer.asUint8List(byteData.offsetInBytes, byteData.lengthInBytes));
_jarPath = file.path;
Expand Down
Empty file modified linux-appimage/Unyo.AppDir/AppRun
100755 → 100644
Empty file.
Empty file modified linux-appimage/appimagetool.AppImage
100755 → 100644
Empty file.

0 comments on commit 610051d

Please sign in to comment.