confirm push to ghost

delete cached images on start
hauntED
yova 3 months ago
parent da174106ee
commit 9f02934faf

@ -143,7 +143,7 @@ class MainActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
supportActionBar!!.setDisplayShowTitleEnabled(false)
deleteCache()
@ -409,34 +409,41 @@ class MainActivity : AppCompatActivity() {
}
R.id.push_ghost -> {
webView.evaluateJavascript("getHtml();", {
val msg = URLDecoder.decode(it.removeSurrounding("\""))
if (metaData.metaData.get("url") !== null) {
CoroutineScope(Dispatchers.Main).launch {
withContext(Dispatchers.IO) {
if (metaData.getId() == null) {
this@MainActivity.runOnUiThread({
Toast.makeText(
this@MainActivity,
"No ID for url in Metadata found. Deleted? Trying repost.",
Toast.LENGTH_LONG
).show()
})
sendPosting(html=msg, author = credManager.username)
} else {
Log.i(javaClass.simpleName,"posting $msg")
updatePost(
title = metaData.get("title") ?: getDisplayName(thisFileUri),
author = credManager.username,
html = msg,
id = metaData.getId()!!
)
with(AlertDialog.Builder(this)){
setTitle("Push to ghostCMS?")
setPositiveButton("Yes", { dialog, id ->
webView.evaluateJavascript("getHtml();", {
val msg = URLDecoder.decode(it.removeSurrounding("\""))
if (metaData.metaData.get("url") !== null) {
CoroutineScope(Dispatchers.Main).launch {
withContext(Dispatchers.IO) {
if (metaData.getId() == null) {
this@MainActivity.runOnUiThread({
Toast.makeText(
this@MainActivity,
"No ID for url in Metadata found. Deleted? Trying repost.",
Toast.LENGTH_LONG
).show()
})
sendPosting(html=msg, author = credManager.username)
} else {
Log.i(javaClass.simpleName,"posting $msg")
updatePost(
title = metaData.get("title") ?: getDisplayName(thisFileUri),
author = credManager.username,
html = msg,
id = metaData.getId()!!
)
}
}
}
}
}
} else
shareGhost(msg, ::sendPost)
})
} else
shareGhost(msg, ::sendPost)
})
})
setNeutralButton("No", { dialog, id -> })
show()
}
}
R.id.settings -> {
ghostSettings.launch(Intent(this, LoginActivity::class.java))
@ -720,6 +727,7 @@ class MainActivity : AppCompatActivity() {
try {
val dir = File(cacheDir, "html")
deleteDir(dir)
deleteDir(applicationContext.filesDir)
} catch (e: java.lang.Exception) {
e.printStackTrace()
}
@ -1137,6 +1145,7 @@ class MainActivity : AppCompatActivity() {
webView.evaluateJavascript(script, {
thisFileUri = uri
Log.d(javaClass.simpleName,"File read: ${thisFileUri}")
saveFile()
})
webView.requestFocus()
})

Loading…
Cancel
Save