Skip to content

Commit

Permalink
Merge pull request #3228 from TeamAmaze/feature/gradle-7.4-lib-upgrades
Browse files Browse the repository at this point in the history
Upgrade Gradle to 7.4 + lib upgrades + Target SDK 31 + publish test report at Github actions
  • Loading branch information
VishalNehra authored Nov 18, 2022
2 parents 62c53ab + 0a843b5 commit 7761b94
Show file tree
Hide file tree
Showing 37 changed files with 381 additions and 237 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/android-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "corretto"
distribution: "temurin"
java-version: 11
- name: Check formatting using spotless
uses: gradle/gradle-build-action@v2
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
distribution: "corretto"
distribution: "temurin"
java-version: 11
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
Expand All @@ -44,4 +44,11 @@ jobs:
- name: Run test cases
uses: gradle/gradle-build-action@v2
with:
arguments: jacocoTestPlayDebugUnitTestReport --stacktrace --info
arguments: jacocoTestPlayDebugUnitTestReport --stacktrace --info
- name: Publish test results
uses: dorny/test-reporter@v1
if: always()
with:
name: test-results
path: 'app/build/test-results/testPlayDebugUnitTest/TEST-*.xml'
reporter: java-junit
25 changes: 17 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android {
defaultConfig {
applicationId "com.amaze.filemanager"
minSdkVersion 14
targetSdkVersion 30
targetSdkVersion 31
versionCode 115
versionName "3.8.3"
multiDexEnabled true
Expand Down Expand Up @@ -80,6 +80,10 @@ android {
}
}

sourceSets {
test.java.srcDirs += '../testShared/src/test/java'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -127,7 +131,7 @@ dependencies {
kapt "androidx.room:room-compiler:$roomVersion"
// RxJava support for Room
implementation "androidx.room:room-rxjava2:$roomVersion"
kapt 'androidx.annotation:annotation:1.2.0'
kapt "androidx.annotation:annotation:$androidXAnnotationVersion"

implementation "androidx.preference:preference:$androidXPrefVersion"
implementation "androidx.preference:preference-ktx:$androidXPrefVersion"
Expand All @@ -145,7 +149,7 @@ dependencies {
testImplementation "org.mockito.kotlin:mockito-kotlin:$mockitoKotlinVersion"
testImplementation "org.apache.sshd:sshd-core:1.7.0"
testImplementation "org.awaitility:awaitility:$awaitilityVersion"
testImplementation 'org.jsoup:jsoup:1.11.2'
testImplementation "org.jsoup:jsoup:$jsoupVersion"
testImplementation "androidx.room:room-migration:$roomVersion"
testImplementation "io.mockk:mockk:$mockkVersion"
kaptTest "com.google.auto.service:auto-service:1.0-rc4"
Expand All @@ -157,7 +161,7 @@ dependencies {
androidTestImplementation "androidx.test:rules:$androidXTestVersion"
androidTestImplementation "androidx.test.ext:junit:$androidXTestExtVersion"
// androidTestImplementation "androidx.test.uiautomator:uiautomator:$uiAutomatorVersion"
androidTestImplementation 'commons-net:commons-net:3.6'
androidTestImplementation "commons-net:commons-net:$commonsNetVersion"
androidTestImplementation "org.awaitility:awaitility:$awaitilityVersion"

//Detect memory leaks
Expand All @@ -175,11 +179,11 @@ dependencies {

//implementation files('libs/ftplet-api-1.1.0-SNAPSHOT.jar')
// https://mvnrepository.com/artifact/org.apache.ftpserver/ftplet-api
implementation group: 'org.apache.ftpserver', name: 'ftplet-api', version: '1.1.1'
implementation "org.apache.ftpserver:ftplet-api:$ftpserverVersion"

//implementation files('libs/ftpserver-core-1.1.0-SNAPSHOT.jar')
// https://mvnrepository.com/artifact/org.apache.ftpserver/ftpserver-core
implementation group: 'org.apache.ftpserver', name: 'ftpserver-core', version: '1.1.1'
implementation "org.apache.ftpserver:ftpserver-core:$ftpserverVersion"

implementation 'org.greenrobot:eventbus:3.3.1'

Expand Down Expand Up @@ -237,10 +241,10 @@ dependencies {

implementation project(':commons_compress_7z')
implementation project(':file_operations')
implementation "androidx.core:core-ktx:$kotlin_version"
implementation "androidx.core:core-ktx:$androidXCoreVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "ch.acra:acra-core:5.7.0"
runtimeOnly 'org.slf4j:slf4j-api:1.7.32'
runtimeOnly 'org.slf4j:slf4j-api:1.7.36'
runtimeOnly "com.github.tony19:logback-android:$logbackAndroidVersion"
}

Expand Down Expand Up @@ -288,6 +292,11 @@ jacoco {
toolVersion = "${jacocoVersion}"
}

jacocoAndroidUnitTestReport {
html.enabled true
xml.enabled true
}

tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
jacoco.excludes = ['jdk.internal.*']
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
android:banner="@drawable/about_header">

<activity
android:exported="true"
android:label="@string/appbar_name"
android:launchMode="singleInstance"
android:name=".ui.activities.MainActivity"
Expand Down Expand Up @@ -130,6 +131,7 @@
</activity>

<activity
android:exported="true"
android:uiOptions="splitActionBarWhenNarrow"
android:configChanges="orientation|screenSize|uiMode"
android:label="@string/setting"
Expand All @@ -142,6 +144,7 @@

</activity>
<activity
android:exported="true"
android:label="@string/textreader"
android:name=".ui.activities.texteditor.TextEditorActivity"
android:configChanges="uiMode"
Expand All @@ -159,6 +162,7 @@

</activity>
<activity
android:exported="true"
android:label="@string/databasereader"
android:name=".ui.activities.DatabaseViewerActivity"
android:theme="@style/appCompatBlack"
Expand Down Expand Up @@ -278,6 +282,7 @@
android:permission="${applicationId}.permission.CONTROL_FTP_SERVER"/>

<service android:name=".asynchronous.services.ftp.FtpTileService"
android:exported="true"
android:icon="@drawable/ic_ftp_dark"
android:label="@string/ftp"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

package com.amaze.filemanager.asynchronous.services;

import static android.app.PendingIntent.FLAG_IMMUTABLE;
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.S;

import java.util.ArrayList;

import org.slf4j.Logger;
Expand All @@ -35,7 +40,6 @@
import com.amaze.filemanager.utils.ProgressHandler;
import com.amaze.filemanager.utils.Utils;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
Expand All @@ -47,6 +51,7 @@
import androidx.annotation.CallSuper;
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;

/**
* @author Emmanuel Messulam <[email protected]> on 28/11/2017, at 19:32.
Expand All @@ -72,7 +77,7 @@ public void onCreate() {
wakeLock.setReferenceCounted(false);
}

protected abstract NotificationManager getNotificationManager();
protected abstract NotificationManagerCompat getNotificationManager();

protected abstract NotificationCompat.Builder getNotificationBuilder();

Expand Down Expand Up @@ -342,7 +347,7 @@ void finalizeNotification(ArrayList<HybridFile> failedOps, boolean move) {
intent.putExtra("move", move);

PendingIntent pIntent =
PendingIntent.getActivity(this, 101, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.getActivity(this, 101, intent, getPendingIntentFlag(FLAG_UPDATE_CURRENT));

mBuilder.setContentIntent(pIntent);
mBuilder.setSmallIcon(R.drawable.ic_folder_lock_open_white_36dp);
Expand Down Expand Up @@ -383,4 +388,20 @@ public void initNotificationViews() {
.setProgressBar(R.id.notification_service_progressBar_big, 0, 0, true);
getNotificationManager().notify(getNotificationId(), getNotificationBuilder().build());
}

/**
* For compatibility purposes. Wraps the pending intent flag, return with FLAG_IMMUTABLE if device
* SDK >= 32.
*
* @see PendingIntent.FLAG_IMMUTABLE
* @param pendingIntentFlag proposed PendingIntent flag
* @return original PendingIntent flag if SDK < 32, otherwise adding FLAG_IMMUTABLE flag.
*/
public static int getPendingIntentFlag(final int pendingIntentFlag) {
if (SDK_INT < S) {
return pendingIntentFlag;
} else {
return pendingIntentFlag | FLAG_IMMUTABLE;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

package com.amaze.filemanager.asynchronous.services;

import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;

import java.io.IOException;
import java.util.ArrayList;

Expand Down Expand Up @@ -49,7 +51,6 @@
import com.amaze.filemanager.utils.ObtainableServiceBinder;
import com.amaze.filemanager.utils.ProgressHandler;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -64,6 +65,7 @@

import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.preference.PreferenceManager;

public class CopyService extends AbstractProgressiveService {
Expand All @@ -77,7 +79,7 @@ public class CopyService extends AbstractProgressiveService {

public static final String TAG_BROADCAST_COPY_CANCEL = "copycancel";

private NotificationManager mNotifyManager;
private NotificationManagerCompat mNotifyManager;
private NotificationCompat.Builder mBuilder;
private Context c;

Expand Down Expand Up @@ -118,22 +120,23 @@ public int onStartCommand(Intent intent, int flags, final int startId) {
.getCurrentUserColorPreferences(this, sharedPreferences)
.getAccent();

mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotifyManager = NotificationManagerCompat.from(getApplicationContext());
b.putInt(TAG_COPY_START_ID, startId);

Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, notificationIntent, getPendingIntentFlag(0));

customSmallContentViews =
new RemoteViews(getPackageName(), R.layout.notification_service_small);
customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);

Intent stopIntent = new Intent(TAG_BROADCAST_COPY_CANCEL);
PendingIntent stopPendingIntent =
PendingIntent.getBroadcast(c, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.getBroadcast(c, 1234, stopIntent, getPendingIntentFlag(FLAG_UPDATE_CURRENT));
NotificationCompat.Action action =
new NotificationCompat.Action(
R.drawable.ic_content_copy_white_36dp, getString(R.string.stop_ftp), stopPendingIntent);
Expand Down Expand Up @@ -172,7 +175,7 @@ public int onStartCommand(Intent intent, int flags, final int startId) {
}

@Override
protected NotificationManager getNotificationManager() {
protected NotificationManagerCompat getNotificationManager() {
return mNotifyManager;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

package com.amaze.filemanager.asynchronous.services;

import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
import static com.amaze.filemanager.asynchronous.services.EncryptService.TAG_PASSWORD;

import java.util.ArrayList;
Expand All @@ -46,7 +47,6 @@
import com.amaze.filemanager.utils.ObtainableServiceBinder;
import com.amaze.filemanager.utils.ProgressHandler;

import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
Expand All @@ -59,6 +59,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.StringRes;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.preference.PreferenceManager;

/**
Expand All @@ -73,7 +74,7 @@ public class DecryptService extends AbstractProgressiveService {
public static final String TAG_BROADCAST_CRYPT_CANCEL = "crypt_cancel";
private final Logger LOG = LoggerFactory.getLogger(DecryptService.class);

private NotificationManager notificationManager;
private NotificationManagerCompat notificationManager;
private NotificationCompat.Builder notificationBuilder;
private Context context;
private final IBinder mBinder = new ObtainableServiceBinder<>(this);
Expand Down Expand Up @@ -114,20 +115,22 @@ public int onStartCommand(Intent intent, int flags, int startId) {

OpenMode openMode =
OpenMode.values()[intent.getIntExtra(TAG_OPEN_MODE, OpenMode.UNKNOWN.ordinal())];
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager = NotificationManagerCompat.from(getApplicationContext());
Intent notificationIntent = new Intent(this, MainActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
notificationIntent.putExtra(MainActivity.KEY_INTENT_PROCESS_VIEWER, true);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
PendingIntent pendingIntent =
PendingIntent.getActivity(this, 0, notificationIntent, getPendingIntentFlag(0));

customSmallContentViews =
new RemoteViews(getPackageName(), R.layout.notification_service_small);
customBigContentViews = new RemoteViews(getPackageName(), R.layout.notification_service_big);

Intent stopIntent = new Intent(TAG_BROADCAST_CRYPT_CANCEL);
PendingIntent stopPendingIntent =
PendingIntent.getBroadcast(context, 1234, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.getBroadcast(
context, 1234, stopIntent, getPendingIntentFlag(FLAG_UPDATE_CURRENT));
NotificationCompat.Action action =
new NotificationCompat.Action(
R.drawable.ic_folder_lock_open_white_36dp,
Expand Down Expand Up @@ -161,7 +164,7 @@ public int onStartCommand(Intent intent, int flags, int startId) {
}

@Override
protected NotificationManager getNotificationManager() {
protected NotificationManagerCompat getNotificationManager() {
return notificationManager;
}

Expand Down
Loading

0 comments on commit 7761b94

Please sign in to comment.