mirror of https://github.com/jlelse/teleposter
Trying things
This commit is contained in:
parent
b1ea82a3fb
commit
7d7bc7c1fb
|
@ -2,10 +2,10 @@ package telegra.ph
|
|||
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.support.v7.app.AlertDialog
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.text.Html
|
||||
import android.view.ActionMode
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.afollestad.materialdialogs.MaterialDialog
|
||||
|
@ -80,6 +80,18 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
else super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onActionModeStarted(mode: ActionMode?) {
|
||||
val menu = mode?.menu
|
||||
mode?.menuInflater?.inflate(R.menu.formatting, menu)
|
||||
menu?.findItem(R.id.format)?.apply {
|
||||
setOnMenuItemClickListener {
|
||||
executeJavaScript("javascript:showFormatTooltip();")
|
||||
false
|
||||
}
|
||||
}
|
||||
super.onActionModeStarted(mode)
|
||||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||
super.onCreateOptionsMenu(menu)
|
||||
menuInflater.inflate(R.menu.activity_main, menu)
|
||||
|
@ -108,4 +120,12 @@ class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
|||
}
|
||||
}
|
||||
|
||||
private fun executeJavaScript(code: String) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
webView?.evaluateJavascript(code, null)
|
||||
} else {
|
||||
webView?.loadUrl(code)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
<item
|
||||
android:id="@+id/format"
|
||||
android:title="@string/format"
|
||||
app:showAsAction="always"/>
|
||||
</menu>
|
|
@ -5,4 +5,5 @@
|
|||
<string name="help_text">
|
||||
<![CDATA[<h3>How to use text formatting?</h3>You can use formatting like <b>bold</b>, <i>italics</i> and so on at least on Lollipop and above by double tapping the text.<h3>The app only shows strange things!</h3>It\'s not verified, that the app will work on devices with KitKat or lower. In Lollipop Google introduced a Chrome based and updatable WebView with more features and fixes. I\'m sorry! But in December \'16 Telegram will publish docs for the Telegraph API, so I\'ll be able to create a native app instead of a wrapper. Be patient!]]>
|
||||
</string>
|
||||
<string name="format">Format</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in New Issue