This commit is contained in:
Jan-Lukas Else 2019-01-23 17:36:46 +01:00
parent 207ef7fdf0
commit 57140d34e2
15 changed files with 43 additions and 45 deletions

View File

@ -3,13 +3,13 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
buildToolsVersion "28.0.3"
defaultConfig {
applicationId "telegra.ph"
minSdkVersion 17
targetSdkVersion 28
versionCode 14
versionName "1.5.1"
versionCode 15
versionName "1.5.2"
resConfigs "en", "de"
}
buildTypes {
@ -27,13 +27,13 @@ android {
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.github.delight-im:Android-AdvancedWebView:v3.1.3'
implementation 'com.afollestad.material-dialogs:core:2.0.0-alpha11'
implementation 'com.afollestad.material-dialogs:input:2.0.0-alpha11'
implementation 'com.github.kittinunf.fuel:fuel:1.15.0'
implementation 'com.github.kittinunf.fuel:fuel-android:1.15.0'
implementation 'com.github.delight-im:Android-AdvancedWebView:3.1.3'
implementation 'com.afollestad.material-dialogs:core:2.0.0-rc7'
implementation 'com.afollestad.material-dialogs:input:2.0.0-rc7'
implementation 'com.github.kittinunf.fuel:fuel:1.16.0'
implementation 'com.github.kittinunf.fuel:fuel-android:1.16.0'
}

View File

@ -5,7 +5,7 @@
<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="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>
* {
max-width: 100% !important;
@ -27,8 +27,8 @@
<body>
<div id="summernote"></div>
<script src="http://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/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote-lite.min.js"></script>
<script>
function domToNode(domNode) {
if (domNode.nodeType == domNode.TEXT_NODE) {
@ -68,7 +68,7 @@
$.ajax({
data: data,
type: "POST",
url: "http://telegra.ph/upload",
url: "https://telegra.ph/upload",
cache: false,
contentType: false,
processData: false,

View File

@ -6,7 +6,7 @@
<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.1.3/css/bootstrap.min.css">
href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.2.1/css/bootstrap.min.css">
<style>
* {
max-width: 100% !important;
@ -25,7 +25,7 @@
<div id="viewerViews"></div>
<div id="viewerContent"></div>
</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>
function setTitle(title) {

View File

@ -27,7 +27,8 @@ class Editor : AdvancedWebView {
this.addJavascriptInterface(MyJavaScriptInterface(), "android")
this.settings.loadWithOverviewMode = 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 {

View File

@ -4,12 +4,13 @@ import android.content.Intent
import android.graphics.Bitmap
import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import android.view.Menu
import android.view.MenuItem
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import im.delight.android.webview.AdvancedWebView
import java.net.URI
@ -188,12 +189,12 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
MaterialDialog(this)
.title(R.string.title_question)
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
?: "") { _, title ->
?: "", allowEmpty = false) { _, title ->
MaterialDialog(this)
.title(R.string.name_question)
.input(hintRes = R.string.name_hint, prefill = if (isEdit) currentPage?.authorName
?: authorName ?: "" else authorName
?: "") { _, name ->
?: "", allowEmpty = true) { _, name ->
if (!isEdit) authorName = name.toString()
if (isEdit) TelegraphApi.editPage(accessToken, currentPage?.path
?: "", authorName = name.toString(), title = title.toString(), content = json
@ -232,14 +233,15 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
.title(R.string.delete_bookmark)
.positiveButton(R.string.delete)
.negativeButton(android.R.string.cancel)
.listItemsSingleChoice(items = bookmarks().reversed().map { it.second }) { _, index, _ ->
.listItemsMultiChoice(items = bookmarks().reversed().map { it.second }) { _, indices, _ ->
MaterialDialog(this)
.title(R.string.delete)
.message(R.string.delete_question)
.positiveButton(android.R.string.yes)
.negativeButton(android.R.string.no)
.positiveButton { _ ->
deleteBookmark(bookmarks().reversed().map { it.first }[index])
.positiveButton {
val tmpBookmarks = bookmarks().reversed().map { it.first }
for (index in indices) deleteBookmark(tmpBookmarks[index])
}
.show()
}
@ -265,7 +267,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
MaterialDialog(this)
.title(R.string.title_question)
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
?: "") { _, input ->
?: "", allowEmpty = false) { _, input ->
val curPage = currentPage
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)))
true
}
R.id.help -> {
MaterialDialog(this)
.title(R.string.help)
.message(R.string.help_text)
.positiveButton(android.R.string.ok)
.show()
R.id.about -> {
val aboutIntent = Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/jlelse/teleposter"))
startActivity(aboutIntent)
true
}
R.id.login -> {
@ -294,7 +293,7 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
.title(R.string.login)
.message(R.string.login_desc)
.positiveButton(android.R.string.ok)
.positiveButton { _ ->
.positiveButton {
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/telegraph")))
}
.show()

View File

@ -1,6 +1,5 @@
package telegra.ph
import com.github.kittinunf.fuel.Fuel
import com.github.kittinunf.fuel.android.core.Json
import com.github.kittinunf.fuel.android.extension.responseJson
import com.github.kittinunf.fuel.core.FuelError
@ -140,6 +139,9 @@ object TelegraphApi {
if (optJSONObject(i) == null) optString(i)?.let {
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
}

View File

@ -27,7 +27,7 @@ class Viewer : AdvancedWebView {
this.settings.useWideViewPort = true
overScrollMode = View.OVER_SCROLL_NEVER
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) {

View File

@ -42,7 +42,7 @@
android:title="@string/login"
app:showAsAction="never" />
<item
android:id="@+id/help"
android:title="@string/help"
android:id="@+id/about"
android:title="@string/about"
app:showAsAction="never" />
</menu>

View File

@ -1,9 +1,7 @@
<resources>
<string name="app_name">Teleposter</string>
<string name="share">Teilen</string>
<string name="help">Hilfe</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="about">Über</string>
<string name="bookmarks">Lesezeichen</string>
<string name="bookmark_this">Als Lesezeichen setzen</string>
<string name="delete_bookmark">Lesezeichen löschen</string>

View File

@ -1,9 +1,7 @@
<resources>
<string name="app_name">Teleposter</string>
<string name="share">Share</string>
<string name="help">Help</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="about">About</string>
<string name="bookmarks">Bookmarks</string>
<string name="bookmark_this">Bookmark this</string>
<string name="delete_bookmark">Delete Bookmark</string>

View File

@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.2.70'
ext.kotlin_version = '1.3.11'
repositories {
jcenter()
mavenCentral()
google()
}
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"
}
}

Binary file not shown.

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
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
zipStorePath=wrapper/dists

2
gradlew vendored
View File

@ -28,7 +28,7 @@ APP_NAME="Gradle"
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.
DEFAULT_JVM_OPTS=""
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

2
gradlew.bat vendored
View File

@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
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.
set DEFAULT_JVM_OPTS=
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome