Ver código fonte

If file is shared to NC now the correct color is set for the chosen account

tobiasKaminsky 7 anos atrás
pai
commit
24c198fb32

+ 9 - 1
src/main/java/com/owncloud/android/ui/activity/ReceiveExternalFilesActivity.java

@@ -35,6 +35,7 @@ import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.res.Resources.NotFoundException;
 import android.graphics.PorterDuff;
+import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.os.Parcelable;
@@ -765,7 +766,14 @@ public class ReceiveExternalFilesActivity extends FileActivity
             mListView.setAdapter(sa);
             Button btnChooseFolder = (Button) findViewById(R.id.uploader_choose_folder);
             btnChooseFolder.setOnClickListener(this);
-            btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(), PorterDuff.Mode.SRC_ATOP);
+            btnChooseFolder.getBackground().setColorFilter(ThemeUtils.primaryColor(getAccount()),
+                    PorterDuff.Mode.SRC_ATOP);
+
+            getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ThemeUtils.primaryColor(getAccount())));
+
+            ThemeUtils.colorStatusBar(this, ThemeUtils.primaryDarkColor(getAccount()));
+
+            ThemeUtils.colorToolbarProgressBar(this, ThemeUtils.primaryColor(getAccount()));
 
             Button btnNewFolder = (Button) findViewById(R.id.uploader_cancel);
             btnNewFolder.setOnClickListener(this);

+ 1 - 1
src/main/java/com/owncloud/android/ui/adapter/UploaderAdapter.java

@@ -93,7 +93,7 @@ public class UploaderAdapter extends SimpleAdapter {
 
         if (file.isFolder()) {
             fileIcon.setImageDrawable(MimeTypeUtil.getFolderTypeIcon(file.isSharedWithMe() ||
-                    file.isSharedWithSharee(), file.isSharedViaLink()));
+                    file.isSharedWithSharee(), file.isSharedViaLink(), mAccount));
         } else {
             // get Thumbnail if file is image
             if (MimeTypeUtil.isImage(file) && file.getRemoteId() != null) {

+ 15 - 2
src/main/java/com/owncloud/android/utils/MimeTypeUtil.java

@@ -18,6 +18,7 @@
 
 package com.owncloud.android.utils;
 
+import android.accounts.Account;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.webkit.MimeTypeMap;
@@ -92,10 +93,22 @@ public class MimeTypeUtil {
      * Returns the resource identifier of an image to use as icon associated to a type of folder.
      *
      * @param isSharedViaUsers flag if the folder is shared via the users system
-     * @param isSharedViaLink flag if the folder is publicly shared via link
+     * @param isSharedViaLink  flag if the folder is publicly shared via link
      * @return Identifier of an image resource.
      */
     public static Drawable getFolderTypeIcon(boolean isSharedViaUsers, boolean isSharedViaLink) {
+        return getFolderTypeIcon(isSharedViaUsers, isSharedViaLink, null);
+    }
+
+    /**
+     * Returns the resource identifier of an image to use as icon associated to a type of folder.
+     *
+     * @param isSharedViaUsers flag if the folder is shared via the users system
+     * @param isSharedViaLink flag if the folder is publicly shared via link
+     * @param account account which color should be used
+     * @return Identifier of an image resource.
+     */
+    public static Drawable getFolderTypeIcon(boolean isSharedViaUsers, boolean isSharedViaLink, Account account) {
         int drawableId;
 
         if (isSharedViaLink) {
@@ -106,7 +119,7 @@ public class MimeTypeUtil {
             drawableId = R.drawable.ic_menu_archive;
         }
 
-        return ThemeUtils.tintDrawable(drawableId, ThemeUtils.primaryColor());
+        return ThemeUtils.tintDrawable(drawableId, ThemeUtils.primaryColor(account));
     }
 
     public static Drawable getDefaultFolderIcon() {

+ 21 - 3
src/main/java/com/owncloud/android/utils/ThemeUtils.java

@@ -71,7 +71,11 @@ public class ThemeUtils {
     }
 
     public static int primaryDarkColor() {
-        OCCapability capability = getCapability();
+        return primaryDarkColor(null);
+    }
+
+    public static int primaryDarkColor(Account account) {
+        OCCapability capability = getCapability(account);
 
         try {
             return adjustLightness(-0.2f, Color.parseColor(capability.getServerColor()));
@@ -81,7 +85,11 @@ public class ThemeUtils {
     }
 
     public static int primaryColor() {
-        OCCapability capability = getCapability();
+        return primaryColor(null);
+    }
+
+    public static int primaryColor(Account account) {
+        OCCapability capability = getCapability(account);
 
         try {
             return Color.parseColor(capability.getServerColor());
@@ -311,7 +319,17 @@ public class ThemeUtils {
     }
 
     private static OCCapability getCapability() {
-        Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
+        return getCapability(null);
+    }
+
+    private static OCCapability getCapability(Account acc) {
+        Account account;
+
+        if (acc != null) {
+            account = acc;
+        } else {
+            account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
+        }
 
         if (account != null) {
             Context context = MainApp.getAppContext();