mirror of https://github.com/jlelse/teleposter
Compare commits
23 Commits
Author | SHA1 | Date |
---|---|---|
Jan-Lukas Else | ed27844fa9 | |
Jan-Lukas Else | e99b487218 | |
Jan-Lukas Else | 792bb627c8 | |
Jan-Lukas Else | e47cfe7d38 | |
dependabot[bot] | dda25c44ec | |
dependabot[bot] | 0d80011ac3 | |
dependabot[bot] | 02fb6bb3ae | |
dependabot[bot] | a3343e1f30 | |
Jan-Lukas Else | bf384a8f59 | |
Jan-Lukas Else | 1d00e34219 | |
Jan-Lukas Else | 3946d21e68 | |
dependabot[bot] | 9857315274 | |
dependabot[bot] | cfe2950b34 | |
dependabot[bot] | b989b775b4 | |
dependabot[bot] | 5c6476e99a | |
dependabot[bot] | 35bada0699 | |
dependabot[bot] | cb7f3b7dd1 | |
Jan-Lukas Else | 2957a2f250 | |
Jan-Lukas Else | c93a7ae575 | |
Jan-Lukas Else | b17d8802a5 | |
dependabot[bot] | 7ef293950e | |
dependabot[bot] | 07539e18d7 | |
Licaon_Kter | cb6291be6b |
|
@ -2,15 +2,15 @@ apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 30
|
||||||
buildToolsVersion "28.0.3"
|
buildToolsVersion "30.0.2"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "telegra.ph"
|
applicationId "telegra.ph"
|
||||||
minSdkVersion 17
|
minSdkVersion 19
|
||||||
targetSdkVersion 28
|
targetSdkVersion 30
|
||||||
versionCode 15
|
versionCode 18
|
||||||
versionName "1.5.2"
|
versionName "1.5.5"
|
||||||
resConfigs "en", "de"
|
resConfigs "en", "de", "es", "tr", "ru"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
debug {
|
debug {
|
||||||
|
@ -24,16 +24,19 @@ android {
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lintOptions {
|
||||||
|
abortOnError false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
implementation 'androidx.preference:preference-ktx:1.1.1'
|
||||||
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
implementation 'com.github.delight-im:Android-AdvancedWebView:3.1.3'
|
implementation 'com.github.delight-im:Android-AdvancedWebView:3.2.1'
|
||||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-rc7'
|
implementation 'com.afollestad.material-dialogs:core:3.3.0'
|
||||||
implementation 'com.afollestad.material-dialogs:input:2.0.0-rc7'
|
implementation 'com.afollestad.material-dialogs:input:3.3.0'
|
||||||
implementation 'com.github.kittinunf.fuel:fuel:1.16.0'
|
implementation 'com.github.kittinunf.fuel:fuel:2.3.0'
|
||||||
implementation 'com.github.kittinunf.fuel:fuel-android:1.16.0'
|
implementation 'com.github.kittinunf.fuel:fuel-android:2.3.0'
|
||||||
|
implementation 'com.github.kittinunf.fuel:fuel-json:2.3.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,118 +1,118 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link
|
||||||
|
href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-lite.css"
|
||||||
|
rel="stylesheet"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
max-width: 100% !important;
|
||||||
|
height: auto;
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
<head>
|
#summernote {
|
||||||
<meta charset="utf-8">
|
width: 100%;
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
height: 100%;
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
}
|
||||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-lite.css" rel="stylesheet">
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
max-width: 100% !important;
|
|
||||||
height: auto;
|
|
||||||
word-break: break-all;
|
|
||||||
word-break: break-word;
|
|
||||||
}
|
|
||||||
|
|
||||||
#summernote {
|
.note-editor {
|
||||||
width: 100%;
|
border: none !important;
|
||||||
height: 100%;
|
}
|
||||||
}
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
.note-editor {
|
<body>
|
||||||
border: none !important;
|
<div id="summernote"></div>
|
||||||
}
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||||
</style>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.18/summernote-lite.min.js"></script>
|
||||||
</head>
|
<script>
|
||||||
|
function domToNode(domNode) {
|
||||||
|
if (domNode.nodeType == domNode.TEXT_NODE) {
|
||||||
|
return domNode.data;
|
||||||
|
}
|
||||||
|
if (domNode.nodeType != domNode.ELEMENT_NODE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var nodeElement = {};
|
||||||
|
nodeElement.tag = domNode.tagName.toLowerCase();
|
||||||
|
for (var i = 0; i < domNode.attributes.length; i++) {
|
||||||
|
var attr = domNode.attributes[i];
|
||||||
|
if (attr.name == "href" || attr.name == "src") {
|
||||||
|
if (!nodeElement.attrs) {
|
||||||
|
nodeElement.attrs = {};
|
||||||
|
}
|
||||||
|
nodeElement.attrs[attr.name] = attr.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (domNode.childNodes.length > 0) {
|
||||||
|
nodeElement.children = [];
|
||||||
|
for (var ii = 0; ii < domNode.childNodes.length; ii++) {
|
||||||
|
var child = domNode.childNodes[ii];
|
||||||
|
nodeElement.children.push(domToNode(child));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nodeElement;
|
||||||
|
}
|
||||||
|
|
||||||
<body>
|
function getNodeJson() {
|
||||||
<div id="summernote"></div>
|
window.android.getText(
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
JSON.stringify(
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote-lite.min.js"></script>
|
domToNode(document.getElementsByClassName("note-editable")[0])
|
||||||
<script>
|
.children
|
||||||
function domToNode(domNode) {
|
)
|
||||||
if (domNode.nodeType == domNode.TEXT_NODE) {
|
);
|
||||||
return domNode.data;
|
}
|
||||||
}
|
|
||||||
if (domNode.nodeType != domNode.ELEMENT_NODE) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var nodeElement = {};
|
|
||||||
nodeElement.tag = domNode.tagName.toLowerCase();
|
|
||||||
for (var i = 0; i < domNode.attributes.length; i++) {
|
|
||||||
var attr = domNode.attributes[i];
|
|
||||||
if (attr.name == 'href' || attr.name == 'src') {
|
|
||||||
if (!nodeElement.attrs) {
|
|
||||||
nodeElement.attrs = {};
|
|
||||||
}
|
|
||||||
nodeElement.attrs[attr.name] = attr.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (domNode.childNodes.length > 0) {
|
|
||||||
nodeElement.children = [];
|
|
||||||
for (var ii = 0; ii < domNode.childNodes.length; ii++) {
|
|
||||||
var child = domNode.childNodes[ii];
|
|
||||||
nodeElement.children.push(domToNode(child));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nodeElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getNodeJson() {
|
function uploadImage(file) {
|
||||||
window.android.getText(JSON.stringify(domToNode(document.getElementsByClassName('note-editable')[0]).children));
|
data = new FormData();
|
||||||
}
|
data.append("FileUpload", file);
|
||||||
|
$.ajax({
|
||||||
|
data: data,
|
||||||
|
type: "POST",
|
||||||
|
url: "https://telegra.ph/upload",
|
||||||
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
if (data) {
|
||||||
|
$("#summernote").summernote("insertImage", data[0].src);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function uploadImage(file) {
|
$(document).ready(function() {
|
||||||
data = new FormData();
|
$("#summernote").summernote({
|
||||||
data.append("FileUpload", file);
|
focus: true,
|
||||||
$.ajax({
|
placeholder: "Start writing...",
|
||||||
data: data,
|
styleTags: ["p", "h3", "h4", "blockquote", "pre"],
|
||||||
type: "POST",
|
toolbar: [
|
||||||
url: "https://telegra.ph/upload",
|
["style", ["style", "bold", "italic", "underline", "clear"]],
|
||||||
cache: false,
|
["para", ["ul", "ol"]],
|
||||||
contentType: false,
|
["insert", ["link", "picture", "hr"]],
|
||||||
processData: false,
|
["history", ["undo", "redo"]],
|
||||||
success: function (data) {
|
["other", ["codeview"]]
|
||||||
if (data) {
|
],
|
||||||
$('#summernote').summernote('insertImage', data[0].src);
|
callbacks: {
|
||||||
}
|
onInit: function(e) {
|
||||||
}
|
$("#summernote").summernote("fullscreen.toggle");
|
||||||
});
|
},
|
||||||
}
|
onImageUpload: function(files) {
|
||||||
|
uploadImage(files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
function setContent(content) {
|
||||||
$('#summernote').summernote({
|
$("#summernote").summernote("code", content);
|
||||||
height: 1200,
|
}
|
||||||
focus: true,
|
</script>
|
||||||
placeholder: 'Start writing...',
|
</body>
|
||||||
styleTags: ['p', 'h3', 'h4', 'blockquote', 'pre'],
|
</html>
|
||||||
toolbar: [
|
|
||||||
['style', ['style', 'bold', 'italic', 'underline', 'clear']],
|
|
||||||
['para', ['ul', 'ol']],
|
|
||||||
['insert', ['link', 'picture', 'hr']],
|
|
||||||
['history', ['undo', 'redo']],
|
|
||||||
['other', ['codeview']]
|
|
||||||
],
|
|
||||||
callbacks: {
|
|
||||||
onInit: function (e) {
|
|
||||||
$("#summernote").summernote("fullscreen.toggle");
|
|
||||||
},
|
|
||||||
onImageUpload: function (files) {
|
|
||||||
uploadImage(files[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
function setContent(content) {
|
|
||||||
reset();
|
|
||||||
if (content) $('#summernote').summernote('code', content);
|
|
||||||
}
|
|
||||||
|
|
||||||
function reset() {
|
|
||||||
$('#summernote').summernote('reset');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,58 +1,60 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css"
|
||||||
|
/>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
max-width: 100% !important;
|
||||||
|
height: auto;
|
||||||
|
word-break: break-all;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main role="main" class="container">
|
||||||
|
<div id="viewerTitle" class="mt-3"></div>
|
||||||
|
<div id="viewerAuthor"></div>
|
||||||
|
<div id="viewerViews"></div>
|
||||||
|
<div id="viewerContent"></div>
|
||||||
|
</main>
|
||||||
|
<script>
|
||||||
|
function setTitle(title) {
|
||||||
|
document.getElementById("viewerTitle").innerHTML =
|
||||||
|
"<h1>" + title + "</h1>";
|
||||||
|
}
|
||||||
|
|
||||||
<head>
|
function setAuthor(author, url) {
|
||||||
<meta charset="utf-8">
|
var viewerAuthor = document.getElementById("viewerAuthor");
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
if (author && url && author.length > 0 && url.length > 0)
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
viewerAuthor.innerHTML =
|
||||||
<link rel="stylesheet"
|
'By <a href="' + url + '">' + author + "</a><br>";
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css">
|
else if (author && author.length > 0)
|
||||||
<style>
|
viewerAuthor.innerHTML = "By " + author + "<br>";
|
||||||
* {
|
else if (url && url.length > 0)
|
||||||
max-width: 100% !important;
|
viewerAuthor.innerHTML =
|
||||||
height: auto;
|
'By <a href="' + url + '"><i>Author</i></a><br>';
|
||||||
word-break: break-all;
|
else viewerAuthor.innerHTML = "";
|
||||||
word-break: break-word;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
function setViews(views) {
|
||||||
</head>
|
document.getElementById("viewerViews").innerHTML =
|
||||||
|
views + " times viewed<br><br>";
|
||||||
|
}
|
||||||
|
|
||||||
<body>
|
function setDescription(description) {
|
||||||
<main role="main" class="container">
|
document.getElementById("viewerContent").innerHTML = description;
|
||||||
<div id="viewerTitle" class="mt-3"></div>
|
}
|
||||||
<div id="viewerAuthor"></div>
|
|
||||||
<div id="viewerViews"></div>
|
|
||||||
<div id="viewerContent"></div>
|
|
||||||
</main>
|
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
function setTitle(title) {
|
function setContent(content) {
|
||||||
$('#viewerTitle').html('<h1>' + title + '</h1>');
|
document.getElementById("viewerContent").innerHTML = content;
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
function setAuthor(author, url) {
|
</body>
|
||||||
if (author && url && author.length > 0 && url.length > 0) $('#viewerAuthor').html('By <a href="' + url + '">' + author + '</a><br>');
|
</html>
|
||||||
else if (author && author.length > 0) $('#viewerAuthor').html('By ' + author + '<br>');
|
|
||||||
else if (url && url.length > 0) $('#viewerAuthor').html('By <a href="' + url + '"><i>Author</i></a><br>');
|
|
||||||
else $('#viewerAuthor').html('');
|
|
||||||
}
|
|
||||||
|
|
||||||
function setViews(views) {
|
|
||||||
$('#viewerViews').html(views + ' times viewed<br><br>');
|
|
||||||
}
|
|
||||||
|
|
||||||
function setDescription(description) {
|
|
||||||
$('#viewerContent').html(description);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setContent(content) {
|
|
||||||
$('#viewerContent').html(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -6,23 +6,17 @@ import android.util.AttributeSet
|
||||||
import android.webkit.JavascriptInterface
|
import android.webkit.JavascriptInterface
|
||||||
import im.delight.android.webview.AdvancedWebView
|
import im.delight.android.webview.AdvancedWebView
|
||||||
|
|
||||||
class Editor : AdvancedWebView {
|
class Editor @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
|
) : AdvancedWebView(context, attrs, defStyleAttr) {
|
||||||
private var getCallback: (json: String?) -> Unit? = {}
|
private var getCallback: (json: String?) -> Unit? = {}
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
init {
|
||||||
init()
|
prepare()
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
|
|
||||||
init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled", "AddJavascriptInterface")
|
@SuppressLint("SetJavaScriptEnabled", "AddJavascriptInterface")
|
||||||
private fun init() {
|
fun prepare() {
|
||||||
this.settings.javaScriptEnabled = true
|
this.settings.javaScriptEnabled = true
|
||||||
this.addJavascriptInterface(MyJavaScriptInterface(), "android")
|
this.addJavascriptInterface(MyJavaScriptInterface(), "android")
|
||||||
this.settings.loadWithOverviewMode = true
|
this.settings.loadWithOverviewMode = true
|
||||||
|
@ -33,15 +27,12 @@ class Editor : AdvancedWebView {
|
||||||
|
|
||||||
private inner class MyJavaScriptInterface {
|
private inner class MyJavaScriptInterface {
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
|
@SuppressWarnings("unused")
|
||||||
fun getText(json: String) {
|
fun getText(json: String) {
|
||||||
getCallback(json)
|
getCallback(json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reset() {
|
|
||||||
this.loadUrl("javascript:reset();")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setContent(content: String?) {
|
fun setContent(content: String?) {
|
||||||
this.loadUrl("javascript:setContent('${content?.replace("'", "\\'")}');")
|
this.loadUrl("javascript:setContent('${content?.replace("'", "\\'")}');")
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,17 +15,55 @@ import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||||
import im.delight.android.webview.AdvancedWebView
|
import im.delight.android.webview.AdvancedWebView
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
class MainActivity : AppCompatActivity() {
|
||||||
private val viewer: Viewer? by lazy {
|
private val viewer: Viewer? by lazy {
|
||||||
findViewById<Viewer?>(R.id.viewer)?.apply {
|
findViewById<Viewer?>(R.id.viewer)?.apply {
|
||||||
setListener(this@MainActivity, this@MainActivity)
|
setListener(this@MainActivity, object : AdvancedWebView.Listener {
|
||||||
|
override fun onPageFinished(url: String?) {
|
||||||
|
viewerPendingPage?.let { viewer?.showPage(it) }
|
||||||
|
viewerPendingPage = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDownloadRequested(url: String?, suggestedFilename: String?, mimeType: String?, contentLength: Long, contentDisposition: String?, userAgent: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onExternalPageRequest(url: String?) {
|
||||||
|
AdvancedWebView.Browsers.openUrl(this@MainActivity, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPageStarted(url: String?, favicon: Bitmap?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private var viewerPendingPage: TelegraphApi.Page? = null
|
||||||
private val editor: Editor? by lazy {
|
private val editor: Editor? by lazy {
|
||||||
findViewById<Editor?>(R.id.editor)?.apply {
|
findViewById<Editor?>(R.id.editor)?.apply {
|
||||||
setListener(this@MainActivity, this@MainActivity)
|
setListener(this@MainActivity, object : AdvancedWebView.Listener {
|
||||||
|
override fun onPageFinished(url: String?) {
|
||||||
|
editorPendingPage?.let { editor?.setContent(it.content) }
|
||||||
|
editorPendingPage = null
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDownloadRequested(url: String?, suggestedFilename: String?, mimeType: String?, contentLength: Long, contentDisposition: String?, userAgent: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onExternalPageRequest(url: String?) {
|
||||||
|
AdvancedWebView.Browsers.openUrl(this@MainActivity, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPageStarted(url: String?, favicon: Bitmap?) {
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private var editorPendingPage: TelegraphApi.Page? = null
|
||||||
|
|
||||||
private var currentPage: TelegraphApi.Page? = null
|
private var currentPage: TelegraphApi.Page? = null
|
||||||
private var editorMode = true
|
private var editorMode = true
|
||||||
|
@ -51,34 +89,43 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadEditor(path: String? = null) {
|
override fun onNewIntent(intent: Intent?) {
|
||||||
runOnUiThread {
|
super.onNewIntent(intent)
|
||||||
editorMode = true
|
if (intent?.action == Intent.ACTION_VIEW) {
|
||||||
canEdit = false
|
val uri = URI.create(intent.dataString)
|
||||||
isEdit = false
|
when (uri.host) {
|
||||||
invalidateOptionsMenu()
|
"telegra.ph", "graph.org" -> loadPage(uri.path)
|
||||||
editor?.visibility = View.VISIBLE
|
"edit.telegra.ph", "edit.graph.org" -> login(uri.toString())
|
||||||
viewer?.visibility = View.GONE
|
|
||||||
currentPage = null
|
|
||||||
// Load
|
|
||||||
if (path != null) TelegraphApi.getPage(accessToken, path, true) { success, page, error ->
|
|
||||||
if (success && page != null) {
|
|
||||||
isEdit = true
|
|
||||||
currentPage = page
|
|
||||||
editor?.setContent(page.content)
|
|
||||||
} else {
|
|
||||||
showError(error)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Reset
|
|
||||||
editor?.reset()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun loadEditor(path: String? = null) {
|
||||||
|
editorMode = true
|
||||||
|
canEdit = false
|
||||||
|
isEdit = false
|
||||||
|
invalidateOptionsMenu()
|
||||||
|
editor?.visibility = View.VISIBLE
|
||||||
|
viewer?.visibility = View.GONE
|
||||||
|
currentPage = null
|
||||||
|
// Load
|
||||||
|
if (path != null) TelegraphApi.getPage(accessToken, path, true) { success, page, error ->
|
||||||
|
if (success && page != null) {
|
||||||
|
isEdit = true
|
||||||
|
currentPage = page
|
||||||
|
editorPendingPage = page
|
||||||
|
editor?.prepare()
|
||||||
|
} else {
|
||||||
|
showError(error)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editor?.prepare()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun login(authUrl: String) {
|
private fun login(authUrl: String) {
|
||||||
TelegraphApi.login(authUrl) { success, accessToken, account ->
|
TelegraphApi.login(authUrl) { success, accessToken, account ->
|
||||||
if (success && accessToken != null) {
|
if (success && !accessToken.isNullOrEmpty()) {
|
||||||
this.accessToken = accessToken
|
this.accessToken = accessToken
|
||||||
this.authorName = account?.authorName
|
this.authorName = account?.authorName
|
||||||
showMessage(getString(R.string.success), getString(R.string.login_success))
|
showMessage(getString(R.string.success), getString(R.string.login_success))
|
||||||
|
@ -87,38 +134,22 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadPage(path: String) {
|
private fun loadPage(path: String) {
|
||||||
runOnUiThread {
|
editorMode = false
|
||||||
editorMode = false
|
canEdit = false
|
||||||
canEdit = false
|
invalidateOptionsMenu()
|
||||||
invalidateOptionsMenu()
|
viewer?.visibility = View.VISIBLE
|
||||||
viewer?.visibility = View.VISIBLE
|
editor?.visibility = View.GONE
|
||||||
editor?.visibility = View.GONE
|
currentPage = null
|
||||||
currentPage = null
|
// Load
|
||||||
// Load
|
TelegraphApi.getPage(accessToken, path, true) { success, page, error ->
|
||||||
TelegraphApi.getPage(accessToken, path, true) { success, page, error ->
|
if (success && page != null) {
|
||||||
if (success && page != null) showPage(page)
|
canEdit = page.canEdit ?: false
|
||||||
else showError(error)
|
invalidateOptionsMenu()
|
||||||
}
|
currentPage = page
|
||||||
}
|
viewerPendingPage = page
|
||||||
}
|
viewer?.prepare()
|
||||||
|
|
||||||
private fun showPage(page: TelegraphApi.Page?) {
|
|
||||||
runOnUiThread {
|
|
||||||
editorMode = false
|
|
||||||
canEdit = page?.canEdit ?: false
|
|
||||||
invalidateOptionsMenu()
|
|
||||||
viewer?.visibility = View.VISIBLE
|
|
||||||
editor?.visibility = View.GONE
|
|
||||||
currentPage = page
|
|
||||||
viewer?.clearHistory()
|
|
||||||
// Show
|
|
||||||
page?.let {
|
|
||||||
viewer?.setArticleTitle(it.title)
|
|
||||||
viewer?.setAuthor(it.authorName, it.authorUrl)
|
|
||||||
viewer?.setViews(it.views)
|
|
||||||
if (it.content == null) viewer?.setDescription(it.description)
|
|
||||||
else viewer?.setContent(it.content)
|
|
||||||
}
|
}
|
||||||
|
else showError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,29 +157,11 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
?: getString(R.string.error_desc))
|
?: getString(R.string.error_desc))
|
||||||
|
|
||||||
private fun showMessage(title: String? = null, message: String? = null) {
|
private fun showMessage(title: String? = null, message: String? = null) {
|
||||||
runOnUiThread {
|
MaterialDialog(this@MainActivity)
|
||||||
MaterialDialog(this)
|
.title(text = title ?: "")
|
||||||
.title(text = title ?: "")
|
.message(text = message ?: "")
|
||||||
.message(text = message ?: "")
|
.positiveButton(android.R.string.ok)
|
||||||
.positiveButton(android.R.string.ok)
|
.show()
|
||||||
.show()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageFinished(url: String?) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageStarted(url: String?, favicon: Bitmap?) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onPageError(errorCode: Int, description: String?, failingUrl: String?) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onDownloadRequested(url: String?, suggestedFilename: String?, mimeType: String?, contentLength: Long, contentDisposition: String?, userAgent: String?) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onExternalPageRequest(url: String?) {
|
|
||||||
AdvancedWebView.Browsers.openUrl(this, url)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
@ -186,11 +199,11 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
}
|
}
|
||||||
R.id.publish -> {
|
R.id.publish -> {
|
||||||
editor?.getText { json ->
|
editor?.getText { json ->
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.title_question)
|
.title(R.string.title_question)
|
||||||
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
||||||
?: "", allowEmpty = false) { _, title ->
|
?: "", allowEmpty = false) { _, title ->
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.name_question)
|
.title(R.string.name_question)
|
||||||
.input(hintRes = R.string.name_hint, prefill = if (isEdit) currentPage?.authorName
|
.input(hintRes = R.string.name_hint, prefill = if (isEdit) currentPage?.authorName
|
||||||
?: authorName ?: "" else authorName
|
?: authorName ?: "" else authorName
|
||||||
|
@ -199,11 +212,11 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
if (isEdit) TelegraphApi.editPage(accessToken, currentPage?.path
|
if (isEdit) TelegraphApi.editPage(accessToken, currentPage?.path
|
||||||
?: "", authorName = name.toString(), title = title.toString(), content = json
|
?: "", authorName = name.toString(), title = title.toString(), content = json
|
||||||
?: "", returnContent = true) { success, page, error ->
|
?: "", returnContent = true) { success, page, error ->
|
||||||
if (success && page != null) showPage(page)
|
if (success && page != null) loadPage(page.path)
|
||||||
else showError(error)
|
else showError(error)
|
||||||
} else TelegraphApi.createPage(accessToken, content = json
|
} else TelegraphApi.createPage(accessToken, content = json
|
||||||
?: "", title = title.toString(), authorName = name.toString(), returnContent = true) { success, page, error ->
|
?: "", title = title.toString(), authorName = name.toString(), returnContent = true) { success, page, error ->
|
||||||
if (success && page != null) showPage(page)
|
if (success && page != null) loadPage(page.path)
|
||||||
else showError(error)
|
else showError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +231,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.bookmarks -> {
|
R.id.bookmarks -> {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.bookmarks)
|
.title(R.string.bookmarks)
|
||||||
.positiveButton(R.string.open)
|
.positiveButton(R.string.open)
|
||||||
.negativeButton(android.R.string.cancel)
|
.negativeButton(android.R.string.cancel)
|
||||||
|
@ -229,16 +242,16 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.delete_bookmark -> {
|
R.id.delete_bookmark -> {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.delete_bookmark)
|
.title(R.string.delete_bookmark)
|
||||||
.positiveButton(R.string.delete)
|
.positiveButton(R.string.delete)
|
||||||
.negativeButton(android.R.string.cancel)
|
.negativeButton(android.R.string.cancel)
|
||||||
.listItemsMultiChoice(items = bookmarks().reversed().map { it.second }) { _, indices, _ ->
|
.listItemsMultiChoice(items = bookmarks().reversed().map { it.second }) { _, indices, _ ->
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.delete)
|
.title(R.string.delete)
|
||||||
.message(R.string.delete_question)
|
.message(R.string.delete_question)
|
||||||
.positiveButton(android.R.string.yes)
|
.positiveButton(R.string.yes)
|
||||||
.negativeButton(android.R.string.no)
|
.negativeButton(R.string.no)
|
||||||
.positiveButton {
|
.positiveButton {
|
||||||
val tmpBookmarks = bookmarks().reversed().map { it.first }
|
val tmpBookmarks = bookmarks().reversed().map { it.first }
|
||||||
for (index in indices) deleteBookmark(tmpBookmarks[index])
|
for (index in indices) deleteBookmark(tmpBookmarks[index])
|
||||||
|
@ -251,7 +264,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
R.id.published -> {
|
R.id.published -> {
|
||||||
TelegraphApi.getPageList(accessToken) { success, pageList, error ->
|
TelegraphApi.getPageList(accessToken) { success, pageList, error ->
|
||||||
if (success && pageList != null && pageList.pages != null) {
|
if (success && pageList != null && pageList.pages != null) {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.published)
|
.title(R.string.published)
|
||||||
.positiveButton(R.string.open)
|
.positiveButton(R.string.open)
|
||||||
.negativeButton(android.R.string.cancel)
|
.negativeButton(android.R.string.cancel)
|
||||||
|
@ -264,7 +277,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.bookmark -> {
|
R.id.bookmark -> {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.title_question)
|
.title(R.string.title_question)
|
||||||
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
||||||
?: "", allowEmpty = false) { _, input ->
|
?: "", allowEmpty = false) { _, input ->
|
||||||
|
@ -289,7 +302,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.login -> {
|
R.id.login -> {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this@MainActivity)
|
||||||
.title(R.string.login)
|
.title(R.string.login)
|
||||||
.message(R.string.login_desc)
|
.message(R.string.login_desc)
|
||||||
.positiveButton(android.R.string.ok)
|
.positiveButton(android.R.string.ok)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package telegra.ph
|
package telegra.ph
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
|
||||||
const val listItemSeparator = "+++;+++"
|
const val listItemSeparator = "+++;+++"
|
||||||
const val itemSeparator = "xxx;xxx"
|
const val itemSeparator = "xxx;xxx"
|
||||||
|
@ -30,7 +30,7 @@ fun Context.saveBookmarks(bookmarks: List<Pair<String, String>>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var Context.accessToken: String
|
var Context.accessToken: String
|
||||||
get() = PreferenceManager.getDefaultSharedPreferences(this).getString("accessToken", "")
|
get() = PreferenceManager.getDefaultSharedPreferences(this).getString("accessToken", "") as String
|
||||||
set(value) {
|
set(value) {
|
||||||
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("accessToken", value).apply()
|
PreferenceManager.getDefaultSharedPreferences(this).edit().putString("accessToken", value).apply()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
package telegra.ph
|
package telegra.ph
|
||||||
|
|
||||||
import com.github.kittinunf.fuel.android.core.Json
|
|
||||||
import com.github.kittinunf.fuel.android.extension.responseJson
|
|
||||||
import com.github.kittinunf.fuel.core.FuelError
|
import com.github.kittinunf.fuel.core.FuelError
|
||||||
import com.github.kittinunf.fuel.core.FuelManager
|
import com.github.kittinunf.fuel.core.FuelManager
|
||||||
import com.github.kittinunf.fuel.core.Request
|
import com.github.kittinunf.fuel.core.Request
|
||||||
import com.github.kittinunf.fuel.core.Response
|
import com.github.kittinunf.fuel.core.Response
|
||||||
import com.github.kittinunf.fuel.core.interceptors.redirectResponseInterceptor
|
import com.github.kittinunf.fuel.core.interceptors.redirectResponseInterceptor
|
||||||
import com.github.kittinunf.fuel.core.interceptors.validatorResponseInterceptor
|
|
||||||
import com.github.kittinunf.fuel.httpPost
|
import com.github.kittinunf.fuel.httpPost
|
||||||
|
import com.github.kittinunf.fuel.json.FuelJson
|
||||||
|
import com.github.kittinunf.fuel.json.responseJson
|
||||||
import com.github.kittinunf.result.Result
|
import com.github.kittinunf.result.Result
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
@ -27,12 +26,11 @@ object TelegraphApi {
|
||||||
// Fix login
|
// Fix login
|
||||||
FuelManager.instance.addResponseInterceptor {
|
FuelManager.instance.addResponseInterceptor {
|
||||||
redirectResponseInterceptor(FuelManager.instance)
|
redirectResponseInterceptor(FuelManager.instance)
|
||||||
validatorResponseInterceptor(200..299)
|
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun callService(method: String, parameters: List<Pair<String, Any?>>, handler: (Request, Response, Result<Json, FuelError>) -> Unit) {
|
private fun callService(method: String, parameters: List<Pair<String, Any?>>, handler: (Request, Response, Result<FuelJson, FuelError>) -> Unit) {
|
||||||
val requestObject = JSONObject()
|
val requestObject = JSONObject()
|
||||||
parameters.forEach {
|
parameters.forEach {
|
||||||
requestObject.put(it.first, it.second)
|
requestObject.put(it.first, it.second)
|
||||||
|
@ -153,7 +151,7 @@ object TelegraphApi {
|
||||||
|
|
||||||
// Teleposter
|
// Teleposter
|
||||||
|
|
||||||
private fun <T> handleResponse(result: Result<Json, FuelError>, handler: (success: Boolean, obj: T?, error: String?) -> Unit, callback: (obj: JSONObject) -> Unit) {
|
private fun <T> handleResponse(result: Result<FuelJson, FuelError>, handler: (success: Boolean, obj: T?, error: String?) -> Unit, callback: (obj: JSONObject) -> Unit) {
|
||||||
val (json, error) = result
|
val (json, error) = result
|
||||||
if (error == null && json != null) {
|
if (error == null && json != null) {
|
||||||
val jsonObj = json.obj()
|
val jsonObj = json.obj()
|
||||||
|
@ -182,8 +180,8 @@ object TelegraphApi {
|
||||||
private fun telegraphLoginInterceptor(): (Request, Response) -> Response =
|
private fun telegraphLoginInterceptor(): (Request, Response) -> Response =
|
||||||
{ _, response ->
|
{ _, response ->
|
||||||
response.headers["Set-Cookie"]
|
response.headers["Set-Cookie"]
|
||||||
?.flatMap { HttpCookie.parse(it) }
|
.flatMap { HttpCookie.parse(it) }
|
||||||
?.find { it.name == "tph_token" }
|
.find { it.name == "tph_token" }
|
||||||
?.let {
|
?.let {
|
||||||
loginAccessToken = it.value
|
loginAccessToken = it.value
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,49 +4,53 @@ import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.webkit.JavascriptInterface
|
||||||
import im.delight.android.webview.AdvancedWebView
|
import im.delight.android.webview.AdvancedWebView
|
||||||
|
|
||||||
class Viewer : AdvancedWebView {
|
class Viewer @JvmOverloads constructor(
|
||||||
|
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
|
||||||
|
) : AdvancedWebView(context, attrs, defStyleAttr) {
|
||||||
|
|
||||||
constructor(context: Context) : super(context) {
|
init {
|
||||||
init()
|
prepare()
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
|
|
||||||
init()
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
|
|
||||||
init()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled", "AddJavascriptInterface")
|
@SuppressLint("SetJavaScriptEnabled", "AddJavascriptInterface")
|
||||||
private fun init() {
|
fun prepare() {
|
||||||
this.settings.javaScriptEnabled = true
|
settings.javaScriptEnabled = true
|
||||||
this.settings.loadWithOverviewMode = true
|
settings.loadWithOverviewMode = true
|
||||||
this.settings.useWideViewPort = true
|
settings.useWideViewPort = true
|
||||||
overScrollMode = View.OVER_SCROLL_NEVER
|
overScrollMode = View.OVER_SCROLL_NEVER
|
||||||
setMixedContentAllowed(true)
|
setMixedContentAllowed(true)
|
||||||
this.loadDataWithBaseURL("https://telegra.ph", context.assets.open("viewer.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
loadDataWithBaseURL("https://telegra.ph", context.assets.open("viewer.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setArticleTitle(title: String) {
|
fun showPage(page: TelegraphApi.Page) {
|
||||||
|
clearHistory()
|
||||||
|
setArticleTitle(page.title)
|
||||||
|
setAuthor(page.authorName, page.authorUrl)
|
||||||
|
setViews(page.views)
|
||||||
|
if (page.content == null) setDescription(page.description)
|
||||||
|
else setContent(page.content)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setArticleTitle(title: String) {
|
||||||
this.loadUrl("javascript:setTitle('$title');")
|
this.loadUrl("javascript:setTitle('$title');")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setAuthor(author: String?, url: String?) {
|
private fun setAuthor(author: String?, url: String?) {
|
||||||
this.loadUrl("javascript:setAuthor('$author','$url');")
|
this.loadUrl("javascript:setAuthor('$author','$url');")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setViews(views: Int) {
|
private fun setViews(views: Int) {
|
||||||
this.loadUrl("javascript:setViews('$views');")
|
this.loadUrl("javascript:setViews('$views');")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setDescription(description: String) {
|
private fun setDescription(description: String) {
|
||||||
this.loadUrl("javascript:setDescription('${description.replace("\n", "<br>")}');")
|
this.loadUrl("javascript:setDescription('${description.replace("\n", "<br>")}');")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setContent(content: String?) {
|
private fun setContent(content: String?) {
|
||||||
this.loadUrl("javascript:setContent('${content?.replace("'", "\\'")}');")
|
this.loadUrl("javascript:setContent('${content?.replace("'", "\\'")}');")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Teleposter</string>
|
<string name="app_name">Teleposter</string>
|
||||||
|
<string name="yes">Ja</string>
|
||||||
|
<string name="no">Nein</string>
|
||||||
<string name="share">Teilen</string>
|
<string name="share">Teilen</string>
|
||||||
<string name="about">Über</string>
|
<string name="about">Über</string>
|
||||||
<string name="bookmarks">Lesezeichen</string>
|
<string name="bookmarks">Lesezeichen</string>
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Teleposter</string>
|
||||||
|
<string name="yes">Sí</string>
|
||||||
|
<string name="no">No</string>
|
||||||
|
<string name="share">Compartir</string>
|
||||||
|
<string name="about">Acerca de</string>
|
||||||
|
<string name="bookmarks">Favoritos</string>
|
||||||
|
<string name="bookmark_this">Añadir a favoritos</string>
|
||||||
|
<string name="delete_bookmark">Borrar favorito</string>
|
||||||
|
<string name="create">Nueva</string>
|
||||||
|
<string name="title_question">¿Título?</string>
|
||||||
|
<string name="title_hint">Entrada increíble #1</string>
|
||||||
|
<string name="delete">Borrar</string>
|
||||||
|
<string name="delete_question">¿Realmente quiere eliminar esto?</string>
|
||||||
|
<string name="publish">Publicar</string>
|
||||||
|
<string name="edit">Editar</string>
|
||||||
|
<string name="try_edit">Prueba a editar.</string>
|
||||||
|
<string name="error">Error</string>
|
||||||
|
<string name="error_desc">¡Pasó algo inesperado!</string>
|
||||||
|
<string name="published">Entradas publicadas</string>
|
||||||
|
<string name="name_question">¿Su nombre?</string>
|
||||||
|
<string name="name_hint">Awesome Writer</string>
|
||||||
|
<string name="login_failed">Login fallido. ¡Inténtelo de nuevo!</string>
|
||||||
|
<string name="success">Hecho</string>
|
||||||
|
<string name="login_success">¡Login realizado correctamente!</string>
|
||||||
|
<string name="login">Login</string>
|
||||||
|
<string name="login_desc">Abre el bot de Telegraph en Telegram, elija \"Login as * on this device\" y seleccione Teleposter.</string>
|
||||||
|
<string name="open">Abrir</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Teleposter</string>
|
||||||
|
<string name="yes">да</string>
|
||||||
|
<string name="no">Нет</string>
|
||||||
|
<string name="share">Поделиться</string>
|
||||||
|
<string name="about">Информация</string>
|
||||||
|
<string name="bookmarks">Закладки</string>
|
||||||
|
<string name="bookmark_this">Добавить в закладки</string>
|
||||||
|
<string name="delete_bookmark">Удалить закладку</string>
|
||||||
|
<string name="create">Новый</string>
|
||||||
|
<string name="title_question">Заглавие?</string>
|
||||||
|
<string name="title_hint">Крутой пост #1</string>
|
||||||
|
<string name="delete">Удалить</string>
|
||||||
|
<string name="delete_question">Вы действительно хотите удалить это?</string>
|
||||||
|
<string name="publish">Публикация</string>
|
||||||
|
<string name="edit">Изменить</string>
|
||||||
|
<string name="try_edit">Повторить изменение</string>
|
||||||
|
<string name="error">Ошибка</string>
|
||||||
|
<string name="error_desc">Случилось что-то неожиданное!</string>
|
||||||
|
<string name="published">Опубликованные посты</string>
|
||||||
|
<string name="name_question">Ваше имя?</string>
|
||||||
|
<string name="name_hint">Крутой писатель</string>
|
||||||
|
<string name="login_failed">Неудачный вход. Попробуй еще раз!</string>
|
||||||
|
<string name="success">Готово</string>
|
||||||
|
<string name="login_success">Вы успешно вошли!</string>
|
||||||
|
<string name="login">Вход</string>
|
||||||
|
<string name="login_desc">Откройте Telegraph bot в Telegram, выберите \"Login as * on this device\" и выберите Teleposter.</string>
|
||||||
|
<string name="open">Открыть</string>
|
||||||
|
</resources>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<resources>
|
||||||
|
<string name="app_name">Teleposter</string>
|
||||||
|
<string name="yes">Evet</string>
|
||||||
|
<string name="no">Hayır</string>
|
||||||
|
<string name="share">Paylaş</string>
|
||||||
|
<string name="about">Hakkında</string>
|
||||||
|
<string name="bookmarks">Yer imleri</string>
|
||||||
|
<string name="bookmark_this">Buna yer işareti koy</string>
|
||||||
|
<string name="delete_bookmark">Yer işaretini sil</string>
|
||||||
|
<string name="create">Yeni</string>
|
||||||
|
<string name="title_question">Başlık?</string>
|
||||||
|
<string name="title_hint">Harika mesaj #1</string>
|
||||||
|
<string name="delete">Sil</string>
|
||||||
|
<string name="delete_question">Bunu gerçekten silmek istiyor musun?</string>
|
||||||
|
<string name="publish">Yayınla</string>
|
||||||
|
<string name="edit">Düzenle</string>
|
||||||
|
<string name="try_edit">Düzenlemeye çalış</string>
|
||||||
|
<string name="error">Hata</string>
|
||||||
|
<string name="error_desc">Beklenmedik bir şey oldu!</string>
|
||||||
|
<string name="published">Mesaj yayınlandı</string>
|
||||||
|
<string name="name_question">Adınız?</string>
|
||||||
|
<string name="name_hint">Süper yazar</string>
|
||||||
|
<string name="login_failed">Giriş başarısız. Tekrar deneyin!</string>
|
||||||
|
<string name="success">Başarılı</string>
|
||||||
|
<string name="login_success">Başarıyla giriş yaptınız!</string>
|
||||||
|
<string name="login">Giriş</string>
|
||||||
|
<string name="login_desc">Telegram\'da Telegraph botunu açın, \"Login as * on this device\" seçeneğini ve Teleposter\'ı seçin.</string>
|
||||||
|
<string name="open">Aç</string>
|
||||||
|
</resources>
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="colorPrimary">#fafafa</color>
|
<color name="primaryColor">#fafafa</color>
|
||||||
<color name="colorPrimaryDark">#c7c7c7</color>
|
<color name="primaryDarkColor">#c7c7c7</color>
|
||||||
<color name="colorAccent">#212121</color>
|
<color name="primaryTextColor">#000000</color>
|
||||||
</resources>
|
</resources>
|
|
@ -1,5 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Teleposter</string>
|
<string name="app_name">Teleposter</string>
|
||||||
|
<string name="yes">Yes</string>
|
||||||
|
<string name="no">No</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
<string name="about">About</string>
|
<string name="about">About</string>
|
||||||
<string name="bookmarks">Bookmarks</string>
|
<string name="bookmarks">Bookmarks</string>
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<resources>
|
<resources>
|
||||||
|
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light">
|
<style name="AppTheme" parent="Theme.AppCompat.Light">
|
||||||
<item name="colorPrimary">@color/colorPrimary</item>
|
<item name="colorPrimary">@color/primaryColor</item>
|
||||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
<item name="colorPrimaryDark">@color/primaryDarkColor</item>
|
||||||
<item name="colorAccent">@color/colorAccent</item>
|
<item name="android:textColorPrimary">@color/primaryTextColor</item>
|
||||||
<item name="android:colorBackground">@android:color/white</item>
|
<item name="md_color_button_text">@color/primaryTextColor</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.11'
|
ext.kotlin_version = '1.4.10'
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.0'
|
classpath 'com.android.tools.build:gradle:4.1.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.github.ben-manes.versions' version '0.20.0'
|
id 'com.github.ben-manes.versions' version '0.33.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
|
@ -21,6 +21,5 @@ allprojects {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
|
@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
@ -66,6 +82,7 @@ esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
@ -109,10 +126,11 @@ if $darwin; then
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# For Cygwin, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if $cygwin ; then
|
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
# We build the pattern for arguments to be converted via cygpath
|
||||||
|
@ -138,19 +156,19 @@ if $cygwin ; then
|
||||||
else
|
else
|
||||||
eval `echo args$i`="\"$arg\""
|
eval `echo args$i`="\"$arg\""
|
||||||
fi
|
fi
|
||||||
i=$((i+1))
|
i=`expr $i + 1`
|
||||||
done
|
done
|
||||||
case $i in
|
case $i in
|
||||||
(0) set -- ;;
|
0) set -- ;;
|
||||||
(1) set -- "$args0" ;;
|
1) set -- "$args0" ;;
|
||||||
(2) set -- "$args0" "$args1" ;;
|
2) set -- "$args0" "$args1" ;;
|
||||||
(3) set -- "$args0" "$args1" "$args2" ;;
|
3) set -- "$args0" "$args1" "$args2" ;;
|
||||||
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
||||||
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
||||||
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
||||||
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
||||||
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
||||||
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -159,14 +177,9 @@ save () {
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||||
echo " "
|
echo " "
|
||||||
}
|
}
|
||||||
APP_ARGS=$(save "$@")
|
APP_ARGS=`save "$@"`
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||||
|
|
||||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
|
||||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
|
||||||
cd "$(dirname "$0")"
|
|
||||||
fi
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|
|
@ -1,3 +1,19 @@
|
||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
|
@ -13,15 +29,18 @@ if "%DIRNAME%" == "" set DIRNAME=.
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m"
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto init
|
if "%ERRORLEVEL%" == "0" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
@ -35,7 +54,7 @@ goto fail
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto init
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
@ -45,28 +64,14 @@ echo location of your Java installation.
|
||||||
|
|
||||||
goto fail
|
goto fail
|
||||||
|
|
||||||
:init
|
|
||||||
@rem Get command-line arguments, handling Windows variants
|
|
||||||
|
|
||||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
|
||||||
|
|
||||||
:win9xME_args
|
|
||||||
@rem Slurp the command line arguments.
|
|
||||||
set CMD_LINE_ARGS=
|
|
||||||
set _SKIP=2
|
|
||||||
|
|
||||||
:win9xME_args_slurp
|
|
||||||
if "x%~1" == "x" goto execute
|
|
||||||
|
|
||||||
set CMD_LINE_ARGS=%*
|
|
||||||
|
|
||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
|
Loading…
Reference in New Issue