From 20015bd9d8be7b3accabb887f32a40e79fef0163 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Erik=20Bj=C3=A4reholt?= Date: Fri, 13 Oct 2023 12:21:57 +0200 Subject: [PATCH] fix: fixes and improvements to onboarding (now can't be avoided by pressing back, as per Google Play policies) --- .../net/activitywatch/android/MainActivity.kt | 16 +++++---- .../android/OnboardingActivity.kt | 33 ++++++++++++++++--- .../android/watcher/UsageStatsWatcher.kt | 3 ++ .../main/res/layout/activity_onboarding.xml | 14 +++++++- 4 files changed, 54 insertions(+), 12 deletions(-) diff --git a/mobile/src/main/java/net/activitywatch/android/MainActivity.kt b/mobile/src/main/java/net/activitywatch/android/MainActivity.kt index d422465..0c439e0 100644 --- a/mobile/src/main/java/net/activitywatch/android/MainActivity.kt +++ b/mobile/src/main/java/net/activitywatch/android/MainActivity.kt @@ -36,13 +36,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - binding = ActivityMainBinding.inflate(layoutInflater) - val view = binding.root - setContentView(view) - - // Set up alarm to send heartbeats - val usw = UsageStatsWatcher(this) - usw.setupAlarm() // If first time, or usage not allowed, show onboarding activity val prefs = AWPreferences(this) @@ -52,6 +45,15 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte startActivity(intent) } + // Set up UI + binding = ActivityMainBinding.inflate(layoutInflater) + val view = binding.root + setContentView(view) + + // Set up alarm to send heartbeats + val usw = UsageStatsWatcher(this) + usw.setupAlarm() + binding.navView.setNavigationItemSelectedListener(this) val ri = RustInterface(this) diff --git a/mobile/src/main/java/net/activitywatch/android/OnboardingActivity.kt b/mobile/src/main/java/net/activitywatch/android/OnboardingActivity.kt index bc5f01a..76d05bf 100644 --- a/mobile/src/main/java/net/activitywatch/android/OnboardingActivity.kt +++ b/mobile/src/main/java/net/activitywatch/android/OnboardingActivity.kt @@ -37,13 +37,22 @@ class OnboardingActivity : AppCompatActivity() { viewPager.adapter = OnboardingAdapter(this) TabLayoutMediator(tabLayout, viewPager) { _, _ -> }.attach() + val nextButton = findViewById