Skip to content

Commit

Permalink
Chore: Updated flavor definition to allow resource separation (#634)
Browse files Browse the repository at this point in the history
## Proposed Changes

- Define `flavorDimensions` for `provider` where specific resources for
`ooni` or `dw` can be placed.
- Provide base strings in the main resources `English` where more
languages can be added in the provider folders and supported languages
added.
  - Move `ooni` specific translations to the right folder.

---------

Co-authored-by: Simone Basso <bassosimone@gmail.com>
  • Loading branch information
aanorbel and bassosimone authored Dec 5, 2023
1 parent 4650b5a commit 50f9d4b
Show file tree
Hide file tree
Showing 97 changed files with 694 additions and 600 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
- run: ./gradlew clean assembleDevFullRelease
- run: ./gradlew clean assembleOoniDevFullRelease
- name: uploads dev apk
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
strategy:
matrix:
version:
- "StableFullRelease"
- "StableFdroidRelease"
- "OoniStableFullRelease"
- "OoniStableFdroidRelease"
steps:
- uses: actions/setup-java@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/emulator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
arch: x86_64
profile: Nexus 6
ram-size: 2048M
script: ./gradlew connectedStableFullDebugAndroidTest
script: ./gradlew connectedOoniStableFullDebugAndroidTest
- name: uploads test results
uses: actions/upload-artifact@v2
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
distribution: 'temurin'
- name: checkout
uses: actions/checkout@v2
- run: ./gradlew testStableFullRelease
- run: ./gradlew testOoniStableFullRelease
- name: uploads test results
uses: actions/upload-artifact@v2
if: failure()
Expand Down
69 changes: 34 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,85 +61,84 @@ implement the following flavours:

- `full` and `fdroid` (dimension: `license`).

- `ooni` and `dw` (dimension: `brand`).

The `testing` dimension controls whether we're building a release
or a more unstable version. We build releases using the `stable`
flavour. The `dev` flavour builds the version of the app that should
be released on the store as the beta channel. The `experimental`
flavour, instead, allows a developer to build a one-off version of
the app that uses a custom build of the `oonimkall` library.

For `stable` and `dev`, we fetch `oonimkall` from the
[Maven central](https://search.maven.org/artifact/org.ooni/oonimkall)
repository. The `experimental` flavour, instead, requires you to
put the `oonimkall.aar` you built inside `engine-experimental`.

The `license` dimension controls which proprietary libraries to include
into the build. The `full` flavour includes all such dependencies,
while the `fdroid` flavour does not include any of them.

The variant names are therefore:
The `brand` dimension controls the branding of the application. The `ooni` flavour is the default branding, while the `dw` flavour is for the "News Media Scan" branding.

- `experimentalFullDebug`
- `experimentalFullRelease`
- `devFullDebug`
- `devFullRelease`
- `stableFullDebug`
- `stableFullRelease`
The variant names are therefore:

We additionally have `stableFdroidDebug` and `stableFdroidRelease`.
- `ooniExperimentalFullDebug`
- `ooniExperimentalFullRelease`
- `ooniDevFullDebug`
- `ooniDevFullRelease`
- `ooniStableFullDebug`
- `ooniStableFullRelease`
- `dwExperimentalFullDebug`
- `dwExperimentalFullRelease`
- `dwDevFullDebug`
- `dwDevFullRelease`
- `dwStableFullDebug`
- `dwStableFullRelease`

We additionally have `ooniStableFdroidDebug`, `ooniStableFdroidRelease`, `dwStableFdroidDebug` and `dwStableFdroidRelease`.

All of this is controlled by [app/build.gradle](app/build.gradle).

## Gradle modules

- [app](app) contains the mobile app;
- [engine](engine) contains wrappers for `oonimkall`, the
measurement engine library;
- [engine-experimental](engine-experimental) allows us
to implement the `experimental` build flavour where you
put the `oonimkall.aar` file you built inside `engine-experimental`
rather than downloading it from Maven Central.
- [engine](engine) contains wrappers for `oonimkall`, the measurement engine library;
- [engine-experimental](engine-experimental) allows us to implement the `experimental` build flavour where you put the `oonimkall.aar` file you built inside `engine-experimental` rather than downloading it from Maven Central.

## Building an apk

Ensure you have Android Studio and Android SDK installed. Build the `devFullRelease`
Ensure you have Android Studio and Android SDK installed. Build the `ooniDevFullRelease`
variant using Android Studio or this command line:

```
./gradlew assembleDevFullRelease
```sh
./gradlew assembleOoniDevFullRelease
```

## Building the app for f-droid

Instead to build the app to stay compliant to F-Droid use `fdroid`, which
contains small tweaks required to have the app accepted by [f-droid](https://f-droid.org/).
Instead to build the app to stay compliant to F-Droid use `fdroid`, which contains small tweaks required to have the app accepted by [f-droid](https://f-droid.org/).

```
./gradlew assembleFdroid
```sh
./gradlew assembleOoniDevFullRelease
```

## Testing

Run unit tests
Run unit tests/

```
./gradlew testStableFullDebug
```sh
./gradlew testOoniStableFullDebug
```

Run instrumented tests

_Note: To also run the automation tests (to generate screenshots), set the Build Config flag
`RUN_AUTOMATION` as true._
_Note: To also run the automation tests (to generate screenshots), set the Build Config flag `RUN_AUTOMATION` as true._

```
./gradlew connectedStableFullDebugAndroidTest
```sh
./gradlew connectedOoniStableFullDebugAndroidTest
```

Generate code coverage report (after all unit and instrumented tests successfully passed)

```
```sh
./gradlew jacocoAndroidTestReport
```
```

## Managing translations

Expand Down
30 changes: 17 additions & 13 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,21 @@ android {
}
}

flavorDimensions 'testing', 'license'
flavorDimensions = ['brand', 'testing', 'license']

productFlavors {
ooni {
getIsDefault().set(true)
dimension 'brand'
}
dw {
dimension 'brand'
applicationId 'com.dw.ooniprobe'
resValue "string", "APP_ID", 'com.dw.ooniprobe'
resValue "string", "APP_NAME", "News Media Scan"
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"news-media-scan-android"'
buildConfigField "boolean", "SHOW_DISABLED_CARDS", "false"
}
stable {
dimension 'testing'
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android"'
Expand All @@ -59,7 +72,6 @@ android {
versionNameSuffix "-beta.1"
versionCode versionCodeDate()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-dev"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.dev'
resValue "string", "APP_NAME", "OONI Dev"
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
}
Expand All @@ -69,7 +81,6 @@ android {
versionNameSuffix "-experimental.1"
versionCode versionCodeDate()
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"ooniprobe-android-experimental"'
resValue "string", "APP_ID", 'org.openobservatory.ooniprobe.experimental'
resValue "string", "APP_NAME", "OONI Exp"
buildConfigField 'String', 'COUNTLY_KEY', '"e6c2cfe53e85951d50567467cef3f9fa2eab32c3"'
}
Expand All @@ -79,16 +90,9 @@ android {
full {
dimension 'license'
}
dw {
dimension 'testing'
applicationId 'com.dw.ooniprobe'
resValue "string", "APP_ID", 'com.dw.ooniprobe'
resValue "string", "APP_NAME", "News Media Scan"
buildConfigField 'String', 'BASE_SOFTWARE_NAME', '"news-media-scan-android"'
buildConfigField "boolean", "SHOW_DISABLED_CARDS", "false"
//versionName '0.0.1'
//versionCode 1
}
}
applicationVariants.all { variant ->
variant.resValue "string", "APP_ID", "\"${applicationId}\""
}
variantFilter { variant ->
def names = variant.flavors*.name
Expand Down
3 changes: 3 additions & 0 deletions app/src/dw/dev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# News Media Scan Dev
This is a collection of resources to be used by the News Media Scan specific flavors of the application.
A corresponding directory exits in [app/src/ooni](../../ooni).
56 changes: 56 additions & 0 deletions app/src/dw/dev/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"project_info": {
"project_number": "951667061699",
"firebase_url": "https://ooniprobe-android.firebaseio.com",
"project_id": "ooniprobe-android",
"storage_bucket": "ooniprobe-android.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:951667061699:android:6293922d7e8d4180374376",
"android_client_info": {
"package_name": "com.dw.ooniprobe.dev"
}
},
"oauth_client": [
{
"client_id": "951667061699-6ijvga26pl048jrqfnd33o60bqcn0g7c.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.dw.ooniprobe.dev",
"certificate_hash": "a8f4bc5bef49e43d386647bdffdad32c07a8d3b8"
}
},
{
"client_id": "951667061699-2aq9bnbot04qdjbed2bpnl9ee4ro0c39.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBsbX_pOQoqlyOOyZ6yf7CJf0lZZn6O1yg"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "951667061699-2aq9bnbot04qdjbed2bpnl9ee4ro0c39.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "951667061699-tuprsdjjv9eje6506lkvkski1p6v87lp.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "org.openobservatory.ooniprobe",
"app_store_id": "1199566366"
}
}
]
}
}
}
],
"configuration_version": "1"
}
56 changes: 56 additions & 0 deletions app/src/dw/experimental/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"project_info": {
"project_number": "951667061699",
"firebase_url": "https://ooniprobe-android.firebaseio.com",
"project_id": "ooniprobe-android",
"storage_bucket": "ooniprobe-android.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:951667061699:android:6293922d7e8d4180374376",
"android_client_info": {
"package_name": "com.dw.ooniprobe.experimental"
}
},
"oauth_client": [
{
"client_id": "951667061699-6ijvga26pl048jrqfnd33o60bqcn0g7c.apps.googleusercontent.com",
"client_type": 1,
"android_info": {
"package_name": "com.dw.ooniprobe.experimental",
"certificate_hash": "a8f4bc5bef49e43d386647bdffdad32c07a8d3b8"
}
},
{
"client_id": "951667061699-2aq9bnbot04qdjbed2bpnl9ee4ro0c39.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyBsbX_pOQoqlyOOyZ6yf7CJf0lZZn6O1yg"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "951667061699-2aq9bnbot04qdjbed2bpnl9ee4ro0c39.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "951667061699-tuprsdjjv9eje6506lkvkski1p6v87lp.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "org.openobservatory.ooniprobe",
"app_store_id": "1199566366"
}
}
]
}
}
}
],
"configuration_version": "1"
}
Binary file modified app/src/dw/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/dw/res/drawable-xxxhdpi/info_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/src/dw/res/drawable-xxxhdpi/onboarding_1.png
Binary file not shown.
Binary file removed app/src/dw/res/drawable-xxxhdpi/onboarding_2.png
Binary file not shown.
Binary file removed app/src/dw/res/drawable-xxxhdpi/onboarding_3.png
Binary file not shown.
Binary file added app/src/dw/res/drawable/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions app/src/dw/res/layout/activity_info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax" >
<ImageView
<include
android:id="@+id/image"
android:layout_height="200dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/info_banner" />
layout="@layout/banner"/>
<TextView
android:id="@+id/version"
android:layout_width="match_parent"
Expand Down
21 changes: 21 additions & 0 deletions app/src/dw/res/layout/banner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="180dp">
<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/info_banner" />
<ImageView
android:layout_marginTop="-90dp"
android:layout_marginBottom="-70dp"
android:layout_marginStart="-10dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentTop="true"
android:src="@drawable/logo"/>
</RelativeLayout>
Loading

0 comments on commit 50f9d4b

Please sign in to comment.