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'
|
||||
|
||||
android {
|
||||
compileSdkVersion 27
|
||||
buildToolsVersion "28.0.1"
|
||||
compileSdkVersion 28
|
||||
buildToolsVersion "28.0.2"
|
||||
defaultConfig {
|
||||
applicationId "telegra.ph"
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 27
|
||||
minSdkVersion 17
|
||||
targetSdkVersion 28
|
||||
versionCode 14
|
||||
versionName "1.5.1"
|
||||
resConfigs "en"
|
||||
|
@ -27,11 +27,13 @@ android {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:recyclerview-v7:27.1.1'
|
||||
implementation 'com.android.support:support-v13:27.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
|
||||
implementation 'com.android.support:recyclerview-v7:28.0.0-rc02'
|
||||
implementation 'com.android.support:support-v13:28.0.0-rc02'
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
implementation 'com.github.delight-im:Android-AdvancedWebView:v3.1.3'
|
||||
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
|
||||
implementation 'com.github.kittinunf.fuel:fuel-android:1.14.0'
|
||||
implementation 'com.afollestad.material-dialogs:core:2.0.0-alpha09'
|
||||
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.View
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
import com.afollestad.materialdialogs.input.input
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
import im.delight.android.webview.AdvancedWebView
|
||||
import java.net.URI
|
||||
|
||||
|
@ -124,10 +126,10 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
|
||||
private fun showMessage(title: String? = null, message: String? = null) {
|
||||
runOnUiThread {
|
||||
MaterialDialog.Builder(this)
|
||||
.title(title ?: "")
|
||||
.content(message ?: "")
|
||||
.positiveText(android.R.string.ok)
|
||||
MaterialDialog(this)
|
||||
.title(text = title ?: "")
|
||||
.message(text = message ?: "")
|
||||
.positiveButton(android.R.string.ok)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
|
@ -183,15 +185,15 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
}
|
||||
R.id.publish -> {
|
||||
editor?.getText { json ->
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.title(R.string.title_question)
|
||||
.input(getString(R.string.title_hint), currentPage?.title
|
||||
?: "", { _, title ->
|
||||
MaterialDialog.Builder(this)
|
||||
.input(hintRes = R.string.title_hint, prefill = currentPage?.title
|
||||
?: "") { _, title ->
|
||||
MaterialDialog(this)
|
||||
.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
|
||||
?: "", { _, name ->
|
||||
?: "") { _, name ->
|
||||
if (!isEdit) authorName = name.toString()
|
||||
if (isEdit) TelegraphApi.editPage(accessToken, currentPage?.path
|
||||
?: "", authorName = name.toString(), title = title.toString(), content = json
|
||||
|
@ -203,9 +205,9 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
if (success && page != null) showPage(page)
|
||||
else showError(error)
|
||||
}
|
||||
})
|
||||
}
|
||||
.show()
|
||||
})
|
||||
}
|
||||
.show()
|
||||
}
|
||||
true
|
||||
|
@ -215,24 +217,31 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
true
|
||||
}
|
||||
R.id.bookmarks -> {
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.title(R.string.bookmarks)
|
||||
.positiveText(android.R.string.ok)
|
||||
.items(bookmarks().reversed().map { it.second })
|
||||
.itemsCallback { _, _, i, _ ->
|
||||
loadPage(bookmarks().reversed().map { it.first }[i])
|
||||
.positiveButton(R.string.open)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.listItemsSingleChoice(items = bookmarks().reversed().map { it.second }) { _, index, _ ->
|
||||
loadPage(bookmarks().reversed().map { it.first }[index])
|
||||
}
|
||||
.itemsLongCallback { _, _, i, _ ->
|
||||
MaterialDialog.Builder(this)
|
||||
.show()
|
||||
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)
|
||||
.content(R.string.delete_question)
|
||||
.positiveText(android.R.string.yes)
|
||||
.negativeText(android.R.string.no)
|
||||
.onPositive { _, _ ->
|
||||
deleteBookmark(bookmarks().reversed().map { it.first }[i])
|
||||
.message(R.string.delete_question)
|
||||
.positiveButton(android.R.string.yes)
|
||||
.negativeButton(android.R.string.no)
|
||||
.positiveButton { _ ->
|
||||
deleteBookmark(bookmarks().reversed().map { it.first }[index])
|
||||
}
|
||||
.show()
|
||||
true
|
||||
}
|
||||
.show()
|
||||
true
|
||||
|
@ -240,11 +249,11 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
R.id.published -> {
|
||||
TelegraphApi.getPageList(accessToken) { success, pageList, error ->
|
||||
if (success && pageList != null && pageList.pages != null) {
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.title(R.string.published)
|
||||
.positiveText(android.R.string.ok)
|
||||
.items(pageList.pages.map { it.title })
|
||||
.itemsCallback { _, _, i, _ ->
|
||||
.positiveButton(R.string.open)
|
||||
.negativeButton(android.R.string.cancel)
|
||||
.listItemsSingleChoice(items = pageList.pages.map { it.title }) { _, i, _ ->
|
||||
loadPage(pageList.pages[i].path)
|
||||
}
|
||||
.show()
|
||||
|
@ -253,12 +262,13 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
true
|
||||
}
|
||||
R.id.bookmark -> {
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.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
|
||||
if (curPage?.url != null) addBookmark(curPage.url.split("/").last(), input.toString())
|
||||
})
|
||||
}
|
||||
.show()
|
||||
true
|
||||
}
|
||||
|
@ -272,19 +282,19 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
true
|
||||
}
|
||||
R.id.help -> {
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.title(R.string.help)
|
||||
.content(R.string.help_text, true)
|
||||
.positiveText(android.R.string.ok)
|
||||
.message(R.string.help_text)
|
||||
.positiveButton(android.R.string.ok)
|
||||
.show()
|
||||
true
|
||||
}
|
||||
R.id.login -> {
|
||||
MaterialDialog.Builder(this)
|
||||
MaterialDialog(this)
|
||||
.title(R.string.login)
|
||||
.content(R.string.login_desc)
|
||||
.positiveText(android.R.string.ok)
|
||||
.onPositive { _, _ ->
|
||||
.message(R.string.login_desc)
|
||||
.positiveButton(android.R.string.ok)
|
||||
.positiveButton { _ ->
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://t.me/telegraph")))
|
||||
}
|
||||
.show()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
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
|
||||
|
@ -37,7 +38,7 @@ object TelegraphApi {
|
|||
parameters.forEach {
|
||||
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) {
|
||||
|
|
|
@ -25,6 +25,10 @@
|
|||
android:id="@+id/bookmarks"
|
||||
android:title="@string/bookmarks"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/delete_bookmark"
|
||||
android:title="@string/delete_bookmark"
|
||||
app:showAsAction="never" />
|
||||
<item
|
||||
android:id="@+id/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>
|
||||
<string name="bookmarks">Bookmarks</string>
|
||||
<string name="bookmark_this">Bookmark this</string>
|
||||
<string name="delete_bookmark">Delete Bookmark</string>
|
||||
<string name="create">New</string>
|
||||
<string name="title_question">Title?</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">Login</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>
|
|
@ -1,12 +1,12 @@
|
|||
buildscript {
|
||||
ext.kotlin_version = '1.2.51'
|
||||
ext.kotlin_version = '1.2.61'
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
}
|
||||
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"
|
||||
}
|
||||
}
|
||||
|
@ -21,5 +21,6 @@ allprojects {
|
|||
mavenCentral()
|
||||
google()
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://dl.bintray.com/drummer-aidan/maven/" }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue