mirror of https://github.com/jlelse/teleposter
0.3 Fixed image upload and some other things
This commit is contained in:
parent
27b34de2f7
commit
77d45a4d37
|
@ -1,8 +1,7 @@
|
||||||
*.iml
|
*.iml
|
||||||
.gradle
|
.gradle
|
||||||
/local.properties
|
/local.properties
|
||||||
/.idea/workspace.xml
|
/.idea
|
||||||
/.idea/libraries
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
/build
|
||||||
/captures
|
/captures
|
||||||
|
|
10
README.md
10
README.md
|
@ -1,12 +1,12 @@
|
||||||
# Teleposter
|
# Teleposter for Telegra.ph BETA
|
||||||
|
|
||||||
This app is a completely independent wrapper made for Telegra.ph.
|
Disclaimer: This wrapper is NOT an official wrapper and do not attempt to represent Telegram or Telegra.ph in any way.
|
||||||
|
|
||||||
With this app it's very easy to create and share posts directly to Telegram.
|
This app is a completely independent wrapper made for Telegra.ph, a new and simple publishing platform, made for easy sharing of articles and other stuff. With this app it's very easy to create and share these posts to any app.
|
||||||
|
|
||||||
These posts are marked with "Instant View" and are able to open "instantly" in Telegram. If you don't believe how fast that is, try yourself!
|
For more information aboout Telegra.ph visit https://telegram.org/blog/instant-view
|
||||||
|
|
||||||
Telegra.ph is quite similar to Medium.com.
|
Please take care, that this app might be unstable due to it's early development state!
|
||||||
|
|
||||||
## LICENSE
|
## LICENSE
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -8,8 +8,8 @@ android {
|
||||||
applicationId "telegra.ph"
|
applicationId "telegra.ph"
|
||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
targetSdkVersion 25
|
targetSdkVersion 25
|
||||||
versionCode 2
|
versionCode 3
|
||||||
versionName "0.2 beta"
|
versionName "0.3 beta"
|
||||||
resConfigs "en"
|
resConfigs "en"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -29,4 +29,5 @@ android {
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'com.android.support:appcompat-v7:25.0.1'
|
compile 'com.android.support:appcompat-v7:25.0.1'
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
compile 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
-keep class * extends android.webkit.WebChromeClient { *; }
|
||||||
|
-dontwarn im.delight.android.webview.**
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
package="telegra.ph">
|
package="telegra.ph">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:allowBackup="false"
|
android:allowBackup="false"
|
||||||
|
|
|
@ -1,58 +1,35 @@
|
||||||
package telegra.ph
|
package telegra.ph
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.annotation.TargetApi
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.graphics.Bitmap
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.support.v7.app.AppCompatActivity
|
import android.support.v7.app.AppCompatActivity
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.webkit.*
|
import im.delight.android.webview.AdvancedWebView
|
||||||
|
|
||||||
class MainActivity : AppCompatActivity() {
|
class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||||
|
|
||||||
private val TELEGRAPH = "http://telegra.ph/"
|
private val TELEGRAPH = "http://telegra.ph/"
|
||||||
|
|
||||||
private val webView: WebView? by lazy { findViewById(R.id.webView) as WebView }
|
private val webView: AdvancedWebView? by lazy { findViewById(R.id.webView) as AdvancedWebView }
|
||||||
|
|
||||||
@SuppressLint("SetJavaScriptEnabled")
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
|
||||||
webView?.settings?.apply {
|
webView?.setListener(this, this)
|
||||||
// Enable Javascript
|
|
||||||
javaScriptEnabled = true
|
webView?.apply {
|
||||||
// Allow File Access
|
setMixedContentAllowed(true)
|
||||||
allowFileAccess = true
|
setCookiesEnabled(true)
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
setThirdPartyCookiesEnabled(true)
|
||||||
allowFileAccessFromFileURLs = true
|
addPermittedHostname("telegra.ph")
|
||||||
}
|
|
||||||
// Add Database support
|
|
||||||
databaseEnabled = true
|
|
||||||
domStorageEnabled = true
|
|
||||||
// Add Cache support
|
|
||||||
setAppCacheEnabled(true)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set WebViewClient
|
webView?.settings?.apply {
|
||||||
webView?.setWebViewClient(object : WebViewClient() {
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
|
|
||||||
return urlAllowed(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.N)
|
}
|
||||||
override fun shouldOverrideUrlLoading(view: WebView, request: WebResourceRequest): Boolean {
|
|
||||||
return urlAllowed(request.url.toString())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Set WebChromeClient
|
|
||||||
webView?.setWebChromeClient(object : WebChromeClient() {
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// Check if app is opened to show special page
|
// Check if app is opened to show special page
|
||||||
var urlToLoad = TELEGRAPH
|
var urlToLoad = TELEGRAPH
|
||||||
|
@ -61,7 +38,42 @@ class MainActivity : AppCompatActivity() {
|
||||||
|
|
||||||
// Load URL
|
// Load URL
|
||||||
webView?.loadUrl(urlToLoad)
|
webView?.loadUrl(urlToLoad)
|
||||||
|
}
|
||||||
|
|
||||||
|
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 onResume() {
|
||||||
|
super.onResume()
|
||||||
|
webView?.onResume()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPause() {
|
||||||
|
webView?.onPause()
|
||||||
|
super.onPause()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onDestroy() {
|
||||||
|
webView?.onDestroy()
|
||||||
|
super.onDestroy()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
|
webView?.onActivityResult(requestCode, resultCode, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
|
@ -71,7 +83,7 @@ class MainActivity : AppCompatActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.share -> {
|
R.id.share -> {
|
||||||
val shareIntent = Intent()
|
val shareIntent = Intent()
|
||||||
shareIntent.action = Intent.ACTION_SEND
|
shareIntent.action = Intent.ACTION_SEND
|
||||||
|
@ -79,13 +91,10 @@ class MainActivity : AppCompatActivity() {
|
||||||
shareIntent.putExtra(Intent.EXTRA_TITLE, webView?.title)
|
shareIntent.putExtra(Intent.EXTRA_TITLE, webView?.title)
|
||||||
shareIntent.putExtra(Intent.EXTRA_TEXT, webView?.url)
|
shareIntent.putExtra(Intent.EXTRA_TEXT, webView?.url)
|
||||||
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)))
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.share)))
|
||||||
return true
|
true
|
||||||
}
|
}
|
||||||
else -> return super.onOptionsItemSelected(item)
|
else -> super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extra methods
|
|
||||||
private fun urlAllowed(url: String) = url.contains("telegra.ph")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
|
<im.delight.android.webview.AdvancedWebView
|
||||||
android:id="@+id/webView"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/webView"
|
||||||
android:layout_height="match_parent"/>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"/>
|
|
@ -14,5 +14,6 @@ allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven { url "https://jitpack.io" }
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue