소스 검색

Merge master

Signed-off-by: alperozturk <alper_ozturk@proton.me>
alperozturk 1 년 전
부모
커밋
647e0b74ab

+ 4 - 0
app/build.gradle

@@ -126,6 +126,10 @@ android {
             }
         }
 
+        buildFeatures {
+            buildConfig = true
+        }
+
         productFlavors {
             // used for f-droid
             generic {

+ 41 - 39
app/src/main/java/com/owncloud/android/files/services/FileDownloader.java

@@ -88,7 +88,7 @@ import dagger.android.AndroidInjection;
 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 
 public class FileDownloader extends Service
-    implements OnDatatransferProgressListener, OnAccountsUpdateListener {
+        implements OnDatatransferProgressListener, OnAccountsUpdateListener {
 
     public static final String EXTRA_USER = "USER";
     public static final String EXTRA_FILE = "FILE";
@@ -256,9 +256,9 @@ public class FileDownloader extends Service
     }
 
     /**
-     * Provides a binder object that clients can use to perform operations on the queue of downloads, excepting the
-     * addition of new files.
-     * <p>
+     * Provides a binder object that clients can use to perform operations on the queue of downloads,
+     * excepting the addition of new files.
+     *
      * Implemented to perform cancellation, pause and resume of existing downloads.
      */
     @Override
@@ -278,7 +278,7 @@ public class FileDownloader extends Service
 
     @Override
     public void onAccountsUpdated(Account[] accounts) {
-        //review the current download and cancel it if its account doesn't exist
+         //review the current download and cancel it if its account doesn't exist
         if (mCurrentDownload != null && !accountManager.exists(mCurrentDownload.getUser().toPlatformAccount())) {
             mCurrentDownload.cancel();
         }
@@ -294,11 +294,12 @@ public class FileDownloader extends Service
     public class FileDownloaderBinder extends Binder implements OnDatatransferProgressListener {
 
         /**
-         * Map of listeners that will be reported about progress of downloads from a {@link FileDownloaderBinder}
+         * Map of listeners that will be reported about progress of downloads from a
+         * {@link FileDownloaderBinder}
          * instance.
          */
         private Map<Long, OnDatatransferProgressListener> mBoundListeners =
-            new HashMap<Long, OnDatatransferProgressListener>();
+                new HashMap<Long, OnDatatransferProgressListener>();
 
 
         /**
@@ -316,7 +317,7 @@ public class FileDownloader extends Service
             } else {
                 if (mCurrentDownload != null && currentUser.isPresent() &&
                     mCurrentDownload.getRemotePath().startsWith(file.getRemotePath()) &&
-                    account.name.equals(currentUser.get().getAccountName())) {
+                        account.name.equals(currentUser.get().getAccountName())) {
                     mCurrentDownload.cancel();
                 }
             }
@@ -339,14 +340,14 @@ public class FileDownloader extends Service
 
 
         /**
-         * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to
-         * download.
-         * <p>
-         * If 'file' is a directory, returns 'true' if any of its descendant files is downloading or waiting to
-         * download.
+         * Returns True when the file described by 'file' in the ownCloud account 'account'
+         * is downloading or waiting to download.
+         *
+         * If 'file' is a directory, returns 'true' if any of its descendant files is downloading or
+         * waiting to download.
          *
-         * @param user user where the remote file is stored.
-         * @param file A file that could be in the queue of downloads.
+         * @param user    user where the remote file is stored.
+         * @param file    A file that could be in the queue of downloads.
          */
         public boolean isDownloading(User user, OCFile file) {
             return user != null && file != null && mPendingDownloads.contains(user.getAccountName(), file.getRemotePath());
@@ -370,8 +371,8 @@ public class FileDownloader extends Service
         /**
          * Removes a listener interested in the progress of the download for a concrete file.
          *
-         * @param listener Object to notify about progress of transfer.
-         * @param file     {@link OCFile} of interest for listener.
+         * @param listener      Object to notify about progress of transfer.
+         * @param file          {@link OCFile} of interest for listener.
          */
         public void removeDatatransferProgressListener(OnDatatransferProgressListener listener, OCFile file) {
             if (file == null || listener == null) {
@@ -387,7 +388,7 @@ public class FileDownloader extends Service
         public void onTransferProgress(long progressRate, long totalTransferredSoFar,
                                        long totalToTransfer, String fileName) {
             OnDatatransferProgressListener boundListener =
-                mBoundListeners.get(mCurrentDownload.getFile().getFileId());
+                    mBoundListeners.get(mCurrentDownload.getFile().getFileId());
             if (boundListener != null) {
                 boundListener.onTransferProgress(progressRate, totalTransferredSoFar,
                                                  totalToTransfer, fileName);
@@ -398,7 +399,7 @@ public class FileDownloader extends Service
 
     /**
      * Download worker. Performs the pending downloads in the order they were requested.
-     * <p>
+
      * Created with the Looper of a new thread, started in {@link FileUploader#onCreate()}.
      */
     private static class ServiceHandler extends Handler {
@@ -425,10 +426,10 @@ public class FileDownloader extends Service
                     mService.downloadFile(next);
                 }
             }
-            mService.mStartedDownload = false;
+            mService.mStartedDownload=false;
 
             (new Handler()).postDelayed(() -> {
-                if (!mService.mStartedDownload) {
+                if(!mService.mStartedDownload){
                     mService.mNotificationManager.cancel(R.string.downloader_download_in_progress_ticker);
                 }
                 Log_OC.d(TAG, "Stopping after command with id " + msg.arg1);
@@ -468,7 +469,7 @@ public class FileDownloader extends Service
                     // of update
                     OwnCloudAccount ocAccount = currentDownloadUser.get().toOwnCloudAccount();
                     mDownloadClient = OwnCloudClientManagerFactory.getDefaultSingleton().
-                        getClientFor(ocAccount, this);
+                            getClientFor(ocAccount, this);
 
 
                     /// perform the download
@@ -502,7 +503,7 @@ public class FileDownloader extends Service
 
     /**
      * Updates the OC File after a successful download.
-     * <p>
+     *
      * TODO move to DownloadFileOperation
      *  unify with code from {@link DocumentsStorageProvider} and {@link DownloadTask}.
      */
@@ -604,7 +605,7 @@ public class FileDownloader extends Service
 
             if (mNotificationManager != null) {
                 mNotificationManager.notify(R.string.downloader_download_in_progress_ticker,
-                                            mNotificationBuilder.build());
+                        mNotificationBuilder.build());
             }
         }
         mLastPercent = percent;
@@ -633,18 +634,18 @@ public class FileDownloader extends Service
                 return;
             }
             int tickerId = downloadResult.isSuccess() ?
-                R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
+                    R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
 
             boolean needsToUpdateCredentials = ResultCode.UNAUTHORIZED == downloadResult.getCode();
             tickerId = needsToUpdateCredentials ?
-                R.string.downloader_download_failed_credentials_error : tickerId;
+                    R.string.downloader_download_failed_credentials_error : tickerId;
 
             mNotificationBuilder
-                .setTicker(getString(tickerId))
-                .setContentTitle(getString(tickerId))
-                .setAutoCancel(true)
-                .setOngoing(false)
-                .setProgress(0, 0, false);
+                    .setTicker(getString(tickerId))
+                    .setContentTitle(getString(tickerId))
+                    .setAutoCancel(true)
+                    .setOngoing(false)
+                    .setProgress(0, 0, false);
 
             if (needsToUpdateCredentials) {
                 configureUpdateCredentialsNotification(download.getUser());
@@ -657,7 +658,7 @@ public class FileDownloader extends Service
             }
 
             mNotificationBuilder.setContentText(ErrorMessageAdapter.getErrorCauseMessage(downloadResult,
-                                                                                         download, getResources()));
+                    download, getResources()));
 
             if (mNotificationManager != null) {
                 mNotificationManager.notify((new SecureRandom()).nextInt(), mNotificationBuilder.build());
@@ -677,9 +678,9 @@ public class FileDownloader extends Service
         Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
         updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, user.toPlatformAccount());
         updateAccountCredentials.putExtra(
-            AuthenticatorActivity.EXTRA_ACTION,
-            AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
-                                         );
+                AuthenticatorActivity.EXTRA_ACTION,
+                AuthenticatorActivity.ACTION_UPDATE_EXPIRED_TOKEN
+        );
         updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         updateAccountCredentials.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
         updateAccountCredentials.addFlags(Intent.FLAG_FROM_BACKGROUND);
@@ -693,16 +694,17 @@ public class FileDownloader extends Service
 
 
     /**
-     * Sends a broadcast when a download finishes in order to the interested activities can update their view
+     * Sends a broadcast when a download finishes in order to the interested activities can
+     * update their view
      *
      * @param download               Finished download operation
      * @param downloadResult         Result of the download operation
      * @param unlinkedFromRemotePath Path in the downloads tree where the download was unlinked from
      */
     private void sendBroadcastDownloadFinished(
-        DownloadFileOperation download,
-        RemoteOperationResult downloadResult,
-        String unlinkedFromRemotePath) {
+            DownloadFileOperation download,
+            RemoteOperationResult downloadResult,
+            String unlinkedFromRemotePath) {
 
         Intent end = new Intent(getDownloadFinishMessage());
         end.putExtra(EXTRA_DOWNLOAD_RESULT, downloadResult.isSuccess());

+ 11 - 7
app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.java

@@ -350,14 +350,18 @@ public class FileDisplayActivity extends FileActivity
     public void onConfigurationChanged(@NonNull Configuration newConfig) {
         super.onConfigurationChanged(newConfig);
 
-        StoragePermissionDialogFragment fragment = (StoragePermissionDialogFragment) getSupportFragmentManager().findFragmentByTag(PERMISSION_CHOICE_DIALOG_TAG);
-        if (fragment != null) {
-            Dialog dialog = fragment.getDialog();
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
+            StoragePermissionDialogFragment fragment =
+                (StoragePermissionDialogFragment) getSupportFragmentManager()
+                    .findFragmentByTag(PERMISSION_CHOICE_DIALOG_TAG);
+            if (fragment != null) {
+                Dialog dialog = fragment.getDialog();
 
-            if (dialog != null && dialog.isShowing()) {
-                dialog.dismiss();
-                getSupportFragmentManager().beginTransaction().remove(fragment).commitNowAllowingStateLoss();
-                PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils);
+                if (dialog != null && dialog.isShowing()) {
+                    dialog.dismiss();
+                    getSupportFragmentManager().beginTransaction().remove(fragment).commitNowAllowingStateLoss();
+                    PermissionUtil.requestExternalStoragePermission(this, viewThemeUtils);
+                }
             }
         }
     }

+ 0 - 7
app/src/main/res/values/styles.xml

@@ -233,13 +233,6 @@
         <item name="android:textStyle">bold</item>
     </style>
 
-    <style name="Button.Borderless.Destructive" parent="Widget.Material3.Button.TextButton">
-        <item name="android:textColor">@color/highlight_textColor_Warning</item>
-        <item name="android:textAllCaps">false</item>
-        <item name="android:typeface">sans</item>
-        <item name="android:textStyle">bold</item>
-    </style>
-
     <style name="Button.Borderless.Login" parent="Widget.Material3.Button.TextButton">
         <item name="android:textColor">@color/fg_inverse</item>
         <item name="android:textAllCaps">false</item>

+ 1 - 1
build.gradle

@@ -1,6 +1,6 @@
 buildscript {
     ext {
-        androidPluginVersion = '8.1.4'
+        androidPluginVersion = '8.2.0'
         appCompatVersion = '1.6.1'
         jacoco_version = '0.8.10'
         kotlin_version = '1.8.22'

+ 0 - 1
gradle.properties

@@ -4,7 +4,6 @@ NC_TEST_SERVER_USERNAME=test
 NC_TEST_SERVER_PASSWORD=test
 android.enableJetifier=true
 android.useAndroidX=true
-android.defaults.buildfeatures.buildconfig=true
 android.nonTransitiveRClass=false
 android.nonFinalResIds=false
 #android.debug.obsoleteApi=true

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,6 @@
 #Fri Jan 13 08:21:45 CET 2023
 distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME

+ 1 - 1
scripts/analysis/lint-results.txt

@@ -1,2 +1,2 @@
 DO NOT TOUCH; GENERATED BY DRONE
-      <span class="mdl-layout-title">Lint Report: 74 warnings</span>
+      <span class="mdl-layout-title">Lint Report: 9 errors and 75 warnings</span>