Skip to content

Commit

Permalink
Version 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Threema committed Dec 4, 2023
1 parent dae8136 commit a59da15
Show file tree
Hide file tree
Showing 379 changed files with 12,308 additions and 4,271 deletions.
12 changes: 6 additions & 6 deletions app/assets/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,6 @@ <h2>Emoji art supplied by <a href="http://emojione.com">EmojiOne</a></h2>
<p>Licensed under Creative Commons License (CC-BY 4.0).</p>


<h2>ExoPlayer</h2>

<p>Copyright (c) 2017 Google, Inc.</p>

<p>Licensed under the Apache License, version 2.0 (copy below).</p>

<h2>ez-vcard</h2>

<p>Copyright (c) 2012-2021, Michael Angstadt</p>
Expand Down Expand Up @@ -216,6 +210,12 @@ <h2>ez-vcard</h2>
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.</p>

<h2>Gesture Views</h2>

<p>Copyright (c) 2022 Alex Vasilkov</p>

<p>Licensed under the Apache License, version 2.0 (copy below).</p>

<h2>Jackson JSON-processor</h2>

<p>Copyright (c) 2007-2017 Tatu Saloranta, [email protected]</p>
Expand Down
85 changes: 64 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import com.android.tools.profgen.ArtProfileKt
import com.android.tools.profgen.ArtProfileSerializer
import com.android.tools.profgen.DexFile
import org.jetbrains.kotlin.gradle.tasks.KaptGenerateStubs

plugins {
id 'org.sonarqube'
Expand All @@ -17,8 +18,9 @@ if (getGradle().getStartParameter().getTaskRequests().toString().contains("Hms")
}

// version codes
def app_version = "5.1.4"
def app_version = "5.2"
def beta_suffix = "" // with leading dash
def defaultVersionCode = 930

/**
* Return the git hash, if git is installed.
Expand Down Expand Up @@ -86,17 +88,19 @@ android {
// make sure to adjust them in `scripts/Dockerfile` and
// `.gitlab-ci.yml` as well!
compileSdkVersion 33
buildToolsVersion '33.0.0'
ndkVersion '25.1.8937393'
buildToolsVersion '33.0.2'
ndkVersion '26.0.10792818'

defaultConfig {
// https://developer.android.com/training/testing/espresso/setup#analytics
testInstrumentationRunnerArguments notAnnotation: 'ch.threema.app.TestFastlaneOnly,ch.threema.app.DangerousTest', disableAnalytics: 'true'
minSdkVersion 21
//noinspection OldTargetApi
targetSdkVersion 31
targetSdkVersion 33
vectorDrawables.useSupportLibrary = true
applicationId "ch.threema.app"
testApplicationId 'ch.threema.app.test'
versionCode 922
versionCode defaultVersionCode
versionName "${app_version}${beta_suffix}"
resValue "string", "app_name", "Threema"
// package name used for sync adapter - needs to match mime types below
Expand Down Expand Up @@ -129,6 +133,7 @@ android {
buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.threema.ch/\""
buildConfigField "String", "SAFE_SERVER_URL", "\"https://safe-%h.threema.ch/\""
buildConfigField "String", "WEB_SERVER_URL", "\"https://web.threema.ch/\""
buildConfigField "byte[]", "THREEMA_PUSH_PUBLIC_KEY", "new byte[] {(byte) 0xfd, (byte) 0x71, (byte) 0x1e, (byte) 0x1a, (byte) 0x0d, (byte) 0xb0, (byte) 0xe2, (byte) 0xf0, (byte) 0x3f, (byte) 0xca, (byte) 0xab, (byte) 0x6c, (byte) 0x43, (byte) 0xda, (byte) 0x25, (byte) 0x75, (byte) 0xb9, (byte) 0x51, (byte) 0x36, (byte) 0x64, (byte) 0xa6, (byte) 0x2a, (byte) 0x12, (byte) 0xbd, (byte) 0x07, (byte) 0x28, (byte) 0xd8, (byte) 0x7f, (byte) 0x71, (byte) 0x25, (byte) 0xcc, (byte) 0x24}"
buildConfigField "String", "ONPREM_ID_PREFIX", "\"O\""
buildConfigField "String", "LOG_TAG", "\"3ma\""
buildConfigField "String", "DEFAULT_APP_THEME", "\"2\""
Expand Down Expand Up @@ -157,26 +162,50 @@ android {
}

testInstrumentationRunner 'ch.threema.app.ThreemaTestRunner'
testInstrumentationRunnerArgument 'notAnnotation', 'ch.threema.app.TestFastlaneOnly,ch.threema.app.DangerousTest'
testInstrumentationRunnerArgument 'disableAnalytics', 'true' // https://developer.android.com/training/testing/espresso/setup#analytics

// Only include language resources for those languages
resourceConfigurations += [
"en",
"be-rBY",
"ca",
"cs",
"de",
"es",
"fr",
"hu",
"it",
"ja",
"nl-rNL",
"no",
"pl",
"pt-rBR",
"rm",
"ru",
"sk",
"tr",
"uk",
"zh-rCN",
"zh-rTW"
]
}

splits {
abi {
enable true
reset()
include 'armeabi-v7a', 'x86', "arm64-v8a", "x86_64"
include 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
exclude 'armeabi', 'mips', 'mips64'
universalApk true
}
}

// Assign different version code for each output
project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
def abiVersionCodes = ['armeabi-v7a': 2, 'arm64-v8a': 3, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
def abi = output.getFilter("ABI")
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
abiVersionCodes.get(abi, 0) * 1000000 + defaultVersionCode
}
}

Expand Down Expand Up @@ -586,6 +615,10 @@ android {
outputs.upToDateWhen { false }
exceptionFormat = 'full'
}

jvmArgs = jvmArgs + ['--add-opens=java.base/java.util=ALL-UNNAMED']
jvmArgs = jvmArgs + ['--add-opens=java.base/java.util.stream=ALL-UNNAMED']
jvmArgs = jvmArgs + ['--add-opens=java.base/java.lang=ALL-UNNAMED']
}
// By default, local unit tests throw an exception any time the code you are testing tries to access
// Android platform APIs (unless you mock Android dependencies yourself or with a testing
Expand All @@ -602,12 +635,12 @@ android {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

kotlin {
jvmToolchain(11)
jvmToolchain(17)
}

androidResources {
Expand Down Expand Up @@ -687,6 +720,7 @@ dependencies {
}

implementation project(':domain')
implementation project(path: ':task-manager')

implementation 'net.zetetic:sqlcipher-android:4.5.5@aar'

Expand All @@ -699,21 +733,22 @@ dependencies {
implementation 'org.apache.commons:commons-text:1.10.0'
implementation "org.slf4j:slf4j-api:$slf4j_version"
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.28'
implementation 'com.github.CanHub:Android-Image-Cropper:4.3.0'
implementation 'com.vanniktech:android-image-cropper:4.5.0'
implementation 'com.datatheorem.android.trustkit:trustkit:1.1.5'
implementation 'me.zhanghai.android.fastscroll:library:1.2.0'
implementation 'me.zhanghai.android.fastscroll:library:1.3.0'
implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
implementation 'com.alexvasilkov:gesture-views:2.8.3'

// AndroidX / Jetpack support libraries
implementation "androidx.preference:preference-ktx:1.2.1"
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.biometric:biometric:1.1.0'
implementation 'androidx.work:work-runtime-ktx:2.8.1'
implementation 'androidx.fragment:fragment-ktx:1.5.7'
implementation 'androidx.fragment:fragment-ktx:1.6.2'
implementation 'androidx.activity:activity-ktx:1.7.2'
implementation 'androidx.sqlite:sqlite:2.2.2'
implementation "androidx.concurrent:concurrent-futures:1.1.0"
Expand All @@ -734,7 +769,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-process:2.6.2"
implementation "androidx.lifecycle:lifecycle-common-java8:2.6.2"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
implementation "androidx.paging:paging-runtime-ktx:3.2.1"
implementation "androidx.sharetarget:sharetarget:1.2.0"
implementation 'androidx.room:room-runtime:2.5.2'
kapt 'androidx.room:room-compiler:2.5.2'
Expand Down Expand Up @@ -802,7 +837,7 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.4.0', {
exclude group: 'androidx.annotation', module: 'annotation'
}
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0', {
exclude group: 'androidx.annotation', module: 'annotation'
exclude group: 'androidx.appcompat', module: 'appcompat'
Expand All @@ -816,14 +851,16 @@ dependencies {
exclude group: 'androidx.annotation', module: 'annotation'
}
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test:core-ktx:1.5.0'
androidTestImplementation "org.mockito:mockito-core:4.8.1"

// Google Play Services and related libraries
def googleDependencies = [
// Play services
'com.google.android.gms:play-services-base:18.1.0': [],

// Firebase push
'com.google.firebase:firebase-messaging:23.1.2': [
'com.google.firebase:firebase-messaging:23.2.1': [
[group: 'com.google.firebase', module: 'firebase-core'],
[group: 'com.google.firebase', module: 'firebase-analytics'],
[group: 'com.google.firebase', module: 'firebase-measurement-connector'],
Expand Down Expand Up @@ -880,8 +917,14 @@ dependencies {
hmsImplementation(dependency) { excludes.each { exclude it } }
hms_workImplementation(dependency) { excludes.each { exclude it } }
}
hmsImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
hms_workImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
hmsImplementation(name: 'agconnect-core-1.9.1.301', ext: 'aar')
hms_workImplementation(name: 'agconnect-core-1.9.1.301', ext: 'aar')
}

tasks.withType(KaptGenerateStubs).configureEach {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_11.toString()
}
}

sonarqube {
Expand Down
4 changes: 4 additions & 0 deletions app/jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/scrypt/include
LOCAL_CFLAGS += -DANDROID -DHAVE_CONFIG_H -DANDROID_TARGET_ARCH="$(TARGET_ARCH)"
LOCAL_LDFLAGS += -lc -llog

LOCAL_LDFLAGS += -Wl,--build-id=none # Reproducible builds

include $(BUILD_SHARED_LIBRARY)

# libnacl
Expand All @@ -39,4 +41,6 @@ LOCAL_SRC_FILES += $(LOCAL_PATH)/nacl/curve25519-jni.c
LOCAL_SRC_FILES += $(LOCAL_PATH)/nacl/smult_donna.c
LOCAL_SRC_FILES += $(LOCAL_PATH)/nacl/smult_donna-c64.c

LOCAL_LDFLAGS += -Wl,--build-id=none # Reproducible builds

include $(BUILD_SHARED_LIBRARY)
Binary file removed app/libs/agconnect-apms-plugin-1.5.2.302.jar
Binary file not shown.
Binary file added app/libs/agconnect-apms-plugin-1.6.2.300.jar
Binary file not shown.
Binary file removed app/libs/agconnect-core-1.5.0.300.aar
Binary file not shown.
Binary file added app/libs/agconnect-core-1.9.1.301.aar
Binary file not shown.
Binary file removed app/libs/agconnect-crash-symbol-lib-1.6.0.300.jar
Binary file not shown.
Binary file added app/libs/agconnect-crash-symbol-lib-1.9.1.301.jar
Binary file not shown.
Binary file removed app/libs/agcp-1.6.0.300.jar
Binary file not shown.
Binary file added app/libs/agcp-1.9.1.301.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion app/proguard-project.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-dontobfuscate
-verbose

-keepattributes EnclosingMethod,InnerClasses,Exceptions,*Annotation*,SourceFile,LineNumberTable
-keepattributes EnclosingMethod,InnerClasses,Exceptions,*Annotation*,SourceFile,LineNumberTable,Signature

-keeppackagenames ch.threema.**
-keeppackagenames org.saltyrtc.**
Expand Down
53 changes: 53 additions & 0 deletions app/src/androidTest/java/ch/threema/app/PermissionRuleUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* _____ _
* |_ _| |_ _ _ ___ ___ _ __ __ _
* | | | ' \| '_/ -_) -_) ' \/ _` |_
* |_| |_||_|_| \___\___|_|_|_\__,_(_)
*
* Threema for Android
* Copyright (c) 2023 Threema GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package ch.threema.app

import android.os.Build
import androidx.test.rule.GrantPermissionRule

/**
* Get the permission rule for the notification permission. This method can be used to only grant
* the permission for Android TIRAMISU and newer.
*/
fun getNotificationPermissionRule(): GrantPermissionRule {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
GrantPermissionRule.grant(android.Manifest.permission.POST_NOTIFICATIONS)
} else {
GrantPermissionRule.grant()
}
}

/**
* Get the READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE permissions. This method can be used to
* grant the permissions only for those android versions that need them.
*/
fun getReadWriteExternalStoragePermissionRule(): GrantPermissionRule {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// Not needed for Q and newer, therefore return an empty grant permission rule
GrantPermissionRule.grant()
} else {
GrantPermissionRule.grant(
android.Manifest.permission.READ_EXTERNAL_STORAGE,
android.Manifest.permission.WRITE_EXTERNAL_STORAGE
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import android.util.Log;

import org.junit.Rule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestWatcher;
import org.junit.runner.Description;
Expand All @@ -35,9 +34,10 @@
import java.io.OutputStream;

import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.rule.GrantPermissionRule;
import androidx.test.uiautomator.UiDevice;

import static ch.threema.app.PermissionRuleUtilsKt.getReadWriteExternalStoragePermissionRule;

/**
* When a test fails, take a screenshot.
*
Expand All @@ -50,14 +50,10 @@ private ScreenshotTakingRule() { /* Use getRuleChain instead */ }

public static RuleChain getRuleChain() {
return RuleChain
.outerRule(GrantPermissionRule.grant(
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE"
))
.outerRule(getReadWriteExternalStoragePermissionRule())
.around(new ScreenshotTakingRule());
}

@SuppressWarnings("ResultOfMethodCallIgnored")
@Override
protected void failed(Throwable e, Description description) {
final UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
Expand All @@ -76,7 +72,7 @@ protected void failed(Throwable e, Description description) {

// Dump UI state
try {
try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(new File(basePath + ".uix")))) {
try (OutputStream stream = new BufferedOutputStream(new FileOutputStream(basePath + ".uix"))) {
// Note: Explicitly opening and closing stream since the UiAutomator dumpWindowHierarchy(File)
// method leaks a file descriptor.
device.dumpWindowHierarchy(stream);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

package ch.threema.app.backuprestore.csv;

import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
Expand Down Expand Up @@ -73,6 +72,8 @@
import ch.threema.storage.models.data.status.VoipStatusDataModel;
import java8.util.stream.StreamSupport;

import static ch.threema.app.PermissionRuleUtilsKt.getReadWriteExternalStoragePermissionRule;

@RunWith(AndroidJUnit4.class)
@LargeTest
@DangerousTest // Deletes data and possibly identity
Expand All @@ -94,7 +95,7 @@ public class BackupServiceTest {
private @NonNull BallotService ballotService;

@Rule
public GrantPermissionRule permissionRule = GrantPermissionRule.grant(Manifest.permission.WRITE_EXTERNAL_STORAGE);
public GrantPermissionRule permissionRule = getReadWriteExternalStoragePermissionRule();

/**
* Ensure that an identity is set up, initialize static {@link #TEST_IDENTITY} variable.
Expand Down
Loading

0 comments on commit a59da15

Please sign in to comment.