Skip to content

Commit

Permalink
Updated Result to contain reference to the descriptor.
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Aug 4, 2023
1 parent 23d541f commit 781c70d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@ public void onPreMigrate() {

}

@Migration(version = 4, database = AppDatabase.class)
public static class Migration4 extends AlterTableMigration<Result> {

public Migration4(Class<Result> table) {
super(table);
}

@Override
public void onPreMigrate() {
addForeignKeyColumn(SQLiteType.INTEGER, "descriptor_runId", "TestDescriptor (`runId`)");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -40,6 +41,9 @@ public RunItem(Result extra, View.OnClickListener onClickListener, View.OnLongCl
viewHolder.itemView.setOnLongClickListener(onLongClickListener);
viewHolder.itemView.setBackgroundColor(ContextCompat.getColor(viewHolder.itemView.getContext(), extra.is_viewed ? android.R.color.transparent : R.color.color_yellow0));
viewHolder.asnName.setText(Network.toString(viewHolder.asnName.getContext(), extra.network));
viewHolder.name.setText(extra.getTestSuite().getTitle());
viewHolder.icon.setImageDrawable(viewHolder.itemView.getContext().getDrawable(extra.getTestSuite().getIconGradient()));
viewHolder.icon.setColorFilter(viewHolder.itemView.getResources().getColor(R.color.color_gray7));
viewHolder.startTime.setText(DateFormat.format(DateFormat.getBestDateTimePattern(Locale.getDefault(), "yMdHm"), extra.start_time));
boolean allUploaded = true;
for (Measurement m : extra.getMeasurements())
Expand All @@ -48,9 +52,12 @@ public RunItem(Result extra, View.OnClickListener onClickListener, View.OnLongCl
}

class ViewHolder extends RecyclerView.ViewHolder {
@BindView(R.id.name) TextView name;
@BindView(R.id.asnName) TextView asnName;
@BindView(R.id.startTime) TextView startTime;

@BindView(R.id.icon) ImageView icon;

ViewHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class Result extends BaseModel implements Serializable {
@Column public String failure_msg;

@ForeignKey(saveForeignKeyModel = true) public Network network;

@ForeignKey(saveForeignKeyModel = true) public TestDescriptor descriptor;
private List<Measurement> measurements;

public Result() {
Expand Down Expand Up @@ -193,7 +195,7 @@ public AbstractSuite getTestSuite() {
case ExperimentalSuite.NAME:
return new ExperimentalSuite(FlowManager.getContext().getResources());
case OONIRunSuite.NAME:
return new OONIRunSuite(FlowManager.getContext(),TestDescriptor.Builder.aTestDescriptor().build());
return new OONIRunSuite(FlowManager.getContext(),descriptor);
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.openobservatory.ooniprobe.R;
import org.openobservatory.ooniprobe.common.PreferenceManager;
import org.openobservatory.ooniprobe.common.StringUtils;
import org.openobservatory.ooniprobe.model.database.Result;
import org.openobservatory.ooniprobe.model.database.TestDescriptor;
import org.openobservatory.ooniprobe.test.test.AbstractTest;
import org.openobservatory.ooniprobe.test.test.Experimental;
Expand Down Expand Up @@ -46,4 +47,10 @@ public AbstractTest[] getTestList(@Nullable PreferenceManager pm) {
public TestDescriptor getDescriptor() {
return descriptor;
}

public Result getResult() {
Result result = super.getResult();
result.descriptor = descriptor;
return result;
}
}
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_ooni_run.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
android:src="@drawable/about_ooni" />

<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
Expand Down

0 comments on commit 781c70d

Please sign in to comment.