Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New Designs] Update Dashboard view to match new design #631

Merged
merged 18 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
Expand All @@ -16,4 +16,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: dev-apk
path: app/build/outputs/apk/devFull/release
path: app/build/outputs/apk/devFull/release
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
steps:
- uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
Expand Down
21 changes: 13 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'kotlin-android'
id 'kotlin-kapt'
}
apply from: 'jacoco.gradle'

Expand Down Expand Up @@ -85,8 +86,11 @@ android {
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17
}
buildFeatures {
viewBinding = true
Expand All @@ -99,6 +103,7 @@ dependencies {

// AndroidX
implementation libs.androidx.appcompat
//implementation libs.androidx.core
aanorbel marked this conversation as resolved.
Show resolved Hide resolved
implementation libs.androidx.constraintlayout
implementation libs.androidx.lifecycle.process
implementation libs.androidx.preference
Expand All @@ -111,7 +116,7 @@ dependencies {
implementation libs.google.gson

// Third-party
annotationProcessor libs.dbflow.processor
kapt libs.dbflow.processor
implementation libs.dbflow.core
implementation libs.dbflow.lib

Expand All @@ -136,7 +141,7 @@ dependencies {

// Dependency Injection
implementation libs.google.dagger
annotationProcessor libs.google.dagger.compiler
kapt libs.google.dagger.compiler

// Logger
implementation project(':applogger')
Expand All @@ -145,15 +150,15 @@ 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
testImplementation libs.mockito.inline
testImplementation libs.robolectric
testImplementation libs.faker
testImplementation libs.ooni.oonimkall
testAnnotationProcessor libs.google.dagger.compiler
kaptTest libs.google.dagger.compiler

// Instrumentation Testing
androidTestImplementation project(':shared-test')
Expand All @@ -166,7 +171,7 @@ dependencies {
androidTestImplementation libs.androidx.espresso.contrib
androidTestImplementation libs.androidx.espresso.core
androidTestImplementation libs.barista
androidTestAnnotationProcessor libs.google.dagger.compiler
kaptAndroidTest libs.google.dagger.compiler
}

static def versionCodeDate() {
Expand Down
20 changes: 13 additions & 7 deletions app/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ task jacocoAndroidTestReport(type: JacocoReport) {
executionData.from += fileTree(dir: codeCoverageDataLocation, includes: ['**/*.ec'])
}

reports {
html.enabled true
html.destination file("${buildDir}/reports/coverage")
xml.enabled true
xml.destination file("${buildDir}/reports/coverage.xml")
csv.enabled false
}
reports {
html {
enabled true
destination file("${buildDir}/reports/coverage")
}
xml {
enabled true
destination file("${buildDir}/reports/coverage.xml")
}
csv {
enabled false
}
}

doLast {
println "Wrote HTML coverage report to ${reports.html.destination}/index.html"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

public class MainActivity extends AbstractActivity implements ConfirmDialogFragment.OnConfirmedListener {
private static final String RES_ITEM = "resItem";
private static final String RES_SNACKBAR_MESSAGE = "resSnackbarMessage";
public static final String NOTIFICATION_DIALOG = "notification";
public static final String AUTOTEST_DIALOG = "automatic_testing";
public static final String BATTERY_DIALOG = "battery_optimization";
Expand All @@ -59,7 +60,14 @@ public static Intent newIntent(Context context, int resItem) {
return new Intent(context, MainActivity.class).putExtra(RES_ITEM, resItem).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}

@Override
public static Intent newIntent(Context context, int resItem, String message) {
return new Intent(context, MainActivity.class)
.putExtra(RES_ITEM, resItem)
.putExtra(RES_SNACKBAR_MESSAGE, message)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
}

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getActivityComponent().inject(this);
Expand All @@ -85,7 +93,17 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
return false;
}
});
// TODO(aanorbel): Fix change in state(theme change from notification) changing the selected item.
aanorbel marked this conversation as resolved.
Show resolved Hide resolved
binding.bottomNavigation.setSelectedItemId(getIntent().getIntExtra(RES_ITEM, R.id.dashboard));
/* Check if we are restoring the activity from a saved state first.
* If we have a message to show, show it as a snackbar.
* This is used to show the message from test completion.
*/
if (savedInstanceState == null && getIntent().hasExtra(RES_SNACKBAR_MESSAGE)) {
Snackbar.make(binding.getRoot(), getIntent().getStringExtra(RES_SNACKBAR_MESSAGE), Snackbar.LENGTH_SHORT)
.setAnchorView(binding.bottomNavigation)
.show();
}
if (notificationManager.shouldShowAutoTest()) {
new ConfirmDialogFragment.Builder()
.withTitle(getString(R.string.Modal_Autorun_Modal_Title))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ protected void onDestroy() {
}

private void testEnded(Context context) {
startActivity(MainActivity.newIntent(context, R.id.testResults));
startActivity(MainActivity.newIntent(context, R.id.testResults,"Probe Run complete"));
finish();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package org.openobservatory.ooniprobe.adapters

import android.content.res.Resources
import android.graphics.PorterDuff
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.cardview.widget.CardView
import androidx.recyclerview.widget.RecyclerView
import org.openobservatory.ooniprobe.R
import org.openobservatory.ooniprobe.common.PreferenceManager
import org.openobservatory.ooniprobe.databinding.ItemSeperatorBinding
import org.openobservatory.ooniprobe.databinding.ItemTestsuiteBinding
import org.openobservatory.ooniprobe.test.suite.AbstractSuite

class DashboardAdapter(
private val items: List<Any>,
private val onClickListener: View.OnClickListener,
private val preferenceManager: PreferenceManager,
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

companion object {
private const val VIEW_TYPE_TITLE = 0
private const val VIEW_TYPE_CARD = 1
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return when (viewType) {
VIEW_TYPE_TITLE -> {
CardGroupTitleViewHolder(
ItemSeperatorBinding.inflate(
LayoutInflater.from(parent.context), parent, false
)
)
}

else -> {
CardViewHolder(
ItemTestsuiteBinding.inflate(
LayoutInflater.from(parent.context), parent, false
)
)
}
}
}

override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val item = items[position]
when (holder.itemViewType) {
VIEW_TYPE_TITLE -> {
val separator = holder as CardGroupTitleViewHolder
separator.binding.root.text = item as String
aanorbel marked this conversation as resolved.
Show resolved Hide resolved
}

VIEW_TYPE_CARD -> {
val cardHolder = holder as CardViewHolder
if (item is AbstractSuite) {
cardHolder.binding.apply {
title.setText(item.title)
desc.setText(item.cardDesc)
icon.setImageResource(item.icon)
}
holder.itemView.tag = item
if (item.isTestEmpty(preferenceManager)) {
holder.setIsRecyclable(false)
holder.itemView.apply {
elevation = 0f
isClickable = false
}
val resources: Resources = holder.itemView.context.resources
(holder.itemView as CardView).setCardBackgroundColor(resources.getColor(R.color.disabled_test_background))
holder.binding.apply {
title.setTextColor(resources.getColor(R.color.disabled_test_text))
desc.setTextColor(resources.getColor(R.color.disabled_test_text))
icon.setColorFilter(resources.getColor(R.color.disabled_test_text), PorterDuff.Mode.SRC_IN)
}
} else {
holder.itemView.setOnClickListener(onClickListener)
}
}
}
}
}

override fun getItemCount(): Int {
return items.size
}

override fun getItemViewType(position: Int): Int {
return when (items[position]) {
is String -> VIEW_TYPE_TITLE
else -> VIEW_TYPE_CARD
}
}

/**
* ViewHolder for dashboard item group
* @param binding
*/
class CardGroupTitleViewHolder(var binding: ItemSeperatorBinding) : RecyclerView.ViewHolder(binding.root)

/**
* ViewHolder for dashboard item
* @param binding
*/
class CardViewHolder(var binding: ItemTestsuiteBinding) : RecyclerView.ViewHolder(binding.root)
}
Loading
Loading