Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ActivityWatch/aw-android
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9d1058849284b47bfef2afaef0491703ee7b2166
Choose a base ref
..
head repository: ActivityWatch/aw-android
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e0c5193f84c55745987cca0158388f033c769042
Choose a head ref
6 changes: 2 additions & 4 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -11,12 +11,10 @@ android {
targetSdkVersion 34

// Set in CI on tagged commit
// FIXME: should be set before tagging, so that F-droid picks it up correctly
// https://gitlab.com/fdroid/fdroiddata/-/merge_requests/11786?commit_id=d2cedcbe3d26db59378d582a8cf952af16b6407f#note_1966750559
versionName "0.12.1"
versionName "0.12.0"

// Set in CI by `bundle exec fastlane update_version`
versionCode 34
versionCode 26

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// NOTE: This only works for API level 28 and above
11 changes: 0 additions & 11 deletions mobile/src/main/java/net/activitywatch/android/RustInterface.kt
Original file line number Diff line number Diff line change
@@ -53,15 +53,6 @@ class RustInterface constructor(context: Context? = null) {

fun startServerTask(context: Context) {

Check warning on line 54 in mobile/src/main/java/net/activitywatch/android/RustInterface.kt

GitHub Actions / Test

Parameter 'context' is never used
if(!serverStarted) {
// check if port 5600 is already in use
try {
val socket = java.net.ServerSocket(5600)
socket.close()
} catch(e: java.net.BindException) {
Log.e(TAG, "Port 5600 is already in use, server probably already started")
return
}

serverStarted = true
val executor = Executors.newSingleThreadExecutor()
val handler = Handler(Looper.getMainLooper())
@@ -74,8 +65,6 @@ class RustInterface constructor(context: Context? = null) {

handler.post {
// will run on UI thread after the task is done
Log.i(TAG, "Server finished")
serverStarted = false
}
}
Log.w(TAG, "Server started")
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ class ChromeWatcher : AccessibilityService() {
}

try {
if (event.source != null) {
if (event != null && event.source != null) {
// Get URL
val urlBars = event.source!!.findAccessibilityNodeInfosByViewId("com.android.chrome:id/url_bar")
if (urlBars.any()) {
@@ -65,13 +65,10 @@ class ChromeWatcher : AccessibilityService() {
}

// Get title
val webView = findWebView(event.source!!)
var webView = findWebView(event.source!!)
if (webView != null) {
val title = webView.text.toString()
if (title != lastTitle) {
lastTitle = title
Log.i(TAG, "Title: ${lastTitle}")
}
lastTitle = webView.text.toString()
Log.i(TAG, "Title: ${lastTitle}")
}
}
}
@@ -81,6 +78,9 @@ class ChromeWatcher : AccessibilityService() {
}

fun findWebView(info : AccessibilityNodeInfo) : AccessibilityNodeInfo? {
if(info == null)
return null

if(info.className == "android.webkit.WebView" && info.text != null)
return info

@@ -90,17 +90,17 @@ class ChromeWatcher : AccessibilityService() {
if (webView != null) {
return webView
}
child?.recycle()
if(child != null){
child.recycle()
}
}

return null
}

fun onUrl(newUrl : String?) {
Log.i(TAG, "Url: ${newUrl}")
if (newUrl != lastUrl) { // URL changed
if (newUrl != null) {
Log.i(TAG, "Url: $newUrl")
}
if (lastUrl != null) {
// Log last URL and title as a completed browser event.
// We wait for the event to complete (marked by a change in URL) to ensure that