0.3 Fixed image upload and some other things

This commit is contained in:
Jan-Lk Else 2016-11-26 08:58:37 +01:00
parent 27b34de2f7
commit 77d45a4d37
9 changed files with 69 additions and 56 deletions

3
.gitignore vendored
View File

@ -1,8 +1,7 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
/.idea
.DS_Store
/build
/captures

View File

@ -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

BIN
apks/0.3.apk Normal file

Binary file not shown.

View File

@ -8,8 +8,8 @@ android {
applicationId "telegra.ph"
minSdkVersion 9
targetSdkVersion 25
versionCode 2
versionName "0.2 beta"
versionCode 3
versionName "0.3 beta"
resConfigs "en"
}
buildTypes {
@ -29,4 +29,5 @@ android {
dependencies {
compile 'com.android.support:appcompat-v7:25.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile 'com.github.delight-im:Android-AdvancedWebView:v3.0.0'
}

View File

@ -1 +1,2 @@
-keep class * extends android.webkit.WebChromeClient { *; }
-dontwarn im.delight.android.webview.**

View File

@ -3,6 +3,7 @@
package="telegra.ph">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="false"

View File

@ -1,58 +1,35 @@
package telegra.ph
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.content.Intent
import android.os.Build
import android.graphics.Bitmap
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.Menu
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 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?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
webView?.settings?.apply {
// Enable Javascript
javaScriptEnabled = true
// Allow File Access
allowFileAccess = true
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
allowFileAccessFromFileURLs = true
}
// Add Database support
databaseEnabled = true
domStorageEnabled = true
// Add Cache support
setAppCacheEnabled(true)
webView?.setListener(this, this)
webView?.apply {
setMixedContentAllowed(true)
setCookiesEnabled(true)
setThirdPartyCookiesEnabled(true)
addPermittedHostname("telegra.ph")
}
// Set WebViewClient
webView?.setWebViewClient(object : WebViewClient() {
@SuppressWarnings("deprecation")
override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean {
return urlAllowed(url)
}
webView?.settings?.apply {
@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
var urlToLoad = TELEGRAPH
@ -61,7 +38,42 @@ class MainActivity : AppCompatActivity() {
// Load URL
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 {
@ -71,7 +83,7 @@ class MainActivity : AppCompatActivity() {
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
return when (item.itemId) {
R.id.share -> {
val shareIntent = Intent()
shareIntent.action = Intent.ACTION_SEND
@ -79,13 +91,10 @@ class MainActivity : AppCompatActivity() {
shareIntent.putExtra(Intent.EXTRA_TITLE, webView?.title)
shareIntent.putExtra(Intent.EXTRA_TEXT, webView?.url)
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")
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<im.delight.android.webview.AdvancedWebView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

View File

@ -14,5 +14,6 @@ allprojects {
repositories {
jcenter()
mavenCentral()
maven { url "https://jitpack.io" }
}
}