Skip to content

Commit

Permalink
fix: issues/2756 (#766)
Browse files Browse the repository at this point in the history
Fixes  ooni/probe#2756

## Proposed Changes

  - Change share icon.
  - WebConnectivity row for run v2 tests
  - Change checkbox size
  - Add dividers to `RunTestActivity`
  - Add `eta` to progress fragment.
  - Limit the number of revisions displayed.

|.|.|.|.|.|
|-|-|-|-|-|
|
![Screenshot_20240705_192047](https://github.com/ooni/probe-android/assets/17911892/d3b02572-533e-484b-a1aa-e81c7e0e4d3f)
|
![Screenshot_20240705_192104](https://github.com/ooni/probe-android/assets/17911892/6cbffd29-6c1d-4684-bf6c-8bc5afec4c3c)
|
![Screenshot_20240705_192121](https://github.com/ooni/probe-android/assets/17911892/2305fd82-a1f5-41b0-918f-b60e5f00a135)
|
![Screenshot_20240705_192157](https://github.com/ooni/probe-android/assets/17911892/641e5561-3bfa-48f7-9155-d4723725d663)
|
![Screenshot_20240705_194853](https://github.com/ooni/probe-android/assets/17911892/0ba4086f-2f58-49cb-bcb4-e1183a930321)
|
  • Loading branch information
aanorbel authored Jul 5, 2024
1 parent 552e055 commit ac9f103
Show file tree
Hide file tree
Showing 31 changed files with 341 additions and 149 deletions.
4 changes: 3 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ android {
testInstrumentationRunner "org.openobservatory.ooniprobe.TestAndroidJUnitRunner"
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.ooni.io/"'
buildConfigField 'String', 'NOTIFICATION_SERVER', '"https://countly.ooni.io"'
buildConfigField 'String', 'OONI_RUN_DASHBOARD_URL', '"https://run.test.ooni.org"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe'
resValue "string", "APP_NAME", "OONI Probe"
buildConfigField 'String', 'SOFTWARE_NAME', 'BASE_SOFTWARE_NAME+IS_DEBUG'
Expand Down Expand Up @@ -51,7 +52,8 @@ android {
stable {
dimension 'testing'
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android"'
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.dev.ooni.io"'
buildConfigField 'String', 'OONI_API_BASE_URL', '"https://api.prod.ooni.io/"'
buildConfigField 'String', 'OONI_RUN_DASHBOARD_URL', '"https://run-v2.ooni.org"'
}
dev {
dimension 'testing'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.google.android.material.snackbar.Snackbar;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.activity.reviewdescriptorupdates.AvailableUpdatesViewModel;
import org.openobservatory.ooniprobe.common.AppUpdatesViewModel;
import org.openobservatory.ooniprobe.activity.reviewdescriptorupdates.ReviewDescriptorUpdatesActivity;
import org.openobservatory.ooniprobe.common.PreferenceManager;
import org.openobservatory.ooniprobe.common.TestDescriptorManager;
Expand Down Expand Up @@ -71,7 +71,7 @@ public class MainActivity extends ReviewUpdatesAbstractActivity implements Confi
TestDescriptorManager descriptorManager;

@Inject
AvailableUpdatesViewModel updatesViewModel;
AppUpdatesViewModel updatesViewModel;


public static Intent newIntent(Context context, int resItem) {
Expand Down Expand Up @@ -101,6 +101,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
getSupportFragmentManager().beginTransaction().replace(R.id.content, new DashboardFragment()).commit();
return true;
case R.id.testResults:
updatesViewModel.getTestRunComplete().setValue(false);
getSupportFragmentManager().beginTransaction().replace(R.id.content, new ResultListFragment()).commit();
return true;
case R.id.settings:
Expand Down Expand Up @@ -366,4 +367,8 @@ public void onActivityResult(int requestCode, int resultCode, @Nullable Intent d
}
}
}

public void showResults() {
binding.bottomNavigation.setSelectedItemId(R.id.testResults);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import android.text.TextUtils;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
Expand All @@ -37,7 +36,7 @@
import org.openobservatory.ooniprobe.activity.overview.OverviewTestsExpandableListViewAdapter;
import org.openobservatory.ooniprobe.activity.overview.OverviewViewModel;
import org.openobservatory.ooniprobe.activity.overview.RevisionsFragment;
import org.openobservatory.ooniprobe.activity.reviewdescriptorupdates.AvailableUpdatesViewModel;
import org.openobservatory.ooniprobe.common.AppUpdatesViewModel;
import org.openobservatory.ooniprobe.activity.reviewdescriptorupdates.ReviewDescriptorUpdatesActivity;
import org.openobservatory.ooniprobe.common.AbstractDescriptor;
import org.openobservatory.ooniprobe.common.OONITests;
Expand Down Expand Up @@ -71,7 +70,7 @@ public class OverviewActivity extends ReviewUpdatesAbstractActivity implements C
OverviewViewModel viewModel;

@Inject
AvailableUpdatesViewModel updatesViewModel;
AppUpdatesViewModel updatesViewModel;

@Inject
TestDescriptorManager testDescriptorManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ private void applyUIChanges(RunTestService service) {
binding.eta.setText(R.string.Dashboard_Running_CalculatingETA);
}

if (Objects.equals(service.task.currentTest.getLabelResId(),R.string.Test_Experimental_Fullname)) {
if (Objects.equals(service.task.currentSuite.getName(),OONITests.EXPERIMENTAL.getLabel())) {
binding.name.setText(service.task.currentTest.getName());
} else {
binding.name.setText(getString(service.task.currentTest.getLabelResId()));
Expand Down Expand Up @@ -293,8 +293,8 @@ public void onEnd(Context context) {
}

@NonNull
private static String readableTimeRemaining(double timeLeft) {
public static String readableTimeRemaining(double timeLeft) {
long letaValue = Math.round(timeLeft);
return String.format(ENGLISH,"%dm %02ds", letaValue/60, letaValue%60);
return String.format(ENGLISH," %dm %02ds", letaValue/60, letaValue%60);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ class AddDescriptorActivity : AbstractActivity() {
finish()
}

viewModel.selectedAllBtnStatus.observe(this) { state ->
binding.testsCheckbox.checkedState = state;
binding.expandableListView.viewTreeObserver.addOnGlobalLayoutListener {
binding.testsCheckbox.checkedState = viewModel.selectedAllBtnStatus.value!!
}

// This observer is used to change the state of the "Select All" button when a checkbox is clicked.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class OoniRunV2Activity : AbstractActivity() {
private fun fetchDescriptorComplete(descriptorResponse: TestDescriptor?) {
descriptorResponse?.let {
startActivity(AddDescriptorActivity.newIntent(this, descriptorResponse))
finish()
} ?: run {
finishWithError()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.gson.Gson
import org.openobservatory.engine.OONIRunRevisions
import org.openobservatory.ooniprobe.BuildConfig
import org.openobservatory.ooniprobe.R
import org.openobservatory.ooniprobe.databinding.FragmentRevisionsBinding
import org.openobservatory.ooniprobe.databinding.ItemTextBinding
Expand Down Expand Up @@ -63,14 +64,15 @@ class RevisionsFragment : Fragment() {

with(binding.list) {
layoutManager = LinearLayoutManager(context)
adapter = revisions?.revisions?.let {
adapter = revisions?.revisions?.take(5)?.let {
RevisionsRecyclerViewAdapter(it, object : OnItemClickListener {
override fun onItemClick(position: Int) {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse(
"https://run.test.ooni.org/revisions/%s?revision=%s".format(
"%s/revisions/%s?revision=%s".format(
BuildConfig.OONI_RUN_DASHBOARD_URL,
runId,
it[position]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import android.view.ViewGroup
import android.widget.BaseExpandableListAdapter
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
Expand All @@ -24,6 +23,7 @@ import com.google.gson.internal.LinkedTreeMap
import org.openobservatory.engine.BaseNettest
import org.openobservatory.ooniprobe.R
import org.openobservatory.ooniprobe.activity.AbstractActivity
import org.openobservatory.ooniprobe.common.AppUpdatesViewModel
import org.openobservatory.ooniprobe.common.TestDescriptorManager
import org.openobservatory.ooniprobe.databinding.ActivityReviewDescriptorUpdatesBinding
import org.openobservatory.ooniprobe.databinding.FragmentDescriptorUpdateBinding
Expand Down Expand Up @@ -79,7 +79,7 @@ class ReviewDescriptorUpdatesActivity : AbstractActivity() {
lateinit var gson: Gson

@Inject
lateinit var updatesViewModel: AvailableUpdatesViewModel
lateinit var updatesViewModel: AppUpdatesViewModel

private lateinit var reviewUpdatesPagingAdapter: ReviewUpdatesPagingAdapter

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.openobservatory.ooniprobe.activity.runtests.adapter.RunTestsExpandabl
import org.openobservatory.ooniprobe.activity.runtests.models.ChildItem
import org.openobservatory.ooniprobe.activity.runtests.models.GroupItem
import org.openobservatory.ooniprobe.common.AbstractDescriptor
import org.openobservatory.ooniprobe.common.OONIDescriptor
import org.openobservatory.ooniprobe.common.OONITests
import org.openobservatory.ooniprobe.common.PreferenceManager
import org.openobservatory.ooniprobe.common.disableTest
Expand Down Expand Up @@ -82,10 +83,20 @@ class RunTestsActivity : AbstractActivity() {
intent.extras?.getSerializable(TESTS) as List<AbstractDescriptor<BaseNettest>>?
descriptors?.let { _descriptors ->

adapter = RunTestsExpandableListViewAdapter(
_descriptors.map { descriptor ->
val groupedItemList = mutableListOf<Any>()

_descriptors.groupBy { it.javaClass }.forEach { (type, itemList) ->
if (type == OONIDescriptor::class.java){
groupedItemList.add("OONI Tests".uppercase())
} else {
groupedItemList.add("OONI RUN Links".uppercase())
}
groupedItemList.addAll(itemList.map { descriptor ->
descriptor.toRunTestsGroupItem(preferenceManager = preferenceManager)
},
})
}
adapter = RunTestsExpandableListViewAdapter(
groupedItemList,
viewModel
)

Expand Down Expand Up @@ -137,22 +148,25 @@ class RunTestsActivity : AbstractActivity() {
*/
private fun updatePreferences() {
for (i in 0 until adapter.groupCount) {
val group = adapter.getGroup(i)
when (group.name) {
OONITests.EXPERIMENTAL.label -> {
val testNames = OONITests.EXPERIMENTAL.nettests.map { it.name };
when(group.nettests.filter { testNames.contains(it.name) }.map { it.selected }.all { it }) {
true -> preferenceManager.enableTest(OONITests.EXPERIMENTAL.label)
false -> preferenceManager.disableTest(OONITests.EXPERIMENTAL.label)
}
}
else -> group.nettests.forEach { nettest ->
when(nettest.selected) {
true -> preferenceManager.enableTest(nettest.name, group.preferencePrefix())
false -> preferenceManager.disableTest(nettest.name, group.preferencePrefix())
}
}
}
when(val group = adapter.getGroup(i)) {
is GroupItem ->{
when (group.name) {
OONITests.EXPERIMENTAL.label -> {
val testNames = OONITests.EXPERIMENTAL.nettests.map { it.name };
when(group.nettests.filter { testNames.contains(it.name) }.map { it.selected }.all { it }) {
true -> preferenceManager.enableTest(OONITests.EXPERIMENTAL.label)
false -> preferenceManager.disableTest(OONITests.EXPERIMENTAL.label)
}
}
else -> group.nettests.forEach { nettest ->
when(nettest.selected) {
true -> preferenceManager.enableTest(nettest.name, group.preferencePrefix())
false -> preferenceManager.disableTest(nettest.name, group.preferencePrefix())
}
}
}
}
}
}
}

Expand Down Expand Up @@ -197,22 +211,30 @@ class RunTestsActivity : AbstractActivity() {
private fun getChildItemsSelectedIdList(): List<String> {
val childItemSelectedIdList: MutableList<String> = ArrayList()
for (i in 0 until adapter.groupCount) {
val secondLevelItemList: List<ChildItem> = adapter.getGroup(i).nettests
secondLevelItemList
.asSequence()
.filter { it.selected }
.mapTo(childItemSelectedIdList) { it.name }
when(val group = adapter.getGroup(i)) {
is GroupItem ->{
val secondLevelItemList: List<ChildItem> = group.nettests
secondLevelItemList
.asSequence()
.filter { it.selected }
.mapTo(childItemSelectedIdList) { it.name }
}
}
}
return childItemSelectedIdList
}

private fun getGroupItemsAtLeastOneChildEnabled(): List<GroupItem> {
val items: MutableList<GroupItem> = ArrayList()
for (i in 0 until adapter.groupCount) {
if (adapter.getGroup(i).nettests.any { it.selected }) {
items.add(adapter.getGroup(i).apply {
nettests = nettests.filter { it.selected }
})
when(val group = adapter.getGroup(i)) {
is GroupItem ->{
if (group.nettests.any { it.selected }) {
items.add(group.apply {
nettests = nettests.filter { it.selected }
})
}
}
}
}
return items
Expand Down
Loading

0 comments on commit ac9f103

Please sign in to comment.