diff --git a/app/build.gradle b/app/build.gradle
index 1c215b084..6aa91d6f4 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -103,6 +103,7 @@ dependencies {
// AndroidX
implementation libs.androidx.appcompat
+ //implementation libs.androidx.core
implementation libs.androidx.constraintlayout
implementation libs.androidx.lifecycle.process
implementation libs.androidx.preference
@@ -149,7 +150,7 @@ dependencies {
// Unit Testing
testImplementation project(':shared-test')
testImplementation libs.junit4
- testImplementation libs.androidx.core
+ testImplementation libs.androidx.test.core
testImplementation libs.androidx.runner
testImplementation libs.androidx.rules
testImplementation libs.mockito.core
diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.java b/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.java
deleted file mode 100644
index b37840428..000000000
--- a/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package org.openobservatory.ooniprobe.fragment;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentFilter;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import androidx.core.app.ActivityCompat;
-import androidx.fragment.app.Fragment;
-import androidx.localbroadcastmanager.content.LocalBroadcastManager;
-import org.openobservatory.ooniprobe.R;
-import org.openobservatory.ooniprobe.activity.RunningActivity;
-import org.openobservatory.ooniprobe.common.Application;
-import org.openobservatory.ooniprobe.common.PreferenceManager;
-import org.openobservatory.ooniprobe.common.TestProgressRepository;
-import org.openobservatory.ooniprobe.common.service.RunTestService;
-import org.openobservatory.ooniprobe.databinding.FragmentProgressBinding;
-import org.openobservatory.ooniprobe.receiver.TestRunBroadRequestReceiver;
-
-import javax.inject.Inject;
-
-/**
- * Monitors and displays progress of {@link RunTestService}.
- */
-public class ProgressFragment extends Fragment {
- private TestRunBroadRequestReceiver receiver;
-
- private FragmentProgressBinding biding;
-
- @Inject
- PreferenceManager preferenceManager;
- @Inject
- TestProgressRepository testProgressRepository;
-
- public ProgressFragment() {
- // Required empty public constructor
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
- biding = FragmentProgressBinding.inflate(inflater, container, false);
- ((Application) getActivity().getApplication()).getFragmentComponent().inject(this);
- biding.getRoot().setOnClickListener(v -> {
- Intent intent = new Intent(getContext(), RunningActivity.class);
- ActivityCompat.startActivity(getActivity(), intent, null);
- });
- testProgressRepository.getProgress().observe(getViewLifecycleOwner(),progressValue -> {
- if (progressValue!=null) {
- biding.progress.setProgress(progressValue);
- }
- });
- return biding.getRoot();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- IntentFilter filter = new IntentFilter("org.openobservatory.ooniprobe.activity.RunningActivity");
- receiver = new TestRunBroadRequestReceiver(preferenceManager, new TestRunnerEventListener(),testProgressRepository);
- LocalBroadcastManager.getInstance(getActivity()).registerReceiver(receiver, filter);
- //Bind the RunTestService
- this.bindTestService();
- }
-
- public void bindTestService() {
- Activity activity = getActivity();
- if (activity!=null && ((Application)activity.getApplication()).isTestRunning()) {
- Intent intent = new Intent(getActivity(), RunTestService.class);
- getActivity().bindService(intent, receiver, Context.BIND_AUTO_CREATE);
- biding.progressLayout.setVisibility(View.VISIBLE);
- }
- else
- biding.progressLayout.setVisibility(View.GONE);
- }
-
- private void updateUI(RunTestService service){
- Activity activity = getActivity();
- if (activity!=null && ((Application)activity.getApplication()).isTestRunning()){
-
- Integer progressLevel = testProgressRepository.getProgress().getValue();
- if (progressLevel != null) {
- biding.progress.setProgress(progressLevel);
- } else {
- biding.progress.setIndeterminate(true);
- }
- if (service != null && service.task != null){
- if (service.task.currentSuite != null)
- biding.progress.setMax(service.task.getMax(preferenceManager));
- if (service.task.currentTest != null)
- biding.name.setText(getString(service.task.currentTest.getLabelResId()));
- }
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- if (receiver.isBound()) {
- getActivity().unbindService(receiver);
- receiver.setBound(false);
- }
- LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiver);
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(receiver);
- }
-
- private class TestRunnerEventListener implements TestRunBroadRequestReceiver.EventListener {
- @Override
- public void onStart(RunTestService service) {
- updateUI(service);
- }
-
- @Override
- public void onRun(String value) {
- biding.name.setText(value);
- }
-
- @Override
- public void onProgress(int state, double eta) {
- if (biding.progress.isIndeterminate())
- updateUI(receiver.service);
- biding.progress.setIndeterminate(false);
- biding.progress.setProgress(state);
- }
-
- @Override
- public void onLog(String value) {
- /* nothing */
- }
-
- @Override
- public void onError(String value) {
- /* nothing */
- }
-
- @Override
- public void onUrl() {
- biding.progress.setIndeterminate(false);
- }
-
- @Override
- public void onInterrupt() {
- biding.running.setText(getString(R.string.Dashboard_Running_Stopping_Title));
- }
-
- @Override
- public void onEnd(Context context) {
- biding.progressLayout.setVisibility(View.GONE);
- }
- }
-}
\ No newline at end of file
diff --git a/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.kt b/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.kt
new file mode 100644
index 000000000..b0911d5e3
--- /dev/null
+++ b/app/src/main/java/org/openobservatory/ooniprobe/fragment/ProgressFragment.kt
@@ -0,0 +1,148 @@
+package org.openobservatory.ooniprobe.fragment
+
+import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
+import android.os.Bundle
+import android.view.LayoutInflater
+import android.view.View
+import android.view.ViewGroup
+import androidx.core.app.ActivityCompat
+import androidx.fragment.app.Fragment
+import androidx.localbroadcastmanager.content.LocalBroadcastManager
+import org.openobservatory.ooniprobe.R
+import org.openobservatory.ooniprobe.activity.RunningActivity
+import org.openobservatory.ooniprobe.common.Application
+import org.openobservatory.ooniprobe.common.PreferenceManager
+import org.openobservatory.ooniprobe.common.TestProgressRepository
+import org.openobservatory.ooniprobe.common.service.RunTestService
+import org.openobservatory.ooniprobe.databinding.FragmentProgressBinding
+import org.openobservatory.ooniprobe.receiver.TestRunBroadRequestReceiver
+import javax.inject.Inject
+
+/**
+ * Monitors and displays progress of [RunTestService].
+ */
+class ProgressFragment : Fragment() {
+ private lateinit var receiver: TestRunBroadRequestReceiver
+ private lateinit var biding: FragmentProgressBinding
+
+ @Inject
+ lateinit var preferenceManager: PreferenceManager
+
+ @Inject
+ lateinit var testProgressRepository: TestProgressRepository
+
+ override fun onCreateView(
+ inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?
+ ): View {
+ biding = FragmentProgressBinding.inflate(inflater, container, false)
+ (requireActivity().application as Application).fragmentComponent.inject(this)
+ biding.root.setOnClickListener { _: View? ->
+ val intent = Intent(context, RunningActivity::class.java)
+ ActivityCompat.startActivity(requireContext(), intent, null)
+ }
+ testProgressRepository.progress.observe(viewLifecycleOwner) { progressValue: Int? ->
+ if (progressValue != null) {
+ biding.progress.progress = progressValue
+ }
+ }
+ return biding.root
+ }
+
+ override fun onResume() {
+ super.onResume()
+ val filter = IntentFilter("org.openobservatory.ooniprobe.activity.RunningActivity")
+ receiver = TestRunBroadRequestReceiver(
+ preferenceManager, TestRunnerEventListener(), testProgressRepository
+ )
+ // NOTE: Simple update to ContextCompat#registerReceiver not possible at the moment.
+ LocalBroadcastManager.getInstance(requireContext()).registerReceiver(receiver, filter)
+ bindTestService()
+ }
+
+ fun bindTestService() {
+ if ((requireActivity().application as Application).isTestRunning) {
+ requireContext().bindService(
+ Intent(requireContext(), RunTestService::class.java),
+ receiver,
+ Context.BIND_AUTO_CREATE
+ )
+ biding.progressLayout.visibility = View.VISIBLE
+ } else {
+ biding.progressLayout.visibility = View.GONE
+ }
+ }
+
+ private fun updateUI(service: RunTestService?) {
+ if ((requireActivity().application as Application).isTestRunning) {
+ val progressLevel = testProgressRepository.progress.value
+ when {
+ progressLevel != null -> {
+ biding.progress.progress = progressLevel
+ }
+ else -> {
+ biding.progress.isIndeterminate = true
+ }
+ }
+ service?.task?.let { task ->
+ task.currentSuite?.let {
+ biding.progress.max = service.task.getMax(preferenceManager)
+ }
+ task.currentTest?.let {
+ biding.name.text = getString(it.labelResId)
+ }
+ }
+ }
+ }
+
+ override fun onPause() {
+ super.onPause()
+ if (receiver.isBound) {
+ requireContext().unbindService(receiver)
+ receiver.isBound = false
+ }
+ LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(receiver)
+ }
+
+ override fun onDestroy() {
+ super.onDestroy()
+ LocalBroadcastManager.getInstance(requireContext()).unregisterReceiver(receiver)
+ }
+
+ private inner class TestRunnerEventListener : TestRunBroadRequestReceiver.EventListener {
+ override fun onStart(service: RunTestService) = updateUI(service)
+
+ override fun onRun(value: String) {
+ biding.name.text = value
+ }
+
+ override fun onProgress(state: Int, eta: Double) {
+ if (biding.progress.isIndeterminate) {
+ updateUI(receiver.service)
+ }
+ biding.progress.apply {
+ isIndeterminate = false
+ progress = state
+ }
+ }
+
+ override fun onLog(value: String) {/* nothing */
+ }
+
+ override fun onError(value: String) {/* nothing */
+ }
+
+ override fun onUrl() {
+ biding.progress.isIndeterminate = false
+ }
+
+ override fun onInterrupt() {
+ biding.running.text = getString(R.string.Dashboard_Running_Stopping_Title)
+ }
+
+ override fun onEnd(context: Context) {
+ biding.progressLayout.visibility = View.GONE
+ }
+ }
+}
diff --git a/app/src/main/res/layout/fragment_progress.xml b/app/src/main/res/layout/fragment_progress.xml
index e37168aec..cff0e4d6d 100644
--- a/app/src/main/res/layout/fragment_progress.xml
+++ b/app/src/main/res/layout/fragment_progress.xml
@@ -5,7 +5,7 @@
android:id="@+id/progress_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:background="@color/color_gray9"
+ android:background="@color/progress_background"
tools:context=".fragment.ProgressFragment">
-
\ No newline at end of file
+
diff --git a/app/src/main/res/values-night/colors.xml b/app/src/main/res/values-night/colors.xml
index 4fbb13f80..0ff0d131a 100644
--- a/app/src/main/res/values-night/colors.xml
+++ b/app/src/main/res/values-night/colors.xml
@@ -5,6 +5,7 @@
#868e96
@color/color_black
#DEE2E6
+ #E9ECEF
#fff
#1b1b1b
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index e4b86dbd8..f557fe2ec 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -5,6 +5,7 @@
@color/color_gray3
@color/color_black
@color/color_gray9
+ @color/color_gray7
#000000
#ffffff
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index df1da5b9d..a21600a5c 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -78,7 +78,8 @@ dbflow-lib = { module = "com.github.Raizlabs.DBFlow:dbflow", version.ref = "dbfl
dbflow-core = { module = "com.github.Raizlabs.DBFlow:dbflow-core", version.ref = "dbflow" }
dbflow-processor = { module = "com.github.Raizlabs.DBFlow:dbflow-processor", version.ref = "dbflow" }
-androidx-core = { module = "androidx.test:core", version.ref = "androidxCore" }
+# androidx-core = { group = "androidx.core", name = "core", version.ref = "androidxCore" }
+androidx-test-core = { module = "androidx.test:core", version.ref = "androidxCore" }
androidx-rules = { module = "androidx.test:rules", version.ref = "androidxCore" }
androidx-runner = { module = "androidx.test:runner", version.ref = "androidxRunner" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }