Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ooni/probe-android into fix/count…
Browse files Browse the repository at this point in the history
…ly-initialization-failure
  • Loading branch information
aanorbel committed Oct 18, 2023
2 parents 0e3d714 + f952115 commit dcca639
Show file tree
Hide file tree
Showing 37 changed files with 1,389 additions and 151 deletions.
1 change: 0 additions & 1 deletion NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Terms: https://firebase.google.com/terms/

- easypermissions
- LocalhostToolkit
- butterknife
- DBFlow
- LocalhostToolkit
- MarkdownView
146 changes: 65 additions & 81 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
apply plugin: 'com.android.application'
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
}
apply from: 'jacoco.gradle'

android {
compileSdk 33
compileSdk libs.versions.compileSdk.get().toInteger()
ndkVersion '22.0.7026061'

defaultConfig {
applicationId 'org.openobservatory.ooniprobe'
minSdk 21
targetSdk 33
defaultConfig {
applicationId 'org.openobservatory.ooniprobe'
minSdk libs.versions.minSdk.get().toInteger()
targetSdk libs.versions.targetSdk.get().toInteger()
versionName '3.8.3'
versionCode 102
testInstrumentationRunner "org.openobservatory.ooniprobe.TestAndroidJUnitRunner"
Expand Down Expand Up @@ -42,19 +45,7 @@ android {
}
}

// Shared test code between Unit and Instrumented tests
sourceSets {
androidTest {
java.srcDirs += "src/sharedTest/java"
resources.srcDirs += "src/sharedTest/resources"
}
test {
java.srcDirs += "src/sharedTest/java"
resources.srcDirs += "src/sharedTest/resources"
}
}

flavorDimensions = ['testing', 'license']
flavorDimensions 'testing', 'license'
productFlavors {
stable {
dimension 'testing'
Expand Down Expand Up @@ -107,82 +98,75 @@ dependencies {
implementation project(path: ':engine')

// AndroidX
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-process:2.5.1'
implementation 'androidx.preference:preference:1.2.0'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
implementation 'com.google.guava:guava:30.1.1-android'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation libs.androidx.appcompat
implementation libs.androidx.constraintlayout
implementation libs.androidx.lifecycle.process
implementation libs.androidx.preference
implementation libs.androidx.localbroadcastmanager
implementation libs.androidx.legacy.support.v4

// Google
implementation libs.google.material
implementation libs.google.guava
implementation libs.google.gson

// Third-party
annotationProcessor 'com.github.Raizlabs.DBFlow:dbflow-processor:4.2.4'
implementation 'com.github.Raizlabs.DBFlow:dbflow-core:4.2.4'
implementation 'com.github.Raizlabs.DBFlow:dbflow:4.2.4'

implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.9.1'
annotationProcessor libs.dbflow.processor
implementation libs.dbflow.core
implementation libs.dbflow.lib

implementation libs.retrofit.lib
implementation libs.retrofit.converter.gson
implementation libs.retrofit.logging.interceptor

implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'

implementation 'com.github.xanscale.LocalhostToolkit:app:19.05.01'
implementation 'com.airbnb.android:lottie:3.0.7'
implementation 'com.google.code.gson:gson:2.8.9'
implementation 'ru.noties:markwon:2.0.1'
implementation 'commons-io:commons-io:2.6'
//arcview to fragment_dashboard
implementation 'com.github.florent37:shapeofview:1.3.2'
implementation libs.xanscale.localhost.toolkit
implementation libs.lottie
implementation libs.markwon
implementation libs.commons.io
//arcview to fragment_dashboard
implementation libs.shapeofview

// Flavor
fullImplementation platform('com.google.firebase:firebase-bom:26.3.0')
fullImplementation 'com.google.firebase:firebase-messaging'
fullImplementation 'ly.count.android:sdk:23.6.0'
fullImplementation 'io.sentry:sentry-android:6.3.0'
fullImplementation 'com.google.android.play:core:1.10.3'
fullImplementation platform(libs.google.firebase.bom)
fullImplementation libs.google.firebase.messaging
fullImplementation libs.countly.sdk
fullImplementation libs.sentry.android
fullImplementation libs.google.play.core

// Dependency Injection
implementation 'com.google.dagger:dagger:2.36'
annotationProcessor 'com.google.dagger:dagger-compiler:2.36'
implementation libs.google.dagger
annotationProcessor libs.google.dagger.compiler

// Logger
implementation project(':applogger')

// Testing
// Unit Testing
testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'androidx.test:runner:1.4.0'
testImplementation 'androidx.test:rules:1.4.0'
testImplementation 'org.mockito:mockito-core:4.6.1'
testImplementation 'org.mockito:mockito-inline:4.6.1'
testImplementation 'org.robolectric:robolectric:4.5.1'
testImplementation 'com.github.blocoio:faker:1.2.8'
testImplementation 'org.ooni:oonimkall:2023.07.18-162729'
testAnnotationProcessor 'com.google.dagger:dagger-compiler:2.36'

// Instrumentation Testing
androidTestImplementation 'tools.fastlane:screengrab:2.0.0'
androidTestImplementation 'com.github.blocoio:faker:1.2.8'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation('androidx.test.espresso:espresso-contrib:3.4.0') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
androidTestImplementation('androidx.test.espresso:espresso-core:3.4.0') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
}
androidTestImplementation('com.schibsted.spain:barista:3.9.0')
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.36"
// Unit Testing
testImplementation project(':shared-test')
testImplementation libs.junit4
testImplementation libs.androidx.core
testImplementation libs.androidx.runner
testImplementation libs.androidx.rules
testImplementation libs.mockito.core
testImplementation libs.mockito.inline
testImplementation libs.robolectric
testImplementation libs.faker
testImplementation libs.ooni.oonimkall
testAnnotationProcessor libs.google.dagger.compiler

// Instrumentation Testing
androidTestImplementation project(':shared-test')
androidTestImplementation libs.fastlane.screengrab
androidTestImplementation libs.faker
androidTestImplementation libs.androidx.runner
androidTestImplementation libs.androidx.rules
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.espresso.intents
androidTestImplementation libs.androidx.espresso.contrib
androidTestImplementation libs.androidx.espresso.core
androidTestImplementation libs.barista
androidTestAnnotationProcessor libs.google.dagger.compiler
}

static def versionCodeDate() {
Expand Down
2 changes: 1 addition & 1 deletion app/jacoco.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'jacoco'

jacoco {
toolVersion '0.8.5'
toolVersion libs.versions.jacoco.get().toString()
}

task jacocoAndroidTestReport(type: JacocoReport) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import androidx.appcompat.app.AppCompatDelegate;
import androidx.core.content.ContextCompat;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.snackbar.Snackbar;

import org.openobservatory.ooniprobe.R;
Expand All @@ -38,8 +37,6 @@

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.app.fragment.ConfirmDialogFragment;

public class MainActivity extends AbstractActivity implements ConfirmDialogFragment.OnConfirmedListener {
Expand Down Expand Up @@ -71,7 +68,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
finish();
}
else {
ButterKnife.bind(this);
binding = ActivityMainBinding.inflate(getLayoutInflater());
setContentView(binding.getRoot());
binding.bottomNavigation.setOnItemSelectedListener(item -> {
Expand Down
18 changes: 7 additions & 11 deletions app/src/main/java/org/openobservatory/ooniprobe/item/DateItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,16 @@

import android.text.format.DateFormat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemDateBinding;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class DateItem extends HeterogeneousRecyclerItem<Date, DateItem.ViewHolder> {
Expand All @@ -27,19 +23,19 @@ public DateItem(Date extra) {
}

@Override public ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolder(layoutInflater.inflate(R.layout.item_date, viewGroup, false));
return new ViewHolder(ItemDateBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolder viewHolder) {
viewHolder.textView.setText(SDF.format(extra));
viewHolder.binding.textView.setText(SDF.format(extra));
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.textView) TextView textView;
ItemDateBinding binding;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ViewHolder(ItemDateBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public ExperimentalItem(Result extra, View.OnClickListener onClickListener, View
viewHolder.itemView.setOnClickListener(onClickListener);
viewHolder.itemView.setOnLongClickListener(onLongClickListener);
viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), extra.is_viewed ? android.R.color.transparent : R.color.color_yellow0));
viewHolder.binding.totalMeasurements.setText(String.format("%d measured", extra.countTotalMeasurements()));
viewHolder.binding.asnName.setText(Network.toString(viewHolder.binding.asnName.getContext(), extra.network));
viewHolder.binding.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
boolean allUploaded = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemFailedBinding;
import org.openobservatory.ooniprobe.model.database.Result;

import java.util.Locale;

import butterknife.BindView;
import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class FailedItem extends HeterogeneousRecyclerItem<Result, FailedItem.ViewHolder> {
Expand All @@ -30,33 +27,30 @@ public FailedItem(Result extra, View.OnClickListener onClickListener, View.OnLon
}

@Override public ViewHolder onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolder(layoutInflater.inflate(R.layout.item_failed, viewGroup, false));
return new ViewHolder(ItemFailedBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolder viewHolder) {
viewHolder.itemView.setTag(extra);
viewHolder.itemView.setOnClickListener(onClickListener);
viewHolder.itemView.setOnLongClickListener(onLongClickListener);
viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray2));
viewHolder.testName.setTextColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray6));
viewHolder.icon.setImageResource(extra.getTestSuite().getIcon());
viewHolder.testName.setText(extra.getTestSuite().getTitle());
viewHolder.binding.testName.setTextColor(ContextCompat.getColor(viewHolder.itemView.getContext(), R.color.color_gray6));
viewHolder.binding.icon.setImageResource(extra.getTestSuite().getIcon());
viewHolder.binding.testName.setText(extra.getTestSuite().getTitle());
String failure_msg = viewHolder.itemView.getContext().getString(R.string.TestResults_Overview_Error);
if (extra.failure_msg != null)
failure_msg += " - " + extra.failure_msg;
viewHolder.subtitle.setText(failure_msg);
viewHolder.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
viewHolder.binding.subtitle.setText(failure_msg);
viewHolder.binding.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.testName) TextView testName;
@BindView(R.id.subtitle) TextView subtitle;
@BindView(R.id.startTime) TextView startTime;
@BindView(R.id.icon) ImageView icon;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ItemFailedBinding binding;

ViewHolder(ItemFailedBinding binding) {
super(binding.getRoot());
this.binding = binding;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.openobservatory.ooniprobe.item;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.databinding.ItemSeperatorBinding;

import butterknife.ButterKnife;
import localhost.toolkit.widget.recyclerview.HeterogeneousRecyclerItem;

public class SeperatorItem extends HeterogeneousRecyclerItem<String, SeperatorItem.ViewHolderImpl> {
Expand All @@ -18,15 +16,14 @@ public SeperatorItem() {
}

@Override public ViewHolderImpl onCreateViewHolder(LayoutInflater layoutInflater, ViewGroup viewGroup) {
return new ViewHolderImpl(layoutInflater.inflate(R.layout.item_seperator, viewGroup, false));
return new ViewHolderImpl(ItemSeperatorBinding.inflate(layoutInflater, viewGroup, false));
}

@Override public void onBindViewHolder(ViewHolderImpl holder) {}

static class ViewHolderImpl extends RecyclerView.ViewHolder {
ViewHolderImpl(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
ViewHolderImpl(ItemSeperatorBinding binding) {
super(binding.getRoot());
}
}
}
Expand Down
Loading

0 comments on commit dcca639

Please sign in to comment.