Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: attempt at fixing CSV exports crashing app #109

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@

myWebView.settings.javaScriptEnabled = true
myWebView.settings.domStorageEnabled = true
myWebView.addJavascriptInterface(WebAppInterface(context), "Android")

Check failure on line 100 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Type mismatch: inferred type is Context? but Context was expected

Check failure on line 100 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Type mismatch: inferred type is Context? but Context was expected

Check failure on line 100 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Build aab

Type mismatch: inferred type is Context? but Context was expected
arguments?.let {
it.getString(ARG_URL)?.let { it1 -> myWebView.loadUrl(it1) }
}
Expand Down Expand Up @@ -145,3 +146,24 @@
}
}
}

class WebAppInterface(private val mContext: Context) {
@JavascriptInterface

Check failure on line 151 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: JavascriptInterface

Check failure on line 151 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: JavascriptInterface

Check failure on line 151 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Build aab

Unresolved reference: JavascriptInterface
fun downloadCSV(csv: String, filename: String) {
downloadFile(csv, filename, "text/csv")
}

@JavascriptInterface

Check failure on line 156 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: JavascriptInterface

Check failure on line 156 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: JavascriptInterface

Check failure on line 156 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Build aab

Unresolved reference: JavascriptInterface
fun downloadJSON(csv: String, filename: String) {
downloadFile(csv, filename, "application/json")
}

fun downloadFile(csv: String, filename: String, mimetype: String) {
val file = File(mContext.getExternalFilesDir(null), filename)

Check failure on line 162 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: File

Check failure on line 162 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Test

Unresolved reference: File

Check failure on line 162 in mobile/src/main/java/net/activitywatch/android/fragments/WebUIFragment.kt

View workflow job for this annotation

GitHub Actions / Build aab

Unresolved reference: File
file.writeText(csv)
val intent = Intent(Intent.ACTION_VIEW)
intent.setDataAndType(Uri.fromFile(file), mimetype)
intent.flags = Intent.FLAG_ACTIVITY_NO_HISTORY
mContext.startActivity(intent)
}
}
Loading