mirror of https://github.com/jlelse/teleposter
Dependency upgrades, basic bug fixing and min API bump
This commit is contained in:
parent
041137004c
commit
0ec5066b18
|
@ -2,12 +2,12 @@ apply plugin: 'com.android.application'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 28
|
||||||
buildToolsVersion "28.0.1"
|
buildToolsVersion "28.0.2"
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "telegra.ph"
|
applicationId "telegra.ph"
|
||||||
minSdkVersion 15
|
minSdkVersion 17
|
||||||
targetSdkVersion 27
|
targetSdkVersion 28
|
||||||
versionCode 14
|
versionCode 14
|
||||||
versionName "1.5.1"
|
versionName "1.5.1"
|
||||||
resConfigs "en"
|
resConfigs "en"
|
||||||
|
@ -27,11 +27,13 @@ android {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
|
||||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
|
||||||
implementation 'com.android.support:support-v13:27.1.1'
|
implementation 'com.android.support:support-v13:28.0.0-rc02'
|
||||||
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:v3.1.3'
|
||||||
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
|
implementation 'com.afollestad.material-dialogs:core:2.0.0-alpha09'
|
||||||
implementation 'com.github.kittinunf.fuel:fuel-android:1.14.0'
|
implementation 'com.afollestad.material-dialogs:input:2.0.0-alpha09'
|
||||||
|
implementation 'com.github.kittinunf.fuel:fuel:1.15.0'
|
||||||
|
implementation 'com.github.kittinunf.fuel:fuel-android:1.15.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import com.afollestad.materialdialogs.input.input
|
||||||
|
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
|
||||||
|
|
||||||
|
@ -124,10 +126,10 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
|
|
||||||
private fun showMessage(title: String? = null, message: String? = null) {
|
private fun showMessage(title: String? = null, message: String? = null) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(title ?: "")
|
.title(text = title ?: "")
|
||||||
.content(message ?: "")
|
.message(text = message ?: "")
|
||||||
.positiveText(android.R.string.ok)
|
.positiveButton(android.R.string.ok)
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,15 +185,15 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
}
|
}
|
||||||
R.id.publish -> {
|
R.id.publish -> {
|
||||||
editor?.getText { json ->
|
editor?.getText { json ->
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.title_question)
|
.title(R.string.title_question)
|
||||||
.input(getString(R.string.title_hint), currentPage?.title
|
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
||||||
?: "", { _, title ->
|
?: "") { _, title ->
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.name_question)
|
.title(R.string.name_question)
|
||||||
.input(getString(R.string.name_hint), if (isEdit) currentPage?.authorName
|
.input(hintRes = R.string.name_hint, prefill = if (isEdit) currentPage?.authorName
|
||||||
?: authorName ?: "" else authorName
|
?: authorName ?: "" else authorName
|
||||||
?: "", { _, name ->
|
?: "") { _, 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
|
||||||
|
@ -203,9 +205,9 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
if (success && page != null) showPage(page)
|
if (success && page != null) showPage(page)
|
||||||
else showError(error)
|
else showError(error)
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.show()
|
.show()
|
||||||
})
|
}
|
||||||
.show()
|
.show()
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
@ -215,24 +217,31 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.bookmarks -> {
|
R.id.bookmarks -> {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.bookmarks)
|
.title(R.string.bookmarks)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveButton(R.string.open)
|
||||||
.items(bookmarks().reversed().map { it.second })
|
.negativeButton(android.R.string.cancel)
|
||||||
.itemsCallback { _, _, i, _ ->
|
.listItemsSingleChoice(items = bookmarks().reversed().map { it.second }) { _, index, _ ->
|
||||||
loadPage(bookmarks().reversed().map { it.first }[i])
|
loadPage(bookmarks().reversed().map { it.first }[index])
|
||||||
}
|
}
|
||||||
.itemsLongCallback { _, _, i, _ ->
|
.show()
|
||||||
MaterialDialog.Builder(this)
|
true
|
||||||
|
}
|
||||||
|
R.id.delete_bookmark -> {
|
||||||
|
MaterialDialog(this)
|
||||||
|
.title(R.string.delete_bookmark)
|
||||||
|
.positiveButton(R.string.delete)
|
||||||
|
.negativeButton(android.R.string.cancel)
|
||||||
|
.listItemsSingleChoice(items = bookmarks().reversed().map { it.second }) { _, index, _ ->
|
||||||
|
MaterialDialog(this)
|
||||||
.title(R.string.delete)
|
.title(R.string.delete)
|
||||||
.content(R.string.delete_question)
|
.message(R.string.delete_question)
|
||||||
.positiveText(android.R.string.yes)
|
.positiveButton(android.R.string.yes)
|
||||||
.negativeText(android.R.string.no)
|
.negativeButton(android.R.string.no)
|
||||||
.onPositive { _, _ ->
|
.positiveButton { _ ->
|
||||||
deleteBookmark(bookmarks().reversed().map { it.first }[i])
|
deleteBookmark(bookmarks().reversed().map { it.first }[index])
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
true
|
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
true
|
true
|
||||||
|
@ -240,11 +249,11 @@ 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.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.published)
|
.title(R.string.published)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveButton(R.string.open)
|
||||||
.items(pageList.pages.map { it.title })
|
.negativeButton(android.R.string.cancel)
|
||||||
.itemsCallback { _, _, i, _ ->
|
.listItemsSingleChoice(items = pageList.pages.map { it.title }) { _, i, _ ->
|
||||||
loadPage(pageList.pages[i].path)
|
loadPage(pageList.pages[i].path)
|
||||||
}
|
}
|
||||||
.show()
|
.show()
|
||||||
|
@ -253,12 +262,13 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.bookmark -> {
|
R.id.bookmark -> {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.title_question)
|
.title(R.string.title_question)
|
||||||
.input(getString(R.string.title_hint), "", { _, input ->
|
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
||||||
|
?: "") { _, 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())
|
||||||
})
|
}
|
||||||
.show()
|
.show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
@ -272,19 +282,19 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.help -> {
|
R.id.help -> {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.help)
|
.title(R.string.help)
|
||||||
.content(R.string.help_text, true)
|
.message(R.string.help_text)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveButton(android.R.string.ok)
|
||||||
.show()
|
.show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.login -> {
|
R.id.login -> {
|
||||||
MaterialDialog.Builder(this)
|
MaterialDialog(this)
|
||||||
.title(R.string.login)
|
.title(R.string.login)
|
||||||
.content(R.string.login_desc)
|
.message(R.string.login_desc)
|
||||||
.positiveText(android.R.string.ok)
|
.positiveButton(android.R.string.ok)
|
||||||
.onPositive { _, _ ->
|
.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,5 +1,6 @@
|
||||||
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
|
||||||
|
@ -37,7 +38,7 @@ object TelegraphApi {
|
||||||
parameters.forEach {
|
parameters.forEach {
|
||||||
requestObject.put(it.first, it.second)
|
requestObject.put(it.first, it.second)
|
||||||
}
|
}
|
||||||
method.httpPost().header("Content-Type" to "application/json").body(requestObject.toString()).responseJson(handler)
|
method.httpPost().header(mapOf("Content-Type" to "application/json")).body(requestObject.toString()).responseJson(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createAccount(shortName: String, authorName: String? = null, authorUrl: String? = null, callback: (success: Boolean, account: Account?, error: String?) -> Unit) {
|
fun createAccount(shortName: String, authorName: String? = null, authorUrl: String? = null, callback: (success: Boolean, account: Account?, error: String?) -> Unit) {
|
||||||
|
|
|
@ -25,6 +25,10 @@
|
||||||
android:id="@+id/bookmarks"
|
android:id="@+id/bookmarks"
|
||||||
android:title="@string/bookmarks"
|
android:title="@string/bookmarks"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/delete_bookmark"
|
||||||
|
android:title="@string/delete_bookmark"
|
||||||
|
app:showAsAction="never" />
|
||||||
<item
|
<item
|
||||||
android:id="@+id/published"
|
android:id="@+id/published"
|
||||||
android:title="@string/published"
|
android:title="@string/published"
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<![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>
|
<![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="create">New</string>
|
<string name="create">New</string>
|
||||||
<string name="title_question">Title?</string>
|
<string name="title_question">Title?</string>
|
||||||
<string name="title_hint">Awesome Post #1</string>
|
<string name="title_hint">Awesome Post #1</string>
|
||||||
|
@ -24,4 +25,5 @@
|
||||||
<string name="login_success">You successfully logged in!</string>
|
<string name="login_success">You successfully logged in!</string>
|
||||||
<string name="login">Login</string>
|
<string name="login">Login</string>
|
||||||
<string name="login_desc">Open the Telegraph bot in Telegram, select \"Login as * on this device\" and choose Teleposter.</string>
|
<string name="login_desc">Open the Telegraph bot in Telegram, select \"Login as * on this device\" and choose Teleposter.</string>
|
||||||
|
<string name="open">Open</string>
|
||||||
</resources>
|
</resources>
|
|
@ -1,12 +1,12 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.51'
|
ext.kotlin_version = '1.2.61'
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.1.3'
|
classpath 'com.android.tools.build:gradle:3.1.4'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,6 @@ allprojects {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
google()
|
google()
|
||||||
maven { url "https://jitpack.io" }
|
maven { url "https://jitpack.io" }
|
||||||
|
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue