diff --git a/build.gradle b/build.gradle index 3200257b..ec552256 100644 --- a/build.gradle +++ b/build.gradle @@ -1,13 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.2.71' + ext.kotlin_version = '1.6.21' repositories { jcenter() google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.1' + classpath 'com.android.tools.build:gradle:7.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong diff --git a/filestack/build.gradle b/filestack/build.gradle index 09b419d4..7c9caa0b 100644 --- a/filestack/build.gradle +++ b/filestack/build.gradle @@ -1,5 +1,4 @@ plugins { - id 'com.github.dcendents.android-maven' version '2.0' id 'com.jfrog.bintray' version '1.7.3' } @@ -11,15 +10,14 @@ version = '5.3.0' project.archivesBaseName = 'filestack-android' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { minSdkVersion 16 - targetSdkVersion 28 - versionCode 1 - versionName version + targetSdkVersion 33 + multiDexEnabled = true - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' vectorDrawables { useSupportLibrary true @@ -40,14 +38,14 @@ android { dependencies { api 'com.filestack:filestack-java:0.9.0' - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support:design:28.0.0' - implementation 'com.android.support:customtabs:28.0.0' + implementation 'androidx.appcompat:appcompat:1.0.0' + implementation 'com.google.android.material:material:1.0.0' + implementation 'androidx.browser:browser:1.0.0' implementation 'com.squareup.picasso:picasso:2.5.2' implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) testImplementation 'junit:junit:4.12' diff --git a/filestack/src/androidTest/java/com/filestack/android/ExampleInstrumentedTest.java b/filestack/src/androidTest/java/com/filestack/android/ExampleInstrumentedTest.java index f283db20..91c5dd0e 100644 --- a/filestack/src/androidTest/java/com/filestack/android/ExampleInstrumentedTest.java +++ b/filestack/src/androidTest/java/com/filestack/android/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.filestack.android; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/filestack/src/main/AndroidManifest.xml b/filestack/src/main/AndroidManifest.xml index 1bb5843f..4d6bac88 100644 --- a/filestack/src/main/AndroidManifest.xml +++ b/filestack/src/main/AndroidManifest.xml @@ -8,13 +8,14 @@ + android:supportsRtl="true" > + android:theme="@style/FilestackNoActionBar" + android:exported="true"> diff --git a/filestack/src/main/java/com/filestack/android/FsActivity.java b/filestack/src/main/java/com/filestack/android/FsActivity.java index 206adf66..a526c766 100644 --- a/filestack/src/main/java/com/filestack/android/FsActivity.java +++ b/filestack/src/main/java/com/filestack/android/FsActivity.java @@ -5,41 +5,36 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; -import android.graphics.Color; import android.graphics.PorterDuff; import android.graphics.drawable.Drawable; import android.os.Build; import android.os.Bundle; -import android.support.annotation.ColorInt; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.design.widget.NavigationView; -import android.support.v4.app.ActivityCompat; -import android.support.v4.app.Fragment; -import android.support.v4.app.FragmentManager; -import android.support.v4.app.FragmentTransaction; -import android.support.v4.content.ContextCompat; -import android.support.v4.graphics.ColorUtils; -import android.support.v4.graphics.drawable.DrawableCompat; -import android.support.v4.view.GravityCompat; -import android.support.v4.view.MenuCompat; -import android.support.v4.view.MenuItemCompat; -import android.support.v4.view.ViewCompat; -import android.support.v4.view.WindowCompat; -import android.support.v4.widget.DrawerLayout; -import android.support.v4.widget.ImageViewCompat; -import android.support.v7.app.ActionBarDrawerToggle; -import android.support.v7.app.AlertDialog; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.widget.AppCompatImageButton; -import android.support.v7.widget.Toolbar; +import androidx.annotation.ColorInt; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import com.google.android.material.navigation.NavigationView; +import androidx.core.app.ActivityCompat; +import androidx.fragment.app.Fragment; +import androidx.core.content.ContextCompat; +import androidx.core.graphics.ColorUtils; +import androidx.core.graphics.drawable.DrawableCompat; +import androidx.core.view.GravityCompat; +import androidx.core.view.MenuCompat; +import androidx.core.view.MenuItemCompat; +import androidx.core.view.ViewCompat; +import androidx.core.view.WindowCompat; +import androidx.drawerlayout.widget.DrawerLayout; +import androidx.core.widget.ImageViewCompat; +import androidx.appcompat.app.ActionBarDrawerToggle; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatActivity; +import androidx.appcompat.widget.AppCompatImageButton; +import androidx.appcompat.widget.Toolbar; import android.util.Log; import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.View; -import android.widget.ImageButton; -import android.widget.ImageView; import android.widget.TextView; import com.filestack.CloudResponse; diff --git a/filestack/src/main/java/com/filestack/android/FsConstants.java b/filestack/src/main/java/com/filestack/android/FsConstants.java index 2a1aae1d..bb57bf70 100644 --- a/filestack/src/main/java/com/filestack/android/FsConstants.java +++ b/filestack/src/main/java/com/filestack/android/FsConstants.java @@ -34,8 +34,12 @@ public class FsConstants { public static final String EXTRA_FILE_LINK = "fileLink"; /** For uploads, returns upload status string. */ public static final String EXTRA_STATUS = "status"; + /** For uploads, returns upload percent uploaded. */ + public static final String EXTRA_PERCENT = "percent"; /** Indicates an upload completed successfully. */ public static final String STATUS_COMPLETE = "complete"; + /** Indicates an upload is still in progress. */ + public static final String STATUS_IN_PROGRESS = "inProgress"; /** Indicates an upload failed. */ public static final String STATUS_FAILED = "failed"; diff --git a/filestack/src/main/java/com/filestack/android/Theme.java b/filestack/src/main/java/com/filestack/android/Theme.java index 5b65d366..b9f16166 100644 --- a/filestack/src/main/java/com/filestack/android/Theme.java +++ b/filestack/src/main/java/com/filestack/android/Theme.java @@ -1,11 +1,9 @@ package com.filestack.android; -import android.content.Context; import android.graphics.Color; -import android.os.Build; import android.os.Parcel; import android.os.Parcelable; -import android.support.annotation.ColorInt; +import androidx.annotation.ColorInt; public class Theme implements Parcelable { diff --git a/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java b/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java index dc65f96f..2e379d84 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/CameraFragment.java @@ -7,11 +7,11 @@ import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.view.ViewCompat; -import android.support.v4.widget.ImageViewCompat; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.core.view.ViewCompat; +import androidx.core.widget.ImageViewCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; diff --git a/filestack/src/main/java/com/filestack/android/internal/CloudAuthFragment.java b/filestack/src/main/java/com/filestack/android/internal/CloudAuthFragment.java index 0fd679b1..b1b73e3c 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CloudAuthFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/CloudAuthFragment.java @@ -1,15 +1,14 @@ package com.filestack.android.internal; -import android.content.Intent; import android.content.res.ColorStateList; import android.net.Uri; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.customtabs.CustomTabsIntent; -import android.support.v4.app.Fragment; -import android.support.v4.content.ContextCompat; -import android.support.v4.view.ViewCompat; -import android.support.v4.widget.ImageViewCompat; +import androidx.annotation.Nullable; +import androidx.browser.customtabs.CustomTabsIntent; +import androidx.fragment.app.Fragment; +import androidx.core.content.ContextCompat; +import androidx.core.view.ViewCompat; +import androidx.core.widget.ImageViewCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; diff --git a/filestack/src/main/java/com/filestack/android/internal/CloudListAdapter.java b/filestack/src/main/java/com/filestack/android/internal/CloudListAdapter.java index b75481c0..bfaca360 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CloudListAdapter.java +++ b/filestack/src/main/java/com/filestack/android/internal/CloudListAdapter.java @@ -1,8 +1,8 @@ package com.filestack.android.internal; import android.os.Bundle; -import android.support.v4.graphics.ColorUtils; -import android.support.v7.widget.RecyclerView; +import androidx.core.graphics.ColorUtils; +import androidx.recyclerview.widget.RecyclerView; import android.text.TextUtils; import android.text.format.Formatter; import android.view.LayoutInflater; @@ -11,7 +11,6 @@ import com.filestack.CloudItem; import com.filestack.CloudResponse; -import com.filestack.android.R; import com.filestack.android.Selection; import com.filestack.android.Theme; diff --git a/filestack/src/main/java/com/filestack/android/internal/CloudListFragment.java b/filestack/src/main/java/com/filestack/android/internal/CloudListFragment.java index 88c8ef6c..7ae8f087 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CloudListFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/CloudListFragment.java @@ -3,12 +3,12 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuItem; diff --git a/filestack/src/main/java/com/filestack/android/internal/CloudListViewHolder.java b/filestack/src/main/java/com/filestack/android/internal/CloudListViewHolder.java index 54bcbfbd..503b02e4 100644 --- a/filestack/src/main/java/com/filestack/android/internal/CloudListViewHolder.java +++ b/filestack/src/main/java/com/filestack/android/internal/CloudListViewHolder.java @@ -2,10 +2,10 @@ import android.content.Context; import android.content.res.ColorStateList; -import android.support.annotation.ColorInt; -import android.support.v4.graphics.ColorUtils; -import android.support.v4.widget.ImageViewCompat; -import android.support.v7.widget.RecyclerView; +import androidx.annotation.ColorInt; +import androidx.core.graphics.ColorUtils; +import androidx.core.widget.ImageViewCompat; +import androidx.recyclerview.widget.RecyclerView; import android.view.View; import android.widget.ImageView; import android.widget.TextView; diff --git a/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java b/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java index 48585b18..04580d45 100644 --- a/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java +++ b/filestack/src/main/java/com/filestack/android/internal/LocalFilesFragment.java @@ -9,10 +9,10 @@ import android.net.Uri; import android.os.Bundle; import android.provider.OpenableColumns; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; -import android.support.v4.view.ViewCompat; -import android.support.v4.widget.ImageViewCompat; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; +import androidx.core.view.ViewCompat; +import androidx.core.widget.ImageViewCompat; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; diff --git a/filestack/src/main/java/com/filestack/android/internal/SpacingDecoration.java b/filestack/src/main/java/com/filestack/android/internal/SpacingDecoration.java index 93fc30f7..1fbb1104 100644 --- a/filestack/src/main/java/com/filestack/android/internal/SpacingDecoration.java +++ b/filestack/src/main/java/com/filestack/android/internal/SpacingDecoration.java @@ -1,10 +1,10 @@ package com.filestack.android.internal; import android.graphics.Rect; -import android.support.v7.widget.GridLayoutManager; -import android.support.v7.widget.LinearLayoutManager; -import android.support.v7.widget.RecyclerView; -import android.support.v7.widget.StaggeredGridLayoutManager; +import androidx.recyclerview.widget.GridLayoutManager; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; import android.view.View; // Taken from https://stackoverflow.com/a/32971704/5121687 diff --git a/filestack/src/main/java/com/filestack/android/internal/SquareImageView.java b/filestack/src/main/java/com/filestack/android/internal/SquareImageView.java index 8f2a90e8..de61a11f 100644 --- a/filestack/src/main/java/com/filestack/android/internal/SquareImageView.java +++ b/filestack/src/main/java/com/filestack/android/internal/SquareImageView.java @@ -1,7 +1,7 @@ package com.filestack.android.internal; import android.content.Context; -import android.support.v7.widget.AppCompatImageView; +import androidx.appcompat.widget.AppCompatImageView; import android.util.AttributeSet; public class SquareImageView extends AppCompatImageView { diff --git a/filestack/src/main/java/com/filestack/android/internal/UploadService.java b/filestack/src/main/java/com/filestack/android/internal/UploadService.java index 27c70197..cbfe888d 100644 --- a/filestack/src/main/java/com/filestack/android/internal/UploadService.java +++ b/filestack/src/main/java/com/filestack/android/internal/UploadService.java @@ -1,26 +1,22 @@ package com.filestack.android.internal; import android.annotation.TargetApi; -import android.app.IntentService; import android.app.Notification; import android.app.NotificationChannel; import android.app.NotificationManager; import android.app.Service; import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.net.Uri; import android.os.Build; import android.os.IBinder; -import android.support.annotation.NonNull; -import android.support.annotation.Nullable; -import android.support.v4.app.JobIntentService; -import android.support.v4.app.NotificationCompat; -import android.support.v4.app.NotificationManagerCompat; -import android.support.v4.app.ServiceCompat; -import android.support.v4.content.LocalBroadcastManager; + +import androidx.annotation.Nullable; +import androidx.core.app.NotificationCompat; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; import com.filestack.FileLink; +import com.filestack.Progress; import com.filestack.Sources; import com.filestack.StorageOptions; import com.filestack.android.FsConstants; @@ -35,7 +31,8 @@ import java.util.concurrent.Executor; import java.util.concurrent.Executors; -import okhttp3.internal.Internal; +import io.reactivex.Flowable; +import io.reactivex.functions.Consumer; /** * If the auto upload option is left enabled, a user's selections will be sent to this service @@ -114,7 +111,7 @@ private void uploadFiles(List selections, StorageOptions storeOpts) { } sendProgressNotification(i, total, name); - sendBroadcast(item, fileLink); + sendBroadcast(item, fileLink, 1); } } @@ -131,14 +128,26 @@ private FileLink upload(Selection selection, StorageOptions baseOptions) { .mimeType(mimeType) .build(); + Consumer> progressConsumer = (Consumer>) progress -> { + double percent = progress.getPercent(); + if (percent < 1) { + sendBroadcast(selection, progress.getData(), percent); + } + }; try { switch (selection.getProvider()) { case Sources.CAMERA: // TODO This should maybe be unified into an InputStream upload - return Util.getClient().upload(path, false, options); + Flowable> cameraUpload = Util.getClient().uploadAsync( + path, false, options); + cameraUpload = cameraUpload.doOnNext(progressConsumer); + return cameraUpload.blockingLast().getData(); case Sources.DEVICE: InputStream input = getContentResolver().openInputStream(uri); - return Util.getClient().upload(input, size, false, options); + Flowable> deviceUpload = Util.getClient().uploadAsync( + input, size, false, options); + deviceUpload = deviceUpload.doOnNext(progressConsumer); + return deviceUpload.blockingLast().getData(); default: return Util.getClient().storeCloudItem(provider, path, options); } @@ -201,14 +210,19 @@ private void sendErrorNotification(String name) { notificationManager.notify(errorNotificationId, builder.build()); } - private void sendBroadcast(Selection selection, FileLink fileLink) { + private void sendBroadcast(Selection selection, FileLink fileLink, double percent) { Intent intent = new Intent(FsConstants.BROADCAST_UPLOAD); intent.putExtra(FsConstants.EXTRA_SELECTION, selection); if (fileLink == null) { - intent.putExtra(FsConstants.EXTRA_STATUS, FsConstants.STATUS_FAILED); + if (percent == 1) { + intent.putExtra(FsConstants.EXTRA_STATUS, FsConstants.STATUS_FAILED); + } else { + intent.putExtra(FsConstants.EXTRA_STATUS, FsConstants.STATUS_IN_PROGRESS); + } } else { intent.putExtra(FsConstants.EXTRA_STATUS, FsConstants.STATUS_COMPLETE); } + intent.putExtra(FsConstants.EXTRA_PERCENT, percent); intent.putExtra(FsConstants.EXTRA_FILE_LINK, fileLink); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); diff --git a/filestack/src/main/java/com/filestack/android/internal/Util.java b/filestack/src/main/java/com/filestack/android/internal/Util.java index 2486e168..4e0a0bd2 100644 --- a/filestack/src/main/java/com/filestack/android/internal/Util.java +++ b/filestack/src/main/java/com/filestack/android/internal/Util.java @@ -4,8 +4,8 @@ import android.content.Intent; import android.net.Uri; import android.os.Environment; -import android.support.v4.content.FileProvider; -import android.support.v4.content.MimeTypeFilter; +import androidx.core.content.FileProvider; +import androidx.core.content.MimeTypeFilter; import android.widget.TextView; import com.filestack.Client; diff --git a/filestack/src/main/res/layout-sw600dp/filestack__activity_filestack.xml b/filestack/src/main/res/layout-sw600dp/filestack__activity_filestack.xml index 28a16a6b..9751eaf7 100644 --- a/filestack/src/main/res/layout-sw600dp/filestack__activity_filestack.xml +++ b/filestack/src/main/res/layout-sw600dp/filestack__activity_filestack.xml @@ -6,20 +6,20 @@ android:layout_height="match_parent" tools:context="com.filestack.android.FsActivity"> - - - + - + app:elevation="0dp" + app:headerLayout="@layout/filestack__nav_header_filestack"/> - - - - + - - + diff --git a/filestack/src/main/res/layout/filestack__app_bar_filestack.xml b/filestack/src/main/res/layout/filestack__app_bar_filestack.xml new file mode 100644 index 00000000..72d13e68 --- /dev/null +++ b/filestack/src/main/res/layout/filestack__app_bar_filestack.xml @@ -0,0 +1,19 @@ + + + + + + diff --git a/filestack/src/main/res/layout/filestack__fragment_cloud_list.xml b/filestack/src/main/res/layout/filestack__fragment_cloud_list.xml index 035abc90..30e867b5 100644 --- a/filestack/src/main/res/layout/filestack__fragment_cloud_list.xml +++ b/filestack/src/main/res/layout/filestack__fragment_cloud_list.xml @@ -1,9 +1,9 @@ - - + diff --git a/gradle.properties b/gradle.properties index aac7c9b4..efa05a11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,8 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. +android.enableJetifier=false +android.useAndroidX=true org.gradle.jvmargs=-Xmx1536m # When configured, Gradle will run in incubating parallel mode. diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index e362f97d..7d5cf0fe 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Sep 24 11:10:49 CEST 2018 +#Thu Aug 03 15:17:02 CEST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip diff --git a/samples/form/app/build.gradle b/samples/form/app/build.gradle index 5ea2d585..d1097a48 100644 --- a/samples/form/app/build.gradle +++ b/samples/form/app/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 27 + compileSdkVersion 33 defaultConfig { applicationId "com.filestack.android.samples.form" minSdkVersion 19 - targetSdkVersion 27 + targetSdkVersion 33 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/samples/form/app/src/androidTest/java/com/filestack/android/samples/ExampleInstrumentedTest.java b/samples/form/app/src/androidTest/java/com/filestack/android/samples/ExampleInstrumentedTest.java index 8855f3e0..363f021e 100644 --- a/samples/form/app/src/androidTest/java/com/filestack/android/samples/ExampleInstrumentedTest.java +++ b/samples/form/app/src/androidTest/java/com/filestack/android/samples/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.filestack.android.samples; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/samples/form/app/src/main/AndroidManifest.xml b/samples/form/app/src/main/AndroidManifest.xml index f4e572d6..cd1447e5 100644 --- a/samples/form/app/src/main/AndroidManifest.xml +++ b/samples/form/app/src/main/AndroidManifest.xml @@ -17,7 +17,7 @@ diff --git a/samples/form/app/src/main/java/com/filestack/android/samples/form/CompleteFragment.java b/samples/form/app/src/main/java/com/filestack/android/samples/form/CompleteFragment.java index 7e45ac60..5669dfbb 100644 --- a/samples/form/app/src/main/java/com/filestack/android/samples/form/CompleteFragment.java +++ b/samples/form/app/src/main/java/com/filestack/android/samples/form/CompleteFragment.java @@ -1,8 +1,8 @@ package com.filestack.android.samples.form; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/samples/form/app/src/main/java/com/filestack/android/samples/form/EntryActivity.java b/samples/form/app/src/main/java/com/filestack/android/samples/form/EntryActivity.java index 610c87d8..7a9cbc5f 100644 --- a/samples/form/app/src/main/java/com/filestack/android/samples/form/EntryActivity.java +++ b/samples/form/app/src/main/java/com/filestack/android/samples/form/EntryActivity.java @@ -2,7 +2,7 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; public class EntryActivity extends AppCompatActivity { @Override diff --git a/samples/form/app/src/main/java/com/filestack/android/samples/form/FormFragment.java b/samples/form/app/src/main/java/com/filestack/android/samples/form/FormFragment.java index 836ce811..0f728619 100644 --- a/samples/form/app/src/main/java/com/filestack/android/samples/form/FormFragment.java +++ b/samples/form/app/src/main/java/com/filestack/android/samples/form/FormFragment.java @@ -3,8 +3,8 @@ import android.content.Context; import android.content.Intent; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/samples/form/app/src/main/java/com/filestack/android/samples/form/LoadingFragment.java b/samples/form/app/src/main/java/com/filestack/android/samples/form/LoadingFragment.java index d7dd5a66..7ab432a2 100644 --- a/samples/form/app/src/main/java/com/filestack/android/samples/form/LoadingFragment.java +++ b/samples/form/app/src/main/java/com/filestack/android/samples/form/LoadingFragment.java @@ -1,8 +1,8 @@ package com.filestack.android.samples.form; import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v4.app.Fragment; +import androidx.annotation.Nullable; +import androidx.fragment.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; diff --git a/samples/form/app/src/main/java/com/filestack/android/samples/form/MainActivity.java b/samples/form/app/src/main/java/com/filestack/android/samples/form/MainActivity.java index 79c336f6..f663c969 100644 --- a/samples/form/app/src/main/java/com/filestack/android/samples/form/MainActivity.java +++ b/samples/form/app/src/main/java/com/filestack/android/samples/form/MainActivity.java @@ -5,8 +5,8 @@ import android.content.Intent; import android.content.IntentFilter; import android.os.Bundle; -import android.support.v4.content.LocalBroadcastManager; -import android.support.v7.app.AppCompatActivity; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import androidx.appcompat.app.AppCompatActivity; import com.filestack.FileLink; import com.filestack.android.FsConstants; diff --git a/tester/build.gradle b/tester/build.gradle index 51c44fd4..33dcac2c 100644 --- a/tester/build.gradle +++ b/tester/build.gradle @@ -1,16 +1,17 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 28 + compileSdkVersion 33 defaultConfig { applicationId "com.filestack.android.demo" minSdkVersion 16 - targetSdkVersion 28 + targetSdkVersion 33 versionCode 1 versionName "1.0" + multiDexEnabled = true - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' } @@ -47,15 +48,15 @@ dependencies { implementation 'io.reactivex.rxjava2:rxandroid:2.1.0' implementation 'io.reactivex.rxjava2:rxjava:2.2.2' - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.2' - implementation 'com.android.support:preference-v7:28.0.0' - implementation 'com.android.support:preference-v14:28.0.0' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.constraintlayout:constraintlayout:2.1.4' + implementation 'androidx.preference:preference:1.2.1' + implementation 'androidx.legacy:legacy-preference-v14:1.0.0' - implementation 'com.github.kizitonwose.colorpreference:support:1.0.6' + implementation 'com.github.kizitonwose.colorpreference:support:1.1.0' - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { + androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', { exclude group: 'com.android.support', module: 'support-annotations' }) - testImplementation 'junit:junit:4.12' + testImplementation 'junit:junit:4.13.2' } diff --git a/tester/src/androidTest/java/com/filestack/android/demo/ExampleInstrumentedTest.java b/tester/src/androidTest/java/com/filestack/android/demo/ExampleInstrumentedTest.java index 65571c6d..012dc06e 100644 --- a/tester/src/androidTest/java/com/filestack/android/demo/ExampleInstrumentedTest.java +++ b/tester/src/androidTest/java/com/filestack/android/demo/ExampleInstrumentedTest.java @@ -1,8 +1,8 @@ package com.filestack.android.demo; import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/tester/src/main/AndroidManifest.xml b/tester/src/main/AndroidManifest.xml index ce41a559..1aa90109 100644 --- a/tester/src/main/AndroidManifest.xml +++ b/tester/src/main/AndroidManifest.xml @@ -10,7 +10,8 @@ android:theme="@style/AppTheme"> + android:name=".MainActivity" + android:exported="true"> @@ -23,7 +24,7 @@ android:parentActivityName=".MainActivity"/> diff --git a/tester/src/main/java/com/filestack/android/demo/EntryActivity.java b/tester/src/main/java/com/filestack/android/demo/EntryActivity.java index aed8f111..2b0093e3 100644 --- a/tester/src/main/java/com/filestack/android/demo/EntryActivity.java +++ b/tester/src/main/java/com/filestack/android/demo/EntryActivity.java @@ -2,7 +2,7 @@ import android.content.Intent; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; public class EntryActivity extends AppCompatActivity { @Override diff --git a/tester/src/main/java/com/filestack/android/demo/MainActivity.java b/tester/src/main/java/com/filestack/android/demo/MainActivity.java index aa96c07c..6d71abb6 100644 --- a/tester/src/main/java/com/filestack/android/demo/MainActivity.java +++ b/tester/src/main/java/com/filestack/android/demo/MainActivity.java @@ -4,34 +4,27 @@ import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; -import android.support.v4.content.ContextCompat; -import android.support.v4.content.LocalBroadcastManager; -import android.support.v7.app.AppCompatActivity; -import android.support.v7.preference.PreferenceManager; +import androidx.core.content.ContextCompat; +import androidx.localbroadcastmanager.content.LocalBroadcastManager; +import androidx.appcompat.app.AppCompatActivity; +import androidx.preference.PreferenceManager; import android.util.Log; import android.view.View; -import android.widget.ArrayAdapter; -import android.widget.EditText; -import android.widget.Spinner; -import android.widget.SpinnerAdapter; +import android.widget.ScrollView; import android.widget.TextView; import android.widget.Toast; import com.filestack.Config; import com.filestack.android.FilestackPicker; -import com.filestack.android.FsActivity; import com.filestack.android.FsConstants; import com.filestack.android.Selection; import com.filestack.android.Theme; -import com.filestack.android.internal.Util; -import java.sql.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Locale; -import java.util.Set; public class MainActivity extends AppCompatActivity { private static final int REQUEST_FILESTACK = RESULT_FIRST_USER; @@ -45,8 +38,9 @@ protected void onCreate(Bundle savedInstanceState) { if (savedInstanceState == null) { IntentFilter intentFilter = new IntentFilter(FsConstants.BROADCAST_UPLOAD); + ScrollView scrollView = findViewById(R.id.scrollView); TextView logView = findViewById(R.id.log); - UploadStatusReceiver receiver = new UploadStatusReceiver(logView); + UploadStatusReceiver receiver = new UploadStatusReceiver(logView, scrollView); LocalBroadcastManager.getInstance(this).registerReceiver(receiver, intentFilter); } diff --git a/tester/src/main/java/com/filestack/android/demo/SettingsActivity.java b/tester/src/main/java/com/filestack/android/demo/SettingsActivity.java index df0bbd21..a5725e4a 100644 --- a/tester/src/main/java/com/filestack/android/demo/SettingsActivity.java +++ b/tester/src/main/java/com/filestack/android/demo/SettingsActivity.java @@ -1,7 +1,7 @@ package com.filestack.android.demo; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; +import androidx.appcompat.app.AppCompatActivity; public class SettingsActivity extends AppCompatActivity { diff --git a/tester/src/main/java/com/filestack/android/demo/SettingsFragment.java b/tester/src/main/java/com/filestack/android/demo/SettingsFragment.java index ef3fe2d2..c860d58c 100644 --- a/tester/src/main/java/com/filestack/android/demo/SettingsFragment.java +++ b/tester/src/main/java/com/filestack/android/demo/SettingsFragment.java @@ -1,7 +1,7 @@ package com.filestack.android.demo; import android.os.Bundle; -import android.support.v14.preference.PreferenceFragment; +import androidx.preference.PreferenceFragment; public class SettingsFragment extends PreferenceFragment { diff --git a/tester/src/main/java/com/filestack/android/demo/UploadStatusReceiver.java b/tester/src/main/java/com/filestack/android/demo/UploadStatusReceiver.java index b3a769aa..3797f570 100644 --- a/tester/src/main/java/com/filestack/android/demo/UploadStatusReceiver.java +++ b/tester/src/main/java/com/filestack/android/demo/UploadStatusReceiver.java @@ -1,9 +1,13 @@ package com.filestack.android.demo; +import static com.filestack.android.FsConstants.STATUS_IN_PROGRESS; + import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; +import android.view.View; +import android.widget.ScrollView; import android.widget.TextView; import com.filestack.FileLink; @@ -16,9 +20,11 @@ public class UploadStatusReceiver extends BroadcastReceiver { private static final String TAG = "UploadStatusReceiver"; private TextView logView; + private ScrollView scrollView; - public UploadStatusReceiver(TextView logView) { + public UploadStatusReceiver(TextView logView, ScrollView scrollView) { this.logView = logView; + this.scrollView = scrollView; } @Override @@ -27,12 +33,21 @@ public void onReceive(Context context, Intent intent) { Selection selection = intent.getParcelableExtra(FsConstants.EXTRA_SELECTION); FileLink fileLink = (FileLink) intent.getSerializableExtra(FsConstants.EXTRA_FILE_LINK); String name = selection.getName(); - String handle = fileLink != null ? fileLink.getHandle() : "n/a"; - logView.append("========================\n"); logView.append(status.toUpperCase() + "\n"); logView.append(name + "\n"); - logView.append("https://cdn.filestackcontent.com/" + handle + "\n"); + if (status.equals(STATUS_IN_PROGRESS)) { + double percent = intent.getDoubleExtra(FsConstants.EXTRA_PERCENT, 100); + logView.append(String.format("Percentage completed: %f%%\n", percent * 100)); + } else { + String handle = fileLink != null ? fileLink.getHandle() : "n/a"; + logView.append("https://cdn.filestackcontent.com/" + handle + "\n"); + } logView.append("========================\n"); + scrollDown(); + } + + private void scrollDown() { + scrollView.post(() -> scrollView.fullScroll(View.FOCUS_DOWN)); } } diff --git a/tester/src/main/res/layout/activity_main.xml b/tester/src/main/res/layout/activity_main.xml index 849f9d69..dbad4f23 100644 --- a/tester/src/main/res/layout/activity_main.xml +++ b/tester/src/main/res/layout/activity_main.xml @@ -6,6 +6,7 @@ android:layout_height="match_parent" tools:context="com.filestack.android.demo.MainActivity">