Initial working proof-of-concept for android.
This commit is contained in:
parent
8242e2088d
commit
b269712c32
37 changed files with 1017 additions and 0 deletions
|
@ -0,0 +1,28 @@
|
|||
package com.mozilla.send.sendandroid
|
||||
|
||||
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import android.content.Intent
|
||||
import android.util.Log
|
||||
import android.net.Uri
|
||||
|
||||
class IntentActivity : AppCompatActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val intent = getIntent()
|
||||
val action = intent.getAction()
|
||||
val type = intent.getType()
|
||||
if (Intent.ACTION_SEND.equals(action) && type != null) {
|
||||
if ("text/plain".equals(type)) {
|
||||
val sharedText = intent.getStringExtra(Intent.EXTRA_TEXT)
|
||||
Log.w("INTENT", "text/plain " + sharedText);
|
||||
} else if (type.startsWith("image/")) {
|
||||
val imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM) as Uri
|
||||
|
||||
Log.w("INTENT", "image/ " + imageUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.mozilla.send.sendandroid
|
||||
|
||||
|
||||
import android.support.v7.app.AppCompatActivity
|
||||
import android.os.Bundle
|
||||
import im.delight.android.webview.AdvancedWebView
|
||||
import android.graphics.Bitmap
|
||||
import android.content.Intent
|
||||
import android.annotation.SuppressLint
|
||||
import android.webkit.WebView
|
||||
import android.util.Log
|
||||
|
||||
class MainActivity : AppCompatActivity(), AdvancedWebView.Listener {
|
||||
private var mWebView: AdvancedWebView? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
mWebView = findViewById<WebView>(R.id.webview) as AdvancedWebView
|
||||
mWebView!!.setListener(this, this)
|
||||
|
||||
val webSettings = mWebView!!.getSettings()
|
||||
webSettings.setJavaScriptEnabled(true)
|
||||
|
||||
mWebView!!.loadUrl("https://send.firefox.com")
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
mWebView!!.onResume()
|
||||
// ...
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun onPause() {
|
||||
mWebView!!.onPause()
|
||||
// ...
|
||||
super.onPause()
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mWebView!!.onDestroy()
|
||||
// ...
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, intent: Intent) {
|
||||
super.onActivityResult(requestCode, resultCode, intent)
|
||||
mWebView!!.onActivityResult(requestCode, resultCode, intent)
|
||||
// ...
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
if (!mWebView!!.onBackPressed()) {
|
||||
return
|
||||
}
|
||||
// ...
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
||||
override fun onPageStarted(url: String, favicon: Bitmap?) {
|
||||
Log.w("MAIN", "onPageStarted");
|
||||
}
|
||||
|
||||
override fun onPageFinished(url: String) {
|
||||
Log.w("MAIN", "onPageFinished")
|
||||
}
|
||||
|
||||
override fun onPageError(errorCode: Int, description: String, failingUrl: String) {
|
||||
Log.w("MAIN", "onPageError")
|
||||
}
|
||||
|
||||
override fun onDownloadRequested(url: String, suggestedFilename: String, mimeType: String, contentLength: Long, contentDisposition: String, userAgent: String) {
|
||||
Log.w("MAIN", "onDownloadRequested")
|
||||
}
|
||||
|
||||
override fun onExternalPageRequest(url: String) {
|
||||
Log.w("MAIN", "onExternalPageRequest")
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue