working android example. File access still not working
This commit is contained in:
parent
a04fd0293f
commit
340833ea7b
6 changed files with 50 additions and 17 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -11,7 +11,7 @@ node_modules
|
||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
*.local
|
||||||
|
src-tauri/gen/android/keystore.properties
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,15 @@
|
||||||
"main"
|
"main"
|
||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
{
|
||||||
|
"identifier": "fs:allow-read",
|
||||||
|
"allow": [{ "path": "$HOME/**" }]
|
||||||
|
},
|
||||||
"core:default",
|
"core:default",
|
||||||
"shell:allow-open",
|
"shell:allow-open",
|
||||||
"fs:default",
|
"log:default",
|
||||||
"log:default"
|
"fs:allow-home-read-recursive",
|
||||||
|
"fs:scope-home-recursive",
|
||||||
|
"fs:read-all"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
|
import java.io.FileInputStream
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("com.android.application")
|
id("com.android.application")
|
||||||
|
|
@ -24,6 +25,22 @@ android {
|
||||||
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
|
||||||
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
|
||||||
}
|
}
|
||||||
|
signingConfigs {
|
||||||
|
create("release") {
|
||||||
|
val keystorePropertiesFile = rootProject.file("keystore.properties")
|
||||||
|
val keystoreProperties = Properties()
|
||||||
|
if (keystorePropertiesFile.exists()) {
|
||||||
|
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
|
||||||
|
}
|
||||||
|
|
||||||
|
keyAlias = keystoreProperties["keyAlias"] as String
|
||||||
|
keyPassword = keystoreProperties["password"] as String
|
||||||
|
storeFile = file(keystoreProperties["storeFile"] as String)
|
||||||
|
storePassword = keystoreProperties["password"] as String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
getByName("debug") {
|
getByName("debug") {
|
||||||
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
manifestPlaceholders["usesCleartextTraffic"] = "true"
|
||||||
|
|
@ -37,6 +54,7 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getByName("release") {
|
getByName("release") {
|
||||||
|
signingConfig = signingConfigs.getByName("release")
|
||||||
isMinifyEnabled = true
|
isMinifyEnabled = true
|
||||||
proguardFiles(
|
proguardFiles(
|
||||||
*fileTree(".") { include("**/*.pro") }
|
*fileTree(".") { include("**/*.pro") }
|
||||||
|
|
@ -66,4 +84,4 @@ dependencies {
|
||||||
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
apply(from = "tauri.build.gradle.kts")
|
apply(from = "tauri.build.gradle.kts")
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<!-- AndroidTV support -->
|
<!-- AndroidTV support -->
|
||||||
<uses-feature android:name="android.software.leanback" android:required="false" />
|
<uses-feature android:name="android.software.leanback" android:required="false" />
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@
|
||||||
"assetProtocol": {
|
"assetProtocol": {
|
||||||
"enable": true,
|
"enable": true,
|
||||||
"scope": [
|
"scope": [
|
||||||
"$HOME/**"
|
"$HOME/**",
|
||||||
|
"**"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
30
src/main.js
30
src/main.js
|
|
@ -1,4 +1,5 @@
|
||||||
const { convertFileSrc, invoke } = window.__TAURI__.core;
|
const { convertFileSrc, invoke } = window.__TAURI__.core;
|
||||||
|
// const { invoke } = window.__TAURI__.core;
|
||||||
const { homeDir, join } = window.__TAURI__.path;
|
const { homeDir, join } = window.__TAURI__.path;
|
||||||
const { readFile } = window.__TAURI__.fs;
|
const { readFile } = window.__TAURI__.fs;
|
||||||
|
|
||||||
|
|
@ -7,20 +8,25 @@ const filePath = await join(appDataDirPath, 'Pictures/wallpaper.png');
|
||||||
|
|
||||||
const assetUrl = convertFileSrc(filePath);
|
const assetUrl = convertFileSrc(filePath);
|
||||||
|
|
||||||
|
|
||||||
let text = "";
|
let text = "";
|
||||||
window.addEventListener("DOMCharacterDataModified", () => {
|
// window.addEventListener("DOMCharacterDataModified", () => {
|
||||||
|
// var tag_id = document.getElementById('rendered_markdown');
|
||||||
|
// tag_id.innerHTML = "<p>HI</p>"
|
||||||
// window.addEventListener("DOMContentLoaded", () => {
|
// window.addEventListener("DOMContentLoaded", () => {
|
||||||
let textarea = document.getElementById('markdown_input');
|
let textarea = document.getElementById('markdown_input');
|
||||||
textarea.addEventListener('input', ()=> {
|
textarea.addEventListener('input', ()=> {
|
||||||
text = textarea.innerText;
|
text = textarea.innerText;
|
||||||
invoke("parse_markdown", { document: text }).then(
|
var tag_id = document.getElementById('rendered_markdown');
|
||||||
(ret)=>{
|
tag_id.innerHTML = "<p>HI</p>"
|
||||||
var tag_id = document.getElementById('rendered_markdown');
|
// invoke("parse_markdown", { document: text }).then(
|
||||||
// tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
|
// (ret)=>{
|
||||||
tag_id.innerHTML = assetUrl.concat(" ", ' \n <img src="'.concat("", assetUrl).concat("", '" alt="Girl in a jacket" width="500" height="600">'))
|
// var tag_id = document.getElementById('rendered_markdown');
|
||||||
}
|
// // tag_id.innerHTML = assetUrl.concat(" ", ' \n <img src="'.concat("", assetUrl).concat("", '" alt="Girl in a jacket" width="500" height="600">'))
|
||||||
);
|
// tag_id.innerHTML = "<p>HI</p>"
|
||||||
|
// // tag_id.innerHTML = "<pre>".concat("", ret).concat("", "</pre>");
|
||||||
|
tag_id.innerHTML = assetUrl.concat(" ", ' \n <img src="'.concat("", assetUrl).concat("", '" alt="Girl in a jacket" width="500" height="600">'))
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue