-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* upgrade react-native-webview * optimise: no render reader content when change reader settings * optimise: no render reader content when change general settings * fix: missing page when open reader * fix: library only downloaded filter * fix: center reader footer * fix: reader footer padding * fix: stop loading after fetch chapters * showToast if cancel epub * optimise: plugin list * fix: remove LNReader path * optimise: replace RNFS utf-8 by native * fix: add description as epub summary * feat: hot reload for assets files (reader statics files)
- Loading branch information
Showing
25 changed files
with
521 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
android/app/src/main/java/com/rajarsheechatterjee/TextFile/TextFile.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package com.rajarsheechatterjee.TextFile; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileOutputStream; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
|
||
public class TextFile extends ReactContextBaseJavaModule { | ||
TextFile(ReactApplicationContext context) { | ||
super(context); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public String getName() { | ||
return "TextFile"; | ||
} | ||
|
||
@ReactMethod | ||
public void writeFile(String path, String content, Promise promise) { | ||
try { | ||
FileWriter fw = new FileWriter(path); | ||
fw.write(content); | ||
fw.close(); | ||
promise.resolve(null); | ||
} catch (Exception e) { | ||
promise.reject(e); | ||
} | ||
} | ||
|
||
@ReactMethod void readFile(String path, Promise promise) { | ||
try { | ||
StringBuilder sb = new StringBuilder(); | ||
BufferedReader br = new BufferedReader(new FileReader(path)); | ||
String line; | ||
while ((line = br.readLine()) != null) sb.append(line).append('\n'); | ||
promise.resolve(sb.toString()); | ||
} catch (Exception e) { | ||
promise.reject(e); | ||
} | ||
|
||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
android/app/src/main/java/com/rajarsheechatterjee/TextFile/TextFilePackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.rajarsheechatterjee.TextFile; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
import com.facebook.react.ReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.uimanager.ViewManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class TextFilePackage implements ReactPackage { | ||
@NonNull | ||
@Override | ||
public List<NativeModule> createNativeModules(@NonNull ReactApplicationContext reactApplicationContext) { | ||
List<NativeModule> modules = new ArrayList<>(); | ||
try { | ||
modules.add(new TextFile(reactApplicationContext)); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
return modules; | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactApplicationContext) { | ||
return Collections.emptyList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,44 @@ | ||
// Learn more https://docs.expo.io/guides/customizing-metro | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const { mergeConfig } = require('metro-config'); | ||
const { getDefaultConfig } = require('expo/metro-config'); | ||
const defaultConfig = getDefaultConfig(__dirname); | ||
|
||
module.exports = getDefaultConfig(__dirname); | ||
const map = { | ||
'.ico': 'image/x-icon', | ||
'.html': 'text/html', | ||
'.js': 'text/javascript', | ||
'.json': 'application/json', | ||
'.css': 'text/css', | ||
'.png': 'image/png', | ||
'.jpg': 'image/jpeg', | ||
}; | ||
const customConfig = { | ||
server: { | ||
port: 8081, | ||
enhanceMiddleware: (metroMiddleware, metroServer) => { | ||
return (request, res, next) => { | ||
const filePath = path.join( | ||
__dirname, | ||
'android/app/src/main', | ||
request._parsedUrl.path || '', | ||
); | ||
const ext = path.parse(filePath).ext; | ||
if (fs.existsSync(filePath)) { | ||
try { | ||
const data = fs.readFileSync(filePath); | ||
res.setHeader('Content-type', map[ext] || 'text/plain'); | ||
res.end(data); | ||
} catch (err) { | ||
res.statusCode = 500; | ||
res.end(`Error getting the file: ${err}.`); | ||
} | ||
} else { | ||
return metroMiddleware(request, res, next); | ||
} | ||
}; | ||
}, | ||
}, | ||
}; | ||
module.exports = mergeConfig(defaultConfig, customConfig); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.