mirror of https://github.com/jlelse/teleposter
1.5.2
This commit is contained in:
parent
207ef7fdf0
commit
57140d34e2
|
@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
buildToolsVersion "28.0.2"
|
buildToolsVersion "28.0.3"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "telegra.ph"
|
applicationId "telegra.ph"
|
||||||
minSdkVersion 17
|
minSdkVersion 17
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 14
|
versionCode 15
|
||||||
versionName "1.5.1"
|
versionName "1.5.2"
|
||||||
resConfigs "en", "de"
|
resConfigs "en", "de"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -27,13 +27,13 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'androidx.appcompat:appcompat:1.0.0'
|
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
implementation 'androidx.recyclerview:recyclerview:1.0.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
|
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:v3.1.3'
|
implementation 'com.github.delight-im:Android-AdvancedWebView:3.1.3'
|
||||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-alpha11'
|
implementation 'com.afollestad.material-dialogs:core:2.0.0-rc7'
|
||||||
implementation 'com.afollestad.material-dialogs:input:2.0.0-alpha11'
|
implementation 'com.afollestad.material-dialogs:input:2.0.0-rc7'
|
||||||
implementation 'com.github.kittinunf.fuel:fuel:1.15.0'
|
implementation 'com.github.kittinunf.fuel:fuel:1.16.0'
|
||||||
implementation 'com.github.kittinunf.fuel:fuel-android:1.15.0'
|
implementation 'com.github.kittinunf.fuel:fuel-android:1.16.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.10/summernote-lite.css" rel="stylesheet">
|
<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.11/summernote-lite.css" rel="stylesheet">
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
max-width: 100% !important;
|
max-width: 100% !important;
|
||||||
|
@ -27,8 +27,8 @@
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="summernote"></div>
|
<div id="summernote"></div>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote-lite.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote-lite.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function domToNode(domNode) {
|
function domToNode(domNode) {
|
||||||
if (domNode.nodeType == domNode.TEXT_NODE) {
|
if (domNode.nodeType == domNode.TEXT_NODE) {
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: data,
|
data: data,
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "http://telegra.ph/upload",
|
url: "https://telegra.ph/upload",
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
processData: false,
|
processData: false,
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css">
|
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css">
|
||||||
<style>
|
<style>
|
||||||
* {
|
* {
|
||||||
max-width: 100% !important;
|
max-width: 100% !important;
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
<div id="viewerViews"></div>
|
<div id="viewerViews"></div>
|
||||||
<div id="viewerContent"></div>
|
<div id="viewerContent"></div>
|
||||||
</main>
|
</main>
|
||||||
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
function setTitle(title) {
|
function setTitle(title) {
|
||||||
|
|
|
@ -27,7 +27,8 @@ class Editor : AdvancedWebView {
|
||||||
this.addJavascriptInterface(MyJavaScriptInterface(), "android")
|
this.addJavascriptInterface(MyJavaScriptInterface(), "android")
|
||||||
this.settings.loadWithOverviewMode = true
|
this.settings.loadWithOverviewMode = true
|
||||||
this.settings.useWideViewPort = true
|
this.settings.useWideViewPort = true
|
||||||
this.loadDataWithBaseURL("http://telegra.ph", context.assets.open("editor.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
setMixedContentAllowed(true)
|
||||||
|
this.loadDataWithBaseURL("https://telegra.ph", context.assets.open("editor.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class MyJavaScriptInterface {
|
private inner class MyJavaScriptInterface {
|
||||||
|
|
|
@ -4,12 +4,13 @@ import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
import com.afollestad.materialdialogs.input.input
|
import com.afollestad.materialdialogs.input.input
|
||||||
|
import com.afollestad.materialdialogs.list.listItemsMultiChoice
|
||||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
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
|
||||||
|
@ -188,12 +189,12 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this)
|
||||||
.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
|
||||||
?: "") { _, title ->
|
?: "", allowEmpty = false) { _, title ->
|
||||||
MaterialDialog(this)
|
MaterialDialog(this)
|
||||||
.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
|
||||||
?: "") { _, name ->
|
?: "", allowEmpty = true) { _, name ->
|
||||||
if (!isEdit) authorName = name.toString()
|
if (!isEdit) authorName = name.toString()
|
||||||
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
|
||||||
|
@ -232,14 +233,15 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
.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)
|
||||||
.listItemsSingleChoice(items = bookmarks().reversed().map { it.second }) { _, index, _ ->
|
.listItemsMultiChoice(items = bookmarks().reversed().map { it.second }) { _, indices, _ ->
|
||||||
MaterialDialog(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.delete)
|
.title(R.string.delete)
|
||||||
.message(R.string.delete_question)
|
.message(R.string.delete_question)
|
||||||
.positiveButton(android.R.string.yes)
|
.positiveButton(android.R.string.yes)
|
||||||
.negativeButton(android.R.string.no)
|
.negativeButton(android.R.string.no)
|
||||||
.positiveButton { _ ->
|
.positiveButton {
|
||||||
deleteBookmark(bookmarks().reversed().map { it.first }[index])
|
val tmpBookmarks = bookmarks().reversed().map { it.first }
|
||||||
|
for (index in indices) deleteBookmark(tmpBookmarks[index])
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
|
@ -265,7 +267,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
MaterialDialog(this)
|
MaterialDialog(this)
|
||||||
.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
|
||||||
?: "") { _, input ->
|
?: "", allowEmpty = false) { _, input ->
|
||||||
val curPage = currentPage
|
val curPage = currentPage
|
||||||
if (curPage?.url != null) addBookmark(curPage.url.split("/").last(), input.toString())
|
if (curPage?.url != null) addBookmark(curPage.url.split("/").last(), input.toString())
|
||||||
}
|
}
|
||||||
|
@ -281,12 +283,9 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)))
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)))
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.help -> {
|
R.id.about -> {
|
||||||
MaterialDialog(this)
|
val aboutIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jlelse/teleposter"))
|
||||||
.title(R.string.help)
|
startActivity(aboutIntent)
|
||||||
.message(R.string.help_text)
|
|
||||||
.positiveButton(android.R.string.ok)
|
|
||||||
.show()
|
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.login -> {
|
R.id.login -> {
|
||||||
|
@ -294,7 +293,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
.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)
|
||||||
.positiveButton { _ ->
|
.positiveButton {
|
||||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/telegraph")))
|
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/telegraph")))
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package telegra.ph
|
package telegra.ph
|
||||||
|
|
||||||
import com.github.kittinunf.fuel.Fuel
|
|
||||||
import com.github.kittinunf.fuel.android.core.Json
|
import com.github.kittinunf.fuel.android.core.Json
|
||||||
import com.github.kittinunf.fuel.android.extension.responseJson
|
import com.github.kittinunf.fuel.android.extension.responseJson
|
||||||
import com.github.kittinunf.fuel.core.FuelError
|
import com.github.kittinunf.fuel.core.FuelError
|
||||||
|
@ -140,6 +139,9 @@ object TelegraphApi {
|
||||||
if (optJSONObject(i) == null) optString(i)?.let {
|
if (optJSONObject(i) == null) optString(i)?.let {
|
||||||
content += it
|
content += it
|
||||||
}
|
}
|
||||||
|
// Fix mixed content
|
||||||
|
content = content.replace("http://telegra.ph", "https://telegra.ph")
|
||||||
|
content = content.replace("http://graph.org", "https://graph.org")
|
||||||
}
|
}
|
||||||
return content
|
return content
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Viewer : AdvancedWebView {
|
||||||
this.settings.useWideViewPort = true
|
this.settings.useWideViewPort = true
|
||||||
overScrollMode = View.OVER_SCROLL_NEVER
|
overScrollMode = View.OVER_SCROLL_NEVER
|
||||||
setMixedContentAllowed(true)
|
setMixedContentAllowed(true)
|
||||||
this.loadDataWithBaseURL("http://telegra.ph", context.assets.open("viewer.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
this.loadDataWithBaseURL("https://telegra.ph", context.assets.open("viewer.html").bufferedReader().readText(), "text/html", "utf-8", null)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setArticleTitle(title: String) {
|
fun setArticleTitle(title: String) {
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
android:title="@string/login"
|
android:title="@string/login"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/help"
|
android:id="@+id/about"
|
||||||
android:title="@string/help"
|
android:title="@string/about"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
|
@ -1,9 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Teleposter</string>
|
<string name="app_name">Teleposter</string>
|
||||||
<string name="share">Teilen</string>
|
<string name="share">Teilen</string>
|
||||||
<string name="help">Hilfe</string>
|
<string name="about">Über</string>
|
||||||
<string name="help_text">
|
|
||||||
<![CDATA[<h3>Verwendete Bibliotheken</h3><a href=\"https://github.com/afollestad/material-dialogs\">Material Dialogs</a>, <a href=\"https://github.com/kittinunf/Fuel\">Fuel</a>, <a href=\"https://github.com/delight-im/Android-AdvancedWebView\">AdvancedWebView</a><h3>About</h3>Diese App wurde von <a href="https://jlelse.me">Jan-Lukas Else</a> entwickelt und der Code bei <a href="https://github.com/jlelse/teleposter">Github</a> veröffentlicht.]]></string>
|
|
||||||
<string name="bookmarks">Lesezeichen</string>
|
<string name="bookmarks">Lesezeichen</string>
|
||||||
<string name="bookmark_this">Als Lesezeichen setzen</string>
|
<string name="bookmark_this">Als Lesezeichen setzen</string>
|
||||||
<string name="delete_bookmark">Lesezeichen löschen</string>
|
<string name="delete_bookmark">Lesezeichen löschen</string>
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Teleposter</string>
|
<string name="app_name">Teleposter</string>
|
||||||
<string name="share">Share</string>
|
<string name="share">Share</string>
|
||||||
<string name="help">Help</string>
|
<string name="about">About</string>
|
||||||
<string name="help_text">
|
|
||||||
<![CDATA[<h3>Used libraries</h3><a href=\"https://github.com/afollestad/material-dialogs\">Material Dialogs</a>, <a href=\"https://github.com/kittinunf/Fuel\">Fuel</a>, <a href=\"https://github.com/delight-im/Android-AdvancedWebView\">AdvancedWebView</a><h3>About</h3>This app is made by <a href="https://jlelse.me">Jan-Lukas Else</a> and it\'s code is published on <a href="https://github.com/jlelse/teleposter">Github</a>.]]></string>
|
|
||||||
<string name="bookmarks">Bookmarks</string>
|
<string name="bookmarks">Bookmarks</string>
|
||||||
<string name="bookmark_this">Bookmark this</string>
|
<string name="bookmark_this">Bookmark this</string>
|
||||||
<string name="delete_bookmark">Delete Bookmark</string>
|
<string name="delete_bookmark">Delete Bookmark</string>
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.70'
|
ext.kotlin_version = '1.3.11'
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.0-alpha11'
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
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-4.10.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -28,7 +28,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=""
|
DEFAULT_JVM_OPTS='"-Xmx64m"'
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
|
@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@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=
|
set DEFAULT_JVM_OPTS="-Xmx64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
Loading…
Reference in New Issue