mirror of
https://github.com/AllanWang/Frost-for-Facebook.git
synced 2024-11-10 04:52:38 +01:00
misc (#428)
* Add permission check * Validate uri before downloading * Update links, addresses # 411 * Update crashlytics
This commit is contained in:
parent
e4b3f3534a
commit
3e0d4547a5
@ -133,8 +133,9 @@ class AboutActivity : AboutActivityBase(null, {
|
||||
val size = c.dimenPixelSize(R.dimen.kau_avatar_bounds)
|
||||
images = arrayOf<Pair<IIcon, () -> Unit>>(
|
||||
GoogleMaterial.Icon.gmd_star to { c.startPlayStoreLink(R.string.play_store_package_id) },
|
||||
CommunityMaterial.Icon.cmd_reddit to { c.startLink("https://www.reddit.com/r/FrostForFacebook/") },
|
||||
CommunityMaterial.Icon.cmd_github_circle to { c.startLink("https://github.com/AllanWang/Frost-for-Facebook") }
|
||||
CommunityMaterial.Icon.cmd_reddit to { c.startLink(R.string.reddit_url) },
|
||||
CommunityMaterial.Icon.cmd_github_circle to { c.startLink(R.string.github_url) },
|
||||
CommunityMaterial.Icon.cmd_xda to { c.startLink(R.string.xda_url) }
|
||||
).mapIndexed { i, (icon, onClick) ->
|
||||
ImageView(c).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(size, size)
|
||||
|
@ -5,6 +5,8 @@ import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebChromeClient
|
||||
import ca.allanwang.kau.permissions.PERMISSION_WRITE_EXTERNAL_STORAGE
|
||||
import ca.allanwang.kau.permissions.kauRequestPermissions
|
||||
import ca.allanwang.kau.utils.string
|
||||
import com.pitchedapps.frost.R
|
||||
import com.pitchedapps.frost.utils.L
|
||||
@ -29,11 +31,17 @@ class FileChooserDelegate : FileChooserContract {
|
||||
override var filePathCallback: ValueCallback<Array<Uri>?>? = null
|
||||
|
||||
override fun Activity.openMediaPicker(filePathCallback: ValueCallback<Array<Uri>?>, fileChooserParams: WebChromeClient.FileChooserParams) {
|
||||
this@FileChooserDelegate.filePathCallback = filePathCallback
|
||||
val intent = Intent()
|
||||
intent.type = fileChooserParams.acceptTypes.firstOrNull()
|
||||
intent.action = Intent.ACTION_GET_CONTENT
|
||||
startActivityForResult(Intent.createChooser(intent, string(R.string.pick_image)), MEDIA_CHOOSER_RESULT)
|
||||
kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ ->
|
||||
if (!granted) {
|
||||
filePathCallback.onReceiveValue(null)
|
||||
return@kauRequestPermissions
|
||||
}
|
||||
this@FileChooserDelegate.filePathCallback = filePathCallback
|
||||
val intent = Intent()
|
||||
intent.type = fileChooserParams.acceptTypes.firstOrNull()
|
||||
intent.action = Intent.ACTION_GET_CONTENT
|
||||
startActivityForResult(Intent.createChooser(intent, string(R.string.pick_image)), MEDIA_CHOOSER_RESULT)
|
||||
}
|
||||
}
|
||||
|
||||
override fun Activity.onActivityResultWeb(requestCode: Int, resultCode: Int, intent: Intent?): Boolean {
|
||||
|
@ -20,9 +20,12 @@ import com.pitchedapps.frost.dbflow.loadFbCookie
|
||||
*/
|
||||
fun Context.frostDownload(url: String, userAgent: String, contentDisposition: String, mimeType: String, contentLength: Long) {
|
||||
L.d("Received download request", "Download $url")
|
||||
val uri = Uri.parse(url) ?: return
|
||||
if (uri.scheme != "http" && uri.scheme != "https")
|
||||
return L.e("Invalid download attempt", url)
|
||||
kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ ->
|
||||
if (!granted) return@kauRequestPermissions
|
||||
val request = DownloadManager.Request(Uri.parse(url))
|
||||
val request = DownloadManager.Request(uri)
|
||||
request.setMimeType(mimeType)
|
||||
val cookie = loadFbCookie(Prefs.userId) ?: return@kauRequestPermissions
|
||||
request.addRequestHeader("cookie", cookie.cookie)
|
||||
|
@ -4,6 +4,9 @@
|
||||
<string name="paypal" translatable="false">PayPal</string>
|
||||
<string name="play_store_package_id" translatable="false">com.pitchedapps.frost</string>
|
||||
<string name="translation_url" translatable="false">https://crwd.in/frost-for-facebook</string>
|
||||
<string name="github_url">https://github.com/AllanWang/Frost-for-Facebook</string>
|
||||
<string name="reddit_url">https://www.reddit.com/r/FrostForFacebook</string>
|
||||
<string name="xda_url" translatable="false">https://forum.xda-developers.com/android/apps-games/app-frost-facebook-t3685896</string>
|
||||
<string name="frost_prefix" translatable="false">Frost for Facebook:</string>
|
||||
<string name="feedback" translatable="false">Feedback</string>
|
||||
<string name="bug_report" translatable="false">Bug Report</string>
|
||||
|
@ -21,7 +21,7 @@ KAU=7513227
|
||||
KOTLIN=1.1.51
|
||||
|
||||
COMMONS_TEXT=1.1
|
||||
CRASHLYTICS=2.7.0
|
||||
CRASHLYTICS=2.7.1
|
||||
DBFLOW=4.0.5
|
||||
IAB=1.0.44
|
||||
IICON_COMMUNITY=1.9.32.2
|
||||
|
Loading…
Reference in New Issue
Block a user